rank.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <view :style="vuex_skin">
  3. <view class="">
  4. <!-- #ifdef MP-WEIXIN -->
  5. <u-navbar v-show="navbarShow" :custom-back="customBack" title-color="#fff" :border-bottom="false"
  6. back-icon-color="#fff" title="排行榜" :background="{'backgroundColor': vuex_theme.bgColor}"></u-navbar>
  7. <back v-show="!navbarShow" :custom-back="customBack"></back>
  8. <!-- #endif -->
  9. <view class="bg-img flex-direction flex justify-center" :class="isH5?'marginTop':''"
  10. style="height: 380rpx;"
  11. :style="rankBgImg">
  12. <view class="title" style="padding: 80rpx 0 0 60rpx;">排行榜</view>
  13. </view>
  14. <view class="flex justify-center align-center padding-bottom">
  15. <view class="search">
  16. <u-search @search="searchWorks" v-model="keyword" search-icon="/static/rank/search.png"
  17. :show-action="false" bg-color="#fff" style="width: 100%;" placeholder-color="#CCCCCC">
  18. </u-search>
  19. </view>
  20. </view>
  21. <mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" :up="upOption" @down="downCallback"
  22. @up="upCallback">
  23. <block v-for="(item, index) in rankList" :key="item.id">
  24. <block v-if="index == 0 || index == 1 || index == 2">
  25. <view class=" flex align-center "
  26. style="height: 230rpx;position: relative;margin: 10rpx 20rpx 20rpx 20rpx;"
  27. :class="index == 0 ? 'first1' : index == 1 ? 'second2' : index == 2 ? 'third3' : '' ">
  28. <view class="" style="width: 220rpx;">
  29. <u-image width="220" height="220" mode="aspectFill" border-radius="10"
  30. :src="item.imgUrl">
  31. </u-image>
  32. </view>
  33. <view class="flex justify-between container" style="width: 100%;">
  34. <view class="left" style="width: 95%;">
  35. <view class="padding-top-20 " style="display: flex;">
  36. <view class="center ">
  37. <view class="cu-tag sm bg-tag radius margin-right-10">
  38. 编号:{{item.productNo}}
  39. </view>
  40. </view>
  41. <view class="center">
  42. <text class="name text-cut-1">{{item.title}}</text>
  43. </view>
  44. </view>
  45. <view class="padding-tb-sm text-sm center"
  46. style="color: #888888;justify-content: flex-start">
  47. <!-- <u-avatar :src="item.userImg?item.userImg:'/static/icon/unlogin.png'" size="56">
  48. </u-avatar>
  49. <text class="margin-left-10">{{item.username || '暂无信息'}}</text> -->
  50. <rich-text class="desc text-cut-2" style="max-height: 80rpx;" :nodes="decodeURIComponent(item.content)">
  51. </rich-text>
  52. </view>
  53. <view class="flex justify-between">
  54. <view class="hot-value center" style="justify-content: flex-start;">
  55. <text class="cuIcon-hotfill text-base " style="font-size: 32rpx;"></text>
  56. <text style="padding-left: 4rpx;">{{item.voteCount}}</text>
  57. </view>
  58. <button
  59. @click.stop="$jump('/pages/activity/activityDetail?id='+item.id+'&isCustomBack=false')"
  60. class="cu-btn round bg-base sm text-white"
  61. style="padding: 20rpx 38rpx;margin-bottom: 30rpx;">
  62. <text>去投票</text>
  63. </button>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="" style="position: absolute;right: -16rpx;top: -16rpx;">
  68. <image v-if="index==0" style="width: 70rpx;height: 70rpx;"
  69. src="../../static/rank/no1.png" mode=""></image>
  70. <image v-if="index==1" style="width: 70rpx;height: 70rpx;"
  71. src="../../static/rank/no2.png" mode=""></image>
  72. <image v-if="index==2" style="width: 70rpx;height: 70rpx;"
  73. src="../../static/rank/no3.png" mode=""></image>
  74. </view>
  75. </view>
  76. </block>
  77. <view v-else class="flex margin-20">
  78. <view class="center text-bold text-lg" style="margin:0 20rpx;">
  79. <text>{{index + 1}}</text>
  80. </view>
  81. <view class=" flex align-center "
  82. style="background-color: #FFFFFF;border-radius: 20rpx;height: 210rpx;width: 95%;">
  83. <view class="" style="width: 190rpx;">
  84. <u-image width="190" height="190" border-radius="10" :src="item.imgUrl"></u-image>
  85. </view>
  86. <view class="flex justify-between container" style="width: 100%;">
  87. <view class="left" style="width: 95%;">
  88. <view class="flex" style="padding-top: 20rpx;width: 430rpx;">
  89. <view class="cu-tag sm bg-tag radius">
  90. 编号:{{item.productNo}}
  91. </view>
  92. <view class="name text-cut-1" style="font-size: 28rpx;font-weight: 600;">
  93. {{item.title}}
  94. </view>
  95. </view>
  96. <view class="text-sm center"
  97. style="color: #888888;justify-content: flex-start; padding: 10rpx 0 10rpx 0;">
  98. <!-- <u-avatar :src="item.userImg?item.userImg:'/static/icon/unlogin.png'" size="56">
  99. </u-avatar>
  100. <text class="margin-left-10">{{item.username || '暂无信息'}}</text> -->
  101. <rich-text class="desc text-cut-2" style="max-height: 80rpx;" :nodes="decodeURIComponent(item.content)">
  102. </rich-text>
  103. </view>
  104. <view class="flex justify-between">
  105. <view class="hot-value center" style="justify-content: flex-start;">
  106. <text class="cuIcon-hotfill text-base" style="font-size: 32rpx;"></text>
  107. <text style="padding-left: 4rpx;">{{item.voteCount}}</text>
  108. </view>
  109. <button
  110. @click.stop="$jump('/pages/activity/activityDetail?id='+item.id+'&isCustomBack=false')"
  111. class="cu-btn round bg-base sm text-white"
  112. style="padding: 20rpx 38rpx;margin-bottom: 30rpx;">
  113. <text>去投票</text>
  114. </button>
  115. </view>
  116. </view>
  117. </view>
  118. </view>
  119. </view>
  120. </block>
  121. </mescroll-body>
  122. </view>
  123. <home-btn></home-btn>
  124. </view>
  125. </template>
  126. <script>
  127. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  128. import back from '@/components/back.vue'
  129. export default {
  130. mixins: [MescrollMixin],
  131. components: {
  132. back
  133. },
  134. data() {
  135. return {
  136. isH5: false,
  137. downOption: {
  138. auto: false
  139. },
  140. upOption: {
  141. auto: false,
  142. use: true
  143. },
  144. navbarShow: false,
  145. rankList: [],
  146. //搜索关键字
  147. keyword: '',
  148. activeId: '',
  149. }
  150. },
  151. onPageScroll(res) {
  152. if (res.scrollTop > 40) {
  153. this.navbarShow = true
  154. } else {
  155. this.navbarShow = false
  156. }
  157. },
  158. onLoad(options) {
  159. this.activeId = options.activeId
  160. // #ifdef MP-WEIXIN
  161. this.mescroll.resetUpScroll();
  162. // #endif
  163. // #ifdef H5
  164. this.getActivityParams();
  165. this.isH5 = true
  166. //h5端要延时才能获取到mescroll对象
  167. setTimeout(() => {
  168. this.mescroll.resetUpScroll();
  169. }, 20)
  170. // #endif
  171. },
  172. computed:{
  173. rankBgImg(){
  174. if (this.$isEmpty(this.vuex_theme.rankBgImg)) {
  175. return 'background-image: url(https://guosen-bucket-ldt.obs.cn-south-1.myhuaweicloud.com:443/4872ea85f7e74a75a920135ce1384262-bg.png)'
  176. }
  177. return 'background-image: url('+this.vuex_theme.rankBgImg+')'
  178. }
  179. },
  180. methods: {
  181. /**
  182. * 获取活动参数
  183. */
  184. async getActivityParams() {
  185. if(this.$isNotEmpty(this.vuex_active_setting)&&this.$isNotEmpty(this.vuex_active_setting.shareParam)){ //有缓存直接从缓存获取
  186. this.vuex_active_setting.shareParam.link = window.location.href
  187. this.$shareConfig.H5Share(this.vuex_active_setting.shareParam)
  188. }else{
  189. let params = {
  190. activeId: this.activeId,
  191. platformSettingEnum: 'ACTIVE_SETTING'
  192. }
  193. let activeSetting = JSON.parse((await this.$api.platform.getPlatformValue(params)).data.data);
  194. if (this.$isNotEmpty(activeSetting.shareParam)) {
  195. let shareParam=activeSetting.shareParam
  196. shareParam.link=window.location.href
  197. this.$shareConfig.H5Share(shareParam)
  198. }
  199. activeSetting.defaultActiveId = this.activeId
  200. this.$u.vuex('vuex_active_setting', activeSetting);
  201. }
  202. },
  203. downCallback() {
  204. setTimeout(() => {
  205. this.mescroll.resetUpScroll();
  206. }, 1000)
  207. },
  208. async upCallback(mescroll) {
  209. try {
  210. let params = {
  211. current: mescroll.num,
  212. size: mescroll.size,
  213. activeId: this.activeId
  214. }
  215. this.$api.activity.sortListQuery(params).then(res => {
  216. let data = res.data.data.records
  217. let total = res.data.data.total
  218. mescroll.endBySize(data.length, total);
  219. if (mescroll.num == 1) this.rankList = []; //如果是第一页需手动制空列表
  220. this.rankList = this.rankList.concat(data); //追加新数据
  221. })
  222. } catch (e) {
  223. console.error(e);
  224. this.mescroll.endErr()
  225. }
  226. },
  227. searchWorks(value) {
  228. this.$api.activity.searchWork(value).then(res => {
  229. this.rankList = res.data.data;
  230. })
  231. },
  232. customBack() {
  233. uni.switchTab({
  234. url: "/pages/index/home"
  235. })
  236. }
  237. }
  238. }
  239. </script>
  240. <style lang="scss" scoped>
  241. .marginTop {
  242. margin-top: -80rpx;
  243. }
  244. .search {
  245. margin-top: -60upx;
  246. width: 80%;
  247. border-radius: 50upx;
  248. line-height: 60upx;
  249. background-color: #FFFFFF;
  250. display: flex;
  251. justify-content: center;
  252. align-items: center;
  253. color: #9D9D9D;
  254. font-size: 20upx;
  255. }
  256. .title {
  257. font-size: 52upx;
  258. font-family: PingFang SC;
  259. font-weight: 800;
  260. color: #FFFFFF;
  261. }
  262. .container {
  263. .left {
  264. padding-left: 20upx;
  265. .name {
  266. font-size: 32upx;
  267. font-family: PingFang SC;
  268. font-weight: 800;
  269. color: #333;
  270. }
  271. .hot-value {
  272. font-size: 24upx;
  273. font-family: PingFang SC;
  274. font-weight: 400;
  275. color: #353535;
  276. }
  277. }
  278. .right {
  279. text-align: center;
  280. padding-right: 10upx;
  281. .rank {
  282. height: 70%;
  283. font-size: 36upx;
  284. font-family: PingFang SC;
  285. font-weight: 800;
  286. font-style: italic;
  287. }
  288. }
  289. }
  290. .music {
  291. .name {
  292. font-size: 30upx;
  293. font-family: PingFang SC;
  294. font-weight: 400;
  295. color: #000000;
  296. }
  297. .author {
  298. font-size: 14upx;
  299. font-family: PingFang SC;
  300. font-weight: 400;
  301. color: #9A9A9A;
  302. }
  303. .hot-vaule {
  304. margin-top: 10upx;
  305. font-size: 14upx;
  306. font-family: PingFang SC;
  307. font-weight: 400;
  308. color: #3F372A;
  309. }
  310. }
  311. .lines-purple::after {
  312. border-color: #5a3ee8;
  313. }
  314. .lines-purple {
  315. color: #5a3ee8;
  316. }
  317. </style>