userinfo.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view class="content">
  3. <view class="row1">
  4. <text class="tit">头像</text>
  5. <view class="background-img" @click.stop="imgsub"><image class="background-img" v-model="userInfo.avatar" :src="userInfo.avatar" mode="aspectFill"></image></view>
  6. </view>
  7. <view class="row">
  8. <text class="tit">昵称</text>
  9. <input class="input" type="text" v-model="userInfo.nickname" placeholder-class="placeholder" />
  10. </view>
  11. <view class="row">
  12. <text class="tit">ID</text>
  13. <input class="input" type="text" disabled="true" v-model="userInfo.uid" placeholder-class="placeholder" />
  14. </view>
  15. <view class="row">
  16. <text class="tit">账户</text>
  17. <input class="input" type="text" disabled="true" v-model="userInfo.phone" placeholder-class="placeholder" />
  18. </view>
  19. <view class="add-btn" @click="confirm">提交</view>
  20. <!-- <view class="out" @click="cancel">注销账户</view> -->
  21. <uni-popup ref="popup" type="center">
  22. <view class="psw-wrapper">
  23. <view class="psw-title">请输入自己的账户</view>
  24. <input type="text" v-model="password" class="psw-ipt" />
  25. <view class="psw-btn">
  26. <text @click.stop="qx">取消</text>
  27. <text class="psw-qd" @click.stop="pswQd">确定</text>
  28. </view>
  29. </view>
  30. </uni-popup>
  31. </view>
  32. </template>
  33. <script>
  34. import { mapState, mapMutations } from 'vuex';
  35. import { upload } from '@/api/order.js';
  36. import { userEdit, logout } from '@/api/set.js';
  37. export default {
  38. data() {
  39. return {
  40. show: false,
  41. password: ''
  42. };
  43. },
  44. onLoad() {
  45. console.log(this.userInfo);
  46. },
  47. computed: {
  48. ...mapState('user', ['userInfo'])
  49. },
  50. methods: {
  51. ...mapMutations('user', ['logout']),
  52. imgsub() {
  53. console.log('上传头像');
  54. upload({
  55. filename: ''
  56. }).then(data => {
  57. console.log('data', data);
  58. this.userInfo.avatar = data[0].url;
  59. });
  60. },
  61. confirm() {
  62. userEdit({ avatar: this.userInfo.avatar, nickname: this.userInfo.nickname })
  63. .then(e => {
  64. this.$api.msg('修改成功');
  65. setTimeout(() => {
  66. uni.switchTab({
  67. url: '/pages/user/user'
  68. });
  69. }, 1000);
  70. console.log(e);
  71. })
  72. .catch(e => {
  73. console.log(e);
  74. });
  75. },
  76. toLogout() {
  77. let obj = this;
  78. uni.showModal({
  79. content: '确定要退出登录么',
  80. success: e => {
  81. if (e.confirm) {
  82. logout({})
  83. .then(e => {
  84. uni.navigateBack();
  85. })
  86. .catch(e => {
  87. console.log(e);
  88. });
  89. obj.logout();
  90. }
  91. }
  92. });
  93. },
  94. cancel() {
  95. this.$refs.popup.open();
  96. },
  97. qx() {
  98. this.password = '';
  99. this.$refs.popup.close();
  100. },
  101. pswQd() {
  102. if (this.password != this.userInfo.phone) {
  103. this.$refs.popup.close();
  104. this.password = '';
  105. this.$api.msg('请输入自己的账户');
  106. return;
  107. }
  108. this.$refs.popup.close();
  109. this.password = '';
  110. this.$api.msg('申请注销成功,请耐心等待审核');
  111. }
  112. }
  113. };
  114. </script>
  115. <style lang="scss">
  116. .row1 {
  117. display: flex;
  118. align-items: center;
  119. justify-content: space-between;
  120. position: relative;
  121. padding: 0 30upx;
  122. height: 110upx;
  123. background: #fff;
  124. margin-bottom: 20upx;
  125. .tit {
  126. flex-shrink: 0;
  127. width: 120upx;
  128. font-size: $font-lg;
  129. color: $font-color-dark;
  130. }
  131. .background-img {
  132. width: 80rpx;
  133. height: 80rpx;
  134. border-radius: 50%;
  135. background: #f2f2f2;
  136. }
  137. }
  138. .row {
  139. display: flex;
  140. align-items: center;
  141. padding: 0 30upx;
  142. height: 110upx;
  143. background: #fff;
  144. .tit {
  145. flex-shrink: 0;
  146. width: 120upx;
  147. font-size: $font-lg;
  148. color: $font-color-dark;
  149. }
  150. .input {
  151. flex: 1;
  152. text-align: right;
  153. font-size: $font-base;
  154. color: $color-gray;
  155. }
  156. }
  157. .add-btn {
  158. display: flex;
  159. align-items: center;
  160. justify-content: center;
  161. margin: 158rpx auto 30rpx;
  162. width: 560rpx;
  163. height: 80rpx;
  164. background: #dc262b;
  165. border-radius: 40px;
  166. color: #ffffff;
  167. }
  168. .out {
  169. display: flex;
  170. align-items: center;
  171. justify-content: center;
  172. margin: 0 auto 30rpx;
  173. width: 560rpx;
  174. height: 80rpx;
  175. border: 1px solid #32c6ff;
  176. background: #ffffff;
  177. border-radius: 40px;
  178. color: #32c6ff;
  179. }
  180. .psw-wrapper {
  181. width: 548rpx;
  182. height: 344rpx;
  183. background-color: #ffffff;
  184. .psw-title {
  185. width: 100%;
  186. font-size: 35rpx;
  187. padding: 43rpx 0 49rpx;
  188. text-align: center;
  189. font-weight: 800;
  190. }
  191. .psw-ipt {
  192. display: block;
  193. background-color: #dce3ed;
  194. height: 90rpx;
  195. width: 464rpx;
  196. padding-left: 30rpx;
  197. margin: 0 auto;
  198. font-size: 80rpx;
  199. }
  200. .psw-btn text {
  201. display: inline-block;
  202. text-align: center;
  203. width: 50%;
  204. padding-top: 29rpx;
  205. font-size: 35rpx;
  206. }
  207. .psw-qd {
  208. color: #32c6ff;
  209. }
  210. }
  211. </style>