index.vue 9.4 KB

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