login.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <!-- 蓝色登录页面2 -->
  2. <view>11111</view>
  3. <template>
  4. <view>
  5. <view class="img-a">
  6. <view class="t-b">
  7. 您好,
  8. <br />
  9. 欢迎使用途宝智能云仓
  10. </view>
  11. </view>
  12. <view class="login-view" style="">
  13. <view class="t-login">
  14. <form class="cl">
  15. <view class="t-a">
  16. <text class="txt">账户名</text>
  17. <input type="text" name="phone" placeholder="请输入您的账户名" maxlength="20" v-model="phone" />
  18. </view>
  19. <view class="t-a">
  20. <text class="txt">密码</text>
  21. <input type="password" name="code" maxlength="18" placeholder="请输入您的密码" v-model="pwd" />
  22. </view>
  23. <view>
  24. <u-checkbox-group>
  25. <u-checkbox v-model="checked" active-color="#2796f2" @change="change">记住密码</u-checkbox>
  26. </u-checkbox-group>
  27. </view>
  28. <u-button type="primary" class="custom-style" :ripple="true" @click="login">登 录</u-button>
  29. </form>
  30. </view>
  31. </view>
  32. <view style="position:absolute; bottom:20rpx;font-size: 20rpx;width: 100%;text-align: center;">
  33. 青岛途宝软件开发有限公司提供技术支持</view>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. data() {
  39. return {
  40. phone: '', //手机号码
  41. pwd: '', //密码
  42. checked: false,
  43. lifeData: {}
  44. }
  45. },
  46. onShow() {
  47. //清除本地缓存
  48. // uni.clearStorageSync();
  49. uni.removeStorageSync('lifeData');
  50. this.$u.vuex('vuex_token', '');
  51. console.log(uni.getStorageSync('lifeData'))
  52. this.phone = uni.getStorageSync('username')
  53. this.pwd = uni.getStorageSync('password')
  54. if (uni.getStorageSync('username')) {
  55. this.checked = true
  56. }
  57. },
  58. methods: {
  59. change(e) {
  60. console.log(e)
  61. },
  62. //当前登录按钮操作
  63. login() {
  64. let this_ = this
  65. this_.$u.post('/login', {
  66. username: this_.phone,
  67. password: this_.pwd
  68. }).then(res => {
  69. // console.log(res)
  70. if (res.code == 200) {
  71. if (this_.checked === true) {
  72. uni.setStorageSync('username', this_.phone);
  73. uni.setStorageSync('password', this_.pwd);
  74. }
  75. this_.lifeData = {
  76. vuex_token: res.token,
  77. vuex_user: this_.phone
  78. }
  79. uni.setStorage({
  80. key: 'lifeData',
  81. data: this_.lifeData,
  82. success(res) {
  83. uni.showToast({
  84. icon: 'none',
  85. title: '登录成功',
  86. position: "bottom"
  87. })
  88. this_.cacheData()
  89. }
  90. })
  91. // console.log(uni.getStorageSync('lifeData'))
  92. }
  93. })
  94. },
  95. cacheData() {
  96. this.$u.vuex('vuex_token', this.lifeData.vuex_token);
  97. // console.log(this.vuex_token)
  98. this.$u.get('/getInfo').then(res => {
  99. // console.log(res)
  100. uni.setStorageSync('deptName', res.user.dept.deptName);
  101. uni.setStorageSync('userId', res.user.userId);
  102. //跳转页面为tabBar页面
  103. uni.switchTab({
  104. url: '/pages/home/home'
  105. })
  106. })
  107. }
  108. }
  109. };
  110. </script>
  111. <style scoped>
  112. .custom-style {
  113. color: #3ab2f7;
  114. margin-top: 140rpx;
  115. }
  116. .txt {
  117. font-size: 32rpx;
  118. font-weight: bold;
  119. color: #333333;
  120. }
  121. .img-a {
  122. width: 100%;
  123. height: 450rpx;
  124. background-image: url(../../static/head.png);
  125. background-size: 100%;
  126. }
  127. .reg {
  128. font-size: 28rpx;
  129. color: #fff;
  130. height: 90rpx;
  131. line-height: 90rpx;
  132. border-radius: 50rpx;
  133. font-weight: bold;
  134. background: #f5f6fa;
  135. color: #000000;
  136. text-align: center;
  137. margin-top: 30rpx;
  138. }
  139. .login-view {
  140. width: 100%;
  141. position: relative;
  142. margin-top: -120rpx;
  143. background-color: #ffffff;
  144. border-radius: 8% 8% 0% 0;
  145. }
  146. .t-login {
  147. width: 600rpx;
  148. margin: 0 auto;
  149. font-size: 28rpx;
  150. padding-top: 80rpx;
  151. }
  152. .t-login button {
  153. font-size: 28rpx;
  154. background: #2796f2;
  155. color: #fff;
  156. height: 90rpx;
  157. line-height: 90rpx;
  158. border-radius: 50rpx;
  159. font-weight: bold;
  160. }
  161. .t-login input {
  162. height: 90rpx;
  163. line-height: 90rpx;
  164. margin-bottom: 50rpx;
  165. border-bottom: 1px solid #e9e9e9;
  166. font-size: 28rpx;
  167. }
  168. .t-login .t-a {
  169. position: relative;
  170. }
  171. .t-b {
  172. text-align: left;
  173. font-size: 42rpx;
  174. color: #ffffff;
  175. padding: 130rpx 0 0 70rpx;
  176. font-weight: bold;
  177. line-height: 70rpx;
  178. }
  179. .t-login .t-c {
  180. position: absolute;
  181. right: 22rpx;
  182. top: 22rpx;
  183. background: #5677fc;
  184. color: #fff;
  185. font-size: 24rpx;
  186. border-radius: 50rpx;
  187. height: 50rpx;
  188. line-height: 50rpx;
  189. padding: 0 25rpx;
  190. }
  191. .t-login .t-d {
  192. text-align: center;
  193. color: #999;
  194. margin: 80rpx 0;
  195. }
  196. .t-login .t-e {
  197. text-align: center;
  198. width: 250rpx;
  199. margin: 80rpx auto 0;
  200. }
  201. .t-login .t-g {
  202. float: left;
  203. width: 50%;
  204. }
  205. .t-login .t-e image {
  206. width: 50rpx;
  207. height: 50rpx;
  208. }
  209. .t-login .t-f {
  210. text-align: center;
  211. margin: 150rpx 0 0 0;
  212. color: #666;
  213. }
  214. .t-login .t-f text {
  215. margin-left: 20rpx;
  216. color: #aaaaaa;
  217. font-size: 27rpx;
  218. }
  219. .t-login .uni-input-placeholder {
  220. color: #aeaeae;
  221. }
  222. .cl {
  223. zoom: 1;
  224. }
  225. .cl:after {
  226. clear: both;
  227. display: block;
  228. visibility: hidden;
  229. height: 0;
  230. content: '\20';
  231. }
  232. </style>