index.vue 6.8 KB

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