userinfo.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <view class="container">
  3. <view class="row b-b flex jg">
  4. <text class="tit">头像</text>
  5. <image :src="userInfo.avatar" @click="imgsub"></image>
  6. </view>
  7. <view class="row b-b flex">
  8. <text class="tit">昵称</text>
  9. <input class="input" v-model="userInfo.nickname" type="text" placeholder-class="placeholder" />
  10. </view>
  11. <view class="row b-b flex">
  12. <text class="tit">邀请码</text>
  13. <input class="input" :value="userInfo.uid" type="text" disabled="true" placeholder-class="placeholder"
  14. style="color: #999;" />
  15. </view>
  16. <view class="row b-b flex" v-if="userInfo.account || userInfo.phone">
  17. <text class="tit">用户账号</text>
  18. <input class="input" :value="userInfo.account || userInfo.phone" type="number" disabled="true"
  19. style="color: #999;" placeholder-class="placeholder" />
  20. </view>
  21. <view class="list-cell log-out-btn out" @click="cancel"><text class="cell-tit">注销账户</text></view>
  22. <view class="list-cell log-out-btn" @click="edit"><text class="cell-tit">确认修改</text></view>
  23. <uni-popup ref="popup" type="center">
  24. <view class="psw-wrapper">
  25. <view class="psw-title">请输入自己的账户</view>
  26. <input type="text" v-model="password" class="psw-ipt" />
  27. <view class="psw-btn">
  28. <text @click.stop="qx">取消</text>
  29. <text class="psw-qd" @click.stop="pswQd">确定</text>
  30. </view>
  31. </view>
  32. </uni-popup>
  33. </view>
  34. </template>
  35. <script>
  36. import uniList from '@/components/uni-list/uni-list.vue';
  37. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  38. import {
  39. mapState,
  40. mapMutations
  41. } from 'vuex';
  42. import {
  43. logout
  44. } from '@/api/set.js';
  45. import {
  46. edit
  47. } from '@/api/user.js';
  48. import {
  49. upload
  50. } from '@/api/order.js';
  51. export default {
  52. components: {
  53. uniList,
  54. uniListItem
  55. },
  56. data() {
  57. return {
  58. userInfo: {},
  59. pics: [],
  60. show: false,
  61. password: '',
  62. };
  63. },
  64. onLoad() {
  65. this.userInfo = uni.getStorageSync('userInfo') || '';
  66. console.log(this.userInfo);
  67. },
  68. methods: {
  69. ...mapMutations('user', ['logout']),
  70. cancel() {
  71. this.$refs.popup.open();
  72. },
  73. pswQd() {
  74. if (this.password != this.userInfo.phone) {
  75. this.$refs.popup.close();
  76. this.password = '';
  77. this.$api.msg("请输入自己的账户")
  78. return
  79. }
  80. this.$refs.popup.close();
  81. this.password = '';
  82. this.$api.msg("申请注销成功,请耐心等待审核")
  83. },
  84. qx() {
  85. this.password = '';
  86. this.$refs.popup.close();
  87. },
  88. //退出登录
  89. toLogout() {
  90. let obj = this;
  91. uni.showModal({
  92. content: '确定要退出登录么',
  93. success: e => {
  94. if (e.confirm) {
  95. logout({})
  96. .then(e => {
  97. obj.logout();
  98. uni.switchTab({
  99. url: '/pages/index/index'
  100. });
  101. })
  102. .catch(e => {
  103. console.log(e);
  104. });
  105. }
  106. }
  107. });
  108. },
  109. imgsub() {
  110. let obj = this;
  111. console.log('上传头像');
  112. // this.$util.uploadImageOne('upload/image', function(res) {
  113. // console.log('------',res);
  114. // this.pics.push(res.data.pathreplace(/http:\/\/mer.crmeb.net/,'https://hy.liuniu946.com'));
  115. // // obj.userInfo.avatar = res.data.path.replace(/http:\/\/mer.crmeb.net/,'http://zccy.frp.liuniu946.com')
  116. // obj.$set(this, 'pics', this.pics);
  117. // obj.$set(this, 'extract_pic', this.pics[0])
  118. // });
  119. // uploads({
  120. // filename: ''
  121. // }).then(data => {
  122. // console.log("data",data);
  123. // this.userInfo.avatar = data[0].url;
  124. // })
  125. upload({
  126. filename: ''
  127. }).then(res => {
  128. console.log(res[0].url);
  129. obj.userInfo.avatar = res[0].url;
  130. // console.log(obj.userInfo.avatar)
  131. });
  132. },
  133. edit() {
  134. const that = this;
  135. uni.showLoading({
  136. title: '提交中...',
  137. mask: true
  138. });
  139. edit({
  140. avatar: this.userInfo.avatar,
  141. nickname: this.userInfo.nickname
  142. })
  143. .then(e => {
  144. uni.hideLoading();
  145. that.$api.msg('修改成功');
  146. setTimeout(() => {
  147. uni.switchTab({
  148. url: '/pages/user/user'
  149. });
  150. }, 1000);
  151. })
  152. .catch(e => {
  153. console.log(e);
  154. that.$api.msg('修改失败');
  155. });
  156. }
  157. }
  158. };
  159. </script>
  160. <style lang="scss">
  161. /* page{
  162. background: $page-color-base;
  163. }
  164. .list-cell{
  165. display:flex;
  166. align-items:baseline;
  167. padding: 20rpx $page-row-spacing;
  168. line-height:60rpx;
  169. position:relative;
  170. background: #fff;
  171. justify-content: center;
  172. &.log-out-btn{
  173. margin-top: 40rpx;
  174. .cell-tit{
  175. color: $uni-color-primary;
  176. text-align: center;
  177. margin-right: 0;
  178. }
  179. }
  180. .cell-tit{
  181. flex: 1;
  182. font-size: $font-base + 2rpx;
  183. color: $font-color-dark;
  184. margin-right:10rpx;
  185. }
  186. .cell-tip{
  187. font-size: $font-base;
  188. color: $font-color-light;
  189. }
  190. switch{
  191. transform: translateX(16rpx) scale(.84);
  192. }
  193. } */
  194. page {
  195. background-color: #f3f3f3;
  196. min-height: 100%;
  197. .container {
  198. height: 100%;
  199. }
  200. }
  201. .row {
  202. background-color: #fff;
  203. padding: 42rpx 25rpx;
  204. font-size: 30rpx;
  205. color: #333333;
  206. image {
  207. width: 80rpx;
  208. height: 80rpx;
  209. border-radius: 50%;
  210. }
  211. .input {
  212. text-align: right;
  213. color: #333333;
  214. }
  215. }
  216. .submit-box {
  217. display: flex;
  218. flex-direction: column;
  219. padding-top: 157rpx;
  220. .submit {
  221. margin: 40rpx auto;
  222. width: 560rpx;
  223. background-color: #08d29b;
  224. color: #ffffff;
  225. text-align: center;
  226. padding: 26rpx 0rpx;
  227. border-radius: 50rpx;
  228. }
  229. .dl {
  230. background-color: #ffffff;
  231. color: #08d29b;
  232. }
  233. }
  234. .jg {
  235. margin-bottom: 20rpx;
  236. }
  237. .list-cell {
  238. display: flex;
  239. align-items: baseline;
  240. margin: 100rpx 30rpx 0 30rpx;
  241. line-height: 80rpx;
  242. height: 80rpx;
  243. position: relative;
  244. background: $bgBaseBg;
  245. border-radius: 10rpx;
  246. justify-content: center;
  247. &.out {
  248. background: #999999
  249. }
  250. &.log-out-btn {
  251. margin-top: 40rpx;
  252. .cell-tit {
  253. color: #fff;
  254. text-align: center;
  255. margin-right: 0;
  256. }
  257. }
  258. .cell-tit {
  259. flex: 1;
  260. font-size: $font-base + 2rpx;
  261. color: $font-color-dark;
  262. margin-right: 10rpx;
  263. }
  264. .cell-tip {
  265. font-size: $font-base;
  266. color: $font-color-light;
  267. }
  268. switch {
  269. transform: translateX(16rpx) scale(0.84);
  270. }
  271. }
  272. .psw-wrapper {
  273. width: 548rpx;
  274. height: 344rpx;
  275. background-color: #ffffff;
  276. .psw-title {
  277. width: 100%;
  278. font-size: 35rpx;
  279. padding: 43rpx 0 49rpx;
  280. text-align: center;
  281. font-weight: 800;
  282. }
  283. .psw-ipt {
  284. display: block;
  285. background-color: #dce3ed;
  286. height: 90rpx;
  287. width: 464rpx;
  288. padding-left: 30rpx;
  289. margin: 0 auto;
  290. font-size: 80rpx;
  291. }
  292. .psw-btn text {
  293. display: inline-block;
  294. text-align: center;
  295. width: 50%;
  296. padding-top: 29rpx;
  297. font-size: 35rpx;
  298. }
  299. .psw-qd {
  300. color: #32C6FF;
  301. }
  302. }
  303. </style>