多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

549 lines
12 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <!-- 修改个人信息 -->
  2. <template>
  3. <view class="container fs28" :style="{height:screenHeight+'px'}">
  4. <global-loading />
  5. <view class="headBox">
  6. <view class="personalHead-box flex-sp-between flex-display flex-items">
  7. <label>头像</label>
  8. <image class="user-headImg" v-if="item.headImage" :src="item.headImage"></image>
  9. <image class="user-headImg" v-else src="https://ceres.zkthink.com/static/img/user/morentouxiang.png">
  10. </image>
  11. </view>
  12. </view>
  13. <view class="personalBack-box flex-items-plus flex-column">
  14. <view class="personalHead-box flex-sp-between flex-display flex-items">
  15. <label>昵称</label>
  16. <!-- <label class="font-color-999" v-if="item.name">{{item.name}}</label>-->
  17. <!-- <label class="font-color-999" v-else>{{item.phone}}</label>-->
  18. <!-- <input class="nameInput" v-if="name" v-model="name" type="text" placeholder="请输入内容" @blur="changeName(1)" /> -->
  19. <!-- <input class="nameInput" v-else type="text" v-model="phone" placeholder="请输入内容" @blur="changeName(2)" /> -->
  20. <input class="nameInput" v-model="name" type="text" placeholder="请输入内容" @blur="changeName" />
  21. </view>
  22. <view class="personalHead-box flex-sp-between flex-display flex-items" @click="sexShowClick">
  23. <label>性别</label>
  24. <label class="font-color-999">{{item.sex}}</label>
  25. </view>
  26. <view class="personalHead-box1 flex-sp-between flex-display flex-items" @click="changeTime">
  27. <label>生日</label>
  28. <label class="font-color-999">{{birthday | parsebirthday}}</label>
  29. <!-- <u-calendar v-model="birthdateShow" :mode="mode"></u-calendar> -->
  30. </view>
  31. <view class="personalHead-box flex-sp-between flex-display flex-items">
  32. <label>真实姓名</label>
  33. <input class="nameInput" v-model="realName" type="text" placeholder="请输入真实姓名" @blur="changeRealName" />
  34. </view>
  35. <view class="personalHead-box flex-sp-between flex-display flex-items">
  36. <label>身份证</label>
  37. <input class="nameInput" v-model="idCard" type="text" placeholder="请输入身份证" @blur="changeIdCard" />
  38. </view>
  39. </view>
  40. <view class="iphoneNumback-box flex-items-plus">
  41. <view class="iphoneNum-box flex-row-plus flex-sp-between flex-items">
  42. <label style="width: 50%;">手机号</label>
  43. <label class="font-color-C5AA7B" v-if="phone">{{phone}}</label>
  44. <label class="font-color-C5AA7B" v-else>
  45. <!-- #ifdef MP-ALIPAY -->
  46. <button class="verifyPhone" open-type="getAuthorize" @getAuthorize="onGetAuthorize"
  47. @error="onAuthError" scope='phoneNumber'>去验证</button>
  48. <!-- #endif -->
  49. <!-- #ifndef MP-ALIPAY -->
  50. 去验证
  51. <!-- #endif -->
  52. </label>
  53. </view>
  54. </view>
  55. <view class="agreement">
  56. <view class="agreement agreement_top" @click="protocol('app_privacy_agreement')">
  57. <text>用户隐私协议</text>
  58. <image src="https://ceres.zkthink.com/static/root/right.png" mode=""></image>
  59. </view>
  60. <view class="agreement" @click="protocol('app_user_agreement')">
  61. <text>用户服务协议</text>
  62. <image src="https://ceres.zkthink.com/static/root/right.png" mode=""></image>
  63. </view>
  64. </view>
  65. <view class="mar-top-100">
  66. <view class="exitLoginBut flex-items-plus" @click="quit">退出登录</view>
  67. <!-- #ifdef APP-PLUS -->
  68. <view class="cancellation" @click="cancellation">注销账号</view>
  69. <!-- #endif -->
  70. </view>
  71. <!-- 修改性别弹窗 -->
  72. <u-select v-model="sexShow" title="修改性别" :list="sexList" @confirm="ConfirmSex"></u-select>
  73. <!-- 修改生日弹窗 -->
  74. <u-picker v-model="timeShow" mode="time" title="修改生日" :params="params" start-year="1970" @confirm="ConfirmTime">
  75. </u-picker>
  76. <!-- <view>
  77. <u-popup v-model="sexShow" mode="center" close-icon-size ="20" border-radius="10" :closeable='true' close-icon-pos = "top-right">
  78. <view class="flex-items-plus flex-column">
  79. <label class="mar-top-50 fs-bold">性别</label>
  80. <u-radio-group class="sexRadio-box flex-items-plus flex-column" v-model="item.sex" @change="sexRadioGroupChange">
  81. <u-radio class="sexRadio"
  82. v-for="(item, index) in sexList" :key="index"
  83. :name="item.id"
  84. :disabled="item.disabled"
  85. active-color="#C5AA7B"
  86. >
  87. {{item.name}}
  88. </u-radio>
  89. </u-radio-group>
  90. </view>
  91. </u-popup>
  92. </view> -->
  93. </view>
  94. </template>
  95. <script>
  96. const NET = require('../../utils/request')
  97. const API = require('../../config/api')
  98. export default {
  99. data() {
  100. return {
  101. screenHeight: 0,
  102. birthdateShow: false,
  103. mode: 'date',
  104. birthday: '',
  105. // sexList: [{
  106. // id: 1,
  107. // name: '男',
  108. // disabled: false
  109. // }, {
  110. // id: 2,
  111. // name: '女',
  112. // disabled: false
  113. // }],
  114. sexShow: false,
  115. timeShow: false,
  116. item: {},
  117. UpdateInfoQuery: {
  118. headimg: '',
  119. sex: '',
  120. nickname: ''
  121. },
  122. code: '',
  123. phone: '',
  124. name: '',
  125. realName:'',
  126. idCard:'',
  127. sexList: [{
  128. value: '1',
  129. label: '男'
  130. },
  131. {
  132. value: '2',
  133. label: '女'
  134. }
  135. ],
  136. params: { // 日期
  137. year: true,
  138. month: true,
  139. day: true,
  140. hour: false,
  141. minute: false,
  142. second: false
  143. },
  144. }
  145. },
  146. onLoad() {
  147. this.GetUser()
  148. },
  149. mounted() {
  150. // 获取手机的屏幕高度
  151. uni.getSystemInfo({
  152. success: (res) => {
  153. this.screenHeight = res.screenHeight
  154. }
  155. })
  156. },
  157. methods: {
  158. // 多商户用户协议
  159. protocol(type) {
  160. uni.navigateTo({
  161. url: 'protocol?type=' + type
  162. })
  163. },
  164. cancellation() {
  165. uni.showModal({
  166. title: "温馨提示",
  167. content: "是否注销此账号!",
  168. confirmText:"前往注销",
  169. success(res) {
  170. if (res.cancel) {
  171. uni.showToast({
  172. icon: 'none',
  173. title: '已取消'
  174. })
  175. } else if (res.confirm) {
  176. uni.navigateTo({
  177. url: 'unsubscribe'
  178. })
  179. }
  180. }
  181. })
  182. },
  183. // 修改生日
  184. changeTime() {
  185. if (this.birthday == '1970-01-01' || this.birthday == '') {
  186. this.timeShow = true
  187. }
  188. },
  189. // 修改昵称
  190. changeName() {
  191. const newName = this.name || this.phone
  192. if (!newName) {
  193. uni.showToast({
  194. title: '请输入新的内容',
  195. icon: "none"
  196. })
  197. return false
  198. }
  199. // uni.showLoading({
  200. // mask: true,
  201. // title: "正在加载中"
  202. // })
  203. NET.request(API.UpdateUser, {
  204. name: newName
  205. }, 'POST').then(res => {
  206. this.GetUser()
  207. uni.hideLoading()
  208. uni.showToast({
  209. title: '修改成功',
  210. icon: "success"
  211. })
  212. }).catch(res => {
  213. uni.hideLoading()
  214. })
  215. },
  216. changeRealName() {
  217. const newRealName = this.realName
  218. if (!newRealName) {
  219. uni.showToast({
  220. title: '请输入新的真实姓名',
  221. icon: "none"
  222. })
  223. return false
  224. }
  225. NET.request(API.UpdateUser, {
  226. realName: newRealName
  227. }, 'POST').then(res => {
  228. this.GetUser()
  229. uni.hideLoading()
  230. uni.showToast({
  231. title: '修改成功',
  232. icon: "success"
  233. })
  234. }).catch(res => {
  235. uni.hideLoading()
  236. })
  237. },
  238. changeIdCard() {
  239. const newIdCard = this.idCard
  240. if (!newIdCard) {
  241. uni.showToast({
  242. title: '请输入新的身份证号码',
  243. icon: "none"
  244. })
  245. return false
  246. }
  247. NET.request(API.UpdateUser, {
  248. idCard: newIdCard
  249. }, 'POST').then(res => {
  250. this.GetUser()
  251. uni.hideLoading()
  252. uni.showToast({
  253. title: '修改成功',
  254. icon: "success"
  255. })
  256. }).catch(res => {
  257. uni.hideLoading()
  258. })
  259. },
  260. // 提交修改生日
  261. ConfirmTime(content) {
  262. if (this.birthday == '1970-01-01' || this.birthday == '') {
  263. let birthday = content.year + '-' + content.month + '-' + content.day
  264. // uni.showLoading({
  265. // mask: true,
  266. // title: "正在加载中"
  267. // })
  268. NET.request(API.UpdateUser, {
  269. birthday
  270. }, 'POST').then(res => {
  271. this.GetUser()
  272. uni.hideLoading()
  273. uni.showToast({
  274. title: '修改成功',
  275. icon: "success"
  276. })
  277. }).catch(res => {
  278. uni.hideLoading()
  279. })
  280. }
  281. },
  282. // 点击弹窗修改性别
  283. sexShowClick() {
  284. this.sexShow = true
  285. },
  286. // 提交修改性别
  287. ConfirmSex(content) {
  288. // uni.showLoading({
  289. // mask: true,
  290. // title: "正在加载中"
  291. // })
  292. let sex = content[0].label
  293. NET.request(API.UpdateUser, {
  294. sex
  295. }, 'POST').then(res => {
  296. this.GetUser()
  297. uni.hideLoading()
  298. uni.showToast({
  299. title: '修改成功',
  300. icon: "success"
  301. })
  302. }).catch(res => {
  303. uni.hideLoading()
  304. })
  305. },
  306. // 获取用户信息
  307. GetUser() {
  308. NET.request(API.GetUser, {}, 'GET').then(res => {
  309. this.item = res.data
  310. this.phone = res.data.phone
  311. this.name = res.data.name
  312. this.birthday = res.data.birthday
  313. this.realName = res.data.realName
  314. this.idCard = res.data.idCard
  315. }).catch(res => {
  316. })
  317. },
  318. userHeadTap() {
  319. return
  320. uni.chooseImage({
  321. count: 1,
  322. sizeType: ['compressed'],
  323. success: (res) => {}
  324. })
  325. },
  326. //生日
  327. birthdateChange(e) {
  328. return
  329. this.item.birth = e.result
  330. },
  331. // 性别
  332. sexRadioGroupChange(e) {
  333. return
  334. },
  335. quit() {
  336. // uni.showLoading({
  337. // mask: true,
  338. // title: '正在退出...',
  339. // duration: 2000,
  340. // });
  341. setTimeout(function() {
  342. uni.removeStorageSync('storage_key');
  343. uni.removeStorageSync('distributorId');
  344. uni.removeStorageSync("allCartNum")
  345. uni.reLaunch({
  346. url: 'login',
  347. success() {
  348. uni.hideLoading()
  349. }
  350. })
  351. }, 1000)
  352. },
  353. onGetAuthorize() {
  354. const that = this
  355. // uni.showLoading({
  356. // mask: true,
  357. // title: '验证中...',
  358. // })
  359. this.$showLoading()
  360. my.getPhoneNumber({
  361. success: (res) => {
  362. this.$hideLoading()
  363. let encryptedData = res.response;
  364. NET.request(API.UpdateAliPhone, {
  365. 'phone': encryptedData
  366. }, 'POST').then(res => {
  367. const item = res.data
  368. uni.setStorageSync('storage_key', item);
  369. that.phone = item.phone
  370. // uni.hideLoading()
  371. }).finally(res => {
  372. uni.hideLoading()
  373. })
  374. },
  375. fail: (res) => {
  376. this.$hideLoading()
  377. uni.hideLoading()
  378. uni.showToast({
  379. title: '验证失败',
  380. icon: 'none'
  381. })
  382. }
  383. });
  384. },
  385. onAuthError() {
  386. }
  387. },
  388. filters: {
  389. parsebirthday(birthday) {
  390. if (birthday == '') {
  391. return "1970-01-01"
  392. } else {
  393. return birthday
  394. }
  395. }
  396. }
  397. }
  398. </script>
  399. <style lang='scss'>
  400. .agreement {
  401. width: 710rpx;
  402. margin: 20rpx auto 0;
  403. background-color: #fff;
  404. .agreement_top {
  405. &::after {
  406. content: "";
  407. display: block;
  408. position: absolute;
  409. left: 32rpx;
  410. bottom: 0;
  411. width: 646rpx;
  412. height: 4rpx;
  413. background: #F5F7FA;
  414. }
  415. }
  416. .agreement {
  417. width: 100%;
  418. height: 108rpx;
  419. display: flex;
  420. justify-content: space-between;
  421. align-items: center;
  422. font-size: 28rpx;
  423. color: #333;
  424. padding: 0 10rpx 0 32rpx;
  425. box-sizing: border-box;
  426. position: relative;
  427. image {
  428. width: 60rpx;
  429. height: 60rpx;
  430. }
  431. }
  432. }
  433. .phoneWxBut {
  434. width: 160rpx;
  435. height: 60rpx;
  436. border: 1rpx solid #FF7800;
  437. border-radius: 44rpx;
  438. font-size: 28rpx;
  439. line-height: 60rpx;
  440. }
  441. .container {
  442. width: 100%;
  443. background-color: #F7F7F7;
  444. padding: 20rpx;
  445. .personalBack-box {
  446. width: 100%;
  447. background-color: #FFFFFF;
  448. .personalHead-box {
  449. width: 90%;
  450. border-bottom: 1upx solid #E5E5E5;
  451. padding-bottom: 20upx;
  452. margin-top: 36upx;
  453. .nameInput {
  454. text-align: right;
  455. }
  456. }
  457. .personalHead-box1 {
  458. width: 90%;
  459. margin-top: 36upx;
  460. padding-bottom: 20upx;
  461. .user-headImg {
  462. width: 120upx;
  463. height: 112upx;
  464. border-radius: 50%;
  465. }
  466. }
  467. }
  468. .iphoneNumback-box {
  469. width: 100%;
  470. background-color: #FFFFFF;
  471. height: 100upx;
  472. margin-top: 20upx;
  473. .iphoneNum-box {
  474. width: 90%;
  475. .verifyPhone {
  476. color: #C5AA7B;
  477. font-size: 30upx;
  478. border: 0;
  479. }
  480. }
  481. }
  482. .exitLoginBut {
  483. height: 100upx;
  484. background: #333333;
  485. color: #FFEBC4;
  486. }
  487. .cancellation {
  488. height: 100rpx;
  489. margin: 24rpx auto 0;
  490. display: flex;
  491. align-items: center;
  492. justify-content: center;
  493. color: #C5AA7B;
  494. font-size: 28rpx;
  495. background: #FFFFFF;
  496. border: 3rpx solid #F3F4F5;
  497. }
  498. .sexRadio-box {
  499. width: 520upx;
  500. height: 328upx;
  501. .sexRadio {
  502. margin-top: 30upx;
  503. padding-bottom: 44upx;
  504. }
  505. }
  506. .headBox {
  507. margin-bottom: 20rpx;
  508. background: #FFFFFF;
  509. padding: 25rpx 0;
  510. .personalHead-box {
  511. width: 90%;
  512. margin: 0 auto;
  513. }
  514. .user-headImg {
  515. width: 120upx;
  516. height: 112upx;
  517. border-radius: 50%;
  518. }
  519. }
  520. }
  521. </style>