userinfo.vue 5.7 KB

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