userinfo.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  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.spread_uid">
  27. <text class="tit">推荐人</text>
  28. <input class="input" type="text" placeholder="请输入推荐人UID" v-model="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. setSpread
  51. } from '@/api/set.js';
  52. export default {
  53. components: {
  54. ykAuthpup
  55. },
  56. data() {
  57. return {
  58. show: false,
  59. password: '',
  60. tjr: ''
  61. }
  62. },
  63. onLoad() {
  64. console.log(this.userInfo)
  65. },
  66. computed: {
  67. ...mapState('user', ['userInfo'])
  68. },
  69. methods: {
  70. ...mapMutations('user', ['logout']),
  71. //获取头像变化的值
  72. openAuth() {
  73. this.$refs['WRITE_EXTERNAL_STORAGE'].open()
  74. },
  75. changeAuth() {
  76. this.imgsub()
  77. },
  78. imgsub() {
  79. console.log('上传头像')
  80. upload({
  81. filename: ''
  82. }).then(data => {
  83. console.log("data", data);
  84. this.userInfo.avatar = data[0].url;
  85. })
  86. },
  87. confirm() {
  88. let that = this;
  89. userEdit({
  90. avatar: that.userInfo.avatar,
  91. nickname: that.userInfo.nickname
  92. })
  93. .then(e => {
  94. that.$api.msg('修改成功');
  95. if(!that.userInfo.spread_uid && that.tjr) {
  96. setSpread({
  97. spread_uid: that.tjr
  98. }).then(res => {
  99. setTimeout(() => {
  100. uni.switchTab({
  101. url: '/pages/user/user'
  102. });
  103. }, 1000);
  104. })
  105. }else {
  106. setTimeout(() => {
  107. uni.switchTab({
  108. url: '/pages/user/user'
  109. });
  110. }, 1000);
  111. }
  112. })
  113. .catch(e => {
  114. console.log(e);
  115. });
  116. },
  117. toLogout() {
  118. let obj = this;
  119. uni.showModal({
  120. content: '确定要退出登录么',
  121. success: (e) => {
  122. if (e.confirm) {
  123. logout({}).then((e) => {
  124. uni.navigateBack();
  125. }).catch((e) => {
  126. console.log(e);
  127. })
  128. obj.logout();
  129. }
  130. }
  131. });
  132. },
  133. cancel() {
  134. // this.$refs.popup.open();
  135. let obj = this;
  136. uni.showModal({
  137. content: '确定要退出登录么',
  138. success: e => {
  139. if (e.confirm) {
  140. logout({}).then(e => {
  141. obj.logout();
  142. uni.switchTab({
  143. url: '/pages/index/index'
  144. })
  145. })
  146. .catch(e => {
  147. console.log(e);
  148. });
  149. }
  150. }
  151. });
  152. },
  153. qx() {
  154. this.password = '';
  155. this.$refs.popup.close();
  156. },
  157. pswQd() {
  158. if (this.password != this.userInfo.phone) {
  159. this.$refs.popup.close();
  160. this.password = '';
  161. this.$api.msg("请输入自己的账户")
  162. return
  163. }
  164. this.$refs.popup.close();
  165. this.password = '';
  166. this.$api.msg("申请注销成功,请耐心等待审核")
  167. }
  168. }
  169. }
  170. </script>
  171. <style lang="scss">
  172. .row1 {
  173. display: flex;
  174. align-items: center;
  175. justify-content: space-between;
  176. position: relative;
  177. padding: 0 30upx;
  178. height: 110upx;
  179. background: #fff;
  180. margin-bottom: 20upx;
  181. .tit {
  182. flex-shrink: 0;
  183. width: 120upx;
  184. font-size: $font-lg;
  185. color: $font-color-dark;
  186. }
  187. .background-img {
  188. width: 80rpx;
  189. height: 80rpx;
  190. border-radius: 50%;
  191. background: #f2f2f2;
  192. }
  193. }
  194. .row {
  195. display: flex;
  196. align-items: center;
  197. padding: 0 30upx;
  198. height: 110upx;
  199. background: #fff;
  200. .tit {
  201. flex-shrink: 0;
  202. width: 120upx;
  203. font-size: $font-lg;
  204. color: $font-color-dark;
  205. }
  206. .input {
  207. flex: 1;
  208. text-align: right;
  209. font-size: $font-base;
  210. color: $color-gray;
  211. }
  212. }
  213. .add-btn {
  214. display: flex;
  215. align-items: center;
  216. justify-content: center;
  217. margin: 40rpx auto 30rpx;
  218. width: 560rpx;
  219. height: 80rpx;
  220. background: #fff;
  221. border-radius: 40px;
  222. color: $base-color;
  223. border: 1px solid $base-color;
  224. }
  225. .tj {
  226. margin-top: 160rpx;
  227. background: $base-color;
  228. color: #fff;
  229. }
  230. .out {
  231. display: flex;
  232. align-items: center;
  233. justify-content: center;
  234. margin: 0 auto 30rpx;
  235. width: 560rpx;
  236. height: 80rpx;
  237. border: 1px solid #DC262B;
  238. background: #FFFFFF;
  239. border-radius: 40px;
  240. color: #DC262B;
  241. }
  242. .psw-wrapper {
  243. width: 548rpx;
  244. height: 344rpx;
  245. background-color: #ffffff;
  246. .psw-title {
  247. width: 100%;
  248. font-size: 35rpx;
  249. padding: 43rpx 0 49rpx;
  250. text-align: center;
  251. font-weight: 800;
  252. }
  253. .psw-ipt {
  254. display: block;
  255. background-color: #dce3ed;
  256. height: 90rpx;
  257. width: 464rpx;
  258. padding-left: 30rpx;
  259. margin: 0 auto;
  260. font-size: 80rpx;
  261. }
  262. .psw-btn text {
  263. display: inline-block;
  264. text-align: center;
  265. width: 50%;
  266. padding-top: 29rpx;
  267. font-size: 35rpx;
  268. }
  269. .psw-qd {
  270. color: #32C6FF;
  271. }
  272. }
  273. .auth_wrap {
  274. position: fixed;
  275. width: 100%;
  276. bottom: -120%;
  277. transition: all 0.35s linear;
  278. &.show {
  279. bottom: 0;
  280. transition: all 0.35s linear;
  281. .mask {
  282. display: block;
  283. }
  284. }
  285. .mask {
  286. width: 100%;
  287. height: 100vh;
  288. position: fixed;
  289. background: rgba(0, 0, 0, 0.5);
  290. z-index: 98;
  291. top: 0;
  292. display: none;
  293. }
  294. .auth_content {
  295. padding: 32rpx 32rpx 72rpx 32rpx;
  296. position: relative;
  297. z-index: 99;
  298. background: #fff;
  299. border-radius: 16rpx 16rpx 0 0;
  300. .auth_top {
  301. position: relative;
  302. .ptitle {
  303. font-size: 30rpx;
  304. font-weight: bold;
  305. margin-bottom: 24rpx;
  306. }
  307. .txt {
  308. font-size: 26rpx;
  309. color: #999;
  310. }
  311. .close {
  312. width: 26rpx;
  313. height: 26rpx;
  314. position: absolute;
  315. right: 0;
  316. top: 0;
  317. image {
  318. width: 100%;
  319. height: 100%;
  320. }
  321. }
  322. }
  323. .auth_ul {
  324. margin-top: 16rpx;
  325. .auth_li {
  326. display: flex;
  327. align-items: center;
  328. border-top: solid 1px #f5f5f5;
  329. padding: 24rpx 0;
  330. &:last-child {
  331. border-bottom: solid 1px #f5f5f5;
  332. }
  333. .tit {
  334. width: 140rpx;
  335. font-size: 30rpx;
  336. }
  337. .rit {
  338. width: calc(100% - 140rpx);
  339. input {
  340. font-size: 28rpx;
  341. height: 72rpx;
  342. width: 100%;
  343. }
  344. image {
  345. width: 54rpx;
  346. height: 54rpx;
  347. border-radius: 50%;
  348. }
  349. button {
  350. width: 100%;
  351. height: 72rpx;
  352. background: #fff;
  353. text-align: left;
  354. padding: 0;
  355. &:after {
  356. border: solid 1px #fff;
  357. }
  358. // opacity: 0;
  359. }
  360. }
  361. }
  362. }
  363. .confirm_btn {
  364. width: 420rpx;
  365. margin: 46rpx auto 0 auto;
  366. background: #39b54a;
  367. color: #fff;
  368. border-radius: 8rpx;
  369. height: 94rpx;
  370. display: flex;
  371. align-items: center;
  372. justify-content: center;
  373. font-size: 30rpx;
  374. }
  375. }
  376. }
  377. </style>