userinfo.vue 5.1 KB

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