personalDetails.vue 11 KB

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