index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. <template>
  2. <view>
  3. <view class="top-nav">
  4. <view class="l">
  5. <block v-if="isLogin">
  6. <image class="user-img" src="../../static/user.png" @click="toAccount"></image>
  7. <view class="l-r">
  8. <text class="u-name">{{userName}}</text>
  9. <text class="c-name" v-if="customerId!=='1'">{{companyName}}</text>
  10. </view>
  11. </block>
  12. <block v-else>
  13. <view class="login-btn" @click="toLogin">登录</view>
  14. </block>
  15. </view>
  16. <view class="r" v-if="isLogin">
  17. <view class="l-out" @click="exitFn">
  18. 退出登录
  19. </view>
  20. </view>
  21. </view>
  22. <view class="top-bg"></view>
  23. <view class="top">
  24. <text class="title">场站管理系统</text>
  25. </view>
  26. <view class="item-box">
  27. <view class="item" hover-class="hover-class" v-for="(indexItem,index) in indexItemList" :key="index"
  28. @click="navTo(indexItem)" v-if="checkPer(indexItem.id)||indexItem.customer">
  29. <image class="icon" :src="indexItem.icon"></image>
  30. <view class="text">
  31. <text v-if="indexItem.text=='企业管理'&&customerId!='1'">信息管理</text>
  32. <text v-else>{{indexItem.text}}</text>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="qrcode">
  37. <image class="qrcode" :src="qrcoderlc"></image>
  38. <text class="text">长按二维码保存分享</text>
  39. </view>
  40. <view style="text-align: center;font-size: 23rpx;">
  41. <a href="https://beian.miit.gov.cn/" target="_blank">桂ICP备12007573号-1</a>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. data() {
  48. return {
  49. isLogin: false, //是否登录状态
  50. userName: '',
  51. companyName: '',
  52. customerId: '',
  53. qrcoderlc: '../../static/qrcode.png',
  54. indexItemList: [{
  55. auth: false,
  56. icon: '../../static/home-icon-01.png',
  57. text: '企业注册',
  58. url: '/pages/enterprise-reg/enterprise-reg',
  59. customer:true
  60. },{
  61. auth: false,
  62. icon: '../../static/home-icon-06.jpg',
  63. text: '车辆消杀',
  64. url: '/pages/onely-disinfect/disinfect-Index',
  65. customer:true
  66. }
  67. ],
  68. code: '',
  69. state: '',
  70. userType: 1,
  71. partnerList: [
  72. {
  73. id:'tb-business-item',
  74. auth: true,
  75. icon: '../../static/home-icon-03.png',
  76. text: '我的业务',
  77. url: '/pages/business-order/partner-business-item',
  78. },
  79. {
  80. id:'admin-list',
  81. auth: true,
  82. icon: '../../static/home-icon-04.png',
  83. text: '用户管理',
  84. url: '/pages/user/user-index',
  85. },{
  86. auth: false,
  87. icon: '../../static/home-icon-06.jpg',
  88. text: '车辆消杀',
  89. url: '/pages/onely-disinfect/disinfect-Index',
  90. customer:true
  91. }
  92. ],
  93. customerList: [{
  94. id: 'tb-costomer-account',
  95. auth: true,
  96. icon: '../../static/home-icon-charge.png',
  97. text: '充值',
  98. url: '/pages/account/account-redirect',
  99. },
  100. {
  101. id: 'tb-declare',
  102. auth: false,
  103. icon: '../../static/home-icon-07.jpg',
  104. text: '申报录入',
  105. url: '/pages/declare/add',
  106. },
  107. {
  108. id: 'tb-disinfect',
  109. auth: false,
  110. icon: '../../static/home-icon-06.jpg',
  111. text: '消杀申报',
  112. url: '/pages/disinfect/addDisinfect',
  113. },
  114. {
  115. id: 'tb-business',
  116. auth: true,
  117. icon: '../../static/home-icon-02.png',
  118. text: '业务录入',
  119. url: '/pages/business-entering/business-entering',
  120. },
  121. {
  122. id: 'tb-business',
  123. auth: true,
  124. icon: '../../static/home-icon-03.png',
  125. text: '业务订单',
  126. url: '/pages/business-order/business-order',
  127. },
  128. {
  129. id: 'tb-business-car',
  130. auth: true,
  131. icon: '../../static/home-icon-05.png',
  132. text: '放行记录',
  133. url: '/pages/inout-record/inout-record',
  134. },
  135. {
  136. id:'admin-list',
  137. auth: true,
  138. icon: '../../static/home-icon-04.png',
  139. text: '用户管理',
  140. url: '/pages/user/user-index',
  141. }
  142. ,{
  143. auth: false,
  144. icon: '../../static/home-icon-06.jpg',
  145. text: '车辆消杀',
  146. url: '/pages/onely-disinfect/disinfect-Index',
  147. customer:true
  148. }
  149. ],
  150. adminList: [{
  151. id: 'tb-business-add',
  152. auth: true,
  153. icon: '../../static/home-icon-02.png',
  154. text: '业务录入',
  155. url: '/pages/business-entering/business-entering',
  156. },
  157. {
  158. auth: false,
  159. icon: '../../static/home-icon-06.jpg',
  160. text: '车辆消杀',
  161. url: '/pages/onely-disinfect/disinfect-Index',
  162. customer:true
  163. },
  164. {
  165. id: 'tb-business-list',
  166. auth: true,
  167. icon: '../../static/home-icon-03.png',
  168. text: '业务订单',
  169. url: '/pages/business-order/business-order',
  170. },
  171. {
  172. id: 'tb-business-car',
  173. auth: true,
  174. icon: '../../static/home-icon-05.png',
  175. text: '放行记录',
  176. url: '/pages/inout-record/inout-record',
  177. },
  178. {
  179. id:'admin-list',
  180. auth: true,
  181. icon: '../../static/home-icon-04.png',
  182. text: '用户管理',
  183. url: '/pages/user/user-index',
  184. },
  185. ]
  186. }
  187. },
  188. onLoad(options) {
  189. this.code = options.code;
  190. this.state = options.state;
  191. this.getOpenidByCode();
  192. },
  193. onShow() {
  194. this.loginByOpenid();
  195. this.checkUserType();
  196. },
  197. onBackPress() {
  198. return true;
  199. },
  200. methods: {
  201. checkPer(code) {
  202. return this.$common.isAuth(code);
  203. },
  204. getOpenidByCode() {
  205. if (!this.code) {
  206. this.$common.to('/pages/home/home')
  207. return;
  208. }
  209. let storeOpenid = uni.getStorageSync('openid');
  210. this.$api.getOpenidByCode({
  211. code: this.code,
  212. openid: storeOpenid
  213. }).then(resp => {
  214. this.success=resp.code==200&&resp.data?1:0
  215. if(resp.code==200&&resp.data){
  216. this.success=1;
  217. }else{
  218. this.success=0
  219. }
  220. let openid = resp.data;
  221. this.openid = openid;
  222. if (openid) {
  223. uni.setStorageSync('openid', openid)
  224. }
  225. this.loginByOpenid(openid)
  226. })
  227. },
  228. getStoreInfo() {
  229. let info = uni.getStorageSync('userInfo');
  230. if (info) {
  231. this.isLogin = true;
  232. this.userName = info.name;
  233. this.customerId = info.customerId;
  234. }
  235. },
  236. loginByOpenid() {
  237. let storeOpenid = uni.getStorageSync('openid');
  238. if (!storeOpenid) {
  239. return;
  240. }
  241. this.$api.doLoginByOpenid({
  242. openid: storeOpenid
  243. }).then(resp => {
  244. if (resp.code == 404) {
  245. return;
  246. }
  247. this.isLogin = true;
  248. let data = resp.data;
  249. this.userName = data.admin.name;
  250. this.customerId = data.admin.customerId;
  251. if (data.tokenInfo) {
  252. uni.setStorageSync('token', data.tokenInfo.tokenValue);
  253. uni.setStorageSync('customerId', data.admin.customerId)
  254. uni.setStorageSync('userInfo', data.admin)
  255. uni.setStorageSync('perList', data.per_list)
  256. this.checkUserType()
  257. } else {
  258. this.$common.toast(resp.msg);
  259. }
  260. })
  261. },
  262. checkUserType() {
  263. let token = uni.getStorageSync('token');
  264. if (token) {
  265. this.$nextTick(function() {
  266. this.$api.checkUserType().then(resp => {
  267. let userType = resp.data;
  268. if (userType == 3) {
  269. this.indexItemList = this.partnerList;
  270. } else if (userType == 2) { //客户
  271. this.indexItemList = this.customerList
  272. } else if (userType == 1) {
  273. this.indexItemList = this.adminList
  274. }
  275. })
  276. })
  277. }
  278. },
  279. toAccount() {
  280. if (this.customerId !== '1') {
  281. this.$common.to('/pages/customer-management/customer-list')
  282. }
  283. },
  284. getStoreInfo() {
  285. let info = uni.getStorageSync('userInfo');
  286. if (info) {
  287. this.isLogin = true;
  288. this.userName = info.name;
  289. this.customerId = info.customerId;
  290. }
  291. },
  292. toLogin() {
  293. this.$common.to('/pages/login/login')
  294. },
  295. exitFn() {
  296. uni.removeStorageSync('token')
  297. uni.removeStorageSync('userInfo')
  298. uni.removeStorageSync('customerId')
  299. uni.removeStorageSync('perList')
  300. let storeOpenid = uni.getStorageSync('openid');
  301. uni.setStorageSync('login_openid', storeOpenid);
  302. uni.removeStorageSync('openid')
  303. this.isLogin = false;
  304. this.userName = '';
  305. this.companyName = ''
  306. this.indexItemList = [
  307. {
  308. auth: false,
  309. icon: '../../static/home-icon-01.png',
  310. text: '企业注册',
  311. url: '/pages/enterprise-reg/enterprise-reg',
  312. customer:true
  313. },
  314. {
  315. auth: false,
  316. icon: '../../static/home-icon-06.jpg',
  317. text: '车辆消杀',
  318. url: '/pages/onely-disinfect/disinfect-Index',
  319. customer:true
  320. }
  321. ]
  322. },
  323. navTo(item) {
  324. let auth = item.auth;
  325. let token = uni.getStorageSync('token');
  326. if (!auth || token) {
  327. this.$common.to(item.url)
  328. } else {
  329. this.$common.to('/pages/login/login')
  330. }
  331. }
  332. }
  333. }
  334. </script>
  335. <style lang="scss">
  336. page {
  337. background-color: #fff;
  338. }
  339. .top-nav {
  340. position: fixed;
  341. top: 0;
  342. left: 0;
  343. right: 0;
  344. z-index: 999;
  345. display: flex;
  346. align-items: center;
  347. justify-content: space-between;
  348. padding: 20rpx 0;
  349. background-color: #0080ff;
  350. .l {
  351. display: flex;
  352. align-items: center;
  353. .login-btn {
  354. border: 1rpx solid #359aff;
  355. border-radius: 8rpx;
  356. color: #fff;
  357. padding: 10rpx 20rpx;
  358. font-size: 28rpx;
  359. margin-left: 30rpx;
  360. }
  361. .user-img {
  362. width: 80rpx;
  363. height: 80rpx;
  364. border-radius: 50%;
  365. margin-left: 30rpx;
  366. margin: 20rpx;
  367. }
  368. .l-r {
  369. display: flex;
  370. flex-direction: column;
  371. .u-name {
  372. font-size: 30rpx;
  373. color: #fff;
  374. font-weight: bold;
  375. }
  376. .c-name {
  377. font-size: 24rpx;
  378. color: #fff;
  379. }
  380. }
  381. }
  382. .r {
  383. display: flex;
  384. align-items: center;
  385. .l-out {
  386. border: 1rpx solid #359aff;
  387. border-radius: 8rpx;
  388. color: #c8e4ff;
  389. padding: 10rpx 20rpx;
  390. font-size: 28rpx;
  391. margin-right: 30rpx;
  392. }
  393. }
  394. }
  395. .top-bg {
  396. position: relative;
  397. top: 0;
  398. left: 0;
  399. right: 0;
  400. height: 400rpx;
  401. background-color: #0080ff;
  402. border-radius: 0 0 20rpx 20rpx;
  403. }
  404. .top {
  405. display: flex;
  406. width: 100%;
  407. align-items: center;
  408. justify-content: center;
  409. margin: 60rpx 0;
  410. margin-top: -400rpx;
  411. position: relative;
  412. z-index: 2;
  413. .title {
  414. font-size: 50rpx;
  415. font-weight: bold;
  416. color: #fff;
  417. }
  418. }
  419. .item-box {
  420. display: flex;
  421. flex-wrap: wrap;
  422. align-content: flex-start;
  423. padding: 40rpx;
  424. box-sizing: border-box;
  425. background-color: #fff;
  426. margin: 0 30rpx;
  427. border-radius: 20rpx;
  428. position: relative;
  429. z-index: 2;
  430. //height: calc(100vh - 170rpx - 500rpx);
  431. box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.03);
  432. .item {
  433. width: 25%;
  434. display: flex;
  435. flex-direction: column;
  436. align-items: center;
  437. justify-content: center;
  438. padding: 40rpx 0;
  439. .icon {
  440. width: 90rpx;
  441. height: 90rpx;
  442. }
  443. .text {
  444. font-size: 28rpx;
  445. color: #191919;
  446. margin-top: 20rpx;
  447. }
  448. }
  449. }
  450. .qrcode {
  451. display: flex;
  452. width: 100%;
  453. flex-direction: column;
  454. align-items: center;
  455. justify-content: center;
  456. margin: 30rpx 0;
  457. .qrcode {
  458. width: 350rpx;
  459. height: 350rpx;
  460. border: 1px solid #191919;
  461. }
  462. .text {
  463. color: #191919;
  464. font-size: 28rpx;
  465. margin-top: 5rpx;
  466. }
  467. }
  468. </style>