moneyPwd.vue 4.7 KB

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