modifypass.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view class="container">
  3. <view class="top">
  4. </view>
  5. <view class="center">
  6. <view class="login_input">
  7. <image class="img" src="https://zhxc2030.com/img/img08.png"></image>
  8. <input class="input" v-model="account" focus placeholder="请输入手机号" />
  9. </view>
  10. <view class="login_input">
  11. <image class="img" src="https://zhxc2030.com/img/img67.png"></image>
  12. <input class="input" type="password" v-model="password" placeholder="请输入新密码" />
  13. </view>
  14. <view class="login_input">
  15. <image class="img" src="https://zhxc2030.com/img/img67.png"></image>
  16. <input class="input" type="password" v-model="password2" placeholder="请重复输入新密码" />
  17. </view>
  18. <view class="login_input">
  19. <image class="img" src="../../static/icon/i9.png"></image>
  20. <input class="input" type="password" v-model="captcha" placeholder="请输入验证码" />
  21. <text class="yzm" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</text>
  22. </view>
  23. <!-- 按钮 -->
  24. <view class="login_buttom" :class="{'bg-gray':loding}" @click="loding?'':confirm()">
  25. 修改密码
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import { verify } from '@/api/login.js';
  32. import { mapState ,mapMutations} from 'vuex';
  33. import { registerReset } from '@/api/set.js';
  34. export default {
  35. data() {
  36. return {
  37. password: '' ,//新密码
  38. password2:'',//重复新密码
  39. time: '', //保存倒计时对象
  40. countDown: 0, //倒计时
  41. account: '', //手机号
  42. captcha: '', //验证码
  43. loding:false,//是否载入中
  44. // #ifdef APP-PLUS
  45. // 保存当前是否为微信浏览器
  46. weixinB:false,
  47. // #endif
  48. };
  49. },
  50. computed: {
  51. ...mapState('user',['userInfo'])
  52. },
  53. watch: {
  54. // 监听倒计时
  55. countDown(i) {
  56. if (i == 0) {
  57. clearInterval(this.time);
  58. }
  59. }
  60. },
  61. onLoad() {
  62. console.log(this)
  63. console.log(this.userInfo);
  64. if(this.userInfo.phone == null){
  65. this.account = '';
  66. }else{
  67. this.account = this.userInfo.phone;
  68. }
  69. },
  70. methods: {
  71. //发送验证码
  72. verification() {
  73. let obj = this;
  74. if (this.account == '') {
  75. this.$api.msg('请输入电话号码');
  76. return;
  77. }
  78. if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(this.account)) {
  79. this.$api.msg('请输入正确的手机号');
  80. return;
  81. }
  82. // 判断是否在倒计时
  83. if (obj.countDown > 0) {
  84. return false;
  85. } else {
  86. obj.countDown = 60;
  87. obj.time = setInterval(() => {
  88. obj.countDown--;
  89. }, 1000);
  90. //调用验证码接口
  91. verify({
  92. phone: obj.account,
  93. type: ''
  94. })
  95. .then(({ data }) => {})
  96. .catch(err => {
  97. console.log(err);
  98. });
  99. }
  100. },
  101. ...mapMutations('user',['logout']),
  102. confirm(e) {
  103. this.loding = true;
  104. registerReset({
  105. account: this.account,
  106. captcha: this.captcha,
  107. password: this.password,
  108. })
  109. .then(({ data }) => {
  110. this.loding = false;
  111. this.$api.msg('修改成功');
  112. logout();
  113. })
  114. .catch(err => {
  115. this.loding = false;
  116. console.log(err);
  117. });
  118. }
  119. }
  120. };
  121. </script>
  122. <style lang="scss">
  123. .bg-gray{
  124. background-color: $color-gray;
  125. }
  126. .yzm{
  127. font-size:23rpx;
  128. font-weight:500;
  129. color:rgba(249,39,63,1);
  130. }
  131. .container {
  132. line-height: 1;
  133. .top {
  134. width: 750rpx;
  135. height: 400rpx;
  136. position: relative;
  137. background-color: $base-color;
  138. image {
  139. width: 750rpx;
  140. height: 500rpx;
  141. }
  142. }
  143. .center {
  144. z-index: 9;
  145. width: 700rpx;
  146. height: 840rpx;
  147. background-color: #FFFFFF;
  148. border-radius: 20rpx;
  149. margin-top: -150rpx;
  150. margin-left: 24rpx;
  151. position: absolute;
  152. .login_input {
  153. width: 560rpx;
  154. display: flex;
  155. justify-content: center;
  156. margin: 70rpx auto;
  157. border-bottom: 2rpx solid #F0F0F0;
  158. padding-bottom: 9rpx;
  159. color: #999999;
  160. .img {
  161. width: 30rpx;
  162. height: auto;
  163. margin-right: 18rpx;
  164. }
  165. .input {
  166. // width: 470rpx;
  167. flex:1;
  168. font-size: $font-base;
  169. letter-spacing: 3rpx;
  170. }
  171. }
  172. .login_buttom {
  173. width: 560rpx;
  174. // height:80rpx;
  175. background:linear-gradient(0deg,rgba(70,126,192,1),rgba(87,155,236,1));
  176. border-radius: 40rpx;
  177. margin: 0 auto;
  178. margin-bottom: 20rpx;
  179. text-align: center;
  180. line-height: 80rpx;
  181. color: #FFFFFF;
  182. font-size: 30rpx;
  183. }
  184. .register_buttom {
  185. width: 560rpx;
  186. line-height: 80rpx;
  187. border: 1rpx solid $base-color;
  188. border-radius: 40rpx;
  189. text-align: center;
  190. margin: 0 auto;
  191. font-size: 30rpx;
  192. font-weight: 500;
  193. color: $base-color;
  194. }
  195. .login_wx_text{
  196. text-align: center;
  197. font-size:24rpx;
  198. font-weight:400;
  199. color:rgba(153,153,153,1);
  200. margin-top: 15rpx;
  201. }
  202. }
  203. }
  204. </style>