login.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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.redirectTo({
  82. url: '/pages/home',
  83. });
  84. }
  85. },
  86. }
  87. }
  88. </script>
  89. <style lang="stylus" scoped>
  90. .login {
  91. flex: 1;
  92. display: flex;
  93. flex-direction: column;
  94. overflow: hidden;
  95. background: url(../static/back.png);
  96. background-size: 100% 100%;
  97. .flex-null-1 {
  98. flex: 2;
  99. }
  100. .flex-null-2 {
  101. flex: 3;
  102. }
  103. .logo-img {
  104. width: 448rpx;
  105. height: 187rpx;
  106. margin: 0 auto 0;
  107. }
  108. .logo-text {
  109. margin-top:40rpx;
  110. /* 1. 字体设置:必须够粗 */
  111. font-family: "Microsoft YaHei", "SimHei", sans-serif;
  112. font-weight: 900;
  113. /* 最粗 */
  114. font-size: 52rpx;
  115. /* 根据实际需要调整大小 */
  116. letter-spacing: 2rpx;
  117. color: #ffffff;
  118. text-shadow:
  119. -1rpx -1rpx 0 #7cb9e8,
  120. 1rpx -1rpx 0 #7cb9e8,
  121. -1rpx 1rpx 0 #7cb9e8,
  122. 1rpx 1rpx 0 #7cb9e8,
  123. -2rpx 0rpx 0 #7cb9e8,
  124. 2rpx 0rpx 0 #7cb9e8,
  125. 0rpx -2rpx 0 #7cb9e8,
  126. 0rpx 2rpx 0 #7cb9e8,
  127. 0rpx 0rpx 4rpx rgba(124, 185, 232, 0.6);
  128. padding: 15rpx 40rpx;
  129. display: inline-block;
  130. text-align: center;
  131. }
  132. .input-max-box {
  133. .input-max-box-one {
  134. overflow: hidden;
  135. // margin-top: 68rpx;
  136. .input-box {
  137. display flex;
  138. width: 600rpx;
  139. height: 80rpx;
  140. border: 1rpx solid #0183FA;
  141. border-radius: 40rpx;
  142. margin: 147rpx auto 0;
  143. img {
  144. width: 28rpx;
  145. height: 32rpx;
  146. margin: 24rpx 31rpx;
  147. }
  148. input {
  149. flex: 1;
  150. font-size: 24rpx;
  151. height: 80rpx;
  152. line-height: 80rpx;
  153. margin-right: 31rpx;
  154. }
  155. }
  156. .text-box {
  157. height: 59rpx;
  158. line-height: 59rpx;
  159. color: #DC1616;
  160. font-size: 24rpx;
  161. margin-left: 102rpx;
  162. }
  163. }
  164. .input-max-box-two {
  165. margin-top: 40rpx;
  166. .input-box {
  167. display flex;
  168. width: 600rpx;
  169. height: 80rpx;
  170. border: 1rpx solid #0183FA;
  171. border-radius: 40rpx;
  172. margin: 0 auto 0;
  173. img {
  174. width: 30rpx;
  175. height: 32rpx;
  176. margin: 24rpx 30rpx;
  177. }
  178. input {
  179. flex: 1;
  180. font-size: 24rpx;
  181. height: 80rpx;
  182. line-height: 80rpx;
  183. margin-right: 31rpx;
  184. }
  185. }
  186. .text-box {
  187. height: 59rpx;
  188. line-height: 59rpx;
  189. color: #DC1616;
  190. font-size: 24rpx;
  191. margin-left: 102rpx;
  192. }
  193. }
  194. }
  195. .button-box {
  196. width: 600rpx;
  197. line-height: 80rpx;
  198. background: #0183FA;
  199. border-radius: 40rpx;
  200. font-size: 36rpx;
  201. color: #fff;
  202. text-align center;
  203. margin: 140rpx auto 0;
  204. }
  205. }
  206. </style>