index.vue 7.3 KB

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