setPaypass.vue 4.4 KB

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