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