setPaypass.vue 5.0 KB

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