index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <view class="page">
  3. <view class="bg">
  4. <view class="title">您好!欢迎使用<br>游嵊泗商家服务平台</view>
  5. </view>
  6. <view class="box">
  7. <view class="login">
  8. <view class="tabs">
  9. <view :class="tidx==0?'active':''" @tap="changeTab(0)">账号登录</view>
  10. <view :class="tidx==1?'active':''" @tap="changeTab(1)">验证码登录</view>
  11. </view>
  12. <view class="card" v-if="tidx==0">
  13. <view class="t_item">
  14. <text>账号</text>
  15. <input type="text" placeholder="请输入您的账号" placeholder-style="{color:#999999}" v-model="account" @blur="setAccount" @confirm="setAccount">
  16. </view>
  17. <view class="t_item">
  18. <text>密码</text>
  19. <input type="password" placeholder="请输入您的密码" placeholder-style="{color:#999999}" v-model="password" @blur="setPassword" @confirm="setPassword">
  20. </view>
  21. </view>
  22. <view class="card" v-if="tidx==1">
  23. <view class="t_item">
  24. <text>手机号</text>
  25. <input type="tel" placeholder="请输入您的手机号" placeholder-style="{color:#999999}" v-model="phone" @blur="setPhone" @confirm="setPhone">
  26. </view>
  27. <view class="t_item">
  28. <text>验证码</text>
  29. <view class="ti_code">
  30. <input type="number" placeholder="请输入验证码" placeholder-style="{color:#999999}" v-model="code" @blur="setCode" @confirm="setCode">
  31. <view class="tic_text">
  32. <text @tap="sendCode" :class="text=='获取验证码'?'active':''">{{text}}</text>
  33. <span v-if="text!='获取验证码'">{{time}}S</span>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="forget" @tap="toForgot">忘记密码?</view>
  39. </view>
  40. <view class="to_login" @tap="toLogin">登录</view>
  41. <view class="agreement">
  42. 登录即代表已阅读并同意<span>《用户协议》</span>
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. var timer;
  49. export default {
  50. data() {
  51. return {
  52. tidx:0,
  53. text:'获取验证码',
  54. time:59,
  55. account:'',
  56. password:'',
  57. phone:'',
  58. code:''
  59. }
  60. },
  61. methods: {
  62. changeTab(idx){
  63. this.tidx = idx;
  64. },
  65. setAccount(e){
  66. this.account = e.target.value;
  67. },
  68. setPassword(e){
  69. this.password = e.target.value;
  70. },
  71. setPhone(e){
  72. this.phone = e.target.value;
  73. },
  74. setCode(e){
  75. this.code = e.target.value;
  76. },
  77. sendCode(){
  78. if(this.text!='获取验证码') return;
  79. this.text = '重新发送';
  80. timer = setInterval(()=>{
  81. this.time--;
  82. if(this.time==0){
  83. this.text = '获取验证码';
  84. this.time = 59;
  85. clearInterval(timer);
  86. }
  87. },1000)
  88. },
  89. toForgot(){
  90. uni.navigateTo({
  91. url:'/pages/login/forgot'
  92. })
  93. },
  94. toLogin(){
  95. if(this.tidx==0){
  96. if(!this.account) return this.$showToast('请输入您的账号');
  97. if(!this.password) return this.$showToast('请输入您的密码');
  98. }
  99. if(this.tidx==1){
  100. if(!/^1([3589]\d|4[5-9]|6[1-2,4-7]|7[0-8])\d{8}$/.test(this.phone)) return this.$showToast('请输入正确的手机号');
  101. if(!this.code) return this.$showToast('请输入验证码');
  102. }
  103. uni.reLaunch({
  104. url:'/pages/home/index'
  105. })
  106. }
  107. }
  108. }
  109. </script>
  110. <style scoped lang="less">
  111. .page{
  112. .bg{
  113. width: 100%;
  114. height: 574rpx;
  115. background: url(https://i.ringzle.com/file/20240106/d96376ae556b4f298abee861105b71b4.png) no-repeat;
  116. background-size: 100% 100%;
  117. padding: 237rpx 0 0 40rpx;
  118. box-sizing: border-box;
  119. position: relative;
  120. z-index: 1;
  121. .title{
  122. font-size: 40rpx;
  123. font-family: PingFang SC, PingFang SC;
  124. font-weight: 800;
  125. color: #FFFFFF;
  126. line-height: 72rpx;
  127. }
  128. }
  129. .box{
  130. width: 100%;
  131. background: #FFFFFF;
  132. border-radius: 60rpx 60rpx 0rpx 0rpx;
  133. padding: 85rpx 30rpx 96rpx;
  134. box-sizing: border-box;
  135. margin-top: -149rpx;
  136. position: relative;
  137. z-index: 2;
  138. .login{
  139. width: 100%;
  140. padding: 0 30rpx;
  141. box-sizing: border-box;
  142. .tabs{
  143. display: flex;
  144. align-items: center;
  145. &>view{
  146. padding-bottom: 16rpx;
  147. font-size: 40rpx;
  148. font-family: PingFang SC, PingFang SC;
  149. font-weight: 800;
  150. color: #999999;
  151. position: relative;
  152. &.active{
  153. color: #333333;
  154. &::after{
  155. content: '';
  156. width: 80rpx;
  157. height: 6rpx;
  158. background: #1372FF;
  159. border-radius: 4rpx 4rpx 4rpx 4rpx;
  160. position: absolute;
  161. left: 50%;
  162. margin-left: -40rpx;
  163. bottom: 0;
  164. }
  165. }
  166. &:last-child{
  167. margin-left: 60rpx;
  168. }
  169. }
  170. }
  171. .card{
  172. padding-top: 20rpx;
  173. .t_item{
  174. margin-top: 40rpx;
  175. display: flex;
  176. flex-direction: column;
  177. padding-bottom: 20rpx;
  178. border-bottom: 1rpx solid #D1D1D1;
  179. text{
  180. font-size: 32rpx;
  181. font-family: PingFang SC, PingFang SC;
  182. font-weight: 800;
  183. color: #333333;
  184. }
  185. input{
  186. border: none;
  187. font-size: 28rpx;
  188. font-family: PingFang SC, PingFang SC;
  189. font-weight: 400;
  190. color: #333333;
  191. margin-top: 30rpx;
  192. }
  193. .ti_code{
  194. display: flex;
  195. align-items: center;
  196. justify-content: space-between;
  197. input{
  198. width: calc(100% - 200rpx);
  199. }
  200. .tic_text{
  201. display: flex;
  202. align-items: center;
  203. margin-top: 30rpx;
  204. text{
  205. font-size: 28rpx;
  206. font-family: PingFang SC, PingFang SC;
  207. font-weight: 400;
  208. color: #999999;
  209. &.active{
  210. color: #1372FF;
  211. }
  212. }
  213. span{
  214. font-size: 28rpx;
  215. font-family: PingFang SC, PingFang SC;
  216. font-weight: 400;
  217. color: #1372FF;
  218. margin-left: 10rpx;
  219. }
  220. }
  221. }
  222. }
  223. }
  224. }
  225. .forget{
  226. width: 100%;
  227. box-sizing: border-box;
  228. text-align: right;
  229. margin-top: 30rpx;
  230. font-size: 24rpx;
  231. font-family: PingFang SC, PingFang SC;
  232. font-weight: 400;
  233. color: #1372FF;
  234. }
  235. .to_login{
  236. width: 100%;
  237. height: 96rpx;
  238. background: #1372FF;
  239. border-radius: 48rpx 48rpx 48rpx 48rpx;
  240. line-height: 96rpx;
  241. text-align: center;
  242. margin-top: 80rpx;
  243. font-size: 34rpx;
  244. font-family: PingFang SC, PingFang SC;
  245. font-weight: 400;
  246. color: #FFFFFF;
  247. letter-spacing: 2rpx;
  248. }
  249. .agreement{
  250. width: 100%;
  251. text-align: center;
  252. margin-top: 303rpx;
  253. font-size: 24rpx;
  254. font-family: PingFang SC, PingFang SC;
  255. font-weight: 400;
  256. color: #999999;
  257. span{
  258. color: #1372FF;
  259. }
  260. }
  261. }
  262. }
  263. </style>