setPaypass.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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'&&noPaypass==false">
  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="findpaypass" @click="$u.route('/center/findpaypass')">忘记密码?</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. noPaypass:true,
  58. fromPage:'',
  59. step:1,
  60. paypass0:'',
  61. paypass1:'',
  62. paypass2:'',
  63. codeInput:{
  64. space:20,
  65. size:45,
  66. maxlength:6,
  67. adjustPosition:false,
  68. dot:true,
  69. disabledKeyboard:false
  70. },
  71. code:'',
  72. }
  73. },
  74. onShow() {
  75. this.checkPaypass()
  76. },
  77. onLoad(page) {
  78. this.fromPage = page.fromPage;
  79. this.code = page.code;
  80. },
  81. methods: {
  82. checkPaypass(){
  83. this.$u.api.getExistPayPassword().then(res=>{
  84. // console.log('res',res.data);
  85. if(res.data==0){
  86. this.noPaypass = true
  87. }else{
  88. this.noPaypass = false;
  89. this.step = 1;
  90. if(this.fromPage=='reset'){
  91. this.step = 'reset'
  92. }
  93. }
  94. console.log('this.noPaypass',this.noPaypass);
  95. }).catch(err=>{
  96. console.log('checkPaypass',err);
  97. })
  98. },
  99. finish0(){
  100. this.$u.api.checkPayPassword({payPassword:this.paypass0}).then(res=>{
  101. console.log('res',res.data);
  102. if(res.data==1){//密码正确
  103. this.step = 1
  104. }else{
  105. this.paypass0 = ''
  106. }
  107. }).catch(err=>{
  108. if(err.msg=='密码错误!'){
  109. this.paypass0 = '';
  110. }
  111. console.log('checkPayPassword',err);
  112. })
  113. },
  114. finish1(){
  115. this.step = 2;
  116. console.log('paypass',this.paypass1);
  117. },
  118. finish2(){
  119. console.log('paypass1',this.paypass1);
  120. console.log('paypass2',this.paypass2);
  121. let that = this;
  122. if(this.paypass1==this.paypass2){
  123. console.log('两次密码一样');
  124. if(this.fromPage == 'forget'){
  125. this.resetPayPassword();
  126. }else{
  127. this.updatePayPassword();
  128. }
  129. }else{
  130. uni.showModal({
  131. showCancel:false,
  132. title: '提示',
  133. content: '两次密码不一样!',
  134. success: res => {
  135. if (res.confirm) {
  136. that.paypass1 = '';
  137. that.paypass2 = '';
  138. that.step = 1;
  139. } else if (res.cancel) {
  140. console.log('用户点击取消');
  141. }
  142. }
  143. });
  144. }
  145. },
  146. updatePayPassword(){
  147. this.$u.api.updatePayPassword({payPassword:this.paypass2}).then(res=>{
  148. uni.showToast({
  149. title:res.msg,
  150. icon:'success',
  151. complete() {
  152. setTimeout(()=>{
  153. uni.reLaunch({url: '/center/center'});
  154. },2000)
  155. }
  156. })
  157. console.log('res',res.data);
  158. }).catch(err=>{
  159. console.log('setPaypass',err);
  160. })
  161. },
  162. resetPayPassword(){
  163. let params = {
  164. payPassword:this.paypass2,
  165. code:this.code,
  166. mobile:this.vuex_member_info.mobile
  167. }
  168. this.$u.api.resetPayPassword(params).then(res=>{
  169. uni.showToast({
  170. title:res.msg,
  171. icon:'success',
  172. complete() {
  173. setTimeout(()=>{
  174. uni.reLaunch({url: '/center/center'});
  175. },2000)
  176. }
  177. })
  178. console.log('res',res.data);
  179. }).catch(err=>{
  180. setTimeout(()=>{
  181. uni.reLaunch({url: '/center/findpaypass'});
  182. },2000)
  183. console.log('setPaypass',err);
  184. })
  185. }
  186. }
  187. }
  188. </script>
  189. <style lang="scss" scoped>
  190. .page-wrap{
  191. text-align: center;
  192. /deep/ .u-code-input__item{
  193. flex-grow: 1!important;
  194. }
  195. }
  196. .title{
  197. font-size: 40rpx;
  198. font-weight: 600;
  199. margin-bottom: 40rpx;
  200. }
  201. .tip{
  202. margin: 24rpx auto 40rpx;
  203. color: #999;
  204. }
  205. .findpaypass{
  206. text-align: right;
  207. margin-top: 40rpx;
  208. color: #999;
  209. font-size: 24rpx;
  210. }
  211. </style>