金诚优选前端代码
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.

221 lines
5.0 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: 60,
  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 = 60;
  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. if(res.data.success){
  91. this.$msg(res.data.message, {icon: 'success'});
  92. }else{
  93. this.$msg(res.data.message);
  94. if(this.timer){
  95. clearInterval(this.timer);
  96. this.timer = null;
  97. this.num = 60;
  98. this.is_code = false;
  99. }
  100. }
  101. })
  102. },
  103. // 下一步
  104. next(){
  105. let phone = this.phone;
  106. if(!phone) return this.$msg('请输入手机号');
  107. if(!this.$check(phone, 'mobile')) return this.$msg('请输入正确的手机号');
  108. if(!this.code) return this.$msg('请输入验证码');
  109. this.$http.post({
  110. api: 'api/user/check_old_mobile',
  111. data: {
  112. code: this.code,
  113. mobile: this.phone
  114. },
  115. header: {
  116. Authorization: this.token
  117. }
  118. }).then(res => {
  119. if(res.data.code == 200){
  120. this.title = '设置密码';
  121. this.show_pay = true;
  122. }else{
  123. this.$msg(res.data.message);
  124. }
  125. })
  126. },
  127. // 输入支付密码
  128. payComfirm(event){
  129. this.show_pay = false;
  130. this.show_again_pay = true;
  131. this.password = event;
  132. },
  133. // 再次输入密码
  134. againPayComfirm(event){
  135. if(this.password == event){
  136. this.$http.post({
  137. api: 'api/user/update_pay_pwd',
  138. data: {
  139. code: this.code,
  140. pay_pwd: event
  141. },
  142. header: {
  143. Authorization: this.token
  144. }
  145. }).then(res => {
  146. if(res.data.code == 200){
  147. this.$msg('设置成功', {icon: 'success'}).then(() => {
  148. this.$toBack();
  149. })
  150. }else{
  151. this.$msg(res.data.message);
  152. }
  153. })
  154. }else{
  155. this.$msg('两次密码不同', {icon: 'error'});
  156. this.phone = '';
  157. this.code = '';
  158. this.show_again_pay = false;
  159. this.title = '验证手机号';
  160. }
  161. }
  162. }
  163. }
  164. </script>
  165. <style lang="scss" scoped="scoped">
  166. .content{
  167. padding: 0 32rpx;
  168. }
  169. .next-btn{
  170. width: 550rpx;
  171. height: 100rpx;
  172. background: #15716E;
  173. border-radius: 50rpx;
  174. position: fixed;
  175. bottom: 10vh;
  176. left: calc(50% - 275rpx);
  177. line-height: 100rpx;
  178. color: #FFFFFF;
  179. }
  180. .list{
  181. height: 106rpx;
  182. width: 100%;
  183. border-bottom: 1rpx solid #e5e5e5;
  184. display: flex;
  185. justify-content: space-between;
  186. align-items: center;
  187. &:nth-child(2n){
  188. margin-top: 30rpx;
  189. }
  190. .input{
  191. width: 540rpx;
  192. height: 80rpx;
  193. font-size: 32rpx;
  194. }
  195. .input-code{
  196. width: 430rpx;
  197. }
  198. .clear{
  199. padding: 20rpx;
  200. }
  201. .code{
  202. min-width: 180rpx;
  203. max-width: 220rpx;
  204. height: 64rpx;
  205. padding: 0 4rpx;
  206. font-size: 24rpx;
  207. color: #15716E;
  208. display: flex;
  209. justify-content: center;
  210. align-items: center;
  211. border-radius: 32rpx;
  212. border: 2rpx solid #15716E;
  213. }
  214. .active-bg{
  215. background: #efefef;
  216. }
  217. }
  218. </style>