index.vue 11 KB

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