金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

211 lines
4.8 KiB

  1. <template>
  2. <view>
  3. <lf-nav :title="title" :showIcon="true"></lf-nav>
  4. <view class="content">
  5. <view class="list">
  6. <view class="lf-flex">
  7. <input class="input" placeholder="请输入手机号" v-model="phone" maxlength="11" />
  8. </view>
  9. <view class="clear" v-if="phone.length" @click="phone = ''">
  10. <text class="lf-iconfont icon--"></text>
  11. </view>
  12. </view>
  13. <view class="list">
  14. <view class="lf-flex">
  15. <input class="input input-code" placeholder="请输入验证码" maxlength="8" v-model="code" />
  16. </view>
  17. <view class="code" :class="{'active-bg': is_code}" @click="getCode">
  18. <text>{{ is_code ? num +'秒后重新获取' : '获取验证码' }}</text>
  19. </view>
  20. </view>
  21. </view>
  22. <button class="next-btn" hover-class="lf-opacity" @click="next">下一步</button>
  23. <lf-pay-password v-if="show_pay" @comfirm="payComfirm" title="请设置6位支付密码"></lf-pay-password>
  24. <lf-pay-password v-else-if="show_again_pay" @comfirm="againPayComfirm" title="请再次输入密码"></lf-pay-password>
  25. </view>
  26. </template>
  27. <script>
  28. import lfPayPassword from '@/components/lf-payPassword/lf-payPassword.vue'
  29. export default {
  30. components: {
  31. lfPayPassword
  32. },
  33. data(){
  34. return {
  35. phone: '',
  36. code: '',
  37. is_code: false,
  38. timer: null,
  39. num: 10,
  40. show_pay: false,
  41. show_again_pay: false,
  42. token: '',
  43. title: '验证手机号',
  44. password: ''
  45. }
  46. },
  47. onLoad(){
  48. var token = this.$cookieStorage.get('user_token');
  49. this.token = token;
  50. },
  51. onUnload(){
  52. if(this.timer){
  53. clearInterval(this.timer);
  54. this.timer = null;
  55. }
  56. },
  57. methods: {
  58. getCode(){
  59. let phone = this.phone;
  60. if(!phone) return this.$msg('请输入手机号');
  61. if(!this.$check(phone, 'mobile')) return this.$msg('请输入正确的手机号');
  62. if(this.is_code) return;
  63. this.is_code = true;
  64. if(this.timer){
  65. clearInterval(this.timer);
  66. this.timer = null;
  67. }
  68. this.getVerifyCode();
  69. this.timer = setInterval(() => {
  70. this.num--;
  71. if(this.num <= 0){
  72. clearInterval(this.timer);
  73. this.timer = null;
  74. this.num = 10;
  75. this.is_code = false;
  76. }
  77. }, 1000);
  78. },
  79. getVerifyCode(){
  80. this.$http.post({
  81. api: 'api/sms/verify-code',
  82. data: {
  83. mobile: this.phone
  84. },
  85. header: {
  86. 'Content-Type': 'application/x-www-form-urlencoded',
  87. Authorization: this.token
  88. }
  89. }).then(res => {
  90. this.$msg(res.data.message, {icon: 'success'});
  91. })
  92. },
  93. // 下一步
  94. next(){
  95. let phone = this.phone;
  96. if(!phone) return this.$msg('请输入手机号');
  97. if(!this.$check(phone, 'mobile')) return this.$msg('请输入正确的手机号');
  98. if(!this.code) return this.$msg('请输入验证码');
  99. this.$http.post({
  100. api: 'api/user/check_old_mobile',
  101. data: {
  102. code: this.code,
  103. mobile: this.phone
  104. },
  105. header: {
  106. Authorization: this.token
  107. }
  108. }).then(res => {
  109. if(res.data.code == 200){
  110. this.title = '设置密码';
  111. this.show_pay = true;
  112. }else{
  113. this.$msg(res.data.message);
  114. }
  115. })
  116. },
  117. // 输入支付密码
  118. payComfirm(event){
  119. this.show_pay = false;
  120. this.show_again_pay = true;
  121. this.password = event;
  122. },
  123. // 再次输入密码
  124. againPayComfirm(event){
  125. if(this.password == event){
  126. this.$http.post({
  127. api: 'api/user/update_pay_pwd',
  128. data: {
  129. code: this.code,
  130. pay_pwd: event
  131. },
  132. header: {
  133. Authorization: this.token
  134. }
  135. }).then(res => {
  136. if(res.data.code == 200){
  137. this.$msg('设置成功', {icon: 'success'}).then(() => {
  138. this.$toBack();
  139. })
  140. }else{
  141. this.$msg(res.data.data);
  142. }
  143. })
  144. }else{
  145. this.$msg('两次密码不同', {icon: 'error'});
  146. this.phone = '';
  147. this.code = '';
  148. this.show_again_pay = false;
  149. this.title = '验证手机号';
  150. }
  151. }
  152. }
  153. }
  154. </script>
  155. <style lang="scss" scoped="scoped">
  156. .content{
  157. padding: 0 32rpx;
  158. }
  159. .next-btn{
  160. width: 550rpx;
  161. height: 100rpx;
  162. background: #15716E;
  163. border-radius: 50rpx;
  164. position: fixed;
  165. bottom: 10vh;
  166. left: calc(50% - 275rpx);
  167. line-height: 100rpx;
  168. color: #FFFFFF;
  169. }
  170. .list{
  171. height: 106rpx;
  172. width: 100%;
  173. border-bottom: 1rpx solid #e5e5e5;
  174. display: flex;
  175. justify-content: space-between;
  176. align-items: center;
  177. &:nth-child(2n){
  178. margin-top: 30rpx;
  179. }
  180. .input{
  181. width: 540rpx;
  182. height: 80rpx;
  183. font-size: 32rpx;
  184. }
  185. .input-code{
  186. width: 430rpx;
  187. }
  188. .clear{
  189. padding: 20rpx;
  190. }
  191. .code{
  192. min-width: 180rpx;
  193. max-width: 220rpx;
  194. height: 64rpx;
  195. padding: 0 4rpx;
  196. font-size: 24rpx;
  197. color: #15716E;
  198. display: flex;
  199. justify-content: center;
  200. align-items: center;
  201. border-radius: 32rpx;
  202. border: 2rpx solid #15716E;
  203. }
  204. .active-bg{
  205. background: #efefef;
  206. }
  207. }
  208. </style>