index.vue 11 KB

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