moneyPwd.vue 4.2 KB

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