userinfo.vue 5.4 KB

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