index.vue 12 KB

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