多租户商城-商户小程序端
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.

551 lines
13 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
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>{{$t('common.head')}}</label>
  8. <image class="user-headImg" v-if="item.headImage" :src="item.headImage"></image>
  9. <image class="user-headImg" v-else src="http://36.138.125.206:8081/ceres-local-file/image/head_default.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>{{$t('common.nickname')}}</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>{{$t('common.sex')}}</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>{{$t('common.birthday')}}</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>{{$t('common.realname')}}</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>{{$t('common.idcard')}}</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%;">{{$t('common.mobilephone')}}</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>{{$t('common.yhysxy')}}</text>
  58. <image src="http://36.138.125.206:8081/ceres-local-file/static/root/right.png" mode=""></image>
  59. </view>
  60. <view class="agreement" @click="protocol('app_user_agreement')">
  61. <text>{{$t('common.yhfwxy')}}</text>
  62. <image src="http://36.138.125.206:8081/ceres-local-file/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">{{$t('navbar.logout')}}</view>
  67. <!-- #ifdef APP-PLUS -->
  68. <view class="cancellation" @click="cancellation">{{$t('common.cancelaccount')}}</view>
  69. <!-- #endif -->
  70. </view>
  71. <!-- 修改性别弹窗 -->
  72. <u-select v-model="sexShow" :title="$t('common.modifysex')" :list="sexList" @confirm="ConfirmSex"></u-select>
  73. <!-- 修改生日弹窗 -->
  74. <u-picker v-model="timeShow" mode="time" :title="$t('common.modifybirthday')" :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. let _this = this;
  166. uni.showModal({
  167. title: _this.$t('common.notice_dialog_title'),
  168. content: "是否注销此账号!",
  169. confirmText:"前往注销",
  170. success(res) {
  171. if (res.cancel) {
  172. uni.showToast({
  173. icon: 'none',
  174. title: '已取消'
  175. })
  176. } else if (res.confirm) {
  177. uni.navigateTo({
  178. url: 'unsubscribe'
  179. })
  180. }
  181. }
  182. })
  183. },
  184. // 修改生日
  185. changeTime() {
  186. if (this.birthday == '1970-01-01' || this.birthday == '') {
  187. this.timeShow = true
  188. }
  189. },
  190. // 修改昵称
  191. changeName() {
  192. const newName = this.name || this.phone
  193. if (!newName) {
  194. uni.showToast({
  195. title: '请输入新的内容',
  196. icon: "none"
  197. })
  198. return false
  199. }
  200. // uni.showLoading({
  201. // mask: true,
  202. // title: "正在加载中"
  203. // })
  204. NET.request(API.UpdateUser, {
  205. name: newName
  206. }, 'POST').then(res => {
  207. this.GetUser()
  208. uni.hideLoading()
  209. uni.showToast({
  210. title: '修改成功',
  211. icon: "success"
  212. })
  213. }).catch(res => {
  214. uni.hideLoading()
  215. })
  216. },
  217. changeRealName() {
  218. const newRealName = this.realName
  219. if (!newRealName) {
  220. uni.showToast({
  221. title: '请输入新的真实姓名',
  222. icon: "none"
  223. })
  224. return false
  225. }
  226. NET.request(API.UpdateUser, {
  227. realName: newRealName
  228. }, 'POST').then(res => {
  229. this.GetUser()
  230. uni.hideLoading()
  231. uni.showToast({
  232. title: '修改成功',
  233. icon: "success"
  234. })
  235. }).catch(res => {
  236. uni.hideLoading()
  237. })
  238. },
  239. changeIdCard() {
  240. const newIdCard = this.idCard
  241. if (!newIdCard) {
  242. uni.showToast({
  243. title: '请输入新的身份证号码',
  244. icon: "none"
  245. })
  246. return false
  247. }
  248. NET.request(API.UpdateUser, {
  249. idCard: newIdCard
  250. }, 'POST').then(res => {
  251. this.GetUser()
  252. uni.hideLoading()
  253. uni.showToast({
  254. title: '修改成功',
  255. icon: "success"
  256. })
  257. }).catch(res => {
  258. uni.hideLoading()
  259. })
  260. },
  261. // 提交修改生日
  262. ConfirmTime(content) {
  263. if (this.birthday == '1970-01-01' || this.birthday == '') {
  264. let birthday = content.year + '-' + content.month + '-' + content.day
  265. // uni.showLoading({
  266. // mask: true,
  267. // title: "正在加载中"
  268. // })
  269. NET.request(API.UpdateUser, {
  270. birthday
  271. }, 'POST').then(res => {
  272. this.GetUser()
  273. uni.hideLoading()
  274. uni.showToast({
  275. title: '修改成功',
  276. icon: "success"
  277. })
  278. }).catch(res => {
  279. uni.hideLoading()
  280. })
  281. }
  282. },
  283. // 点击弹窗修改性别
  284. sexShowClick() {
  285. this.sexShow = true
  286. },
  287. // 提交修改性别
  288. ConfirmSex(content) {
  289. // uni.showLoading({
  290. // mask: true,
  291. // title: "正在加载中"
  292. // })
  293. let sex = content[0].label
  294. NET.request(API.UpdateUser, {
  295. sex
  296. }, 'POST').then(res => {
  297. this.GetUser()
  298. uni.hideLoading()
  299. uni.showToast({
  300. title: '修改成功',
  301. icon: "success"
  302. })
  303. }).catch(res => {
  304. uni.hideLoading()
  305. })
  306. },
  307. // 获取用户信息
  308. GetUser() {
  309. NET.request(API.GetUser, {}, 'GET').then(res => {
  310. this.item = res.data
  311. this.phone = res.data.phone
  312. this.name = res.data.name
  313. this.birthday = res.data.birthday
  314. this.realName = res.data.realName
  315. this.idCard = res.data.idCard
  316. }).catch(res => {
  317. })
  318. },
  319. userHeadTap() {
  320. return
  321. uni.chooseImage({
  322. count: 1,
  323. sizeType: ['compressed'],
  324. success: (res) => {}
  325. })
  326. },
  327. //生日
  328. birthdateChange(e) {
  329. return
  330. this.item.birth = e.result
  331. },
  332. // 性别
  333. sexRadioGroupChange(e) {
  334. return
  335. },
  336. quit() {
  337. // uni.showLoading({
  338. // mask: true,
  339. // title: '正在退出...',
  340. // duration: 2000,
  341. // });
  342. setTimeout(function() {
  343. uni.removeStorageSync('storage_key');
  344. uni.removeStorageSync('distributorId');
  345. uni.removeStorageSync("allCartNum")
  346. uni.reLaunch({
  347. url: 'login',
  348. success() {
  349. uni.hideLoading()
  350. }
  351. })
  352. }, 1000)
  353. },
  354. onGetAuthorize() {
  355. const that = this
  356. // uni.showLoading({
  357. // mask: true,
  358. // title: '验证中...',
  359. // })
  360. this.$showLoading()
  361. my.getPhoneNumber({
  362. success: (res) => {
  363. this.$hideLoading()
  364. let encryptedData = res.response;
  365. NET.request(API.UpdateAliPhone, {
  366. 'phone': encryptedData
  367. }, 'POST').then(res => {
  368. const item = res.data
  369. uni.setStorageSync('storage_key', item);
  370. that.phone = item.phone
  371. // uni.hideLoading()
  372. }).finally(res => {
  373. uni.hideLoading()
  374. })
  375. },
  376. fail: (res) => {
  377. this.$hideLoading()
  378. uni.hideLoading()
  379. uni.showToast({
  380. title: '验证失败',
  381. icon: 'none'
  382. })
  383. }
  384. });
  385. },
  386. onAuthError() {
  387. }
  388. },
  389. filters: {
  390. parsebirthday(birthday) {
  391. if (birthday == '') {
  392. return "1970-01-01"
  393. } else {
  394. return birthday
  395. }
  396. }
  397. }
  398. }
  399. </script>
  400. <style lang='scss'>
  401. .agreement {
  402. width: 710rpx;
  403. margin: 20rpx auto 0;
  404. background-color: #fff;
  405. .agreement_top {
  406. &::after {
  407. content: "";
  408. display: block;
  409. position: absolute;
  410. left: 32rpx;
  411. bottom: 0;
  412. width: 646rpx;
  413. height: 4rpx;
  414. background: #F5F7FA;
  415. }
  416. }
  417. .agreement {
  418. width: 100%;
  419. height: 108rpx;
  420. display: flex;
  421. justify-content: space-between;
  422. align-items: center;
  423. font-size: 28rpx;
  424. color: #333;
  425. padding: 0 10rpx 0 32rpx;
  426. box-sizing: border-box;
  427. position: relative;
  428. image {
  429. width: 60rpx;
  430. height: 60rpx;
  431. }
  432. }
  433. }
  434. .phoneWxBut {
  435. width: 160rpx;
  436. height: 60rpx;
  437. border: 1rpx solid #FF7800;
  438. border-radius: 44rpx;
  439. font-size: 28rpx;
  440. line-height: 60rpx;
  441. }
  442. .container {
  443. width: 100%;
  444. background-color: #F7F7F7;
  445. padding: 20rpx;
  446. .personalBack-box {
  447. width: 100%;
  448. background-color: #FFFFFF;
  449. .personalHead-box {
  450. width: 90%;
  451. border-bottom: 1upx solid #E5E5E5;
  452. padding-bottom: 20upx;
  453. margin-top: 36upx;
  454. .nameInput {
  455. text-align: right;
  456. }
  457. }
  458. .personalHead-box1 {
  459. width: 90%;
  460. margin-top: 36upx;
  461. padding-bottom: 20upx;
  462. .user-headImg {
  463. width: 120upx;
  464. height: 112upx;
  465. border-radius: 50%;
  466. }
  467. }
  468. }
  469. .iphoneNumback-box {
  470. width: 100%;
  471. background-color: #FFFFFF;
  472. height: 100upx;
  473. margin-top: 20upx;
  474. .iphoneNum-box {
  475. width: 90%;
  476. .verifyPhone {
  477. color: #C5AA7B;
  478. font-size: 30upx;
  479. border: 0;
  480. }
  481. }
  482. }
  483. .exitLoginBut {
  484. height: 100rpx;
  485. background: #252744;
  486. border-radius: 50rpx;
  487. color: #FFFFFF;
  488. }
  489. .cancellation {
  490. height: 100rpx;
  491. margin: 24rpx auto 0;
  492. display: flex;
  493. align-items: center;
  494. justify-content: center;
  495. color: #C5AA7B;
  496. font-size: 28rpx;
  497. background: #FFFFFF;
  498. border: 3rpx solid #F3F4F5;
  499. }
  500. .sexRadio-box {
  501. width: 520upx;
  502. height: 328upx;
  503. .sexRadio {
  504. margin-top: 30upx;
  505. padding-bottom: 44upx;
  506. }
  507. }
  508. .headBox {
  509. margin-bottom: 20rpx;
  510. background: #FFFFFF;
  511. padding: 25rpx 0;
  512. .personalHead-box {
  513. width: 90%;
  514. margin: 0 auto;
  515. }
  516. .user-headImg {
  517. width: 120upx;
  518. height: 112upx;
  519. border-radius: 50%;
  520. }
  521. }
  522. }
  523. </style>