home.vue 8.3 KB

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