home.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. <template>
  2. <view :style="vuex_skin">
  3. <!-- #ifdef MP-WEIXIN -->
  4. <u-navbar title-color="#000000" :is-back="fasle" title="首页"></u-navbar>
  5. <!-- #endif -->
  6. <mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" :up="upOption" @down="downCallback"
  7. @up="upCallback">
  8. <view v-if="noticeContent">
  9. <u-notice-bar mode="horizontal" :list="noticeContent"></u-notice-bar>
  10. </view>
  11. <view style="padding: 30rpx 30rpx 10rpx;">
  12. <u-swiper :list="swiperList" border-radius="12" name="url" mode="rect" height="300"></u-swiper>
  13. </view>
  14. <view class="">
  15. <view class="cu-list grid no-border" :class="gridClass" style="border-radius:20rpx ;">
  16. <view class="cu-item" @click.stop="jump(item)" v-for="(item,index) in gridList" :key="index">
  17. <view class="grid-icon">
  18. <image style="width: 88rpx;height: 88rpx;" :src="item.icon" />
  19. </view>
  20. <text style="color: #222222;font-size: 26rpx;">{{item.name}}</text>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="" style="height: 20rpx;background-color: #f8f8f8"></view>
  25. <view style="padding: 30rpx 30rpx 0">
  26. <u-search placeholder="搜索关键词或编号" height="70" @search="searchWorks" v-model="keyword"
  27. :show-action="false">
  28. </u-search>
  29. </view>
  30. <view style="padding: 30rpx 30rpx 0;">
  31. <view class="text-bold" style="font-size: 34rpx;">
  32. {{vuex_active_setting.indexTitle || ''}}
  33. </view>
  34. <view @click="$jump('/pages/activity/activityDetail?id='+item.id)" class="card shadow"
  35. v-for="(item,index) in worksList" :key="item.id">
  36. <view v-if="index==0" class="center bg-img rank-tag"
  37. style="background-image: url(https://vote.guosen-fumao.cn/obsfile/5c923494fae24fdc91ee1dd6965c26b2-qnradpXLKHik8a7c1bd849a731b15ee6726a44cf4052.png);z-index: 2;">
  38. <text>1</text>
  39. </view>
  40. <view v-if="index==1" class="center bg-img rank-tag"
  41. style="background-image: url(https://vote.guosen-fumao.cn/obsfile/72001a127cab486cb4ad66621aa04e96-UpLGLMdL9kFV87f15988cc7debf4ec475216e800b786.png);z-index: 2;">
  42. <text>2</text>
  43. </view>
  44. <view v-if="index==2" class="center bg-img rank-tag"
  45. style="background-image: url(https://vote.guosen-fumao.cn/obsfile/5e65cfb76ccf49cf84661b85804c2455-LRRAX18iJBMH5489e35cc716d71257defce06d673af0.png);z-index: 2;">
  46. <text>3</text>
  47. </view>
  48. <view class="left">
  49. <image :src="item.imgUrl" mode="aspectFill"></image>
  50. </view>
  51. <view class="right" style="width: 100%;">
  52. <view class="flex-direction flex">
  53. <view class="flex">
  54. <view class="center ">
  55. <view class="cu-tag sm bg-tag radius margin-right-10" style="font-weight: 400;">
  56. 编号:{{item.productNo}}
  57. </view>
  58. </view>
  59. <view class="center">
  60. <text class="title text-cut-1">{{item.title}}</text>
  61. </view>
  62. </view>
  63. <rich-text class="desc text-cut-2" style="max-height: 80rpx;" :nodes="decodeURIComponent(item.content)">
  64. </rich-text>
  65. </view>
  66. <view class="bottom" style="width: 100%;">
  67. <view class="flex margin-top-10">
  68. <text class="cuIcon-hotfill text-base" style="font-size: 34rpx;"></text>
  69. <view class="center">
  70. <text
  71. style="color: #353535;margin-left: 6rpx;font-size:28rpx;">{{item.voteCount}}</text>
  72. </view>
  73. </view>
  74. <view class="cu-btn round sm line-base">
  75. 去投票
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. </mescroll-body>
  82. <!-- 海报 -->
  83. <login ref="login" @signIn="signIn" @phoneSuccess="phoneSuccess"></login>
  84. <toast ref="toast"></toast>
  85. <u-tabbar :bg-color="tabbar.bgColor" :icon-size="tabbar.iconSize" :height="100" :border-top="tabbar.borderTop"
  86. :inactive-color="tabbar.inactiveColor" :active-color="tabbar.activeColor" :list="tabbar.list">
  87. </u-tabbar>
  88. </view>
  89. </template>
  90. <script>
  91. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  92. import util from "@/utils/util.js";
  93. import {
  94. tabbar
  95. } from "@/assets/http/tabbar.js"
  96. export default {
  97. mixins: [MescrollMixin],
  98. data() {
  99. return {
  100. //tabbar
  101. tabbar: {},
  102. downOption: {
  103. auto: false
  104. },
  105. upOption: {
  106. auto: false,
  107. empty: {
  108. use: false
  109. }
  110. },
  111. //海报
  112. posetrParams: {
  113. avatar: '',
  114. title: '我是普法帮帮代言人',
  115. subTitle: ''
  116. },
  117. qrCodeImg: '',
  118. //活动id
  119. activeId: '',
  120. //排行榜
  121. worksList: [],
  122. //轮播图
  123. swiperList: [],
  124. //菜单
  125. gridClass: '',
  126. gridList: [],
  127. keyword: '',
  128. noticeContent: [],
  129. //活动详情
  130. activeInfo: {},
  131. //参赛的路径
  132. applyUrl: ""
  133. };
  134. },
  135. async onLoad(options) {
  136. await this.handelRoute(options)
  137. this.fetchTabbar()
  138. },
  139. onShow() {
  140. if (this.canReset) {
  141. this.mescroll.resetUpScroll();
  142. }
  143. this.canReset = true;
  144. },
  145. methods: {
  146. /**
  147. * 更换主题
  148. */
  149. async fetchTabbar() {
  150. this.tabbar = tabbar
  151. if (this.vuex_theme.bgColor) {
  152. this.tabbar.activeColor = this.vuex_theme.bgColor
  153. } else {
  154. this.tabbar.activeColor = this.$config.themeRed.theme.bgColor
  155. }
  156. },
  157. /**
  158. * 获取活动详情
  159. */
  160. async activeDetail() {
  161. let params = {
  162. id: this.activeId
  163. }
  164. this.$api.activerecord.detail(params).then(res => {
  165. this.activeInfo = res.data.data;
  166. })
  167. },
  168. /**
  169. * 获取通知公告
  170. */
  171. async getNotice() {
  172. let params = {
  173. activeId: this.activeId,
  174. title: '活动通知'
  175. }
  176. this.$api.notice.list(params).then(res => {
  177. let notices = res.data.data.records
  178. if (this.$isNotEmpty(notices) && this.$isNotEmpty(notices[0].content)) {
  179. this.noticeContent.push(util.formatHtml(notices[0].content))
  180. }
  181. })
  182. },
  183. /**
  184. * 处理路由转发
  185. */
  186. async handelRoute(options) {
  187. const {
  188. path
  189. } = options;
  190. await this.initParams(options);
  191. if (this.$isNotEmpty(path)) {
  192. this.$jump(decodeURIComponent(path))
  193. }
  194. },
  195. /**
  196. * 获取默认活动id
  197. */
  198. async getDefaultActiveId() {
  199. let params = {
  200. platformSettingEnum: 'COMMON_SETTING'
  201. }
  202. let defaultActiveId = JSON.parse((await this.$api.platform.getPlatformValue(params)).data.data)
  203. .defaultActiveId;
  204. return defaultActiveId
  205. },
  206. /**
  207. * 获取活动参数
  208. */
  209. async getActivityParams() {
  210. let params = {
  211. activeId: this.activeId,
  212. platformSettingEnum: 'ACTIVE_SETTING'
  213. }
  214. let activeSetting = JSON.parse((await this.$api.platform.getPlatformValue(params)).data.data);
  215. this.$config.setTheme(activeSetting.theme, this)
  216. // #ifdef H5
  217. if (this.$isNotEmpty(activeSetting.shareParam)) {
  218. let shareParam = activeSetting.shareParam
  219. shareParam.link = window.location.href.split('?')[0] + '?activeId=' + this.activeId
  220. this.$shareConfig.H5Share(shareParam)
  221. }
  222. // #endif
  223. activeSetting.defaultActiveId = this.activeId
  224. this.$u.vuex('vuex_active_setting', activeSetting);
  225. },
  226. /**
  227. * 获取首页参数
  228. */
  229. async initParams(options) {
  230. const activeId = options.activeId
  231. // if (this.$isNotEmpty(activeId)) {
  232. // //活动列表传进来
  233. // this.activeId = activeId
  234. // } else if (this.$isNotEmpty(this.vuex_active_setting) &&
  235. // this.$isNotEmpty(this.vuex_active_setting.defaultActiveId)) {
  236. // //缓存中有活动id
  237. // this.activeId = this.vuex_active_setting.defaultActiveId
  238. // } else {
  239. // //获取默认的活动id
  240. // this.activeId = await this.getDefaultActiveId()
  241. // }
  242. if (this.$isNotEmpty(activeId)) {
  243. //活动列表传进来
  244. this.activeId = activeId
  245. } else {
  246. //获取默认的活动id
  247. this.activeId = await this.getDefaultActiveId()
  248. }
  249. await this.getActivityParams(activeId)
  250. this.getNotice()
  251. this.activeDetail();
  252. //获取排行榜
  253. this.mescroll.resetUpScroll();
  254. //获取轮播图
  255. let gridList = this.vuex_active_setting.functionItemList
  256. if (this.$isNotEmpty(gridList)) {
  257. this.gridList = gridList.filter(item => item.show == 1)
  258. this.gridClass = 'col-' + this.gridList.length
  259. }
  260. // console.log(gridList, "gridList");
  261. this.swiperList = this.vuex_active_setting.indexImageList
  262. },
  263. jump(item) {
  264. if (item.path == '/pages/rank/rank') {
  265. item.path = `${item.path}?activeId=${this.activeId}`
  266. }
  267. if (item.path == '/pages/apply/apply') {
  268. //登录后才可以参赛
  269. this.applyUrl = `${item.path}?activeId=${this.activeId}&activeType=${this.activeInfo.type}`
  270. this.login()
  271. return;
  272. }
  273. uni.navigateTo({
  274. url: item.path
  275. })
  276. },
  277. init() {
  278. this.goApply()
  279. },
  280. goApply() {
  281. let nowTime = new Date().getTime();
  282. let startTime = this.$dateTime.getTime(this.activeInfo.uploadProductStartTime)
  283. let endTime = this.$dateTime.getTime(this.activeInfo.uploadProductEndTime)
  284. if (nowTime < startTime) {
  285. this.$refs.toast.info("报名未开始");
  286. } else if (nowTime > endTime) {
  287. this.$refs.toast.info("报名已结束");
  288. } else {
  289. uni.navigateTo({
  290. url: this.applyUrl
  291. })
  292. }
  293. },
  294. searchWorks() {
  295. let params = {
  296. activeId: this.activeId,
  297. keyword: this.keyword
  298. }
  299. this.$api.activity.searchWork(params).then(res => {
  300. this.worksList = res.data.data;
  301. })
  302. },
  303. downCallback() {
  304. setTimeout(() => {
  305. this.mescroll.resetUpScroll();
  306. }, 1000)
  307. },
  308. upCallback(mescroll) {
  309. try {
  310. let params = {
  311. current: mescroll.num,
  312. size: mescroll.size,
  313. activeId: this.activeId
  314. }
  315. this.$api.activity.sortListQuery(params).then(res => {
  316. // console.log(res.data.data.records);
  317. let data = res.data.data.records
  318. let total = res.data.data.total
  319. mescroll.endBySize(data.length, total);
  320. if (mescroll.num == 1) this.worksList = []; //如果是第一页需手动制空列表
  321. this.worksList = this.worksList.concat(data); //追加新数据
  322. })
  323. } catch (e) {
  324. console.error(e);
  325. this.mescroll.endErr()
  326. }
  327. },
  328. }
  329. }
  330. </script>
  331. <style>
  332. page {
  333. background-color: #FFFFFF;
  334. }
  335. </style>
  336. <style lang="scss" scoped>
  337. .shadow {
  338. box-shadow: #f8f8f8 0px 0px 10rpx 10rpx
  339. }
  340. .rank-tag {
  341. color: #FFFFFF;
  342. width: 40rpx;
  343. height: 46rpx;
  344. position: absolute;
  345. left: 10rpx;
  346. top: 0rpx;
  347. z-index: 999;
  348. }
  349. .card {
  350. position: relative;
  351. margin-top: 30rpx;
  352. border-radius: 10rpx;
  353. padding: 15rpx;
  354. display: flex;
  355. .left {
  356. display: flex;
  357. justify-content: center;
  358. align-items: center;
  359. image {
  360. width: 210rpx;
  361. height: 210rpx;
  362. border-radius: 10rpx;
  363. }
  364. }
  365. .right {
  366. margin-left: 20rpx;
  367. display: flex;
  368. flex-direction: column;
  369. justify-content: space-between;
  370. .title {
  371. font-weight: 800;
  372. color: #353535;
  373. font-size: 32rpx;
  374. }
  375. .desc {
  376. color: #888888;
  377. line-height: 40rpx;
  378. padding-top: 20rpx;
  379. font-size: 26rpx;
  380. }
  381. .bottom {
  382. display: flex;
  383. justify-content: space-between;
  384. width: 100%;
  385. }
  386. }
  387. }
  388. .canvas-hide {
  389. position: fixed;
  390. right: 100vw;
  391. bottom: 100vh;
  392. z-index: -9999;
  393. opacity: 0;
  394. }
  395. </style>