index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <template>
  2. <view class="activity-page">
  3. <u-navbar title="" :autoBack="true" :bgColor="bgColor" leftIconColor="#222222 "></u-navbar>
  4. <image class="bg_dance" src="/static/images/enter/activity/bg_dance.png" mode=""></image>
  5. <view class="header-bg">
  6. <view class="header-content u-f u-f-jsb">
  7. <view class="left-info">
  8. <view class="title">广场舞大赛</view>
  9. <view class="vote-info">
  10. <text>剩余票数:{{remainingVotes}}</text>
  11. <text class="es-ml-24">已投票数:{{votedCount}}</text>
  12. </view>
  13. <view class="join-btn u-f-ajc" @click="goMyTeam">
  14. <view class="es-mr-8">{{joinShow?'我的队伍':'立即参与'}}</view>
  15. <view class="u-f-ajc">
  16. <image src="/static/images/enter/activity/icon_more.png" class="es-icon-32 rightIcon"
  17. mode="">
  18. </image>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="right-img">
  23. <image src="/static/images/enter/activity/img_wangguan.png" mode="aspectFit"></image>
  24. </view>
  25. </view>
  26. <view class="search-box">
  27. <u-input v-model="workName" placeholder="搜索作品名称/关键字" border="none" shape="circle" prefixIcon="search"
  28. @confirm="onSearch" clearable @clear="onSearch"></u-input>
  29. </view>
  30. </view>
  31. <view class="content-box">
  32. <view class="tabs u-f">
  33. <view v-for="(tab, index) in tabs" :key="index" class="tab-item" :class="{active: currentTab === index}"
  34. @click="switchTab(index)">
  35. {{tab}}
  36. <view class="line" v-if="currentTab === index"></view>
  37. </view>
  38. </view>
  39. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
  40. :down="downOption" :up="upOption">
  41. <view class="work-list">
  42. <view class="work-item" v-for="(item, index) in dataList" :key="index">
  43. <video v-if="item.videoShow" :src="item.videoUrl" class="work-cover" object-fit="cover"
  44. :show-center-play-btn="false"></video>
  45. <image @tap="changeFun(index)" v-else :src="item.coverUrl" mode="aspectFill" class="work-cover">
  46. </image>
  47. <view class="work-info">
  48. <view class="work-title ellipsis">{{item.workName}}</view>
  49. <view class="u-f u-f-jsb u-f-ac">
  50. <view class="vote-num">{{item.voteCount}}票</view>
  51. <view class="vote-btn" :class="{voted: item.isVoted}" @click="handleVote(item)">
  52. {{item.isVoted ? '已投' : '投票'}}
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </mescroll-body>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  64. import {
  65. getWorkList,
  66. castVote,
  67. getVoteCont,
  68. getActivityInfo
  69. } from '@/api/activity.js';
  70. export default {
  71. mixins: [MescrollMixin],
  72. data() {
  73. return {
  74. tabs: ['热门作品', '最新作品'],
  75. currentTab: 0,
  76. dataList: [],
  77. downOption: {
  78. auto: false
  79. },
  80. upOption: {
  81. onScroll: false,
  82. auto: true,
  83. page: {
  84. num: 0,
  85. size: 10
  86. },
  87. noMoreSize: 10,
  88. textNoMore: "已经到底了",
  89. empty: {
  90. icon: 'https://zkzh-2025.oss-cn-beijing.aliyuncs.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  91. tip: '暂无数据'
  92. }
  93. },
  94. sortBy: 'hot', //hot-热门 new-最新
  95. workName: '',
  96. remainingVotes: 100,
  97. votedCount: 12,
  98. joinShow: false, //是否组队
  99. bgColor: 'transparent',
  100. }
  101. },
  102. onLoad() {
  103. this.getVoteContFun()
  104. this.getActivityInfoFun()
  105. },
  106. onPageScroll(e) {
  107. if (e.scrollTop > 20) {
  108. this.bgColor = '#ffefef'
  109. } else {
  110. this.bgColor = 'transparent'
  111. }
  112. },
  113. methods: {
  114. changeFun(index) {
  115. this.dataList[index].videoShow = true
  116. },
  117. async getActivityInfoFun() {
  118. const res = await getActivityInfo({
  119. activityId: getApp().globalData.activityId
  120. })
  121. if (res.code == 200) {
  122. this.joinShow = true
  123. }
  124. },
  125. goMyTeam() {
  126. let url = '/pages_enter/activity/detail'
  127. // if (this.joinShow) {
  128. // url = '/pages_enter/activity/team'
  129. // }
  130. uni.navigateTo({
  131. url: url
  132. });
  133. },
  134. onSearch() {
  135. this.mescroll.resetUpScroll();
  136. },
  137. handleJoin() {
  138. uni.navigateTo({
  139. url: '/pages_enter/activity/detail'
  140. });
  141. },
  142. switchTab(index) {
  143. this.currentTab = index;
  144. this.mescroll.resetUpScroll();
  145. },
  146. upCallback(page) {
  147. const params = {
  148. activityId: getApp().globalData.activityId,
  149. status: 1,
  150. sortBy: this.currentTab === 0 ? 'hot' : 'new',
  151. workName: this.workName,
  152. pageNum: page.num,
  153. pageSize: page.size
  154. };
  155. getWorkList(params).then(res => {
  156. if (res.code === 200) {
  157. let curList = res.data.list || [];
  158. if (page.num === 1) this.dataList = [];
  159. curList = curList.map(item => {
  160. return {
  161. ...item,
  162. videoShow: false
  163. }
  164. })
  165. this.dataList = this.dataList.concat(curList);
  166. this.mescroll.endBySize(this.dataList.length, res.data.total);
  167. } else {
  168. this.mescroll.endErr();
  169. }
  170. }).catch(() => {
  171. this.mescroll.endErr();
  172. this.mescroll.endSuccess(this.dataList.length);
  173. });
  174. },
  175. handleVote(item) {
  176. if (item.isVoted) return;
  177. let params = {
  178. workId: item.id,
  179. activityId: getApp().globalData.activityId,
  180. ipAddress: ""
  181. }
  182. castVote(params).then(res => {
  183. if (res.code === 200) {
  184. item.isVoted = true;
  185. item.voteCount++;
  186. this.getVoteContFun()
  187. uni.showToast({
  188. title: '投票成功',
  189. icon: 'success'
  190. });
  191. } else {
  192. uni.showToast({
  193. icon: 'none',
  194. title: res.msg
  195. })
  196. }
  197. });
  198. },
  199. async getVoteContFun() {
  200. const res = await getVoteCont({activityId:getApp().globalData.activityId})
  201. if (res.code === 200) {
  202. this.votedCount = res.data.todayCurrVoteCount || 0
  203. let todayMaxCount = res.data.todayMaxCount || 0
  204. this.remainingVotes = (todayMaxCount - this.votedCount) || 0
  205. } else {
  206. uni.showToast({
  207. icon: 'none',
  208. title: res.msg
  209. })
  210. }
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="scss" scoped>
  216. .activity-page {
  217. min-height: 100vh;
  218. background-color: #f8f8f8;
  219. background: linear-gradient(0deg, rgba(255, 255, 255, 0.63) 0%, #F7F8FA 100%);
  220. }
  221. .bg_dance {
  222. width: 100%;
  223. position: absolute;
  224. top: 0;
  225. left: 0;
  226. z-index: 0;
  227. height: 530rpx;
  228. }
  229. .header-bg {
  230. height: 480rpx;
  231. padding: 120rpx 40rpx 0;
  232. position: relative;
  233. z-index: 1;
  234. .header-content {
  235. align-items: flex-start;
  236. }
  237. .left-info {
  238. .title {
  239. font-size: 56rpx;
  240. font-weight: bold;
  241. color: #8B1010;
  242. margin-bottom: 22rpx;
  243. }
  244. .vote-info {
  245. font-size: 26rpx;
  246. color: #8B1010;
  247. margin-bottom: 24rpx;
  248. }
  249. .join-btn {
  250. // display: inline-flex;
  251. // align-items: center;
  252. // padding: 12rpx 36rpx;
  253. background-image: url('/static/images/enter/activity/btn.png');
  254. background-size: 100% 100%;
  255. background-repeat: no-repeat;
  256. // background: linear-gradient(90deg, #FF7F50, #FF1493);
  257. // border-radius: 40rpx;
  258. font-size: 28rpx;
  259. color: #FFFFFF;
  260. width: 275rpx;
  261. height: 64rpx;
  262. line-height: 64rpx;
  263. align-items: center;
  264. // font-size: 28rpx;
  265. // box-shadow: 0 4rpx 12rpx rgba(255, 20, 147, 0.3);
  266. }
  267. }
  268. .right-img {
  269. width: 260rpx;
  270. height: 260rpx;
  271. margin-top: -30rpx;
  272. image {
  273. width: 100%;
  274. height: 100%;
  275. }
  276. }
  277. .search-box {
  278. margin-top: 40rpx;
  279. background-color: #fff;
  280. border-radius: 40rpx;
  281. padding: 4rpx 24rpx;
  282. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.05);
  283. }
  284. }
  285. .content-box {
  286. margin-top: 0;
  287. background-color: #fff;
  288. border-radius: 40rpx 40rpx 0 0;
  289. padding: 40rpx 30rpx;
  290. min-height: calc(100vh - 480rpx);
  291. .tabs {
  292. justify-content: space-around;
  293. margin-bottom: 40rpx;
  294. background-color: #fff;
  295. .tab-item {
  296. font-size: 32rpx;
  297. color: #666;
  298. position: relative;
  299. padding-bottom: 10rpx;
  300. &.active {
  301. color: #333;
  302. font-weight: bold;
  303. }
  304. .line {
  305. position: absolute;
  306. bottom: 0;
  307. left: 50%;
  308. transform: translateX(-50%);
  309. width: 40rpx;
  310. height: 6rpx;
  311. background-color: #FF4500;
  312. border-radius: 4rpx;
  313. }
  314. }
  315. }
  316. }
  317. .work-list {
  318. display: grid;
  319. grid-template-columns: repeat(2, 1fr);
  320. gap: 24rpx;
  321. }
  322. .work-item {
  323. background-color: #fff;
  324. border-radius: 20rpx;
  325. overflow: hidden;
  326. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.05);
  327. .work-cover {
  328. width: 100%;
  329. height: 240rpx;
  330. background-color: #eee;
  331. }
  332. .work-info {
  333. padding: 20rpx;
  334. .work-title {
  335. font-size: 28rpx;
  336. font-weight: 500;
  337. color: #333;
  338. margin-bottom: 20rpx;
  339. }
  340. .vote-num {
  341. font-size: 24rpx;
  342. color: #999;
  343. }
  344. .vote-btn {
  345. padding: 8rpx 24rpx;
  346. background-color: #FF4D4F;
  347. color: #fff;
  348. font-size: 24rpx;
  349. border-radius: 30rpx;
  350. }
  351. .voted {
  352. background-color: #CFCFCF;
  353. }
  354. }
  355. }
  356. </style>