moneyPwd.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view class="container">
  3. <view class="row b-b" v-if="userInfo.transaction">
  4. <text class="tit">原密码</text>
  5. <input class="input" v-model="oldPassword" 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位新密码" 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 { transaction } from '@/api/set.js';
  27. export default {
  28. data() {
  29. return {
  30. time: '', //保存倒计时对象
  31. countDown: 0, //倒计时
  32. // account: '', //手机号
  33. // captcha: '', //验证码
  34. oldPassword:'',//老密码
  35. password: '' ,//新密码
  36. yzpassword:'',//重复输入
  37. loding:false,//是否载入中
  38. };
  39. },
  40. computed: {
  41. ...mapState('user',['userInfo'])
  42. },
  43. onLoad() {
  44. console.log(this.userInfo.transaction);
  45. console.log(this.userInfo);
  46. if(this.userInfo.phone == null){
  47. this.account = '';
  48. }else{
  49. this.account = this.userInfo.phone;
  50. this.show = false;
  51. }
  52. },
  53. watch: {
  54. // 监听倒计时
  55. countDown(i) {
  56. if (i == 0) {
  57. clearInterval(this.time);
  58. }
  59. }
  60. },
  61. methods: {
  62. confirm(e) {
  63. const reg = /^[0-9]{6}$/;
  64. console.log(this.yzpassword)
  65. if(!reg.test(this.yzpassword)){
  66. uni.showModal({
  67. title: '错误',
  68. content: '请输入6位数字支付密码',
  69. showCancel: false,
  70. });
  71. return false
  72. }
  73. if(this.yzpassword!=this.password){
  74. uni.showModal({
  75. title: '错误',
  76. content: '密码不一致请重新输入',
  77. showCancel: false,
  78. });
  79. return false
  80. }
  81. this.loding = true;
  82. transaction({
  83. pass: this.password,
  84. oldpass: this.oldPassword,
  85. })
  86. .then(({ data }) => {
  87. this.loding = false;
  88. uni.showModal({
  89. title: '提示',
  90. content: '修改成功',
  91. showCancel: false,
  92. confirmText: '返回个人中心',
  93. success: res => {
  94. uni.switchTab({
  95. url:'/pages/user/user'
  96. })
  97. }
  98. });
  99. })
  100. .catch(err => {
  101. this.loding = false;
  102. console.log(err);
  103. });
  104. }
  105. }
  106. };
  107. </script>
  108. <style lang="scss">
  109. page {
  110. background: $page-color-base;
  111. }
  112. .container {
  113. padding-top: 30rpx;
  114. }
  115. .row {
  116. display: flex;
  117. align-items: center;
  118. position: relative;
  119. padding: 0 30rpx;
  120. height: 110rpx;
  121. background: #fff;
  122. .tit {
  123. flex-shrink: 0;
  124. width: 120rpx;
  125. font-size: 30rpx;
  126. color: $font-color-dark;
  127. }
  128. .input {
  129. flex: 1;
  130. font-size: 30rpx;
  131. color: $font-color-dark;
  132. }
  133. .iconlocation {
  134. font-size: 36rpx;
  135. color: $font-color-light;
  136. }
  137. }
  138. .add-btn {
  139. display: flex;
  140. align-items: center;
  141. justify-content: center;
  142. width: 690rpx;
  143. height: 80rpx;
  144. margin: 60rpx auto;
  145. font-size: $font-lg;
  146. color: #fff;
  147. background: #456FFB;
  148. border-radius: 10rpx;
  149. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  150. }
  151. .bg-gray{
  152. background-color: $color-gray;
  153. }
  154. .code {
  155. color: #5dbc7c;
  156. font-size: 23rpx;
  157. border-left: 1px solid #eeeeee;
  158. width: 150rpx;
  159. flex-shrink: 0;
  160. text-align: center;
  161. }
  162. </style>