index.vue 7.4 KB

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