index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template>
  2. <view class="">
  3. <view>
  4. <!-- <view style="margin: 40px 0 0 20px; font-size: 20px;">
  5. {{form.orgName}}
  6. </view> -->
  7. <u-sticky>
  8. <view class="topToolsBody uni-flex uni-row">
  9. <view class="topTools flex-item" @click="takeMeal()" :style="'width:'+topToolsWidth">
  10. <view>
  11. <image src="../../static/img/home/sys.png"></image>
  12. </view>
  13. 扫一扫
  14. </view>
  15. <view class="topTools flex-item" @click="toPayCodePage" :style="'width:'+topToolsWidth">
  16. <view>
  17. <image src="../../static/img/home/qcCode.png"></image>
  18. </view>
  19. HS码
  20. </view>
  21. <view v-if="type === 3" class="topTools flex-item" @click="toIntegralPage"
  22. :style="'width:'+topToolsWidth">
  23. <view>
  24. <image src="../../static/img/home/jifenshangcheng.png"></image>
  25. </view>
  26. 兑换
  27. </view>
  28. <view class="topTools flex-item" :style="'width:'+topToolsWidth" @click="$showModal('功能暂未开放')">
  29. <view>
  30. <image src="../../static/img/home/task.png"></image>
  31. </view>
  32. 任务
  33. </view>
  34. <view class="topTools flex-item" style="position: relative;" @click="toXiaoxiPage"
  35. :style="'width:'+topToolsWidth">
  36. <view>
  37. <image src="../../static/img/home/xiaoxi.png"></image>
  38. </view>
  39. 消息
  40. <view v-if="msgNum > 0" class="hs-hzl-count count" :style="'left:' +xxjbleft+'rpx'">
  41. {{msgNum}}
  42. </view>
  43. </view>
  44. </view>
  45. </u-sticky>
  46. <view class="modules">
  47. <homelist title="单位通告" :limit="2" :showType="1" @click="onClick" :list="noticeList"
  48. :url="this.$BASE_URL">
  49. </homelist>
  50. </view>
  51. <view class="modules" v-if="type === 3">
  52. <homelist title="相关资讯" :limit="4" :showType="2" :list="xgzxList" :url="baseURL">
  53. </homelist>
  54. </view>
  55. <view class="modules">
  56. <homelist title="平台资讯" :limit="4" :showType="2" :list="ptzxList" :url="baseURL">
  57. </homelist>
  58. </view>
  59. </view>
  60. <!-- <wp-tabbar ref="tab" pagePath="/pages/home/index" :type="type"></wp-tabbar> -->
  61. </view>
  62. </template>
  63. <script>
  64. // 页面模块组件
  65. import Classify1 from '@/components/classify-1/classify-1.vue'
  66. import homelist from '@/components/homelist/homelist.vue'
  67. export default {
  68. name: 'Index',
  69. components: {
  70. Classify1,
  71. homelist
  72. },
  73. data() {
  74. return {
  75. msgNum: 0,
  76. topToolsWidth: "15%",
  77. baseURL: this.$BASE_URL,
  78. ptzxList: [],
  79. xgzxList: [],
  80. xxjbleft: 85,
  81. indexConfig: [{
  82. name: 'banner-1',
  83. data: []
  84. }, {
  85. name: 'classify-1',
  86. data: []
  87. }, {
  88. name: 'homelist',
  89. data: []
  90. }],
  91. noticeList: [],
  92. form: {
  93. },
  94. type: undefined,
  95. openid: '',
  96. tabMark: []
  97. }
  98. },
  99. mounted() {
  100. const userInfo = uni.getStorageSync('userInfo');
  101. const orgInfo = uni.getStorageSync('orgInfo');
  102. this.form.userName = userInfo.nickName
  103. this.form.userNo = userInfo.userName
  104. this.form.orgNo = orgInfo.organizationCode
  105. this.form.orgName = orgInfo.organizationName
  106. uni.setStorageSync('refreshStart', 1)
  107. let baseUrlSocket = this.$BASE_URL_SOCKET
  108. if (!uni.getStorageSync('deptData')) {
  109. this.$httpRequest({
  110. url: '/app/deptInfo?id=' + uni.getStorageSync('org_dept_parent_id'),
  111. urlType: this.$getUrlType()
  112. }).then(res => {
  113. if (res.data.code === 200) {
  114. uni.setStorageSync('deptData', res.data.data)
  115. }
  116. })
  117. }
  118. if (!uni.getStorageSync('postsData')) {
  119. this.$httpRequest({
  120. url: '/app/posts',
  121. urlType: this.$getUrlType()
  122. }).then(res => {
  123. if (res.data.code === 200) {
  124. uni.setStorageSync('postsData', res.data.data)
  125. }
  126. })
  127. }
  128. this.msgs()
  129. setInterval(() => {
  130. this.msgs()
  131. }, 600);
  132. this.type = uni.getStorageSync("tabType")
  133. if (this.type === 2) {
  134. this.topToolsWidth = "20%"
  135. this.xxjbleft = 100
  136. } else if (this.type === 3) {
  137. this.topToolsWidth = "15%"
  138. this.xxjbleft = 85
  139. } else if (this.type === 4) {
  140. this.topToolsWidth = "20%"
  141. this.xxjbleft = 100
  142. } else {
  143. this.topToolsWidth = "20%"
  144. this.xxjbleft = 100
  145. }
  146. this.getCachaData()
  147. //获取主页数据
  148. this.getHomeConfigData(this.$getUrlType())
  149. this.getApiHomeConfigData()
  150. //获取任务提示
  151. //this.getNotRead()
  152. //获取公告
  153. this.getNoice()
  154. this.getOpenIdtoDb()
  155. },
  156. onShow() {
  157. uni.reLaunch({
  158. url: '/pages/tabbar/wpTabbar'
  159. })
  160. this.getCachaData()
  161. //获取主页数据
  162. this.getHomeConfigData(this.$getUrlType())
  163. this.getApiHomeConfigData()
  164. //获取任务提示
  165. //this.getNotRead()
  166. //获取公告
  167. this.getNoice()
  168. this.getOpenIdtoDb()
  169. },
  170. onNavigationBarButtonTap() {
  171. },
  172. onHide() {},
  173. methods: {
  174. getCachaData() {
  175. const userInfo = uni.getStorageSync('userInfo');
  176. const orgInfo = uni.getStorageSync('orgInfo');
  177. if (!(userInfo && orgInfo)) {
  178. uni.reLaunch({
  179. url: '/pageA/login/login'
  180. })
  181. }
  182. this.form.userName = userInfo.nickName
  183. this.form.userNo = userInfo.userName
  184. this.form.orgNo = orgInfo.organizationCode
  185. this.form.orgName = orgInfo.organizationName
  186. uni.setNavigationBarTitle({
  187. title: this.form.orgName
  188. })
  189. },
  190. async getHomeConfigData(type) {
  191. const {
  192. data: res
  193. } = await this.$httpRequest({
  194. url: '/app/getHomeConfigData?orgCode=' + this.form.orgNo,
  195. method: 'get',
  196. urlType: type
  197. })
  198. if (res.code == 200) {
  199. if (type === 2) {
  200. this.ptzxList = res.data
  201. } else if (type === 3) {
  202. this.xgzxList = res.data
  203. }
  204. } else {
  205. this.indexConfig = []
  206. }
  207. },
  208. async getApiHomeConfigData() {
  209. const {
  210. data: res
  211. } = await this.$httpRequest({
  212. url: '/api/getHomeConfigData?orgCode=' + "G00000003",
  213. method: 'get',
  214. urlType: 2,
  215. isNotToken: true
  216. })
  217. if (res && res.code == 200) {
  218. this.ptzxList = res.data
  219. } else {
  220. this.indexConfig = []
  221. }
  222. },
  223. msgs() {
  224. let data = uni.getStorageSync("msgData")
  225. if (!data) {
  226. this.msgNum = 0
  227. return
  228. }
  229. data = JSON.parse(data)
  230. this.msgNum = data.m1 + data.m2 + data.m3 + data.m4 + data.m5 + data.m6 + data.m7 + data.m8 + data.m9
  231. },
  232. toPayCodePage() {
  233. //跳转非pages.json>tabbar>配置过的页面,使用navigateTo
  234. //跳转时保留老页面,一般用于需要返回
  235. uni.navigateTo({
  236. url: "../user/payCode"
  237. })
  238. },
  239. toIntegralPage() {
  240. //跳转非pages.json>tabbar>配置过的页面,使用navigateTo
  241. //跳转时保留老页面,一般用于需要返回
  242. let userInfo = uni.getStorageSync("userInfo")
  243. if (userInfo.userType != '1' && userInfo.userType != '2') {
  244. this.$showModal('仅限内部人员使用')
  245. return
  246. }
  247. uni.navigateTo({
  248. url: "../../pageA/integral/index"
  249. })
  250. },
  251. toXiaoxiPage() {
  252. uni.navigateTo({
  253. url: "../../pageA/msg/userMsgList"
  254. })
  255. },
  256. onClick(e) {
  257. },
  258. async getOpenIdtoDb(type) {
  259. },
  260. async getNotRead() {
  261. const {
  262. data: res
  263. } = await this.$httpRequest({
  264. url: '/api/yq/notRead?userNo=' + this.form.userNo +
  265. "&orgNo=" + this.form.orgNo,
  266. method: 'get',
  267. urlType: this.$getUrlType()
  268. })
  269. if (res.code == 200) {
  270. var num = res.data
  271. if (0 < num) {
  272. uni.setTabBarBadge({
  273. index: 1,
  274. text: num + ""
  275. })
  276. }
  277. } else {
  278. }
  279. },
  280. async getNoice() {
  281. this.$httpRequest({
  282. url: '/app/notice?orgNo=' + this.form.orgNo + '&pageNum=1&pageSize=2',
  283. method: 'get',
  284. urlType: this.$getUrlType()
  285. }).then(res => {
  286. if (res.data.code == 200) {
  287. this.noticeList = res.data.rows
  288. this.noticeList.forEach(n => {
  289. n.createTime = n.createTime.slice(0, 10)
  290. })
  291. }
  292. })
  293. this.$httpRequest({
  294. url: '/app/notice?orgNo=' + this.form.orgNo,
  295. method: 'get',
  296. urlType: this.$getUrlType()
  297. }).then(res => {
  298. if (res.data.code == 200) {
  299. this.noticeList = res.data.rows
  300. this.noticeList.forEach(n => {
  301. n.createTime = n.createTime.slice(0, 10)
  302. })
  303. }
  304. })
  305. },
  306. takeMeal() {
  307. var that = this;
  308. uni.scanCode({
  309. scanType: ['qrCode'],
  310. success: function(res) {
  311. uni.showModal({
  312. content: JSON.stringify(res) + "1",
  313. })
  314. },
  315. fail: function(a) {},
  316. complete: function(b) {}
  317. })
  318. }
  319. }
  320. }
  321. </script>
  322. <style lang="scss" scoped>
  323. .uni-tabbar__icon {
  324. width: 48px;
  325. height: 24px;
  326. }
  327. page {
  328. background-color: #c6c6c6;
  329. padding: 0;
  330. }
  331. .topToolsBody {
  332. box-shadow: 0 0 4px 0px #828282;
  333. padding: 0 10px;
  334. border-radius: 2ch;
  335. margin: 10rpx 10rpx 20rpx;
  336. background-color: #f9f9f9;
  337. image {
  338. width: 40px;
  339. height: 40px;
  340. }
  341. }
  342. .topTools {
  343. align-items: center; //垂直居中
  344. padding: 2.5%;
  345. font-size: 30rpx;
  346. color: #717171;
  347. }
  348. .warp {
  349. height: 100%;
  350. padding-bottom: constant(safe-area-inset-bottom);
  351. padding-bottom: env(safe-area-inset-bottom);
  352. }
  353. .modules {
  354. // margin: 15rpx;
  355. // padding: 10upx;
  356. }
  357. .count {
  358. bottom: 110rpx;
  359. }
  360. </style>