index.vue 10 KB

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