index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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. };
  74. },
  75. onLoad() {},
  76. methods: {
  77. pactChange() {
  78. this.pactChecked = true
  79. },
  80. //当前登录按钮操作
  81. login() {
  82. if (!this.phone) {
  83. uni.showToast({
  84. title: '请输入手机号',
  85. icon: 'none'
  86. });
  87. return;
  88. }
  89. if (!/^[1][3,4,5,7,8,9][0-9]{9}$/.test(this.phone)) {
  90. uni.showToast({
  91. title: '请输入正确手机号',
  92. icon: 'none'
  93. });
  94. return;
  95. }
  96. if (!this.code) {
  97. uni.showToast({
  98. title: '请输入验证码',
  99. icon: 'none'
  100. });
  101. return;
  102. }
  103. if (!this.pactChecked) {
  104. uni.showToast({
  105. title: '请选中协议',
  106. icon: 'none'
  107. });
  108. return;
  109. }
  110. this.loading = true
  111. this.$u.api.token(
  112. this.uuid,
  113. this.phone,
  114. this.code
  115. ).then(data => {
  116. uni.setStorageSync('uuid', this.uuid)
  117. uni.setStorageSync('phone', this.phone);
  118. uni.showToast({
  119. icon: 'none',
  120. title: '登录成功',
  121. position: "bottom",
  122. mask: true
  123. })
  124. let _this = this
  125. setTimeout(function() {
  126. _this.$u.func.login(data)
  127. }, 1000);
  128. })
  129. .finally(() => {
  130. this.loading = false;
  131. });
  132. },
  133. //获取短信验证码
  134. getCode() {
  135. if (!this.phone) {
  136. uni.showToast({
  137. title: '请输入手机号',
  138. icon: 'none'
  139. });
  140. return;
  141. }
  142. if (!/^[1][3,4,5,7,8,9][0-9]{9}$/.test(this.phone)) {
  143. uni.showToast({
  144. title: '请输入正确手机号',
  145. icon: 'none'
  146. });
  147. return;
  148. }
  149. let obj = {
  150. phone: this.phone,
  151. uuid: this.uuid
  152. }
  153. getPhoneVerifyCode(obj).then(res => {
  154. uni.showToast({
  155. title: res.msg,
  156. icon: 'none'
  157. });
  158. if (res.code == 200) {
  159. this.showText = false;
  160. var that = this;
  161. var interval = setInterval(() => {
  162. var times = that.second - 1;
  163. that.second = times < 10 ? '0' + times : times; //小于10秒补 0
  164. that.second = times;
  165. }, 1000);
  166. setTimeout(() => {
  167. clearInterval(interval);
  168. that.second = 60;
  169. that.showText = true;
  170. }, 60000);
  171. }
  172. })
  173. },
  174. //等三方微信登录
  175. wxLogin() {
  176. uni.showToast({
  177. title: '微信登录',
  178. icon: 'none'
  179. });
  180. },
  181. //第三方支付宝登录
  182. zfbLogin() {
  183. uni.showToast({
  184. title: '支付宝登录',
  185. icon: 'none'
  186. });
  187. }
  188. }
  189. };
  190. </script>
  191. <style lang="scss" scoped>
  192. .img-a {
  193. width: 100%;
  194. height: 100vh;
  195. background: url(../../static/images/login/heae.png) no-repeat;
  196. background-size: 100%;
  197. }
  198. .t-login {
  199. width: 100%;
  200. height: 100vh;
  201. font-size: 28rpx;
  202. color: #000;
  203. background-color: #0C7C3E;
  204. }
  205. .t-login-p {
  206. position: relative;
  207. }
  208. .login-card {
  209. width: 649rpx;
  210. background: rgba(7, 97, 47, 0.6);
  211. box-shadow: 0rpx 4rpx 54rpx 0rpx #131413;
  212. border-radius: 12rpx;
  213. }
  214. ::v-deep .uni-easyinput__content {
  215. background-color: transparent !important;
  216. }
  217. ::v-deep .uni-input-input {
  218. color: #fff;
  219. }
  220. ::v-deep .uni-input-placeholder {
  221. color: #FFF !important;
  222. font-size: 28rpx;
  223. }
  224. .t-login .t-a {
  225. position: relative;
  226. }
  227. .t-login .t-a image {
  228. width: 40rpx;
  229. height: 40rpx;
  230. position: absolute;
  231. left: 40rpx;
  232. top: 28rpx;
  233. border-right: 2rpx solid #dedede;
  234. padding-right: 20rpx;
  235. }
  236. .t-login .t-b {
  237. text-align: left;
  238. font-size: 46rpx;
  239. color: #000;
  240. padding: 200rpx 0 120rpx 0;
  241. font-weight: bold;
  242. }
  243. .t-login .t-c {
  244. position: absolute;
  245. right: 22rpx;
  246. top: 22rpx;
  247. background: #03803B;
  248. color: #fff;
  249. font-size: 24rpx;
  250. border-radius: 50rpx;
  251. height: 50rpx;
  252. line-height: 50rpx;
  253. padding: 0 25rpx;
  254. }
  255. .code{
  256. width: 160rpx;
  257. text-align: center;
  258. font-size: 26rpx;
  259. color: #FFF;
  260. border-radius: 8rpx;
  261. border: 1rpx solid #FFFFFF;
  262. padding:3rpx 4rpx ;
  263. }
  264. .pact {
  265. position: absolute;
  266. width: 100%;
  267. bottom: 60rpx;
  268. font-size: 24rpx;
  269. text {
  270. color: #3ba662;
  271. }
  272. .pact-a {
  273. display: flex;
  274. align-items: center;
  275. justify-content: center;
  276. radio {
  277. :deep(.uni-radio-input) {
  278. border: 1rpx solid #3ba662;
  279. }
  280. transform:scale(0.6)
  281. }
  282. }
  283. }
  284. </style>