setPaypass.vue 5.1 KB

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