index.vue 10 KB

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