forget.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view class="content">
  3. <view class="top_bg">
  4. <image class="top_close" @click="$navBack()" src="/static/image/login/close_icon.png" mode="scaleToFill" />
  5. <view class="top_text">
  6. <view>忘记密码</view>
  7. <image
  8. class="top_icon"
  9. src="/static//image/login/dot_icon.png"
  10. mode="scaleToFill"
  11. />
  12. </view>
  13. </view>
  14. <view class="w pdx-40 main">
  15. <u--input class="h-112" v-model="loginParam.phone" placeholder="请输入手机号码" border="bottom"
  16. clearable></u--input>
  17. <u--input class="h-112 mgt-16" v-model="loginParam.code" placeholder="请输入验证码" border="bottom" clearable>
  18. <template slot="suffix">
  19. <u-code :seconds="seconds" @end="end" @start="start" change-text="xs" ref="uCode"
  20. :keep-running="true" @change="codeChange"></u-code>
  21. <u-button :disabled="!isShowCode" @tap="sliderVerify" class="code_btn">{{ tips }}</u-button>
  22. </template>
  23. </u--input>
  24. <u--input class="h-112 mgt-16" v-model="loginParam.password" :password="!isViewPassword" placeholder="请输入密码"
  25. border="bottom" clearable>
  26. <template slot="suffix">
  27. <u-icon @click="isViewPassword = !isViewPassword" :name="isViewPassword ? 'eye-fill' : 'eye-off'"
  28. color="#303030" size="24"></u-icon>
  29. </template>
  30. </u--input>
  31. <u--input class="h-112 mgt-16" v-model="loginParam.confirmPwd" :password="!isViewConfirmPwd"
  32. placeholder="请确认密码" border="bottom" clearable>
  33. <template slot="suffix">
  34. <u-icon @click="isViewConfirmPwd = !isViewConfirmPwd"
  35. :name="isViewConfirmPwd ? 'eye-fill' : 'eye-off'" color="#303030" size="24"></u-icon>
  36. </template>
  37. </u--input>
  38. <u-button :disabled="!isSubmit" class="login" @tap="submit">提交</u-button>
  39. </view>
  40. <zmm-slider-verify ref="sliderVerify" @success="successHandle" @error="errorHandle"
  41. @close="closeHandle"></zmm-slider-verify>
  42. </view>
  43. </template>
  44. <script>
  45. import { isValidPhone, isValidPassword } from '@/utils/index'
  46. export default {
  47. data() {
  48. return {
  49. isViewPassword: false,
  50. isViewConfirmPwd: false,
  51. isCode: false,//验证码按钮状态
  52. tips: '',// 验证码提示文字
  53. seconds: 60,//验证码秒数
  54. loginParam: {
  55. phone: undefined,
  56. code: undefined,
  57. password: undefined,
  58. confirmPwd: undefined,
  59. },
  60. }
  61. },
  62. computed: {
  63. isShowCode() {
  64. return this.loginParam.phone && !this.isCode
  65. },
  66. isSubmit() {
  67. return this.loginParam.phone && this.loginParam.code &&
  68. this.loginParam.password && this.loginParam.confirmPwd
  69. }
  70. },
  71. watch: {
  72. },
  73. onLoad() {
  74. },
  75. methods: {
  76. //显示验证组件
  77. sliderVerify() {
  78. if(isValidPhone(this.loginParam.phone)) {
  79. this.$refs['sliderVerify'].show()
  80. } else {
  81. uni.$u.toast('请输入正确手机号');
  82. }
  83. },
  84. //验证通过回调
  85. successHandle(e) {
  86. console.log(e)
  87. this.getCode()
  88. },
  89. //验证失败回调
  90. errorHandle(e) {
  91. console.log(e)
  92. },
  93. //组件关闭回调
  94. closeHandle(e) {
  95. console.log(e)
  96. },
  97. codeChange(text) {
  98. this.tips = text;
  99. },
  100. getCode() {
  101. if (this.$refs.uCode.canGetCode) {
  102. // 模拟向后端请求验证码
  103. uni.showLoading({
  104. title: '正在获取验证码'
  105. })
  106. setTimeout(() => {
  107. uni.hideLoading();
  108. // 这里此提示会被this.start()方法中的提示覆盖
  109. uni.$u.toast('验证码已发送');
  110. // 通知验证码组件内部开始倒计时
  111. this.$refs.uCode.start();
  112. }, 2000);
  113. } else {
  114. uni.$u.toast('倒计时结束后再发送');
  115. }
  116. },
  117. end() {
  118. // uni.$u.toast('倒计时结束');
  119. this.isCode = false
  120. },
  121. start() {
  122. // uni.$u.toast('倒计时开始');
  123. this.isCode = true
  124. },
  125. submit() {
  126. console.log('提交参数 :===>>', this.loginParam);
  127. }
  128. }
  129. }
  130. </script>
  131. <style scoped lang="scss">
  132. .content {
  133. width: 100vw;
  134. height: 100vh;
  135. display: flex;
  136. flex-direction: column;
  137. align-items: center;
  138. position: relative;
  139. }
  140. .top_bg {
  141. position: relative;
  142. width: 100vw;
  143. height: 568rpx;
  144. flex-shrink: 0;
  145. background: linear-gradient(to bottom, #ffd8bf, #ffffff);
  146. .top_close {
  147. position: absolute;
  148. top: 128rpx;
  149. left: 40rpx;
  150. width: 48rpx;
  151. height: 48rpx;
  152. }
  153. .top_text {
  154. position: absolute;
  155. top: 224rpx;
  156. left: 64rpx;
  157. display: flex;
  158. color: #070602;
  159. font-family: "MiSans VF";
  160. font-size: 52rpx;
  161. font-style: normal;
  162. font-weight: 600;
  163. line-height: normal;
  164. letter-spacing: 0.66rpx;
  165. text-transform: uppercase;
  166. }
  167. .top_icon {
  168. margin-top: -10rpx;
  169. margin-left: 8rpx;
  170. width: 24rpx;
  171. height: 24rpx;
  172. }
  173. }
  174. .main {
  175. margin-top: -72rpx;
  176. .login {
  177. margin-top: 240rpx;
  178. height: 96rpx;
  179. width: 100%;
  180. flex-shrink: 0;
  181. border-radius: 64rpx;
  182. background: #FE6505;
  183. color: #ffffff;
  184. text-align: center;
  185. font-family: "MiSans VF";
  186. font-size: 36rpx;
  187. font-style: normal;
  188. font-weight: 500;
  189. }
  190. .code_btn {
  191. padding: 0rpx 24rpx;
  192. height: 60rpx;
  193. border-radius: 32rpx;
  194. font-size: 24rpx;
  195. color: #fff;
  196. font-weight: 400;
  197. background: linear-gradient(0deg, #FE6505 0%, #FE6505 100%), #141111;
  198. }
  199. .code_btn_off {
  200. background: #fe65054d;
  201. }
  202. }
  203. </style>