index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <!-- 蓝色简洁登录页面 -->
  2. <template>
  3. <view class="t-login">
  4. <!-- 页面装饰图片 -->
  5. <view class="img-a"></view>
  6. <view class="t-login-p">
  7. <view class="t-b">
  8. <view>Hello!<br>欢迎来到库比森</view>
  9. </view>
  10. <form class="cl">
  11. <view class="t-a">
  12. <image src="@/static/sj.png"></image>
  13. <input type="number" name="phone" placeholder="请输入手机号" maxlength="11" v-model="phone" />
  14. </view>
  15. <view class="t-a">
  16. <image src="@/static/yz.png"></image>
  17. <input type="number" name="code" maxlength="6" placeholder="请输入验证码" v-model="code" />
  18. <view v-if="showText" class="t-c" @tap="getCode()">获取验证码</view>
  19. <view v-else class="t-c" style="background-color: #A7A7A7;">重新发送({{ second }})</view>
  20. </view>
  21. <button @tap="login()" :loading="loading">登 录</button>
  22. </form>
  23. </view>
  24. <view class="pact">
  25. <view class="pact-a">
  26. <radio value="pactChecked" activeBackgroundColor="#3ba662" activeBorderColor="#3ba662"
  27. borderColor="#3ba662" color="#fff" @click="pactChange" />
  28. <view>我已阅读并同意<text @click="toPact">《用户协议》</text>和<text @click="toPact">《隐私协议》</text></view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import {
  35. v4 as uuidv4
  36. } from 'uuid';
  37. import {
  38. getPhoneVerifyCode
  39. } from '@/api/user.js'
  40. export default {
  41. data() {
  42. return {
  43. loading: false,
  44. pactChecked: false,
  45. second: 60, //默认60秒
  46. showText: true, //判断短信是否发送
  47. phone: '15933333333', //手机号码
  48. code: '', //验证码
  49. uuid: uuidv4(),
  50. };
  51. },
  52. onLoad() {},
  53. methods: {
  54. pactChange() {
  55. this.pactChecked = true
  56. },
  57. //当前登录按钮操作
  58. login() {
  59. if (!this.phone) {
  60. uni.showToast({
  61. title: '请输入手机号',
  62. icon: 'none'
  63. });
  64. return;
  65. }
  66. if (!/^[1][3,4,5,7,8,9][0-9]{9}$/.test(this.phone)) {
  67. uni.showToast({
  68. title: '请输入正确手机号',
  69. icon: 'none'
  70. });
  71. return;
  72. }
  73. if (!this.code) {
  74. uni.showToast({
  75. title: '请输入验证码',
  76. icon: 'none'
  77. });
  78. return;
  79. }
  80. if (!this.pactChecked) {
  81. uni.showToast({
  82. title: '请选中协议',
  83. icon: 'none'
  84. });
  85. return;
  86. }
  87. this.loading = true
  88. this.$u.api.token(
  89. this.uuid,
  90. this.phone,
  91. this.code
  92. ).then(data => {
  93. uni.setStorageSync('uuid', this.uuid)
  94. uni.setStorageSync('phone', this.phone);
  95. uni.showToast({
  96. icon: 'none',
  97. title: '登录成功',
  98. position: "bottom",
  99. mask: true
  100. })
  101. let _this = this
  102. setTimeout(function() {
  103. _this.$u.func.login(data)
  104. }, 1000);
  105. })
  106. .finally(() => {
  107. this.loading = false;
  108. });
  109. },
  110. //获取短信验证码
  111. getCode() {
  112. if (!this.phone) {
  113. uni.showToast({
  114. title: '请输入手机号',
  115. icon: 'none'
  116. });
  117. return;
  118. }
  119. if (!/^[1][3,4,5,7,8,9][0-9]{9}$/.test(this.phone)) {
  120. uni.showToast({
  121. title: '请输入正确手机号',
  122. icon: 'none'
  123. });
  124. return;
  125. }
  126. this.showText = false;
  127. var that = this;
  128. var interval = setInterval(() => {
  129. var times = that.second - 1;
  130. that.second = times < 10 ? '0' + times : times; //小于10秒补 0
  131. that.second = times;
  132. console.log(times);
  133. }, 1000);
  134. setTimeout(() => {
  135. clearInterval(interval);
  136. that.second = 60;
  137. that.showText = true;
  138. }, 60000);
  139. let obj = {
  140. phone: this.phone,
  141. uuid: this.uuid
  142. }
  143. getPhoneVerifyCode(obj).then(res => {
  144. this.code = res.data.data
  145. })
  146. },
  147. //等三方微信登录
  148. wxLogin() {
  149. uni.showToast({
  150. title: '微信登录',
  151. icon: 'none'
  152. });
  153. },
  154. //第三方支付宝登录
  155. zfbLogin() {
  156. uni.showToast({
  157. title: '支付宝登录',
  158. icon: 'none'
  159. });
  160. }
  161. }
  162. };
  163. </script>
  164. <style lang="scss" scoped>
  165. .img-a {
  166. width: 100%;
  167. height: 565rpx;
  168. background: url(../../static/images/login/heae.png) no-repeat;
  169. background-size: 100%;
  170. }
  171. .img-b {
  172. position: absolute;
  173. width: 50%;
  174. bottom: 0;
  175. left: -50rpx;
  176. margin-bottom: -200rpx;
  177. }
  178. .t-login {
  179. width: 100%;
  180. font-size: 28rpx;
  181. color: #000;
  182. }
  183. .t-login-p {
  184. position: relative;
  185. padding: 0 36rpx;
  186. top: -300rpx;
  187. }
  188. .t-login button {
  189. font-size: 28rpx;
  190. background: #03803B;
  191. color: #fff;
  192. height: 90rpx;
  193. line-height: 90rpx;
  194. border-radius: 50rpx;
  195. box-shadow: 0 5px 7px 0 rgba(86, 119, 252, 0.2);
  196. }
  197. .t-login input {
  198. padding: 0 20rpx 0 120rpx;
  199. height: 90rpx;
  200. line-height: 90rpx;
  201. margin-bottom: 50rpx;
  202. background: #f8f7fc;
  203. border: 1px solid #e9e9e9;
  204. font-size: 28rpx;
  205. border-radius: 50rpx;
  206. }
  207. .t-login .t-a {
  208. position: relative;
  209. }
  210. .t-login .t-a image {
  211. width: 40rpx;
  212. height: 40rpx;
  213. position: absolute;
  214. left: 40rpx;
  215. top: 28rpx;
  216. border-right: 2rpx solid #dedede;
  217. padding-right: 20rpx;
  218. }
  219. .t-login .t-b {
  220. text-align: left;
  221. font-size: 46rpx;
  222. color: #000;
  223. padding: 200rpx 0 120rpx 0;
  224. font-weight: bold;
  225. }
  226. .t-login .t-c {
  227. position: absolute;
  228. right: 22rpx;
  229. top: 22rpx;
  230. background: #03803B;
  231. color: #fff;
  232. font-size: 24rpx;
  233. border-radius: 50rpx;
  234. height: 50rpx;
  235. line-height: 50rpx;
  236. padding: 0 25rpx;
  237. }
  238. .t-login .uni-input-placeholder {
  239. color: #000;
  240. }
  241. .pact {
  242. position: absolute;
  243. width: 100%;
  244. bottom: 60rpx;
  245. font-size: 24rpx;
  246. text {
  247. color: #3ba662;
  248. }
  249. .pact-a {
  250. display: flex;
  251. align-items: center;
  252. justify-content: center;
  253. radio {
  254. :deep(.uni-radio-input) {
  255. border: 1rpx solid #3ba662;
  256. }
  257. transform:scale(0.6)
  258. }
  259. }
  260. }
  261. </style>