otherNumlogin.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view class="page">
  3. <view class="icon">
  4. <image src="../static/login/icon.png" mode="widthFix"></image>
  5. <view class="text">手机号一键登录</view>
  6. </view>
  7. <view class="input">
  8. <input type="text" value="" v-model="phone" placeholder="输入手机号"/>
  9. <view class="" style="display: flex;align-items: center;">
  10. <input type="text" value="" placeholder="输入验证码"/>
  11. <view class="">
  12. <u-code ref="uCode" @change="codeChange" seconds="60" :changeText="'x'"></u-code>
  13. <u--text :text="tips" @tap="getCode" size="28" decoration="underline"></u--text>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="submit" @click="gohome">
  18. 完成
  19. </view>
  20. <view class="aggre">
  21. 登录即代表您同意我们的
  22. <text class="underline">用户协议</text>和
  23. <text class="underline">隐私政策</text>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. export default{
  29. data(){
  30. return{
  31. tips:"获取验证码",
  32. value: '',
  33. // 输入的验证码
  34. code:'',
  35. phone:"",
  36. verify_key:""
  37. }
  38. },
  39. methods:{
  40. // 去首页
  41. gohome(){
  42. uni.switchTab({
  43. url:"index/index"
  44. })
  45. },
  46. codeChange(text){
  47. this.tips = text;
  48. },
  49. getCode() {
  50. console.log("XXXXXXXXX",this.phone)
  51. if (this.$refs.uCode.canGetCode) {
  52. uni.$u.http.post("/api/sms/send",{phone:this.phone}).then((res) => {
  53. console.log(res)
  54. uni.showLoading({
  55. title: '正在获取验证码'
  56. })
  57. setTimeout(() => {
  58. uni.hideLoading();
  59. // 这里此提示会被this.start()方法中的提示覆盖
  60. uni.$u.toast('验证码已发送');
  61. // 通知验证码组件内部开始倒计时
  62. this.$refs.uCode.start();
  63. }, 2000);
  64. this.verify_key=res.verify_key
  65. }).catch((err) => {
  66. console.log(err)
  67. // uni.showToast({
  68. // title: '',
  69. // icon:"none"
  70. // })
  71. })
  72. // 模拟向后端请求验证码
  73. } else {
  74. uni.$u.toast('倒计时结束后再发送');
  75. }
  76. },
  77. change(e) {
  78. console.log('change', e);
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="less">
  84. page{
  85. background-color: #F4F4F4;
  86. color: #333333 ;
  87. }
  88. .page{
  89. margin: 40rpx;
  90. }
  91. .icon{
  92. display: flex;
  93. margin-top: 72rpx;
  94. image{
  95. width: 38rpx;
  96. margin: 0 20rpx;
  97. }
  98. .text{
  99. font-family: PingFangSC-Semibold, PingFang SC;
  100. font-weight: 600;
  101. color: #101010;
  102. }
  103. }
  104. .aggre{
  105. margin-top: 470rpx;
  106. text-align: center;
  107. font-family: PingFang-SC-Medium, PingFang-SC;
  108. font-weight: 500;
  109. font-size: 26rpx;
  110. .underline{
  111. text-decoration:underline;
  112. padding: 0 6rpx;
  113. }
  114. }
  115. .input{
  116. input{
  117. width: 448rpx;
  118. height: 72rpx;
  119. background: #FFFFFF;
  120. padding: 0 30rpx;
  121. margin: 38rpx 0;
  122. margin-right: 20rpx;
  123. }
  124. }
  125. .submit{
  126. margin: 108rpx auto 0;
  127. text-align: center;
  128. width: 654rpx;
  129. height: 92rpx;
  130. line-height: 92rpx;
  131. background: #1E9F6A;
  132. border-radius: 8rpx 32rpx 8rpx 32rpx;
  133. color: #ffffff;
  134. }
  135. </style>