login.vue 10 KB

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