详情小程序
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.

160 lines
3.2 KiB

  1. <template>
  2. <view>
  3. <view class="pure_top"></view>
  4. <view class="content">
  5. <view class="list">
  6. <input class="input" placeholder="输入手机号" v-model="phone" maxlength="11" />
  7. <view class="clear" v-if="phone.length" @click="phone = ''">
  8. <text class="lf-iconfont icon-shanchu"></text>
  9. </view>
  10. </view>
  11. <view class="list">
  12. <input class="input input-code" placeholder="输入验证码" v-model="code" />
  13. <view class="code" :class="{'active-bg': is_code}" @click="getCode">
  14. <text>{{ is_code ? num +'秒后重新获取' : '获取验证码' }}</text>
  15. </view>
  16. </view>
  17. <button class="confirm" hover-class="lf-opacity" @click="confirm">确认</button>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. data(){
  24. return {
  25. phone: '',
  26. code: '',
  27. is_code: false,
  28. timer: null,
  29. num: 10,
  30. click_button: false
  31. }
  32. },
  33. onLoad(){
  34. },
  35. onUnload(){
  36. if(this.timer){
  37. clearInterval(this.timer);
  38. this.timer = null;
  39. }
  40. },
  41. methods: {
  42. getCode(){
  43. if(this.is_code) return;
  44. this.is_code = true;
  45. if(this.timer){
  46. clearInterval(this.timer);
  47. this.timer = null;
  48. }
  49. console.log("测试重复点击", Math.random())
  50. // TODO 在此发送网络请求
  51. this.timer = setInterval(() => {
  52. this.num--;
  53. if(this.num <= 0){
  54. clearInterval(this.timer);
  55. this.timer = null;
  56. this.num = 10;
  57. this.is_code = false;
  58. }
  59. }, 1000);
  60. },
  61. confirm(){
  62. if(this.click_button) return;
  63. this.click_button = true;
  64. this.$msg('确定').then(() => this.click_button = false);
  65. }
  66. }
  67. }
  68. </script>
  69. <style>
  70. page{
  71. background-color: #F5F5F5;
  72. overflow: hidden;
  73. }
  74. </style>
  75. <style lang="scss" scoped="scoped">
  76. .pure_top {
  77. width: 100%;
  78. height: 210rpx;
  79. position: relative;
  80. z-index: 1;
  81. }
  82. .pure_top::after {
  83. content: '';
  84. width: 140%;
  85. height: 210rpx;
  86. position: absolute;
  87. left: -20%;
  88. top: 0;
  89. z-index: -1;
  90. border-radius: 0 0 55% 55%;
  91. background: linear-gradient(180deg, #FE3EA5 0%, #FE7749 100%);
  92. }
  93. .content{
  94. width: 686rpx;
  95. height: max-content;
  96. background-color: #FFFFFF;
  97. position: fixed;
  98. top: 100rpx;
  99. left: calc(50% - 343rpx);
  100. z-index: 3;
  101. border-radius: 20rpx;
  102. box-sizing: border-box;
  103. padding: 60rpx;
  104. .list{
  105. height: 106rpx;
  106. width: 100%;
  107. border-bottom: 1rpx solid #e5e5e5;
  108. display: flex;
  109. justify-content: space-between;
  110. align-items: center;
  111. &:nth-child(2n){
  112. margin-top: 30rpx;
  113. }
  114. .input{
  115. width: 490rpx;
  116. height: 80rpx;
  117. font-size: 32rpx;
  118. }
  119. .input-code{
  120. width: 360rpx;
  121. }
  122. .clear{
  123. padding: 20rpx;
  124. }
  125. .code{
  126. min-width: 154rpx;
  127. max-width: 220rpx;
  128. height: 43rpx;
  129. padding: 0 4rpx;
  130. background: linear-gradient(180deg, #FE3EA5 0%, #FE7251 100%);
  131. border-radius: 5rpx;
  132. font-size: 24rpx;
  133. color: #FFFFFF;
  134. display: flex;
  135. justify-content: center;
  136. align-items: center;
  137. }
  138. .active-bg{
  139. background: #adb5bd;
  140. }
  141. }
  142. .confirm{
  143. width: 100%;
  144. height: 100rpx;
  145. background-color: #E21196;
  146. border-radius: 60rpx;
  147. color: #FFFFFF;
  148. font-size: 36rpx;
  149. display: flex;
  150. justify-content: center;
  151. align-items: center;
  152. margin-top: 100rpx;
  153. margin-bottom: 20rpx;
  154. }
  155. }
  156. </style>