index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view class="login" :style="{background:'url('+ bannerImage +')'}">
  3. <view><nav-bar title="none" icon="none" background="transparent" border-color="transparent" ></nav-bar></view>
  4. <view class="logo"><re-image imgSrc="/retail/login/img_logo_login.png" width="442" height="130"></re-image></view>
  5. <view class="content">
  6. <view class="form">
  7. <view class="input-wrapper">
  8. <view class="label">手机号码</view>
  9. <view class="input-box flex aic"><u-input maxlength="11" v-model="phone" fontSize="32rpx"
  10. border="none" type="text" placeholder="请输入手机号" ></u-input></view>
  11. </view>
  12. <view class="input-wrapper">
  13. <view class="label">验证码</view>
  14. <view class="input-box flex aic">
  15. <u-input maxlength="6" v-model="code" fontSize="30rpx" border="none" type="text" placeholder="请输入验证码"></u-input>
  16. <u-code change-text="重新获取(Xs)" startText="获取验证码" endText="重新获取" @end="end" @start="start" ref="uCode"
  17. @change="codeChange"></u-code>
  18. <view :class="{'getting': getCoding}" class="get-code-btn" @tap="getCode">{{tips}}</view>
  19. </view>
  20. </view>
  21. <view class="btn">
  22. <u-button>登录</u-button>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import {
  30. toRpx
  31. } from '@/utils/calculate.js'
  32. import defaultConfig from '@/config/default.js'
  33. import {
  34. navigateTo,
  35. phoneValidate,
  36. filterPhone,
  37. openFilterPhone
  38. } from '@/utils/utils.js'
  39. export default {
  40. components: {},
  41. computed: {
  42. statusBarHeight() {
  43. return this.$store.state.info.systemInfo?.statusBarHeight
  44. },
  45. },
  46. data() {
  47. return {
  48. bannerImage: defaultConfig.ossImgUrl + '/retail/login/login-bg.png',
  49. navBarHeight: uni.getStorageSync('navBarHeight'),
  50. phone:'',
  51. code:'',
  52. tips:'',
  53. getCoding: false,
  54. }
  55. },
  56. onLoad() {
  57. },
  58. computed:{
  59. canClick() {
  60. return this.phone.length && this.code.length
  61. },
  62. ftPhone() {
  63. return (v) => {
  64. return filterPhone(v)
  65. }
  66. }
  67. },
  68. methods: {
  69. bindPhone() {
  70. console.log('绑定成功')
  71. },
  72. codeChange(text) {
  73. this.tips = text;
  74. },
  75. getCode() {
  76. if (!this.phone) {
  77. uni.showToast({
  78. title: '请先输入手机号',
  79. icon: 'none'
  80. })
  81. return
  82. }
  83. if (!phoneValidate(openFilterPhone(this.phone))) {
  84. uni.showToast({
  85. title: '手机号格式不正确',
  86. icon: 'none'
  87. })
  88. return
  89. }
  90. if (this.$refs.uCode.canGetCode) {
  91. // 模拟向后端请求验证码
  92. uni.showLoading({
  93. title: '正在获取验证码',
  94. icon: 'none'
  95. })
  96. setTimeout(() => {
  97. uni.hideLoading();
  98. // 这里此提示会被this.start()方法中的提示覆盖
  99. uni.$u.toast('验证码已发送');
  100. // 通知验证码组件内部开始倒计时
  101. this.$refs.uCode.start();
  102. }, 1000);
  103. }
  104. },
  105. end() {
  106. this.getCoding = false
  107. },
  108. start() {
  109. this.getCoding = true
  110. }
  111. },
  112. mounted() {
  113. },
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. .login {
  118. background-repeat: no-repeat !important;
  119. background-size: 100% auto !important;
  120. width: 100%;
  121. position: absolute;
  122. top: 0;
  123. bottom: 0;
  124. display: flex;
  125. flex-direction: column;
  126. .logo{
  127. padding: 48rpx 0 0 48rpx;
  128. }
  129. .content{
  130. flex-grow: 1;
  131. padding: 58rpx 32rpx 92rpx;
  132. .form{
  133. height: 100%;
  134. background: #fff;
  135. padding: 40rpx 32rpx;
  136. border-radius: 24rpx;
  137. .input-wrapper {
  138. background:#fff;
  139. padding-bottom: 22rpx;
  140. font-size: 36rpx;
  141. margin-bottom: 50rpx;
  142. .label{
  143. font-weight: 500;
  144. font-size: 32rpx;
  145. color: #171717;
  146. margin-bottom: 20rpx;
  147. }
  148. .input-box{
  149. color: #171717;
  150. height: 84rpx;
  151. background: #F3F7FF;
  152. border-radius: 42rpx;
  153. padding: 0 32rpx;
  154. font-size: 28rpx
  155. }
  156. .icon-pad {
  157. padding: 10rpx;
  158. }
  159. }
  160. .btn{
  161. margin-top: 127rpx;
  162. button{
  163. color: #fff;
  164. background: linear-gradient( 140deg, #FF8500 0%, #FFA600 100%);
  165. border-radius: 48rpx;
  166. }
  167. }
  168. }
  169. }
  170. }
  171. </style>