userinfo.vue 5.1 KB

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