index.vue 7.2 KB

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