home.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <view :style="vuex_skin">
  3. <mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" :up="upOption" @down="downCallback"
  4. @up="upCallback">
  5. <view style="padding: 30rpx 30rpx 10rpx;">
  6. <u-swiper :list="swiperList" border-radius="12" name="url" height="300"></u-swiper>
  7. </view>
  8. <view class="">
  9. <view class="cu-list grid col-4 no-border" style="border-radius:20rpx ;">
  10. <view class="cu-item" @click.stop="jump(item)" v-for="(item,index) in gridList" :key="index">
  11. <view class="grid-icon">
  12. <image style="width: 88rpx;height: 88rpx;" :src="item.icon" />
  13. </view>
  14. <text style="color: #222222;font-size: 26rpx;">{{item.name}}</text>
  15. <view class="cu-tag bg-red badge" v-if="item.count>0">{{item.count}}</view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="" style="height: 20rpx;background-color: #f8f8f8"></view>
  20. <view style="padding: 30rpx 30rpx 0">
  21. <u-search placeholder="搜索关键词或编号" height="70" @search="searchWorks" v-model="keyword"
  22. :show-action="false">
  23. </u-search>
  24. </view>
  25. <view style="padding: 30rpx 30rpx 0;">
  26. <view class="text-bold" style="font-size: 34rpx;">
  27. {{vuex_page_interface_show.indexTitle || ''}}
  28. </view>
  29. <view @click="$jump('/pages/activity/activityDetail?id='+item.id)" class="card shadow"
  30. v-for="(item,index) in worksList" :key="item.id">
  31. <view v-if="index==0" class="center bg-img rank-tag"
  32. style="background-image: url(../../static/icon/ph1.png);z-index: 2;">
  33. <text>1</text>
  34. </view>
  35. <view v-if="index==1" class="center bg-img rank-tag"
  36. style="background-image: url(../../static/icon/ph2.png);z-index: 2;">
  37. <text>2</text>
  38. </view>
  39. <view v-if="index==2" class="center bg-img rank-tag"
  40. style="background-image: url(../../static/icon/ph3.png);z-index: 2;">
  41. <text>3</text>
  42. </view>
  43. <view class="left">
  44. <image :src="item.imgUrl" mode="aspectFill"></image>
  45. </view>
  46. <view class="right" style="width: 100%;">
  47. <view class="flex-direction flex">
  48. <view class="flex">
  49. <view class="center ">
  50. <view class="cu-tag sm bg-red light radius">
  51. 编号:{{item.productNo}}
  52. </view>
  53. </view>
  54. <view class="center">
  55. <text class="title text-cut-1">{{item.title}}</text>
  56. </view>
  57. </view>
  58. <rich-text class="desc text-cut-2" :nodes="decodeURIComponent(item.content)"></rich-text>
  59. </view>
  60. <view class="bottom" style="width: 100%;">
  61. <view class="flex margin-top-10">
  62. <image class="center" style="width: 30rpx;height: 30rpx;"
  63. src="../../static/icon/remen.png">
  64. </image>
  65. <text
  66. style="color: #353535;margin-left: 6rpx;font-size:28rpx;">{{item.heatValue}}</text>
  67. </view>
  68. <view class="cu-btn round sm line-base">
  69. 去助力
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </mescroll-body>
  76. <!-- 海报 -->
  77. <login ref="login" @signIn="signIn" @phoneSuccess="phoneSuccess"></login>
  78. <poster ref="poster" :avatar="posetrParams.avatar" :title="posetrParams.title"
  79. :subTitle="posetrParams.subTitle"></poster>
  80. <uqrcode class="canvas-hide" ref="uqrcode"></uqrcode>
  81. <loading ref="loading" type="3"/>
  82. <toast ref="toast" ></toast>
  83. </view>
  84. </template>
  85. <script>
  86. import poster from "@/components/poster/poster.vue"
  87. import uqrcode from "@/components/uqrcode/uqrcode.vue"
  88. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  89. export default {
  90. mixins: [MescrollMixin],
  91. components:{
  92. poster,
  93. uqrcode
  94. },
  95. data() {
  96. return {
  97. downOption: {
  98. auto: false
  99. },
  100. upOption: {
  101. auto:false,
  102. empty: {
  103. use: false
  104. }
  105. },
  106. //海报
  107. posetrParams: {
  108. avatar: '',
  109. title: '我是普法帮帮代言人',
  110. subTitle: ''
  111. },
  112. qrCodeImg:'',
  113. //活动id
  114. activeId: '',
  115. //排行榜
  116. worksList: [],
  117. //轮播图
  118. swiperList:[],
  119. //菜单
  120. gridList: [{
  121. icon: '/static/grid/jieshao.png',
  122. name: "活动介绍",
  123. path: "/pages/introduce/introduce"
  124. }, {
  125. icon: '/static/grid/baoming.png',
  126. name: "我要代言",
  127. },
  128. {
  129. icon: '/static/grid/rank.png',
  130. name: "排行榜",
  131. path: "/pages/rank/rank"
  132. },
  133. {
  134. icon: '/static/grid/more.png',
  135. name: "更多活动",
  136. }
  137. ]
  138. };
  139. },
  140. onLoad(options) {
  141. this.handelRoute(options)
  142. },
  143. methods: {
  144. /**
  145. * 处理路由转发
  146. */
  147. async handelRoute(options){
  148. const { path } = options;
  149. await this.initParams();
  150. if (this.$isNotEmpty(path)) {
  151. this.$jump(decodeURIComponent(path))
  152. }
  153. },
  154. /**
  155. * 获取活动参数
  156. */
  157. async initParams(){
  158. const {ACTIVE_SETTING,PAGE_INTERFACE_SHOW} = (await this.$api.platform.getPlatformParams({
  159. keys: 'ACTIVE_SETTING,PAGE_INTERFACE_SHOW'
  160. })).data.data;
  161. this.$u.vuex('vuex_active_setting', JSON.parse(ACTIVE_SETTING));
  162. this.$u.vuex('vuex_page_interface_show', JSON.parse(PAGE_INTERFACE_SHOW));
  163. //获取排行榜
  164. this.activeId = JSON.parse(ACTIVE_SETTING).defaultActiveId
  165. this.mescroll.resetUpScroll();
  166. //获取轮播图
  167. this.swiperList=JSON.parse(PAGE_INTERFACE_SHOW).indexImageList
  168. },
  169. jump(item){
  170. if (item.name=='更多活动') {
  171. this.$refs.toast.info('暂无更多活动')
  172. return
  173. }
  174. if (item.name=='我要代言') {
  175. this.showPromotePoster()
  176. return
  177. }
  178. uni.navigateTo({
  179. url:item.path
  180. })
  181. },
  182. searchWorks(value) {
  183. this.$api.activity.searchWork(value).then(res => {
  184. this.worksList = res.data.data;
  185. })
  186. },
  187. downCallback() {
  188. setTimeout(() => {
  189. this.mescroll.resetUpScroll();
  190. }, 1000)
  191. },
  192. upCallback(mescroll) {
  193. try {
  194. let params = {
  195. current: mescroll.num,
  196. size: mescroll.size,
  197. activeId: this.activeId
  198. }
  199. this.$api.activity.sortListQuery(params).then(res => {
  200. console.log(res.data.data.records);
  201. let data = res.data.data.records
  202. let total = res.data.data.total
  203. mescroll.endBySize(data.length, total);
  204. if (mescroll.num == 1) this.worksList = []; //如果是第一页需手动制空列表
  205. this.worksList = this.worksList.concat(data); //追加新数据
  206. })
  207. } catch (e) {
  208. console.error(e);
  209. this.mescroll.endErr()
  210. }
  211. },
  212. //代言人海报
  213. init(){
  214. this.posetrParams = {
  215. avatar: this.$cache.get('userInfo').avatar,
  216. title: '我是普法帮帮代言人'+ this.$cache.get('userInfo').nickName,
  217. subTitle: ''
  218. }
  219. this.$refs.poster.showCanvas(this.qrCodeImg)
  220. },
  221. async showPromotePoster() {
  222. this.$refs.loading.showLoading()
  223. this.posetrParams = {
  224. avatar: this.$cache.get('userInfo').avatar,
  225. title: '我是普法帮帮代言人'+ this.$cache.get('userInfo').nickName,
  226. subTitle: ''
  227. }
  228. let userId = this.vuex_userId
  229. let qrText = this.$config.PRODUCT_PATH + '?userId=' + userId
  230. this.qrCodeImg = (await this.$refs.uqrcode.make({
  231. size: 150,
  232. text: qrText
  233. })).tempFilePath
  234. if (this.$isEmpty(this.vuex_userId)) {
  235. this.$refs.loading.hide()
  236. this.showLogin(true)
  237. return
  238. }
  239. setTimeout(()=>{
  240. this.$refs.poster.showCanvas(this.qrCodeImg)
  241. this.$refs.loading.hide()
  242. },200)
  243. },
  244. }
  245. }
  246. </script>
  247. <style>
  248. page {
  249. background-color: #FFFFFF;
  250. }
  251. </style>
  252. <style lang="scss" scoped>
  253. .shadow {
  254. box-shadow: #f8f8f8 0px 0px 10rpx 10rpx
  255. }
  256. .rank-tag {
  257. color: #FFFFFF;
  258. width: 40rpx;
  259. height: 46rpx;
  260. position: absolute;
  261. left: 10rpx;
  262. top: 0rpx;
  263. z-index: 999;
  264. }
  265. .card {
  266. position: relative;
  267. margin-top: 30rpx;
  268. border-radius: 10rpx;
  269. padding: 15rpx;
  270. display: flex;
  271. .left {
  272. display: flex;
  273. justify-content: center;
  274. align-items: center;
  275. image {
  276. width: 210rpx;
  277. height: 210rpx;
  278. border-radius: 10rpx;
  279. }
  280. }
  281. .right {
  282. margin-left: 20rpx;
  283. display: flex;
  284. flex-direction: column;
  285. justify-content: space-between;
  286. .title {
  287. font-weight: 800;
  288. color: #353535;
  289. font-size: 32rpx;
  290. }
  291. .desc {
  292. color: #888888;
  293. line-height: 40rpx;
  294. padding-top: 20rpx;
  295. font-size: 26rpx;
  296. }
  297. .bottom {
  298. display: flex;
  299. justify-content: space-between;
  300. width: 100%;
  301. }
  302. }
  303. }
  304. .canvas-hide {
  305. position: fixed;
  306. right: 100vw;
  307. bottom: 100vh;
  308. z-index: -9999;
  309. opacity: 0;
  310. }
  311. </style>