login.vue 4.3 KB

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