login.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <!-- 登录 -->
  2. <template>
  3. <view class="login">
  4. <view class="flex-null-1"></view>
  5. <img class="logo-img" src="@/static/logo.png" alt="">
  6. <view class="logo-text">(积分兑换)</view>
  7. <view class="input-max-box">
  8. <view class="input-max-box-one">
  9. <view class="input-box">
  10. <img src="@/static/img_log_in_account.png">
  11. <input type="text" v-model="username" @confirm="login()" placeholder="请输入手机号" maxlength="30">
  12. </view>
  13. </view>
  14. <view class="input-max-box-two">
  15. <view class="input-box">
  16. <img src="@/static/img_log_in_password.png">
  17. <input type="password" v-model="password" @confirm="login()" placeholder="请输入密码" maxlength="30">
  18. </view>
  19. </view>
  20. <view class="button-box" @click="login()">登录</view>
  21. </view>
  22. <view class="flex-null-2"></view>
  23. </view>
  24. </template>
  25. <script>
  26. import {
  27. hex_md5
  28. } from '@/utils/md5.js';
  29. import {
  30. login
  31. } from '@/api/indexAKY';
  32. import {
  33. browserDetection
  34. } from '@/utils/auth';
  35. export default {
  36. data() {
  37. return {
  38. username: "",
  39. password: "",
  40. }
  41. },
  42. onLoad() {
  43. },
  44. onShow() {
  45. browserDetection();
  46. this.getUrlData();
  47. },
  48. methods: {
  49. getUrlData(){
  50. const pages = getCurrentPages();
  51. const currentPage = pages[pages.length - 1];
  52. const fullPath = currentPage.$page ? currentPage.$page.fullPath : currentPage.route;
  53. const tokenMatch = fullPath.match(/[?&]token=([^&]+)/);
  54. if (tokenMatch && tokenMatch[1]) {
  55. const token = tokenMatch[1];
  56. uni.setStorageSync('token', token);
  57. uni.setStorageSync('skipType', 1);
  58. uni.redirectTo({
  59. url: '/pages/home',
  60. });
  61. }else{
  62. uni.removeStorageSync('token');
  63. uni.removeStorageSync('skipType');
  64. }
  65. },
  66. //登录
  67. async login() {
  68. let self = this;
  69. if (!this.username) {
  70. uni.showToast({
  71. mask: true,
  72. icon: "none",
  73. position: "center",
  74. title: "请输入手机号",
  75. duration: 2000
  76. });
  77. return
  78. }
  79. if (!this.password) {
  80. uni.showToast({
  81. mask: true,
  82. icon: "none",
  83. position: "center",
  84. title: "请输入密码",
  85. duration: 2000
  86. });
  87. return
  88. }
  89. let obj = {
  90. // account: this.username,
  91. // password: hex_md5(this.password),
  92. mob : this.username,
  93. pwd : this.password,
  94. // password: hex_md5(this.password),
  95. }
  96. const {
  97. data
  98. } = await login(obj)
  99. if (data.code == 1) {
  100. console.log('data',data);
  101. uni.setStorageSync('token', data.data.token);
  102. uni.redirectTo({
  103. url: '/pages/home',
  104. });
  105. }
  106. },
  107. }
  108. }
  109. </script>
  110. <style lang="stylus" scoped>
  111. .login {
  112. flex: 1;
  113. display: flex;
  114. flex-direction: column;
  115. overflow: hidden;
  116. background: url(../static/back.png);
  117. background-size: 100% 100%;
  118. .flex-null-1 {
  119. flex: 2;
  120. }
  121. .flex-null-2 {
  122. flex: 3;
  123. }
  124. .logo-img {
  125. width: 448rpx;
  126. height: 187rpx;
  127. margin: 0 auto 0;
  128. }
  129. .logo-text {
  130. margin-top:40rpx;
  131. /* 1. 字体设置:必须够粗 */
  132. font-family: "Microsoft YaHei", "SimHei", sans-serif;
  133. font-weight: 900;
  134. /* 最粗 */
  135. font-size: 52rpx;
  136. /* 根据实际需要调整大小 */
  137. letter-spacing: 2rpx;
  138. color: #ffffff;
  139. text-shadow:
  140. -1rpx -1rpx 0 #7cb9e8,
  141. 1rpx -1rpx 0 #7cb9e8,
  142. -1rpx 1rpx 0 #7cb9e8,
  143. 1rpx 1rpx 0 #7cb9e8,
  144. -2rpx 0rpx 0 #7cb9e8,
  145. 2rpx 0rpx 0 #7cb9e8,
  146. 0rpx -2rpx 0 #7cb9e8,
  147. 0rpx 2rpx 0 #7cb9e8,
  148. 0rpx 0rpx 4rpx rgba(124, 185, 232, 0.6);
  149. padding: 15rpx 40rpx;
  150. display: inline-block;
  151. text-align: center;
  152. }
  153. .input-max-box {
  154. .input-max-box-one {
  155. overflow: hidden;
  156. // margin-top: 68rpx;
  157. .input-box {
  158. display flex;
  159. width: 600rpx;
  160. height: 80rpx;
  161. border: 1rpx solid #0183FA;
  162. border-radius: 40rpx;
  163. margin: 147rpx auto 0;
  164. img {
  165. width: 28rpx;
  166. height: 32rpx;
  167. margin: 24rpx 31rpx;
  168. }
  169. input {
  170. flex: 1;
  171. font-size: 24rpx;
  172. height: 80rpx;
  173. line-height: 80rpx;
  174. margin-right: 31rpx;
  175. }
  176. }
  177. .text-box {
  178. height: 59rpx;
  179. line-height: 59rpx;
  180. color: #DC1616;
  181. font-size: 24rpx;
  182. margin-left: 102rpx;
  183. }
  184. }
  185. .input-max-box-two {
  186. margin-top: 40rpx;
  187. .input-box {
  188. display flex;
  189. width: 600rpx;
  190. height: 80rpx;
  191. border: 1rpx solid #0183FA;
  192. border-radius: 40rpx;
  193. margin: 0 auto 0;
  194. img {
  195. width: 30rpx;
  196. height: 32rpx;
  197. margin: 24rpx 30rpx;
  198. }
  199. input {
  200. flex: 1;
  201. font-size: 24rpx;
  202. height: 80rpx;
  203. line-height: 80rpx;
  204. margin-right: 31rpx;
  205. }
  206. }
  207. .text-box {
  208. height: 59rpx;
  209. line-height: 59rpx;
  210. color: #DC1616;
  211. font-size: 24rpx;
  212. margin-left: 102rpx;
  213. }
  214. }
  215. }
  216. .button-box {
  217. width: 600rpx;
  218. line-height: 80rpx;
  219. background: #0183FA;
  220. border-radius: 40rpx;
  221. font-size: 36rpx;
  222. color: #fff;
  223. text-align center;
  224. margin: 140rpx auto 0;
  225. }
  226. }
  227. </style>