resetpassword.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view>
  3. <!-- 基础表单校验 -->
  4. <cu-custom :isBack="true">
  5. <block slot="content">忘记密码</block>
  6. </cu-custom>
  7. <view class="box ">
  8. <view class="box-user flex align-center " style="border-bottom: 1px solid #EFEFEF;"
  9. :class="[shape == 'round' ? 'round' : '']">
  10. <image src="../../static/login/Frame (27).png" mode='aspectFit' class="zai-logo "></image>
  11. <input placeholder="请输入手机号" name="input" v-model="phoneNo"></input>
  12. </view>
  13. <view class="box-user flex align-center" style="border-bottom: 1px solid #EFEFEF;"
  14. :class="[shape == 'round' ? 'round' : '']">
  15. <image src="../../static/login/Frame (28).png" mode='aspectFit' class="zai-logo "></image>
  16. <input class="uni-input" placeholder="请输入验证码" v-model="smsCode" />
  17. <view class="action">
  18. <text class="text-color" :disabled="!isSendSMSEnable" @click="onSMSSend"> {{ getSendBtnText
  19. }}</text>
  20. </view>
  21. </view>
  22. <view class="box-user flex align-center" style="border-bottom: 1px solid #EFEFEF;"
  23. :class="[shape == 'round' ? 'round' : '']">
  24. <image src="../../static/login/Frame (26).png" mode='aspectFit' class="zai-logo "></image>
  25. <input placeholder="请输入新密码" :password="!showPassword" v-model="password"></input>
  26. <view class="action text-lg">
  27. <text :class="[showPassword ? 'cuIcon-attention' : 'cuIcon-attentionforbid']"
  28. @click="changePassword"></text>
  29. </view>
  30. </view>
  31. <view class="box-user flex align-center" :class="[shape == 'round' ? 'round' : '']">
  32. <image src="../../static/login/Frame (26).png" mode='aspectFit' class="zai-logo "></image>
  33. <input placeholder="请再次输入新密码" :password="!showPassword1" v-model="password1"></input>
  34. <view class="action text-lg">
  35. <text :class="[showPassword1 ? 'cuIcon-attention' : 'cuIcon-attentionforbid']"
  36. @click="changePassword1"></text>
  37. </view>
  38. </view>
  39. <view class="footer">
  40. <button type="primary" class="p-button round" @click="onSMSLogin()">确认修改并登录</button>
  41. <!-- <button class="cu-btn round lg bg-blue " style="display: flex;" :loading="loading" :class="[shape=='round'?'round':'']"
  42. @tap="onSMSLogin"><text space="emsp">{{loading ? "注册中...":" 注册 "}}</text>
  43. </button> -->
  44. </view>
  45. </view>
  46. <!-- <view class="example">
  47. <uni-forms ref="valiForm" :rules="rules" :modelValue="valiFormData" label-width="100px">
  48. <uni-forms-item label="手机号" required name="phoneNo">
  49. <view class="cu-form-group shadow-warp" >
  50. <input class="u-input" placeholder="请输入手机号" v-model="valiFormData.phoneNo"/>
  51. </view>
  52. </uni-forms-item>
  53. <uni-forms-item label="验证码" required name="smsCode">
  54. <view class="cu-form-group shadow-warp" >
  55. <input class="u-input" placeholder="请输入验证码" v-model="valiFormData.smsCode"/>
  56. <text style="color: #0081ff;" :disabled="!isSendSMSEnable" @click="onSMSSend">{{ getSendBtnText }}</text>
  57. </view>
  58. </uni-forms-item>
  59. <uni-forms-item label="新密码" required name="age">
  60. <view class="cu-form-group shadow-warp" >
  61. <input class="u-input" placeholder="请输入新密码" v-model="valiFormData.phoneNo"/>
  62. </view>
  63. </uni-forms-item>
  64. <uni-forms-item label="确认密码" required name="age">
  65. <view class="cu-form-group shadow-warp" >
  66. <input class="u-input" placeholder="请输入新密码" v-model="valiFormData.phoneNo"/>
  67. </view>
  68. </uni-forms-item>
  69. </uni-forms>
  70. <button type="primary" class="p-button" @click="submit('valiForm')">确认修改并登录</button>
  71. </view> -->
  72. </view>
  73. </template>
  74. <script>
  75. export default {
  76. computed: {
  77. isSendSMSEnable() {
  78. return this.smsCountDown <= 0 && this.valiFormData.phoneNo.length > 4;
  79. },
  80. getSendBtnText() {
  81. if (this.smsCountDown > 0) {
  82. return this.smsCountDown + '秒后发送';
  83. } else {
  84. return '发送验证码';
  85. }
  86. },
  87. },
  88. data() {
  89. return {
  90. showPassword: false, //是否显示明文
  91. showPassword1: false, //是否显示明文
  92. shape: '',//round 圆形
  93. smsCountDown: 0,
  94. // 校验表单数据
  95. valiFormData: {
  96. phoneNo: '',
  97. smsCode: '',
  98. introduction: '',
  99. },
  100. // 校验规则
  101. rules: {
  102. phoneNo: {
  103. rules: [{
  104. required: true,
  105. errorMessage: '姓名不能为空'
  106. }]
  107. },
  108. smsCode: {
  109. rules: [{
  110. required: true,
  111. errorMessage: '年龄不能为空'
  112. }, {
  113. format: 'number',
  114. errorMessage: '年龄只能输入数字'
  115. }]
  116. }
  117. },
  118. password1: '',
  119. password: '',
  120. phoneNo: '',
  121. smsCode: '',
  122. }
  123. },
  124. methods: {
  125. changePassword() {
  126. this.showPassword = !this.showPassword;
  127. },
  128. changePassword1() {
  129. this.showPassword1 = !this.showPassword1;
  130. },
  131. onSMSSend() {
  132. // let smsParams = {};
  133. // smsParams.phone=this.phoneNo;
  134. // smsParams.smsmode="0";
  135. let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/);
  136. if (!this.phoneNo || this.phoneNo.length == 0) {
  137. this.$tip.toast('请输入手机号');
  138. return false
  139. }
  140. if (!checkPhone.test(this.phoneNo)) {
  141. this.$tip.toast('请输入正确的手机号');
  142. return false
  143. }
  144. this.$http.get("/merchant/app/sendMsg", { params: { phone: this.phoneNo } }).then(res => {
  145. if (res.data.success) {
  146. this.smsCountDown = 60;
  147. this.startSMSTimer();
  148. } else {
  149. this.smsCountDown = 0;
  150. this.$tip.toast(res.data.message);
  151. }
  152. });
  153. },
  154. startSMSTimer() {
  155. this.smsCountInterval = setInterval(() => {
  156. this.smsCountDown--;
  157. if (this.smsCountDown <= 0) {
  158. clearInterval(this.smsCountInterval);
  159. }
  160. }, 1000);
  161. },
  162. onSMSLogin() {
  163. let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/);
  164. if (!this.phoneNo || this.phoneNo.length == 0) {
  165. this.$tip.toast('请填写手机号');
  166. return;
  167. }
  168. if (!checkPhone.test(this.phoneNo)) {
  169. this.$tip.toast('请输入正确的手机号');
  170. return false
  171. }
  172. if (!this.smsCode || this.smsCode.length == 0) {
  173. this.$tip.toast('请填短信验证码');
  174. return;
  175. }
  176. if (this.password !== this.password1) {
  177. this.$tip.toast('请确定密码是否一致');
  178. return;
  179. }
  180. let loginParams = {
  181. phone: this.phoneNo,
  182. passWord: this.password,
  183. code: this.smsCode
  184. };
  185. this.$http.post("/merchant/app/updatePassWord", loginParams).then(res => {
  186. if (res.data.success) {
  187. this.$Router.push({name:"login"})
  188. } else {
  189. this.$tip.error(res.data.message);
  190. }
  191. }).catch((err) => {
  192. let msg = ((err.response || {}).data || {}).message || err.data.message || "请求出现错误,请稍后再试"
  193. this.$tip.error(msg);
  194. });
  195. },
  196. submit(ref) {
  197. this.$refs[ref].validate().then(res => {
  198. console.log('success', res);
  199. uni.showToast({
  200. title: `校验通过`
  201. })
  202. }).catch(err => {
  203. console.log('err', err);
  204. })
  205. },
  206. }
  207. }
  208. </script>
  209. <style scoped lang="scss">
  210. page {
  211. background: #FFFFFF;
  212. height: 100%;
  213. }
  214. .text-color {
  215. color: #449AFF;
  216. margin: 0 5px;
  217. }
  218. .zai-logo {
  219. width: 20px;
  220. height: 20px;
  221. }
  222. .box{
  223. padding: 30px 17px;
  224. }
  225. .box-user {
  226. min-height: 45px;
  227. image {
  228. margin-right: 10px;
  229. }
  230. input {
  231. font-size: 14px;
  232. flex: 1;
  233. }
  234. }
  235. .example {
  236. padding: 20px;
  237. }
  238. .shadow-warp {
  239. min-height: 38px;
  240. font-size: 12px;
  241. }
  242. .u-input {
  243. font-size: 12px;
  244. color: #999;
  245. }
  246. .p-button {
  247. background: #449AFF;
  248. font-size: 14px;
  249. }
  250. .footer{
  251. position: fixed;
  252. bottom: 30px;
  253. width: 92%;
  254. text-align: center; /* 按钮居中 */
  255. // font-size: 14px;
  256. // color: #999999;
  257. // left: 50%;
  258. // transform: translateX(-50%);
  259. }
  260. </style>