personalDetails.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  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. import { J_STORAGE_KEY } from '../../config/constant'
  93. const NET = require('../../utils/request')
  94. const API = require('../../config/api')
  95. export default {
  96. filters: {
  97. parsebirthday(birthday) {
  98. if (birthday == '') {
  99. return '1970-01-01'
  100. }
  101. return birthday
  102. }
  103. },
  104. data() {
  105. return {
  106. screenHeight: 0,
  107. birthdateShow: false,
  108. mode: 'date',
  109. birthday: '',
  110. // sexList: [{
  111. // id: 1,
  112. // name: '男',
  113. // disabled: false
  114. // }, {
  115. // id: 2,
  116. // name: '女',
  117. // disabled: false
  118. // }],
  119. sexShow: false,
  120. timeShow: false,
  121. item: {},
  122. UpdateInfoQuery: {
  123. headimg: '',
  124. sex: '',
  125. nickname: ''
  126. },
  127. code: '',
  128. phone: '',
  129. name: '',
  130. sexList: [{
  131. value: '1',
  132. label: '男'
  133. },
  134. {
  135. value: '2',
  136. label: '女'
  137. }],
  138. params: { // 日期
  139. year: true,
  140. month: true,
  141. day: true,
  142. hour: false,
  143. minute: false,
  144. second: false
  145. }
  146. }
  147. },
  148. onLoad() {
  149. this.GetUser()
  150. },
  151. mounted() {
  152. // 获取手机的屏幕高度
  153. uni.getSystemInfo({
  154. success: (res) => {
  155. this.screenHeight = res.screenHeight
  156. }
  157. })
  158. },
  159. methods: {
  160. // 多商户用户协议
  161. protocol(type) {
  162. uni.navigateTo({
  163. url: 'protocol?type=' + type
  164. })
  165. },
  166. cancellation() {
  167. uni.showModal({
  168. title: '温馨提示',
  169. content: '是否注销此账号!',
  170. confirmText: '前往注销',
  171. success(res) {
  172. if (res.cancel) {
  173. uni.showToast({
  174. icon: 'none',
  175. title: '已取消'
  176. })
  177. } else if (res.confirm) {
  178. uni.navigateTo({
  179. url: 'unsubscribe'
  180. })
  181. }
  182. }
  183. })
  184. },
  185. // 修改生日
  186. changeTime() {
  187. if (this.birthday == '1970-01-01' || this.birthday == '') {
  188. this.timeShow = true
  189. }
  190. },
  191. // 修改昵称
  192. changeName() {
  193. const newName = this.name || this.phone
  194. if (!newName) {
  195. uni.showToast({
  196. title: '请输入新的内容',
  197. icon: 'none'
  198. })
  199. return false
  200. }
  201. // uni.showLoading({
  202. // mask: true,
  203. // title: "正在加载中"
  204. // })
  205. NET.request(API.UpdateUser, {
  206. name: newName
  207. }, 'POST').then((res) => {
  208. this.GetUser()
  209. uni.hideLoading()
  210. uni.showToast({
  211. title: '修改成功',
  212. icon: 'success'
  213. })
  214. })
  215. .catch((res) => {
  216. uni.hideLoading()
  217. })
  218. },
  219. // 提交修改生日
  220. ConfirmTime(content) {
  221. if (this.birthday == '1970-01-01' || this.birthday == '') {
  222. const birthday = content.year + '-' + content.month + '-' + content.day
  223. // uni.showLoading({
  224. // mask: true,
  225. // title: "正在加载中"
  226. // })
  227. NET.request(API.UpdateUser, {
  228. birthday
  229. }, 'POST').then((res) => {
  230. this.GetUser()
  231. uni.hideLoading()
  232. uni.showToast({
  233. title: '修改成功',
  234. icon: 'success'
  235. })
  236. })
  237. .catch((res) => {
  238. uni.hideLoading()
  239. })
  240. }
  241. },
  242. // 点击弹窗修改性别
  243. sexShowClick() {
  244. this.sexShow = true
  245. },
  246. // 提交修改性别
  247. ConfirmSex(content) {
  248. // uni.showLoading({
  249. // mask: true,
  250. // title: "正在加载中"
  251. // })
  252. const sex = content[0].label
  253. NET.request(API.UpdateUser, {
  254. sex
  255. }, 'POST').then((res) => {
  256. this.GetUser()
  257. uni.hideLoading()
  258. uni.showToast({
  259. title: '修改成功',
  260. icon: 'success'
  261. })
  262. })
  263. .catch((res) => {
  264. uni.hideLoading()
  265. })
  266. },
  267. // 获取用户信息
  268. GetUser() {
  269. NET.request(API.GetUser, {}, 'GET').then((res) => {
  270. this.item = res.data
  271. this.phone = res.data.phone
  272. this.name = res.data.name
  273. this.birthday = res.data.birthday
  274. })
  275. .catch((res) => {
  276. })
  277. },
  278. userHeadTap() {
  279. return
  280. uni.chooseImage({
  281. count: 1,
  282. sizeType: [ 'compressed' ],
  283. success: (res) => { }
  284. })
  285. },
  286. // 生日
  287. birthdateChange(e) {
  288. return
  289. this.item.birth = e.result
  290. },
  291. // 性别
  292. sexRadioGroupChange(e) {
  293. },
  294. quit() {
  295. // uni.showLoading({
  296. // mask: true,
  297. // title: '正在退出...',
  298. // duration: 2000,
  299. // });
  300. setTimeout(function () {
  301. uni.removeStorageSync(J_STORAGE_KEY)
  302. uni.removeStorageSync('distributorId')
  303. uni.removeStorageSync('allCartNum')
  304. uni.reLaunch({
  305. url: 'login',
  306. success() {
  307. uni.hideLoading()
  308. }
  309. })
  310. }, 1000)
  311. },
  312. onGetAuthorize() {
  313. const that = this
  314. // uni.showLoading({
  315. // mask: true,
  316. // title: '验证中...',
  317. // })
  318. this.$showLoading()
  319. my.getPhoneNumber({
  320. success: (res) => {
  321. this.$hideLoading()
  322. const encryptedData = res.response
  323. NET.request(API.UpdateAliPhone, {
  324. 'phone': encryptedData
  325. }, 'POST').then((res) => {
  326. const item = res.data
  327. uni.setStorageSync(J_STORAGE_KEY, item)
  328. that.phone = item.phone
  329. // uni.hideLoading()
  330. })
  331. .finally((res) => {
  332. uni.hideLoading()
  333. })
  334. },
  335. fail: (res) => {
  336. this.$hideLoading()
  337. uni.hideLoading()
  338. uni.showToast({
  339. title: '验证失败',
  340. icon: 'none'
  341. })
  342. }
  343. })
  344. },
  345. onAuthError() {
  346. }
  347. }
  348. }
  349. </script>
  350. <style lang='scss'>
  351. .agreement {
  352. width: 710rpx;
  353. margin: 20rpx auto 0;
  354. background-color: #fff;
  355. .agreement_top {
  356. &::after {
  357. content: "";
  358. display: block;
  359. position: absolute;
  360. left: 32rpx;
  361. bottom: 0;
  362. width: 646rpx;
  363. height: 4rpx;
  364. background: #F5F7FA;
  365. }
  366. }
  367. .agreement {
  368. width: 100%;
  369. height: 108rpx;
  370. display: flex;
  371. justify-content: space-between;
  372. align-items: center;
  373. font-size: 28rpx;
  374. color: #333;
  375. padding: 0 10rpx 0 32rpx;
  376. box-sizing: border-box;
  377. position: relative;
  378. image {
  379. width: 60rpx;
  380. height: 60rpx;
  381. }
  382. }
  383. }
  384. .phoneWxBut {
  385. width: 160rpx;
  386. height: 60rpx;
  387. border: 1rpx solid #FF7800;
  388. border-radius: 44rpx;
  389. font-size: 28rpx;
  390. line-height: 60rpx;
  391. }
  392. .container {
  393. width: 100%;
  394. background-color: #F7F7F7;
  395. padding: 20rpx;
  396. .personalBack-box {
  397. width: 100%;
  398. background-color: #FFFFFF;
  399. .personalHead-box {
  400. width: 90%;
  401. border-bottom: 1upx solid #E5E5E5;
  402. padding-bottom: 20upx;
  403. margin-top: 36upx;
  404. .nameInput {
  405. text-align: right;
  406. }
  407. }
  408. .personalHead-box1 {
  409. width: 90%;
  410. margin-top: 36upx;
  411. padding-bottom: 20upx;
  412. .user-headImg {
  413. width: 120upx;
  414. height: 112upx;
  415. border-radius: 50%;
  416. }
  417. }
  418. }
  419. .iphoneNumback-box {
  420. width: 100%;
  421. background-color: #FFFFFF;
  422. height: 100upx;
  423. margin-top: 20upx;
  424. .iphoneNum-box {
  425. width: 90%;
  426. .verifyPhone {
  427. color: #C5AA7B;
  428. font-size: 30upx;
  429. border: 0;
  430. }
  431. }
  432. }
  433. .exitLoginBut {
  434. height: 100upx;
  435. background: #333333;
  436. color: #FFEBC4;
  437. }
  438. .cancellation {
  439. height: 100rpx;
  440. margin: 24rpx auto 0;
  441. display: flex;
  442. align-items: center;
  443. justify-content: center;
  444. color: #C5AA7B;
  445. font-size: 28rpx;
  446. background: #FFFFFF;
  447. border: 3rpx solid #F3F4F5;
  448. }
  449. .sexRadio-box {
  450. width: 520upx;
  451. height: 328upx;
  452. .sexRadio {
  453. margin-top: 30upx;
  454. padding-bottom: 44upx;
  455. }
  456. }
  457. .headBox {
  458. margin-bottom: 20rpx;
  459. background: #FFFFFF;
  460. padding: 25rpx 0;
  461. .personalHead-box {
  462. width: 90%;
  463. margin: 0 auto;
  464. }
  465. .user-headImg {
  466. width: 120upx;
  467. height: 112upx;
  468. border-radius: 50%;
  469. }
  470. }
  471. }
  472. </style>