login.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <!-- 蓝色登录页面2 -->
  2. <template>
  3. <view style="height:100vh;background: #fff;">
  4. <view class="img-a">
  5. <view class="t-b">
  6. 欢迎使用,
  7. <br />
  8. 喵星人智能货柜管理平台
  9. </view>
  10. </view>
  11. <view class="login-view" style="">
  12. <view class="t-login">
  13. <form class="cl">
  14. <view class="t-a">
  15. <text class="txt">账号</text>
  16. <input placeholder="请输入账号" v-model="loginForm.username" name="input" />
  17. </view>
  18. <view class="t-a">
  19. <text class="txt">密码</text>
  20. <input v-model="loginForm.password" type="password" placeholder="请输入密码" name="input" />
  21. </view>
  22. <view class="remember">
  23. <u-checkbox-group>
  24. <u-checkbox size="30" labelSize="26" labelColor="#666" name="1" v-model="isRemember" @change="remember">记住密码</u-checkbox>
  25. </u-checkbox-group>
  26. </view>
  27. <button @click="handleLogin">登 录</button>
  28. </form>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script setup>
  34. import { getCurrentInstance,reactive,toRefs,onMounted } from 'vue'
  35. import {
  36. sysList
  37. } from '@/api/system/menu.js'
  38. import useUserStore from '@/stores/user.js'
  39. import usePermissionStore from '@/stores/permission.js'
  40. const userStore = useUserStore()
  41. const permissionStore = usePermissionStore()
  42. const {
  43. proxy
  44. } = getCurrentInstance();
  45. const data = reactive({
  46. loginForm: {
  47. username: "",
  48. password: "",
  49. code: "",
  50. uuid: ''
  51. },
  52. isRemember: true
  53. })
  54. const {
  55. loginForm,
  56. isRemember
  57. } = toRefs(data);
  58. onMounted(() => {
  59. if (uni.getStorageSync('account')) {
  60. isRemember.value = true
  61. let account = JSON.parse(uni.getStorageSync('account'))
  62. loginForm.value.username = account.username
  63. loginForm.value.password = account.password
  64. }
  65. })
  66. function remember(e) {
  67. isRemember.value = e.value
  68. }
  69. // 登录方法
  70. function handleLogin() {
  71. if (!loginForm.value.username) {
  72. proxy.$modal.msg('请输入账号~')
  73. return
  74. }
  75. if (!loginForm.value.password) {
  76. proxy.$modal.msg('请输入密码~')
  77. return
  78. }
  79. pwdLogin()
  80. }
  81. // 密码登录
  82. async function pwdLogin(params) {
  83. if (isRemember.value) { //记住密码
  84. let account = {
  85. username: loginForm.value.username,
  86. password: loginForm.value.password
  87. }
  88. uni.setStorageSync('account', JSON.stringify(account))
  89. } else {
  90. uni.setStorageSync('account', '')
  91. }
  92. await userStore.Login(loginForm.value)
  93. await permissionStore.GetPermis()
  94. //判断用户是否有任一菜单权限
  95. if (permissionStore.permissions_menu && permissionStore.permissions_menu !=
  96. '[]') {
  97. proxy.$tab.reLaunch('/pages/globalPages/home')
  98. } else {
  99. proxy.$modal.msg('该用户无权限~')
  100. }
  101. }
  102. // 获取系统id
  103. function getSysId() {
  104. return new Promise((resolve, reject) => {
  105. sysList({}).then(res => {
  106. let sysId = 381638941857029; //默认系统id
  107. for (var i = 0; i < res.length; i++) {
  108. let item = res[i];
  109. if (item.code == 'xy_merc_mini') {
  110. sysId = item.id
  111. console.log('系统id:', sysId)
  112. }
  113. }
  114. uni.setStorageSync('sysId', sysId)
  115. resolve(res)
  116. }).catch(err => {
  117. reject(err)
  118. })
  119. })
  120. }
  121. </script>
  122. <style lang="scss" scoped>
  123. .txt {
  124. font-size: 32rpx;
  125. font-weight: bold;
  126. color: #333333;
  127. }
  128. .img-a {
  129. width: 100%;
  130. height: 450rpx;
  131. background-image: url(https://cdn.ossfile.mxrvending.com/assets/xy_mana_mini/images/global/opendoor-manage-mini.png);
  132. background-size: 100%;
  133. }
  134. .reg {
  135. font-size: 28rpx;
  136. color: #fff;
  137. height: 90rpx;
  138. line-height: 90rpx;
  139. border-radius: 50rpx;
  140. font-weight: bold;
  141. background: #f5f6fa;
  142. color: #000000;
  143. text-align: center;
  144. margin-top: 30rpx;
  145. }
  146. .login-view {
  147. width: 100%;
  148. position: relative;
  149. margin-top: -120rpx;
  150. background-color: #ffffff;
  151. border-radius: 8% 8% 0% 0;
  152. }
  153. .t-login {
  154. width: 600rpx;
  155. margin: 0 auto;
  156. font-size: 28rpx;
  157. padding-top: 80rpx;
  158. }
  159. .t-login button {
  160. font-size: 28rpx;
  161. background: #2796f2;
  162. color: #fff;
  163. height: 90rpx;
  164. line-height: 90rpx;
  165. border-radius: 50rpx;
  166. font-weight: bold;
  167. }
  168. .t-login input {
  169. height: 90rpx;
  170. line-height: 90rpx;
  171. margin-bottom: 50rpx;
  172. border-bottom: 1px solid #e9e9e9;
  173. font-size: 28rpx;
  174. }
  175. .t-login .t-a {
  176. position: relative;
  177. }
  178. .t-b {
  179. text-align: left;
  180. font-size: 42rpx;
  181. color: #ffffff;
  182. padding: 130rpx 0 0 70rpx;
  183. font-weight: bold;
  184. line-height: 70rpx;
  185. }
  186. .t-login .t-c {
  187. position: absolute;
  188. right: 22rpx;
  189. top: 22rpx;
  190. background: #5677fc;
  191. color: #fff;
  192. font-size: 24rpx;
  193. border-radius: 50rpx;
  194. height: 50rpx;
  195. line-height: 50rpx;
  196. padding: 0 25rpx;
  197. }
  198. .t-login .t-d {
  199. text-align: center;
  200. color: #999;
  201. margin: 80rpx 0;
  202. }
  203. .t-login .t-e {
  204. text-align: center;
  205. width: 250rpx;
  206. margin: 80rpx auto 0;
  207. }
  208. .t-login .t-g {
  209. float: left;
  210. width: 50%;
  211. }
  212. .t-login .t-e image {
  213. width: 50rpx;
  214. height: 50rpx;
  215. }
  216. .t-login .t-f {
  217. text-align: center;
  218. margin: 150rpx 0 0 0;
  219. color: #666;
  220. }
  221. .t-login .t-f text {
  222. margin-left: 20rpx;
  223. color: #aaaaaa;
  224. font-size: 27rpx;
  225. }
  226. .t-login .uni-input-placeholder {
  227. color: #aeaeae;
  228. }
  229. .cl {
  230. zoom: 1;
  231. }
  232. .cl:after {
  233. clear: both;
  234. display: block;
  235. visibility: hidden;
  236. height: 0;
  237. content: '\20';
  238. }
  239. .remember {
  240. margin-top: 24rpx;
  241. margin-bottom: 40rpx;
  242. }
  243. </style>