userinfo.vue 5.1 KB

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