index.vue 4.9 KB

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