login.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. window.history.back();
  65. }
  66. },
  67. //登录
  68. async login() {
  69. let self = this;
  70. if (!this.username) {
  71. uni.showToast({
  72. mask: true,
  73. icon: "none",
  74. position: "center",
  75. title: "请输入手机号",
  76. duration: 2000
  77. });
  78. return
  79. }
  80. if (!this.password) {
  81. uni.showToast({
  82. mask: true,
  83. icon: "none",
  84. position: "center",
  85. title: "请输入密码",
  86. duration: 2000
  87. });
  88. return
  89. }
  90. let obj = {
  91. // account: this.username,
  92. // password: hex_md5(this.password),
  93. mob : this.username,
  94. pwd : this.password,
  95. // password: hex_md5(this.password),
  96. }
  97. const {
  98. data
  99. } = await login(obj)
  100. if (data.code == 1) {
  101. console.log('data',data);
  102. uni.setStorageSync('token', data.data.token);
  103. uni.redirectTo({
  104. url: '/pages/home',
  105. });
  106. }
  107. },
  108. }
  109. }
  110. </script>
  111. <style lang="stylus" scoped>
  112. .login {
  113. flex: 1;
  114. display: flex;
  115. flex-direction: column;
  116. overflow: hidden;
  117. background: url(../static/back.png);
  118. background-size: 100% 100%;
  119. .flex-null-1 {
  120. flex: 2;
  121. }
  122. .flex-null-2 {
  123. flex: 3;
  124. }
  125. .logo-img {
  126. width: 448rpx;
  127. height: 187rpx;
  128. margin: 0 auto 0;
  129. }
  130. .logo-text {
  131. margin-top:40rpx;
  132. /* 1. 字体设置:必须够粗 */
  133. font-family: "Microsoft YaHei", "SimHei", sans-serif;
  134. font-weight: 900;
  135. /* 最粗 */
  136. font-size: 52rpx;
  137. /* 根据实际需要调整大小 */
  138. letter-spacing: 2rpx;
  139. color: #ffffff;
  140. text-shadow:
  141. -1rpx -1rpx 0 #7cb9e8,
  142. 1rpx -1rpx 0 #7cb9e8,
  143. -1rpx 1rpx 0 #7cb9e8,
  144. 1rpx 1rpx 0 #7cb9e8,
  145. -2rpx 0rpx 0 #7cb9e8,
  146. 2rpx 0rpx 0 #7cb9e8,
  147. 0rpx -2rpx 0 #7cb9e8,
  148. 0rpx 2rpx 0 #7cb9e8,
  149. 0rpx 0rpx 4rpx rgba(124, 185, 232, 0.6);
  150. padding: 15rpx 40rpx;
  151. display: inline-block;
  152. text-align: center;
  153. }
  154. .input-max-box {
  155. .input-max-box-one {
  156. overflow: hidden;
  157. // margin-top: 68rpx;
  158. .input-box {
  159. display flex;
  160. width: 600rpx;
  161. height: 80rpx;
  162. border: 1rpx solid #0183FA;
  163. border-radius: 40rpx;
  164. margin: 147rpx auto 0;
  165. img {
  166. width: 28rpx;
  167. height: 32rpx;
  168. margin: 24rpx 31rpx;
  169. }
  170. input {
  171. flex: 1;
  172. font-size: 24rpx;
  173. height: 80rpx;
  174. line-height: 80rpx;
  175. margin-right: 31rpx;
  176. }
  177. }
  178. .text-box {
  179. height: 59rpx;
  180. line-height: 59rpx;
  181. color: #DC1616;
  182. font-size: 24rpx;
  183. margin-left: 102rpx;
  184. }
  185. }
  186. .input-max-box-two {
  187. margin-top: 40rpx;
  188. .input-box {
  189. display flex;
  190. width: 600rpx;
  191. height: 80rpx;
  192. border: 1rpx solid #0183FA;
  193. border-radius: 40rpx;
  194. margin: 0 auto 0;
  195. img {
  196. width: 30rpx;
  197. height: 32rpx;
  198. margin: 24rpx 30rpx;
  199. }
  200. input {
  201. flex: 1;
  202. font-size: 24rpx;
  203. height: 80rpx;
  204. line-height: 80rpx;
  205. margin-right: 31rpx;
  206. }
  207. }
  208. .text-box {
  209. height: 59rpx;
  210. line-height: 59rpx;
  211. color: #DC1616;
  212. font-size: 24rpx;
  213. margin-left: 102rpx;
  214. }
  215. }
  216. }
  217. .button-box {
  218. width: 600rpx;
  219. line-height: 80rpx;
  220. background: #0183FA;
  221. border-radius: 40rpx;
  222. font-size: 36rpx;
  223. color: #fff;
  224. text-align center;
  225. margin: 140rpx auto 0;
  226. }
  227. }
  228. </style>