login.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. <!-- 登录 -->
  2. <template>
  3. <view id="login">
  4. <img class="login-max-big" :src="loginBanner">
  5. <view class="login-box">
  6. <view class="tabTitle">
  7. <view class="tabTitle_li" @tap="tabClick(index)" :key="index" v-for="(item,index) in tabText">
  8. <view :class="{on:curTab==index}" class="tabTitle_text">{{item}}</view>
  9. <view :class="{on:curTab==index}" class="tabTitle_across"></view>
  10. </view>
  11. </view>
  12. <view class="input-max-box-one">
  13. <view class="input-box">
  14. <img src="@/images/basicsModules/img_log_in_account.png" />
  15. <input type="text" v-model="username" placeholder="请输入账号" maxlength="20">
  16. </view>
  17. </view>
  18. <view class="input-max-box-two">
  19. <view class="input-box">
  20. <img src="@/images/basicsModules/img_log_in_password.png" />
  21. <input type="password" v-model="password" placeholder="请输入密码" maxlength="20">
  22. </view>
  23. </view>
  24. <view class="check-box" @click="checkboxChange">
  25. <img v-if="checkedType" src="@/images/basicsModules/icon_13.png" />
  26. <img v-if="!checkedType" src="@/images/basicsModules/icon_12.png" />
  27. <view>记住我</view>
  28. </view>
  29. <view class="button-box" @click="login">登录</view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import md5 from '@/utils/md5.js'
  35. import {
  36. config
  37. } from '@/api/request/config.js'
  38. import {
  39. login,
  40. configInfo,
  41. getConfigByType,
  42. getGentleIdentifier,
  43. systemAppletRolePermission
  44. } from '@/api/basicsModules/index.js'
  45. import {
  46. Encrypt,
  47. Decrypt
  48. } from '@/utils/secret.js'
  49. export default {
  50. data() {
  51. return {
  52. identityStatus: 1,
  53. // username:"superadmin",
  54. // password:"zd123456",
  55. username: "sudiyu",
  56. password: "zd123456",
  57. checkedType: false,
  58. loginBanner: uni.getStorageSync('loginBanner'),
  59. infoList: [], //模板消息Id
  60. tabText: ['师生登录'],
  61. curTab: 0,
  62. pageType: 0,
  63. supplierType: false,
  64. }
  65. },
  66. onLoad(option) {
  67. //供应商注册成功后返回到供应商注册页面
  68. if (option.status) {
  69. this.identityStatus = 2
  70. }
  71. if (uni.getStorageSync('userName') && uni.getStorageSync('password')) {
  72. this.username = uni.getStorageSync('userName');
  73. this.password = uni.getStorageSync('password');
  74. this.checkedType = true;
  75. }
  76. },
  77. onShow() {
  78. // this.getConfigInfo();
  79. console.log(navigator.userAgent.toLowerCase())
  80. },
  81. methods: {
  82. //顶部tab点击
  83. tabClick(index) {
  84. this.curTab = index;
  85. },
  86. //登录
  87. async login() {
  88. let self = this;
  89. let obj = {
  90. account: this.username,
  91. password: md5.hex_md5(this.password),
  92. }
  93. const {
  94. data
  95. } = await login(obj)
  96. if (data.code == 200) {
  97. uni.setStorageSync('token', data.data.token);
  98. uni.setStorageSync('userId', data.data.userId);
  99. // userType 0-系统 1-教职工 2-学生 3-大屏
  100. uni.setStorageSync('userType', data.data.userType == 0 || data.data.userType == 1 ? '1' :
  101. (data.data.userType == 2 ? '2' : (data.data.userType == 3 ? '3' : 'none')));
  102. if (this.checkedType) {
  103. uni.setStorageSync('userName', this.username)
  104. uni.setStorageSync('password', this.password)
  105. } else {
  106. uni.removeStorageSync('userName')
  107. uni.removeStorageSync('password')
  108. }
  109. //等待配置与字段获取到后跳转
  110. Promise.all([
  111. //获取开发配置
  112. this.getConfigByType(),
  113. //获取权限字段
  114. this.systemAppletRolePermission()
  115. ]).then((result) => {
  116. if (uni.getStorageSync('codeData')) {
  117. uni.redirectTo({
  118. url: '/pages/saoCode/saoCode',
  119. });
  120. } else {
  121. uni.redirectTo({
  122. url: '/pages/mine/mine',
  123. });
  124. }
  125. }).catch((error) => {
  126. wx.showToast({
  127. title: '数据异常,请稍候再试!',
  128. icon: "none",
  129. duration: 3000
  130. });
  131. })
  132. //获取身份标识
  133. // this.getGentleIdentifier();
  134. }
  135. },
  136. //获取权限字段
  137. async systemAppletRolePermission() {
  138. let self = this;
  139. const {
  140. data
  141. } = await systemAppletRolePermission();
  142. if (data.code == 200) {
  143. uni.setStorageSync('permissions', data.data.data)
  144. }
  145. },
  146. switchClick() {
  147. if (this.identityStatus == 1) {
  148. this.identityStatus = 2;
  149. } else {
  150. this.identityStatus = 1;
  151. }
  152. },
  153. //查询公共配置
  154. async getConfigInfo() {
  155. const {
  156. data
  157. } = await configInfo({
  158. type: '1,2,4'
  159. });
  160. if (data.code == 200) {
  161. let list = JSON.parse(data.data)
  162. let newData = {};
  163. list.forEach((item) => {
  164. let obj = JSON.parse(item.configValue)
  165. newData = {
  166. ...newData,
  167. ...obj
  168. }
  169. })
  170. uni.setStorageSync('circularLogo', config.base_url + newData.circularLogo)
  171. uni.setStorageSync('videoCover', config.base_url + newData.videoCover)
  172. this.$set(this, 'loginBanner', config.base_url + newData.loginBanner);
  173. uni.setStorageSync('loginBanner', config.base_url + newData.loginBanner)
  174. this.$set(this, 'supplierType', newData.supplier);
  175. uni.setStorageSync('supplierType', newData.supplier)
  176. uni.setStorageSync('homepageBanner', config.base_url + newData.homepageBanner)
  177. }
  178. },
  179. //获取开发配置
  180. async getConfigByType() {
  181. const {
  182. data
  183. } = await getConfigByType({
  184. category: 2,
  185. configType: 5
  186. });
  187. if (data.code == 200) {
  188. let obj = JSON.parse(data.data.configValue)
  189. //文件预览地址
  190. uni.setStorageSync('filePreviewUrl', 'https://' + obj.fileExtranetUrl)
  191. //摄像头代理访问地址
  192. uni.setStorageSync('cameraExtranetAgent', 'https://' + obj.cameraExtranetAgent)
  193. //摄像头地址ip段
  194. uni.setStorageSync('cameraIntranetAgent', obj.cameraIntranetAgent)
  195. //摄像头访问地址
  196. uni.setStorageSync('cameraUrl', 'https://' + obj.cameraExtranetUrl)
  197. //MQTT地址
  198. uni.setStorageSync('mqttUrl', Decrypt(obj.mqttExtranetUrl))
  199. //MQTT账号
  200. uni.setStorageSync('mqttUser', Decrypt(obj.mqttExtranetUser))
  201. //MQTT密码
  202. uni.setStorageSync('mqttPassword', Decrypt(obj.mqttExtranetPassword))
  203. }
  204. },
  205. checkboxChange() {
  206. this.checkedType = !this.checkedType;
  207. },
  208. },
  209. }
  210. </script>
  211. <style lang="stylus" scoped>
  212. #login {
  213. height: 100%;
  214. width: 100%;
  215. background #f5f5f5;
  216. position relative;
  217. .login-max-big {
  218. width: 750rpx;
  219. height: 1177rpx;
  220. z-index: 0;
  221. }
  222. .login-box {
  223. z-index: 3;
  224. position: absolute;
  225. top: 446rpx;
  226. left: 46rpx;
  227. width: 658rpx;
  228. height: 700rpx;
  229. // background #fff
  230. /* 切换按钮 */
  231. .tabTitle {
  232. display flex;
  233. width: 100%;
  234. height: 100rpx;
  235. position: absolute;
  236. top: 50rpx;
  237. justify-content: center;
  238. .tabTitle_li {
  239. width: 168rpx;
  240. text-align center;
  241. .tabTitle_text {
  242. display: inline-block;
  243. font-size: 32rpx;
  244. font-family: PingFang SC;
  245. font-weight: 500;
  246. color: #333333;
  247. line-height: 90rpx;
  248. &.on {
  249. color: #0183FA;
  250. }
  251. }
  252. .tabTitle_across {
  253. width: 100rpx;
  254. height: 4rpx;
  255. background: #0183FA;
  256. border-radius: 2rpx;
  257. margin-left 30rpx;
  258. display none;
  259. &.on {
  260. display block;
  261. }
  262. }
  263. }
  264. }
  265. border-radius:20rpx;
  266. .input-max-box-one {
  267. overflow: hidden;
  268. margin-top: 68rpx;
  269. .input-box {
  270. display flex;
  271. width: 600rpx;
  272. height: 80rpx;
  273. border: 1rpx solid #e0e0e0;
  274. border-radius: 40rpx;
  275. margin: 147rpx auto 0;
  276. img {
  277. width: 28rpx;
  278. height: 32rpx;
  279. margin: 24rpx 31rpx;
  280. }
  281. input {
  282. flex: 1;
  283. font-size: 24rpx;
  284. height: 80rpx;
  285. line-height: 80rpx;
  286. margin-right: 31rpx;
  287. }
  288. }
  289. .text-box {
  290. height: 59rpx;
  291. line-height: 59rpx;
  292. color: #DC1616;
  293. font-size: 24rpx;
  294. margin-left: 102rpx;
  295. }
  296. }
  297. .input-max-box-two {
  298. margin-top: 40rpx;
  299. .input-box {
  300. display flex;
  301. width: 600rpx;
  302. height: 80rpx;
  303. border: 1rpx solid #e0e0e0;
  304. border-radius: 40rpx;
  305. margin: 0 auto 0;
  306. img {
  307. width: 30rpx;
  308. height: 32rpx;
  309. margin: 24rpx 30rpx;
  310. }
  311. input {
  312. flex: 1;
  313. font-size: 24rpx;
  314. height: 80rpx;
  315. line-height: 80rpx;
  316. margin-right: 31rpx;
  317. }
  318. }
  319. .text-box {
  320. height: 59rpx;
  321. line-height: 59rpx;
  322. color: #DC1616;
  323. font-size: 24rpx;
  324. margin-left: 102rpx;
  325. }
  326. }
  327. .check-box {
  328. margin: 30rpx 0 30rpx 104rpx;
  329. width: 300rpx;
  330. height: 50rpx;
  331. display: flex;
  332. img {
  333. margin-top: 10rpx;
  334. width: 32rpx;
  335. height: 32rpx;
  336. margin-right: 10rpx;
  337. }
  338. view {
  339. font-size: 24rpx;
  340. line-height: 50rpx;
  341. }
  342. }
  343. .button-box {
  344. width: 600rpx;
  345. line-height: 80rpx;
  346. background: #0183FA;
  347. border-radius: 40rpx;
  348. font-size: 36rpx;
  349. color: #fff;
  350. text-align center;
  351. margin: 0 auto 0;
  352. }
  353. /* 供应商注册 */
  354. .supplier {
  355. display: flex;
  356. justify-content: space-between;
  357. margin: 30rpx 40rpx 0;
  358. .supplier_l {
  359. font-size: 24rpx;
  360. font-family: PingFang SC;
  361. font-weight: 400;
  362. color: #333333;
  363. line-height: 24rpx;
  364. }
  365. .supplier_r {
  366. font-size: 24rpx;
  367. font-family: PingFang SC;
  368. font-weight: 400;
  369. color: #333333;
  370. line-height: 24rpx;
  371. >text {
  372. color: #0183FA;
  373. }
  374. }
  375. }
  376. /* 供应商切换 */
  377. .switch_btn {
  378. display: flex;
  379. justify-content: center;
  380. align-items: center;
  381. font-size: 24rpx;
  382. font-family: PingFang SC;
  383. font-weight: 400;
  384. color: #0183FA;
  385. line-height: 24rpx;
  386. margin-top: 60rpx;
  387. >img {
  388. width: 24rpx;
  389. height: 24rpx;
  390. margin-left: 12rpx;
  391. }
  392. }
  393. }
  394. .top-back {
  395. z-index: 2;
  396. position: absolute;
  397. top: 261rpx;
  398. left: 375rpx;
  399. height: 296rpx;
  400. width: 366rpx;
  401. }
  402. }
  403. </style>