index.vue 11 KB

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