updatePassword.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view style="position: relative;">
  3. <view class="bg"></view>
  4. <view class="bg1"></view>
  5. <view class="back" @click="$back">
  6. <u-icon name="arrow-left" size="50" color="#919191"></u-icon>
  7. </view>
  8. <view class="content">
  9. <view class="top">
  10. <view class="title">
  11. <text>修改登录密码</text>
  12. <text>输入手机号修改密码</text>
  13. </view>
  14. </view>
  15. <view style="width: 76%;margin-top: 80rpx;">
  16. <u-form ref="uForm" :model="form" :error-type="['message']">
  17. <u-form-item label="手机号" prop="phone" label-width="150">
  18. <view style="border-bottom: 1rpx solid #DDDDDD;">
  19. <u-input disabled :border="false" placeholder="请输入手机号" v-model="form.phone" type="number"></u-input>
  20. </view>
  21. </u-form-item>
  22. <u-form-item label="旧密码" label-width="150" prop="oldPassword">
  23. <view style="border-bottom: 1rpx solid #DDDDDD;">
  24. <u-input :border="false" type="password" placeholder="请输入旧密码" v-model="form.oldPassword"></u-input>
  25. </view>
  26. </u-form-item>
  27. <u-form-item label="新密码" prop="password" label-width="150">
  28. <view style="border-bottom: 1rpx solid #DDDDDD;">
  29. <u-input :border="false" type="password" placeholder="请设置新的登录密码" v-model="form.password"></u-input>
  30. </view>
  31. </u-form-item>
  32. <u-form-item label="确认密码" prop="confirmPassword" label-width="150">
  33. <view style="border-bottom: 1rpx solid #DDDDDD;">
  34. <u-input :border="false" type="password" placeholder="请再次输入新密码" v-model="form.confirmPassword" ></u-input>
  35. </view>
  36. </u-form-item>
  37. </u-form>
  38. </view>
  39. <view style="width: 86%;margin-top: 80rpx;">
  40. <view @click="update" class="btn cu-btn round" style="width:100%;height: 90rpx;font-size: 34rpx;">
  41. 确定修改密码
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import md5Libs from "uview-ui/libs/function/md5";
  49. export default {
  50. data() {
  51. return {
  52. customStyle:{
  53. 'backgroundColor':'#d18c42',
  54. 'color':'#ffffff'
  55. },
  56. form:{
  57. phone:this.$cache.get('phone'),
  58. password:'',
  59. oldPassword:'',
  60. confirmPassword:'',
  61. },
  62. rules: {
  63. phone: [{
  64. required: true,
  65. message: '请输入手机号',
  66. trigger: ['change', 'blur'],
  67. }],
  68. password: [{
  69. required: true,
  70. message: '请设置新的登录密码',
  71. trigger: ['change', 'blur'],
  72. }],
  73. oldPassword: [{
  74. required: true,
  75. message: '请输入旧密码',
  76. trigger: ['change', 'blur'],
  77. }],
  78. confirmPassword: [{
  79. required: true,
  80. message: '请再次输入新密码',
  81. trigger: ['change', 'blur'],
  82. }]
  83. },
  84. codeTips: '',
  85. }
  86. },
  87. onReady() {
  88. this.$refs.uForm.setRules(this.rules);
  89. },
  90. methods: {
  91. update() {
  92. this.$refs.uForm.validate(valid => {
  93. if (valid) {
  94. setTimeout(()=>{
  95. this.doUpdate()
  96. },500)
  97. }
  98. });
  99. },
  100. async doUpdate(){
  101. if (this.form.password!=this.form.confirmPassword) {
  102. this.$u.toast('输入的两次新密码不一致')
  103. return
  104. }
  105. let params={
  106. type:'MALL',
  107. phone:this.form.phone,
  108. secret:md5Libs.md5(this.form.password),
  109. oldSecret:md5Libs.md5(this.form.oldPassword)
  110. }
  111. this.$api.appaccount.setPassword(params).then(res=>{
  112. if (res.success) {
  113. this.$dialog.showModal('修改成功,请重新登录',false).then(res=>{
  114. uni.clearStorage()
  115. uni.reLaunch({
  116. url:"./account-login"
  117. })
  118. })
  119. }else{
  120. this.$u.toast(res.msg)
  121. }
  122. }).catch(err=>{
  123. this.$u.toast(err.data.msg)
  124. })
  125. },
  126. }
  127. }
  128. </script>
  129. <style lang="scss" scoped>
  130. $color:#d18c42;
  131. page{
  132. background-color: #FFFFFF;
  133. }
  134. .btn{
  135. background-color: $color;
  136. color:#FFFFFF;
  137. }
  138. .btn{
  139. background-color: $color;
  140. color:#FFFFFF;
  141. }
  142. .bg{
  143. z-index: 99;
  144. height: 440rpx;
  145. width: 440rpx;
  146. position: absolute;
  147. right: -240rpx;
  148. top: -240rpx;
  149. background-color: #d18c42;
  150. border-radius: 50%;
  151. box-shadow: 0rpx 0rpx 50rpx #c5803b;
  152. }
  153. .bg1{
  154. height: 500rpx;
  155. width: 500rpx;
  156. position: absolute;
  157. right: -240rpx;
  158. top: -240rpx;
  159. background-color: #d18c42;
  160. border-radius: 50%;
  161. box-shadow: #c6813b;
  162. }
  163. .back{
  164. position: absolute;
  165. top: var(--status-bar-height);
  166. left: 20rpx;
  167. padding-top: var(--status-bar-height);
  168. }
  169. .content{
  170. height: 90vh;
  171. display: flex;
  172. flex-direction: column;
  173. justify-content: center;
  174. align-items: center;
  175. .top{
  176. width: 76%;
  177. display: flex;
  178. .title{
  179. margin-right: 20rpx;
  180. display: flex;
  181. flex-direction: column;
  182. justify-content: center;
  183. align-items: flex-start;
  184. text-align: left;
  185. text:first-child{
  186. font-weight: 800;
  187. font-size: 50rpx;
  188. color: #000;
  189. margin-bottom: 20rpx;
  190. }
  191. text:last-child{
  192. font-size: 28rpx;
  193. color: #7f7f7f;
  194. }
  195. }
  196. }
  197. }
  198. </style>