resetpassword.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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) {
  177. this.$tip.toast('请输入新密码');
  178. return false
  179. }
  180. if (!this.password1) {
  181. this.$tip.toast('请再次输入新密码');
  182. return false
  183. }
  184. if (this.password !== this.password1) {
  185. this.$tip.toast('请确定密码是否一致');
  186. return;
  187. }
  188. let loginParams = {
  189. phone: this.phoneNo,
  190. passWord: this.password,
  191. code: this.smsCode
  192. };
  193. this.$http.post("/merchant/app/updatePassWord", loginParams).then(res => {
  194. if (res.data.success) {
  195. this.$Router.push({name:"login"})
  196. } else {
  197. this.$tip.error(res.data.message);
  198. }
  199. }).catch((err) => {
  200. let msg = ((err.response || {}).data || {}).message || err.data.message || "请求出现错误,请稍后再试"
  201. this.$tip.error(msg);
  202. });
  203. },
  204. submit(ref) {
  205. this.$refs[ref].validate().then(res => {
  206. console.log('success', res);
  207. uni.showToast({
  208. title: `校验通过`
  209. })
  210. }).catch(err => {
  211. console.log('err', err);
  212. })
  213. },
  214. }
  215. }
  216. </script>
  217. <style scoped lang="scss">
  218. page {
  219. background: #FFFFFF;
  220. height: 100%;
  221. }
  222. .text-color {
  223. color: #449AFF;
  224. margin: 0 5px;
  225. }
  226. .zai-logo {
  227. width: 20px;
  228. height: 20px;
  229. }
  230. .box{
  231. padding: 60upx 32upx;
  232. }
  233. .box-user {
  234. min-height: 45px;
  235. image {
  236. margin-right: 10px;
  237. }
  238. input {
  239. font-size: 14px;
  240. flex: 1;
  241. }
  242. }
  243. .example {
  244. padding: 20px;
  245. }
  246. .shadow-warp {
  247. min-height: 38px;
  248. font-size: 12px;
  249. }
  250. .u-input {
  251. font-size: 12px;
  252. color: #999;
  253. }
  254. .p-button {
  255. background: #449AFF;
  256. font-size: 14px;
  257. }
  258. .footer{
  259. position: fixed;
  260. bottom: 64upx;
  261. width: 92%;
  262. text-align: center; /* 按钮居中 */
  263. // font-size: 14px;
  264. // color: #999999;
  265. // left: 50%;
  266. // transform: translateX(-50%);
  267. }
  268. </style>