moneyPwd.vue 3.6 KB

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