index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <!-- 修改个人信息 -->
  2. <template>
  3. <view class="container fs28" :style="{ height: screenHeight + 'px' }">
  4. <JHeader title="个人信息" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
  5. <view class="headBox">
  6. <view class="personalHead-box flex-sp-between flex-display flex-items">
  7. <label>头像</label>
  8. <image v-if="$store.getters.userInfo.headImage" class="user-headImg" :src="common.seamingImgUrl($store.getters.userInfo.headImage)"></image>
  9. <image v-else class="user-headImg" src="../../../static/images/new-user/default-user-avatar.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. <input v-model="name" class="nameInput" type="text" placeholder="请输入内容" @blur="changeName" />
  17. </view>
  18. <view class="personalHead-box flex-sp-between flex-display flex-items" @click="sexShowClick">
  19. <label>性别</label>
  20. <label class="font-color-999">{{ $store.getters.userInfo.sex }}</label>
  21. </view>
  22. <view class="personalHead-box1">
  23. <picker
  24. mode="date" :value="$store.getters.userInfo.birthday" start="1970-01-01"
  25. :disabled="!(($store.getters.userInfo.birthday === '1970-01-01') || !$store.getters.userInfo.birthday)"
  26. @change="handleConfirmTime"
  27. >
  28. <view class="flex-sp-between flex-display flex-items">
  29. <label>生日</label>
  30. <label class="font-color-999">{{ $store.getters.userInfo.birthday }}</label>
  31. </view>
  32. </picker>
  33. </view>
  34. </view>
  35. <view class="iphoneNumback-box flex-items-plus">
  36. <view class="iphoneNum-box flex-row-plus flex-sp-between flex-items">
  37. <label style="width: 50%;">手机号</label>
  38. <label v-if="$store.getters.userInfo.phone" class="font-color-C5AA7B">{{ $store.getters.userInfo.phone }}</label>
  39. <label v-else class="font-color-C5AA7B">
  40. <!-- #ifdef MP-ALIPAY -->
  41. <button class="verifyPhone" open-type="getAuthorize" scope="phoneNumber" @getAuthorize="onGetAuthorize">
  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. <tui-icon :size="60" color="#999999" name="arrowright" unit="upx" margin="0"></tui-icon>
  55. </view>
  56. <view class="agreement" @click="protocol('app_user_agreement')">
  57. <text>用户服务协议</text>
  58. <tui-icon :size="60" color="#999999" name="arrowright" unit="upx" margin="0"></tui-icon>
  59. </view>
  60. </view>
  61. <view style="margin-top: 30upx;background-color: #ffffff;">
  62. <view style="padding: 28upx 38upx;" @click="isShowResettingPasswordDialog = true">重置密码 ></view>
  63. </view>
  64. <view class="mar-top-100">
  65. <view class="exitLoginBut flex-items-plus" @click="handleQuit">退出登录</view>
  66. <!-- #ifdef APP-PLUS -->
  67. <view class="cancellation" @click="cancellation">注销账号</view>
  68. <!-- #endif -->
  69. </view>
  70. <!-- 修改性别弹窗 -->
  71. <tui-select :list="sexList" reverse :show="sexShow" @confirm="handleConfirmSex" @close="sexShow = false"></tui-select>
  72. <tui-dialog
  73. style="position: relative;z-index: 888;" :buttons="[{ text: '取消' }, { text: '确定', color: '#586c94' }]"
  74. :show="isShowResettingPasswordDialog" title="重置密码" @click="handleResettingPassword"
  75. >
  76. <template #content>
  77. <tui-input v-model="resettingFormData.phone" label="手机号" type="number" placeholder="请输入手机号"></tui-input>
  78. <tui-input v-model="resettingFormData.password" label="密码" type="password" placeholder="请输入密码"></tui-input>
  79. <tui-input
  80. v-model="resettingFormData.passwordAgain" label="确认密码" type="password"
  81. placeholder="请再次输入密码"
  82. ></tui-input>
  83. <tui-input v-model="resettingFormData.verificationCode" label="验证码" type="number" placeholder="请输入验证码">
  84. <template #right>
  85. <tui-countdown-verify
  86. ref="refResettingPasswordVerify" width="144upx"
  87. @send="handleSendVerify"
  88. ></tui-countdown-verify>
  89. </template>
  90. </tui-input>
  91. </template>
  92. </tui-dialog>
  93. </view>
  94. </template>
  95. <script>
  96. import { updateAliPhoneAppApi, getVerifyCodeApi, updatePasswordUserApi } from '../../../api/anotherTFInterface'
  97. export default {
  98. name: 'PersonalDetails',
  99. data() {
  100. return {
  101. userId: '',
  102. screenHeight: 0,
  103. sexShow: false,
  104. timeShow: false,
  105. name: '',
  106. sexList: [
  107. { value: '1', text: '男' },
  108. { value: '2', text: '女' }
  109. ],
  110. resettingFormData: {
  111. phone: '',
  112. password: '',
  113. passwordAgain: '',
  114. verificationCode: ''
  115. },
  116. isShowResettingPasswordDialog: false
  117. }
  118. },
  119. onLoad() {
  120. this.getUserInfoData()
  121. },
  122. onShow() {
  123. },
  124. mounted() {
  125. // 获取手机的屏幕高度
  126. uni.getSystemInfo({
  127. success: (res) => {
  128. this.screenHeight = res.screenHeight
  129. }
  130. })
  131. },
  132. methods: {
  133. // 多商户用户协议
  134. protocol(type) {
  135. uni.navigateTo({
  136. url: '/another-tf/another-serve/protocol/index?type=' + type
  137. })
  138. },
  139. cancellation() {
  140. uni.showModal({
  141. title: '温馨提示',
  142. content: '是否注销此账号!',
  143. confirmText: '前往注销',
  144. success(res) {
  145. if (res.cancel) {
  146. uni.showToast({
  147. icon: 'none',
  148. title: '已取消'
  149. })
  150. } else if (res.confirm) {
  151. uni.navigateTo({
  152. url: '/another-tf/another-serve/unsubscribe/index'
  153. })
  154. }
  155. }
  156. })
  157. },
  158. // 修改昵称
  159. changeName() {
  160. const newName = this.name
  161. if (!newName) {
  162. uni.showToast({
  163. title: '请输入新的内容',
  164. icon: 'none'
  165. })
  166. return false
  167. }
  168. this.$store.dispatch('auth/updateUserInfoAction', {
  169. name: newName
  170. })
  171. },
  172. // 提交修改生日
  173. handleConfirmTime(e) {
  174. if ((this.$store.getters.userInfo.birthday == '1970-01-01') || (this.$store.getters.userInfo.birthday == '')) {
  175. const birthday = e.detail.value
  176. this.$store.dispatch('auth/updateUserInfoAction', {
  177. birthday
  178. })
  179. }
  180. },
  181. // 点击弹窗修改性别
  182. sexShowClick() {
  183. this.sexShow = true
  184. },
  185. // 提交修改性别
  186. handleConfirmSex(e) {
  187. this.sexShow = false
  188. uni.showLoading()
  189. const sex = e.options.text
  190. this.$store.dispatch('auth/updateUserInfoAction', {
  191. sex
  192. })
  193. },
  194. // 获取用户信息
  195. getUserInfoData() {
  196. this.$store.dispatch('auth/refrshUserInfoAction', () => {
  197. this.name = this.$store.getters.userInfo.name
  198. })
  199. },
  200. handleQuit() {
  201. this.$store.dispatch('auth/logoutAction', true)
  202. },
  203. onGetAuthorize() {
  204. uni.showLoading({
  205. mask: true,
  206. title: '验证中...'
  207. })
  208. my.getPhoneNumber({
  209. success: (res) => {
  210. const encryptedData = res.response
  211. updateAliPhoneAppApi({
  212. 'phone': encryptedData
  213. }).then((res) => {
  214. this.$store.dispatch('auth/refrshUserInfoAction', () => {
  215. uni.showToast({
  216. title: '验证成功',
  217. icon: 'none'
  218. })
  219. })
  220. uni.hideLoading()
  221. })
  222. .catch((e) => {
  223. uni.hideLoading()
  224. })
  225. },
  226. fail: (res) => {
  227. uni.hideLoading()
  228. uni.showToast({
  229. title: '验证失败',
  230. icon: 'none'
  231. })
  232. }
  233. })
  234. },
  235. handleSendVerify() {
  236. if (!this.resettingFormData.phone) {
  237. this.$refs.refResettingPasswordVerify.reset()
  238. return this.$showToast('请填写手机号')
  239. }
  240. if (!/^1[3-9]\d{9}$/.test(this.resettingFormData.phone)) {
  241. this.$refs.refResettingPasswordVerify.reset()
  242. return this.$showToast('请输入正确的手机号')
  243. }
  244. getVerifyCodeApi({ phone: this.resettingFormData.phone })
  245. .then((res) => {
  246. this.$refs.refResettingPasswordVerify.success()
  247. this.$showToast('发送成功,请注意查看手机短信')
  248. })
  249. .catch(() => {
  250. this.$refs.refResettingPasswordVerify.reset()
  251. })
  252. },
  253. handleResettingPassword(e) {
  254. if (e.index === 0) { } else if (e.index === 1) {
  255. if (!this.resettingFormData.phone) return this.$showToast('请填写手机号')
  256. if (!this.resettingFormData.verificationCode) return this.$showToast('请填写验证码')
  257. if (!this.resettingFormData.password) return this.$showToast('请设置密码!')
  258. if (this.resettingFormData.password !== this.resettingFormData.passwordAgain) return this.$showToast('密码不一致')
  259. uni.showLoading({
  260. title: '操作中'
  261. })
  262. updatePasswordUserApi({ ...this.resettingFormData })
  263. .then(({ data }) => {
  264. uni.hideLoading()
  265. this.$showToast('重置成功')
  266. })
  267. .catch(() => {
  268. uni.hideLoading()
  269. })
  270. }
  271. this.resettingFormData.phone = ''
  272. this.resettingFormData.verificationCode = ''
  273. this.resettingFormData.password = ''
  274. this.resettingFormData.passwordAgain = ''
  275. this.isShowResettingPasswordDialog = false
  276. }
  277. }
  278. }
  279. </script>
  280. <style lang='less' scoped>
  281. .agreement {
  282. width: 710rpx;
  283. margin: 20rpx auto 0;
  284. background-color: #fff;
  285. .agreement_top {
  286. &::after {
  287. content: "";
  288. display: block;
  289. position: absolute;
  290. left: 32rpx;
  291. bottom: 0;
  292. width: 646rpx;
  293. height: 4rpx;
  294. background: #F5F7FA;
  295. }
  296. }
  297. .agreement {
  298. width: 100%;
  299. height: 108rpx;
  300. display: flex;
  301. justify-content: space-between;
  302. align-items: center;
  303. font-size: 28rpx;
  304. color: #333;
  305. padding: 0 10rpx 0 32rpx;
  306. box-sizing: border-box;
  307. position: relative;
  308. }
  309. }
  310. .container {
  311. width: 100%;
  312. background-color: #F7F7F7;
  313. padding: 20rpx;
  314. .personalBack-box {
  315. width: 100%;
  316. background-color: #FFFFFF;
  317. .personalHead-box {
  318. width: 90%;
  319. border-bottom: 1upx solid #E5E5E5;
  320. padding-bottom: 20upx;
  321. margin-top: 36upx;
  322. .nameInput {
  323. text-align: right;
  324. }
  325. }
  326. .personalHead-box1 {
  327. width: 90%;
  328. margin-top: 36upx;
  329. padding-bottom: 20upx;
  330. .user-headImg {
  331. width: 120upx;
  332. height: 112upx;
  333. border-radius: 50%;
  334. }
  335. }
  336. }
  337. .iphoneNumback-box {
  338. width: 100%;
  339. background-color: #FFFFFF;
  340. height: 100upx;
  341. margin-top: 20upx;
  342. .iphoneNum-box {
  343. width: 90%;
  344. .verifyPhone {
  345. color: #C5AA7B;
  346. font-size: 30upx;
  347. border: 0;
  348. }
  349. }
  350. }
  351. .exitLoginBut {
  352. height: 100upx;
  353. background: #333333;
  354. color: #FFEBC4;
  355. }
  356. .cancellation {
  357. height: 100rpx;
  358. margin: 24rpx auto 0;
  359. display: flex;
  360. align-items: center;
  361. justify-content: center;
  362. color: #C5AA7B;
  363. font-size: 28rpx;
  364. background: #FFFFFF;
  365. border: 3rpx solid #F3F4F5;
  366. }
  367. .headBox {
  368. margin-bottom: 20rpx;
  369. background: #FFFFFF;
  370. padding: 25rpx 0;
  371. .personalHead-box {
  372. width: 90%;
  373. margin: 0 auto;
  374. }
  375. .user-headImg {
  376. width: 120upx;
  377. height: 112upx;
  378. border-radius: 50%;
  379. }
  380. }
  381. }
  382. </style>