password.vue 3.6 KB

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