index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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. ],
  87. customerList: [{
  88. id: 'tb-costomer-account',
  89. auth: true,
  90. icon: '../../static/home-icon-charge.png',
  91. text: '充值',
  92. url: '/pages/account/account-redirect',
  93. },
  94. {
  95. id: 'tb-declare',
  96. auth: false,
  97. icon: '../../static/home-icon-07.jpg',
  98. text: '申报录入',
  99. url: '/pages/declare/add',
  100. },
  101. {
  102. id: 'tb-disinfect',
  103. auth: false,
  104. icon: '../../static/home-icon-06.jpg',
  105. text: '消杀申报',
  106. url: '/pages/disinfect/addDisinfect',
  107. },
  108. {
  109. id: 'tb-business',
  110. auth: true,
  111. icon: '../../static/home-icon-02.png',
  112. text: '业务录入',
  113. url: '/pages/business-entering/business-entering',
  114. },
  115. {
  116. id: 'tb-business',
  117. auth: true,
  118. icon: '../../static/home-icon-03.png',
  119. text: '业务订单',
  120. url: '/pages/business-order/business-order',
  121. },
  122. {
  123. id: 'tb-business-car',
  124. auth: true,
  125. icon: '../../static/home-icon-05.png',
  126. text: '放行记录',
  127. url: '/pages/inout-record/inout-record',
  128. },
  129. {
  130. id:'admin-list',
  131. auth: true,
  132. icon: '../../static/home-icon-04.png',
  133. text: '用户管理',
  134. url: '/pages/user/user-index',
  135. },
  136. ],
  137. adminList: [{
  138. id: 'tb-business-add',
  139. auth: true,
  140. icon: '../../static/home-icon-02.png',
  141. text: '业务录入',
  142. url: '/pages/business-entering/business-entering',
  143. },
  144. {
  145. id: 'tb-business-list',
  146. auth: true,
  147. icon: '../../static/home-icon-03.png',
  148. text: '业务订单',
  149. url: '/pages/business-order/business-order',
  150. },
  151. {
  152. id: 'tb-business-car',
  153. auth: true,
  154. icon: '../../static/home-icon-05.png',
  155. text: '放行记录',
  156. url: '/pages/inout-record/inout-record',
  157. },
  158. {
  159. id:'admin-list',
  160. auth: true,
  161. icon: '../../static/home-icon-04.png',
  162. text: '用户管理',
  163. url: '/pages/user/user-index',
  164. },
  165. ]
  166. }
  167. },
  168. onLoad(options) {
  169. this.code = options.code;
  170. this.state = options.state;
  171. this.getOpenidByCode();
  172. },
  173. onShow() {
  174. this.loginByOpenid();
  175. this.checkUserType();
  176. },
  177. onBackPress() {
  178. return true;
  179. },
  180. methods: {
  181. checkPer(code) {
  182. return this.$common.isAuth(code);
  183. },
  184. getOpenidByCode() {
  185. if (!this.code) {
  186. this.$common.to('/pages/home/home')
  187. return;
  188. }
  189. let storeOpenid = uni.getStorageSync('openid');
  190. this.$api.getOpenidByCode({
  191. code: this.code,
  192. openid: storeOpenid
  193. }).then(resp => {
  194. this.success=resp.code==200&&resp.data?1:0
  195. if(resp.code==200&&resp.data){
  196. this.success=1;
  197. }else{
  198. this.success=0
  199. }
  200. let openid = resp.data;
  201. this.openid = openid;
  202. if (openid) {
  203. uni.setStorageSync('openid', openid)
  204. }
  205. this.loginByOpenid(openid)
  206. })
  207. },
  208. getStoreInfo() {
  209. let info = uni.getStorageSync('userInfo');
  210. if (info) {
  211. this.isLogin = true;
  212. this.userName = info.name;
  213. this.customerId = info.customerId;
  214. }
  215. },
  216. loginByOpenid() {
  217. let storeOpenid = uni.getStorageSync('openid');
  218. if (!storeOpenid) {
  219. return;
  220. }
  221. this.$api.doLoginByOpenid({
  222. openid: storeOpenid
  223. }).then(resp => {
  224. if (resp.code == 404) {
  225. return;
  226. }
  227. this.isLogin = true;
  228. let data = resp.data;
  229. this.userName = data.admin.name;
  230. this.customerId = data.admin.customerId;
  231. if (data.tokenInfo) {
  232. uni.setStorageSync('token', data.tokenInfo.tokenValue);
  233. uni.setStorageSync('customerId', data.admin.customerId)
  234. uni.setStorageSync('userInfo', data.admin)
  235. uni.setStorageSync('perList', data.per_list)
  236. this.checkUserType()
  237. } else {
  238. this.$common.toast(resp.msg);
  239. }
  240. })
  241. },
  242. checkUserType() {
  243. let token = uni.getStorageSync('token');
  244. if (token) {
  245. this.$nextTick(function() {
  246. this.$api.checkUserType().then(resp => {
  247. let userType = resp.data;
  248. if (userType == 3) {
  249. this.indexItemList = this.partnerList;
  250. } else if (userType == 2) { //客户
  251. this.indexItemList = this.customerList
  252. } else if (userType == 1) {
  253. this.indexItemList = this.adminList
  254. }
  255. })
  256. })
  257. }
  258. },
  259. toAccount() {
  260. if (this.customerId !== '1') {
  261. this.$common.to('/pages/customer-management/customer-list')
  262. }
  263. },
  264. getStoreInfo() {
  265. let info = uni.getStorageSync('userInfo');
  266. if (info) {
  267. this.isLogin = true;
  268. this.userName = info.name;
  269. this.customerId = info.customerId;
  270. }
  271. },
  272. toLogin() {
  273. this.$common.to('/pages/login/login')
  274. },
  275. exitFn() {
  276. uni.removeStorageSync('token')
  277. uni.removeStorageSync('userInfo')
  278. uni.removeStorageSync('customerId')
  279. uni.removeStorageSync('perList')
  280. let storeOpenid = uni.getStorageSync('openid');
  281. uni.setStorageSync('login_openid', storeOpenid);
  282. uni.removeStorageSync('openid')
  283. this.isLogin = false;
  284. this.userName = '';
  285. this.companyName = ''
  286. this.indexItemList = [
  287. {
  288. auth: false,
  289. icon: '../../static/home-icon-01.png',
  290. text: '企业注册',
  291. url: '/pages/enterprise-reg/enterprise-reg',
  292. customer:true
  293. },
  294. {
  295. auth: false,
  296. icon: '../../static/home-icon-06.jpg',
  297. text: '车辆消杀',
  298. url: '/pages/onely-disinfect/disinfect-Index',
  299. customer:true
  300. }
  301. ]
  302. },
  303. navTo(item) {
  304. let auth = item.auth;
  305. let token = uni.getStorageSync('token');
  306. if (!auth || token) {
  307. this.$common.to(item.url)
  308. } else {
  309. this.$common.to('/pages/login/login')
  310. }
  311. }
  312. }
  313. }
  314. </script>
  315. <style lang="scss">
  316. page {
  317. background-color: #fff;
  318. }
  319. .top-nav {
  320. position: fixed;
  321. top: 0;
  322. left: 0;
  323. right: 0;
  324. z-index: 999;
  325. display: flex;
  326. align-items: center;
  327. justify-content: space-between;
  328. padding: 20rpx 0;
  329. background-color: #0080ff;
  330. .l {
  331. display: flex;
  332. align-items: center;
  333. .login-btn {
  334. border: 1rpx solid #359aff;
  335. border-radius: 8rpx;
  336. color: #fff;
  337. padding: 10rpx 20rpx;
  338. font-size: 28rpx;
  339. margin-left: 30rpx;
  340. }
  341. .user-img {
  342. width: 80rpx;
  343. height: 80rpx;
  344. border-radius: 50%;
  345. margin-left: 30rpx;
  346. margin: 20rpx;
  347. }
  348. .l-r {
  349. display: flex;
  350. flex-direction: column;
  351. .u-name {
  352. font-size: 30rpx;
  353. color: #fff;
  354. font-weight: bold;
  355. }
  356. .c-name {
  357. font-size: 24rpx;
  358. color: #fff;
  359. }
  360. }
  361. }
  362. .r {
  363. display: flex;
  364. align-items: center;
  365. .l-out {
  366. border: 1rpx solid #359aff;
  367. border-radius: 8rpx;
  368. color: #c8e4ff;
  369. padding: 10rpx 20rpx;
  370. font-size: 28rpx;
  371. margin-right: 30rpx;
  372. }
  373. }
  374. }
  375. .top-bg {
  376. position: relative;
  377. top: 0;
  378. left: 0;
  379. right: 0;
  380. height: 400rpx;
  381. background-color: #0080ff;
  382. border-radius: 0 0 20rpx 20rpx;
  383. }
  384. .top {
  385. display: flex;
  386. width: 100%;
  387. align-items: center;
  388. justify-content: center;
  389. margin: 60rpx 0;
  390. margin-top: -400rpx;
  391. position: relative;
  392. z-index: 2;
  393. .title {
  394. font-size: 50rpx;
  395. font-weight: bold;
  396. color: #fff;
  397. }
  398. }
  399. .item-box {
  400. display: flex;
  401. flex-wrap: wrap;
  402. align-content: flex-start;
  403. padding: 40rpx;
  404. box-sizing: border-box;
  405. background-color: #fff;
  406. margin: 0 30rpx;
  407. border-radius: 20rpx;
  408. position: relative;
  409. z-index: 2;
  410. //height: calc(100vh - 170rpx - 500rpx);
  411. box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.03);
  412. .item {
  413. width: 25%;
  414. display: flex;
  415. flex-direction: column;
  416. align-items: center;
  417. justify-content: center;
  418. padding: 40rpx 0;
  419. .icon {
  420. width: 90rpx;
  421. height: 90rpx;
  422. }
  423. .text {
  424. font-size: 28rpx;
  425. color: #191919;
  426. margin-top: 20rpx;
  427. }
  428. }
  429. }
  430. .qrcode {
  431. display: flex;
  432. width: 100%;
  433. flex-direction: column;
  434. align-items: center;
  435. justify-content: center;
  436. margin: 30rpx 0;
  437. .qrcode {
  438. width: 350rpx;
  439. height: 350rpx;
  440. border: 1px solid #191919;
  441. }
  442. .text {
  443. color: #191919;
  444. font-size: 28rpx;
  445. margin-top: 5rpx;
  446. }
  447. }
  448. </style>