setPaypass.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view class="page-wrap">
  3. <view class="step-reset" v-if="step=='reset'">
  4. <view class="title">请输入原始密码</view>
  5. <u-code-input v-model="paypass0"
  6. :space="codeInput.space"
  7. :size="codeInput.size"
  8. @finish="finish0"
  9. :maxlength="codeInput.maxlength"
  10. :adjustPosition="codeInput.adjustPosition"
  11. :dot="codeInput.dot"
  12. :focus="true"
  13. :disabled-keyboard="codeInput.disabledKeyboard" >
  14. </u-code-input>
  15. <view class="tip">建议密码不重复,不连续,不同于登录密码</view>
  16. </view>
  17. <view class="step-1" v-if="step==1">
  18. <view class="title">设置6位数数字支付密码</view>
  19. <u-code-input v-model="paypass1"
  20. :space="codeInput.space"
  21. :size="codeInput.size"
  22. @finish="finish1"
  23. :maxlength="codeInput.maxlength"
  24. :adjustPosition="codeInput.adjustPosition"
  25. :dot="codeInput.dot"
  26. :focus="true"
  27. :disabled-keyboard="codeInput.disabledKeyboard" >
  28. </u-code-input>
  29. <view class="tip">建议密码不重复,不连续,不同于登录密码</view>
  30. </view>
  31. <view class="step-2" v-if="step==2">
  32. <view class="title">请在再次输入</view>
  33. <u-code-input v-model="paypass2"
  34. :space="codeInput.space"
  35. :size="codeInput.size"
  36. @finish="finish2"
  37. :maxlength="codeInput.maxlength"
  38. :adjustPosition="codeInput.adjustPosition"
  39. :dot="codeInput.dot"
  40. :focus="true"
  41. :disabled-keyboard="codeInput.disabledKeyboard" >
  42. </u-code-input>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. fromPage:'',
  51. step:1,
  52. paypass0:'',
  53. paypass1:'',
  54. paypass2:'',
  55. codeInput:{
  56. space:0,
  57. size:45,
  58. maxlength:6,
  59. adjustPosition:false,
  60. dot:true,
  61. disabledKeyboard:false
  62. }
  63. }
  64. },
  65. onShow() {
  66. },
  67. onLoad(page) {
  68. if(page.fromPage=='reset'){
  69. this.step = 'reset'
  70. }
  71. },
  72. methods: {
  73. finish0(){
  74. this.$u.api.checkPayPassword({payPassword:this.paypass0}).then(res=>{
  75. console.log('res',res.data);
  76. if(res.data==1){//密码正确
  77. this.step = 1
  78. }else{
  79. this.paypass0 = ''
  80. }
  81. }).catch(err=>{
  82. if(err.msg=='密码错误!'){
  83. this.paypass0 = '';
  84. }
  85. console.log('checkPayPassword',err);
  86. })
  87. },
  88. finish1(){
  89. this.step = 2;
  90. console.log('paypass',this.paypass1);
  91. },
  92. finish2(){
  93. console.log('paypass1',this.paypass1);
  94. console.log('paypass2',this.paypass2);
  95. let that = this;
  96. if(this.paypass1==this.paypass2){
  97. console.log('两次密码一样');
  98. this.updatePayPassword();
  99. }else{
  100. uni.showModal({
  101. showCancel:false,
  102. title: '提示',
  103. content: '两次密码不一样!',
  104. success: res => {
  105. if (res.confirm) {
  106. that.paypass1 = '';
  107. that.paypass2 = '';
  108. that.step = 1;
  109. } else if (res.cancel) {
  110. console.log('用户点击取消');
  111. }
  112. }
  113. });
  114. }
  115. },
  116. updatePayPassword(){
  117. this.$u.api.updatePayPassword({payPassword:this.paypass2}).then(res=>{
  118. uni.showToast({
  119. title:res.msg,
  120. icon:'success',
  121. complete() {
  122. uni.reLaunch({url: '/center/center'});
  123. }
  124. })
  125. console.log('res',res.data);
  126. }).catch(err=>{
  127. console.log('setPaypass',err);
  128. })
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="scss" scoped>
  134. .page-wrap{
  135. text-align: center;
  136. /deep/ .u-code-input__item{
  137. flex-grow: 1!important;
  138. }
  139. }
  140. .title{
  141. font-size: 40rpx;
  142. font-weight: 600;
  143. margin-bottom: 40rpx;
  144. }
  145. .tip{
  146. margin: 24rpx auto 40rpx;
  147. color: #999;
  148. }
  149. </style>