moneyPwd.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view class="container">
  3. <view class="row b-b" v-if="type == 2">
  4. <text class="tit">手机号</text>
  5. <input class="input" v-model="account" type="text" placeholder="请填写手机号" placeholder-class="placeholder" />
  6. </view>
  7. <view class="row b-b" v-if="type == 2">
  8. <text class="tit">验证码</text>
  9. <input class="input" v-model="captcha" type="text" placeholder="请填写验证码" placeholder-class="placeholder" />
  10. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  11. </view>
  12. <view class="row b-b">
  13. <text class="tit">新密码</text>
  14. <input class="input" v-model="password" type="password" placeholder="请填写6位新密码" placeholder-class="placeholder" />
  15. </view>
  16. <view class="row b-b">
  17. <text class="tit">再次输入</text>
  18. <input class="input" v-model="yzpassword" type="password" placeholder="请重新填写6位新密码" placeholder-class="placeholder" />
  19. </view>
  20. <button class="add-btn" :class="{ 'bg-gray': loding }" @click="loding ? '' : confirm()">提交</button>
  21. </view>
  22. </template>
  23. <script>
  24. import { verify } from '@/api/login.js';
  25. import { mapState } from 'vuex';
  26. import { is_pas, transaction } from '@/api/set.js';
  27. export default {
  28. data() {
  29. return {
  30. type: 1,
  31. time: '', //保存倒计时对象
  32. countDown: 0, //倒计时
  33. account: '', //手机号
  34. captcha: '', //验证码
  35. password: '', //新密码
  36. yzpassword: '', //重复输入
  37. loding: false //是否载入中
  38. };
  39. },
  40. computed: {
  41. ...mapState('user', ['userInfo'])
  42. },
  43. onLoad() {
  44. is_pas().then(({ data }) => {
  45. console.log();
  46. if (data.status != 0) {
  47. this.type = 2;
  48. }
  49. });
  50. },
  51. watch: {
  52. // 监听倒计时
  53. countDown(i) {
  54. if (i == 0) {
  55. clearInterval(this.time);
  56. }
  57. }
  58. },
  59. methods: {
  60. verification() {
  61. let obj = this;
  62. if (this.account == '') {
  63. this.$api.msg('请输入电话号码');
  64. return;
  65. }
  66. if (!/(^1[2|3|4|5|7|8|9][0-9]{9}$)/.test(this.account)) {
  67. this.$api.msg('请输入正确的手机号');
  68. return;
  69. }
  70. // 判断是否在倒计时
  71. if (obj.countDown > 0) {
  72. return false;
  73. } else {
  74. obj.countDown = 60;
  75. obj.time = setInterval(() => {
  76. obj.countDown--;
  77. }, 1000);
  78. //调用验证码接口
  79. verify({
  80. phone: obj.account,
  81. type: 'login'
  82. })
  83. .then(({ data }) => {})
  84. .catch(err => {
  85. console.log(err);
  86. });
  87. }
  88. },
  89. confirm(e) {
  90. const reg = /^[0-9]{6}$/;
  91. console.log(this.yzpassword);
  92. if (!reg.test(this.yzpassword)) {
  93. uni.showModal({
  94. title: '错误',
  95. content: '请输入6位数字支付密码',
  96. showCancel: false
  97. });
  98. return false;
  99. }
  100. if (this.yzpassword != this.password) {
  101. uni.showModal({
  102. title: '错误',
  103. content: '密码不一致请重新输入',
  104. showCancel: false
  105. });
  106. return false;
  107. }
  108. this.loding = true;
  109. transaction({
  110. type: this.type,
  111. payment: this.password,
  112. account: this.account,
  113. captcha: this.captcha
  114. })
  115. .then(({ data }) => {
  116. this.loding = false;
  117. uni.showModal({
  118. title: '提示',
  119. content: '修改成功',
  120. showCancel: false,
  121. confirmText: '返回个人中心',
  122. success: res => {
  123. uni.switchTab({
  124. url: '/pages/user/user'
  125. });
  126. }
  127. });
  128. })
  129. .catch(err => {
  130. this.loding = false;
  131. console.log(err);
  132. });
  133. }
  134. }
  135. };
  136. </script>
  137. <style lang="scss">
  138. page {
  139. background: $page-color-base;
  140. }
  141. .container {
  142. padding-top: 30rpx;
  143. }
  144. .row {
  145. display: flex;
  146. align-items: center;
  147. position: relative;
  148. padding: 0 30rpx;
  149. height: 110rpx;
  150. background: #fff;
  151. .tit {
  152. flex-shrink: 0;
  153. width: 120rpx;
  154. font-size: 30rpx;
  155. color: $font-color-dark;
  156. }
  157. .input {
  158. flex: 1;
  159. font-size: 30rpx;
  160. color: $font-color-dark;
  161. }
  162. .iconlocation {
  163. font-size: 36rpx;
  164. color: $font-color-light;
  165. }
  166. }
  167. .add-btn {
  168. display: flex;
  169. align-items: center;
  170. justify-content: center;
  171. width: 690rpx;
  172. height: 80rpx;
  173. margin: 60rpx auto;
  174. font-size: $font-lg;
  175. color: #fff;
  176. background: #ECC697;
  177. border-radius: 10rpx;
  178. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  179. }
  180. .bg-gray {
  181. background-color: $color-gray;
  182. }
  183. .code {
  184. color: #dc262b;
  185. font-size: 23rpx;
  186. border-left: 1px solid #eeeeee;
  187. width: 150rpx;
  188. flex-shrink: 0;
  189. text-align: center;
  190. }
  191. </style>