forget.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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>
  17. <u-form-item label="手机号" prop="phone" label-width="150">
  18. <u-input :border="false" placeholder="请输入手机号" v-model="form.phone" type="number"></u-input>
  19. </u-form-item>
  20. <u-form-item label="验证码" prop="code" label-width="150">
  21. <u-input style="width: 100%;" :border="false" placeholder="请输入验证码" v-model="form.code"
  22. type="text"></u-input>
  23. <u-button shape="circle" slot="right" :custom-style="customStyle" size="mini" @click="getCode">
  24. {{codeTips}}</u-button>
  25. </u-form-item>
  26. <u-form-item label="新密码" prop="phone" label-width="150">
  27. <u-input :border="false" placeholder="请设置新的登录密码" v-model="form.password" type="password">
  28. </u-input>
  29. </u-form-item>
  30. <u-form-item label="确认新密码" prop="phone" label-width="170">
  31. <u-input :border="false" placeholder="请再次输入新密码" v-model="form.confirmPassword" type="password">
  32. </u-input>
  33. </u-form-item>
  34. </u-form>
  35. </view>
  36. <view style="width: 86%;margin-top: 80rpx;">
  37. <view @click="submit" class="btn cu-btn round" style="width:100%;height: 90rpx;font-size: 34rpx;">
  38. 确认修改密码
  39. </view>
  40. </view>
  41. </view>
  42. <u-verification-code seconds="60" ref="uCode" @change="codeChange"></u-verification-code>
  43. </view>
  44. </template>
  45. <script>
  46. import md5Libs from "uview-ui/libs/function/md5";
  47. export default {
  48. data() {
  49. return {
  50. customStyle: {
  51. 'backgroundColor': '#d18c42',
  52. 'color': '#ffffff'
  53. },
  54. codeTips: '',
  55. form: {
  56. phone: '',
  57. password: '',
  58. confirmPassword: '',
  59. code: '',
  60. },
  61. }
  62. },
  63. methods: {
  64. async submit() {
  65. if (this.$isEmpty(this.form.phone)) {
  66. this.$u.toast('请输入手机号')
  67. return
  68. }
  69. if (this.$isEmpty(this.form.code)) {
  70. this.$u.toast('请输入验证码')
  71. return
  72. }
  73. if (this.$isEmpty(this.form.password)) {
  74. this.$u.toast('请输入新密码')
  75. return
  76. }
  77. if (this.$isEmpty(this.form.confirmPassword)) {
  78. this.$u.toast('请再次输入新密码')
  79. return
  80. }
  81. if (this.form.password != this.form.confirmPassword) {
  82. this.$u.toast('两次输入的新密码不正确!')
  83. return
  84. }
  85. let params = {
  86. type: 1,
  87. code:this.form.code,
  88. phone: this.form.phone,
  89. password: md5Libs.md5(this.form.password),
  90. }
  91. let res = await this.$api.appaccount.forgetPassword(params)
  92. if (res.success) {
  93. this.$dialog.showModalAndBack('操作成功')
  94. } else {
  95. this.$u.toast(res.msg)
  96. }
  97. },
  98. codeChange(text) {
  99. this.codeTips = text;
  100. },
  101. // 获取验证码
  102. getCode() {
  103. if (this.$isEmpty(this.form.phone)) {
  104. this.$u.toast('请输入手机号')
  105. return
  106. }
  107. if (this.$refs.uCode.canGetCode) {
  108. // 模拟向后端请求验证码
  109. uni.showLoading({
  110. title: '正在获取验证码',
  111. mask: true
  112. })
  113. setTimeout(() => {
  114. let params = {
  115. phone: this.form.phone
  116. }
  117. let p = this.$u.queryParams(params)
  118. this.$api.sms.send(p).then(res => {
  119. if (res.data == "success") {
  120. this.$u.toast('验证码已发送');
  121. // 通知验证码组件内部开始倒计时
  122. } else {
  123. this.$u.toast(res.data);
  124. }
  125. this.$refs.uCode.start();
  126. })
  127. }, 2000);
  128. } else {
  129. this.$u.toast('倒计时结束后再发送');
  130. }
  131. }
  132. }
  133. }
  134. </script>
  135. <style>
  136. page {
  137. background-color: #FFFFFF;
  138. }
  139. </style>
  140. <style lang="scss" scoped>
  141. $color:#d18c42;
  142. page {
  143. background-color: #FFFFFF;
  144. }
  145. .btn {
  146. background-color: $color;
  147. color: #FFFFFF;
  148. }
  149. .btn {
  150. background-color: $color;
  151. color: #FFFFFF;
  152. }
  153. .bg {
  154. z-index: 99;
  155. height: 440rpx;
  156. width: 440rpx;
  157. position: absolute;
  158. right: -240rpx;
  159. top: -240rpx;
  160. background-color: #d18c42;
  161. border-radius: 50%;
  162. box-shadow: 0rpx 0rpx 50rpx #c5803b;
  163. }
  164. .bg1 {
  165. height: 500rpx;
  166. width: 500rpx;
  167. position: absolute;
  168. right: -240rpx;
  169. top: -240rpx;
  170. background-color: #d18c42;
  171. border-radius: 50%;
  172. box-shadow: #c6813b;
  173. }
  174. .back {
  175. position: absolute;
  176. top: var(--status-bar-height);
  177. left: 20rpx;
  178. padding-top: var(--status-bar-height);
  179. }
  180. .content {
  181. height: 90vh;
  182. display: flex;
  183. flex-direction: column;
  184. justify-content: center;
  185. align-items: center;
  186. .top {
  187. width: 76%;
  188. display: flex;
  189. .title {
  190. margin-right: 20rpx;
  191. display: flex;
  192. flex-direction: column;
  193. justify-content: center;
  194. align-items: flex-start;
  195. text-align: left;
  196. text:first-child {
  197. font-weight: 800;
  198. font-size: 60rpx;
  199. color: #000;
  200. margin-bottom: 20rpx;
  201. }
  202. text:last-child {
  203. font-size: 28rpx;
  204. color: #7f7f7f;
  205. }
  206. }
  207. }
  208. }
  209. </style>