activity.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <view style="height: 100%; background: #F8F9FA;">
  3. <van-nav-bar
  4. title="活动"
  5. left-arrow
  6. @click-left="leftClick()"
  7. />
  8. <van-tabs :active="active" color="#C29556" title-active-color="#C29556" :duration="0.2" :ellipsis="false" @change="onTabChange" >
  9. <van-tab v-for="(item, index) in activityTypeList" :key="index" :title="item">
  10. <view class="common-page" >
  11. <view class="huodong-ccontent" v-for="(item2, index2) in activityList" :key="index2" @click="toDetail(item2)" v-if="active==index" >
  12. <view :class="[getClass(item2)]" >{{item2.status_text}}</view>
  13. <view class="huodong-ccontent-img">
  14. <van-image
  15. class="huodongText2-img"
  16. height="264rpx"
  17. :src="item2.cover"
  18. width="650rpx"
  19. />
  20. </view>
  21. <view class="activity-content">
  22. <view class="activity-title">{{item2.name}}</view>
  23. <view class="activity-date">
  24. <van-image
  25. class="huodongText2-img"
  26. height="28rpx"
  27. src="/static/huodong-a.png"
  28. width="28rpx"
  29. style="display: flex;align-items: center;"
  30. />
  31. <span style="padding-left: 20rpx">{{item2.start_time}}</span>
  32. </view>
  33. <view class="activity-price">
  34. <van-image
  35. class="huodongText2-img"
  36. height="28rpx"
  37. src="/static/huodong-b.png"
  38. width="28rpx"
  39. style="display: flex;align-items: center;"
  40. />
  41. <span style="padding-left: 20rpx">报名费:<span style="font-size: 32rpx;color: #C29556">¥{{item2.fee}}</span></span>
  42. </view>
  43. <!-- 替换为水平分割线 -->
  44. <div class="horizontal-line"></div>
  45. <view class="activity-stats-and-button">
  46. <view class="activity-stats" v-if="item2.entry_max==0">
  47. 已报名 {{item2.entry_num}} 名额 / 无限制
  48. </view>
  49. <view class="activity-stats" v-if="item2.entry_max!=0">
  50. 已报名 {{item2.entry_num}} 名额 / 共 {{item2.entry_max}} 个名额
  51. </view>
  52. <button class="activity-button" @click.stop="handleRegister(item2)" >立即报名</button>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </van-tab>
  58. </van-tabs>
  59. <tabbarCom current="2"></tabbarCom>
  60. <van-toast id="van-toast"/>
  61. </view>
  62. </template>
  63. <script>
  64. import tabbarCom from "@/components/tabbar/tabbar.vue";
  65. import { getConfigData } from '@/common/api/common.js';
  66. import {getActivityList} from "@/common/api/activity";
  67. export default {
  68. components: {
  69. tabbarCom,
  70. },
  71. data() {
  72. return {
  73. page: 1,
  74. pageSize: 10,
  75. total: 0,
  76. search: "",
  77. sort: "",
  78. cateid: "",
  79. subCateId: '',
  80. sortType: "",
  81. data: [],
  82. active: 0,
  83. activityTypeList: [],
  84. activityList: [],
  85. progressPercentage: 24.01,
  86. progressText: '24.01%',
  87. enrolledCount: 23,
  88. totalSlots: 100,
  89. };
  90. },
  91. onLoad: function(option) {
  92. const type = option.type || 0;
  93. this.active = type * 1;
  94. this.getConfigDatalist();
  95. this.getActivityList();
  96. console.log(this.activityTypeList);
  97. },
  98. onShow() {
  99. this.$nextTick(() => {});
  100. },
  101. onReachBottom() {},
  102. onShareAppMessage(res) {
  103. let configs = uni.getStorageSync('configs') || {};
  104. return {
  105. title: configs.shop_share_title,
  106. imageUrl: configs.shop_share_img,
  107. path: `/pages/activity/activity`
  108. };
  109. },
  110. onShareTimeline(res) {
  111. let configs = uni.getStorageSync('configs') || {};
  112. return {
  113. title: configs.shop_share_title,
  114. imageUrl: configs.shop_share_img,
  115. path: `/pages/activity/activity`
  116. };
  117. },
  118. computed: {},
  119. watch: {},
  120. methods: {
  121. getConfigDatalist() {
  122. getConfigData({ dict_id: 36 }).then(({ data }) => {
  123. this.activityTypeList = data.reverse();
  124. console.log(data);
  125. });
  126. },
  127. toDetail(item) {
  128. console.log("跳转到详情页");
  129. uni.navigateTo({url: `/subPages/activityDetail/activityDetail?activityId=${item.id}`,})
  130. },
  131. getActivityList() {
  132. getActivityList({ page: 1, pageSize: 9999, type: this.active +1}).then(({ data }) => {
  133. this.activityList =data.list
  134. console.log(data);
  135. });
  136. },
  137. leftClick() {
  138. uni.switchTab({
  139. url: '/pages/home/index'
  140. });
  141. },
  142. getClass(row) {
  143. if (row.status == 1||row.status == 4){
  144. return "status-tag-start"
  145. }
  146. return "status-tag"
  147. },
  148. handleRegister(item2) {
  149. uni.navigateTo({url: `/subPages/activityDetail/activitySave?activityId=${ item2.id}`,})
  150. },
  151. onTabChange(event) {
  152. console.log('Tab changed to:', event.detail.index);
  153. this.active = event.detail.index; // 更新 active 的值
  154. this.getActivityList();
  155. }
  156. },
  157. };
  158. </script>
  159. <style lang="scss" scoped>
  160. .common-page {
  161. height: 100%;
  162. padding: 30rpx;
  163. }
  164. .huodong-ccontent {
  165. position: relative; /* 相对定位 */
  166. height: 624rpx;
  167. width: 690rpx;
  168. padding: 0rpx;
  169. margin:0 auto;
  170. margin-bottom: 30rpx;
  171. background: #FFFFFF;
  172. border-radius: 16rpx 16rpx 16rpx 16rpx;
  173. .status-tag{
  174. position: absolute;
  175. top: 0px; /* 距离父级元素顶部20px */
  176. left: 0px; /* 距离父级元素左边20px */
  177. z-index: 1;
  178. width: 120rpx;
  179. height: 40rpx;
  180. background: #E1E1E1;
  181. border-radius: 16rpx 0rpx 16rpx 0rpx;
  182. font-family: 苹方, 苹方;
  183. font-weight: 400;
  184. font-size: 20rpx;
  185. color: #888888;
  186. line-height: 28rpx;
  187. text-align: left;
  188. font-style: normal;
  189. text-transform: none;
  190. display: flex;
  191. align-items: center;
  192. justify-content: center;
  193. }
  194. .status-tag-start{
  195. position: absolute;
  196. top: 0px; /* 距离父级元素顶部20px */
  197. left: 0px; /* 距离父级元素左边20px */
  198. z-index: 1;
  199. width: 120rpx;
  200. height: 40rpx;
  201. background: #C29556;
  202. border-radius: 16rpx 0rpx 16rpx 0rpx;
  203. font-family: 苹方, 苹方;
  204. font-weight: 400;
  205. font-size: 20rpx;
  206. color: #FFFFFF;
  207. line-height: 28rpx;
  208. text-align: left;
  209. font-style: normal;
  210. text-transform: none;
  211. display: flex;
  212. align-items: center;
  213. justify-content: center;
  214. }
  215. .huodong-ccontent-img{
  216. height: 284rpxrpx;
  217. width: 690rpx;
  218. padding-top: 20rpx;
  219. padding-left: 20rpx;
  220. }
  221. }
  222. .activity-content {
  223. margin: 30rpx 0rpx 0rpx 30rpx;
  224. .activity-title {
  225. font-family: PingFang SC, PingFang SC;
  226. font-weight: 400;
  227. font-size: 28rpx;
  228. color: #333333;
  229. line-height: 40rpx;
  230. text-align: left;
  231. font-style: normal;
  232. text-transform: none;
  233. font-weight: bold;
  234. margin-bottom: 10rpx;
  235. }
  236. .activity-date {
  237. height: 44rpx;
  238. font-weight: 400;
  239. font-size: 28rpx;
  240. color: #666666;
  241. line-height: 40rpx;
  242. text-align: left;
  243. font-style: normal;
  244. text-transform: none;
  245. margin-bottom: 10rpx;
  246. display: flex;
  247. align-items: center;
  248. }
  249. .activity-price {
  250. height: 44rpx;
  251. font-weight: 400;
  252. font-size: 24rpx;
  253. color: #666666;
  254. line-height: 40rpx;
  255. text-align: left;
  256. font-style: normal;
  257. text-transform: none;
  258. margin-bottom: 24rpx;
  259. display: flex;
  260. align-items: center;
  261. }
  262. .activity-stats-and-button {
  263. display: flex;
  264. align-items: center;
  265. justify-content: space-between;
  266. height: 128rpx;
  267. }
  268. .activity-stats {
  269. width: 330rpx;
  270. font-size: 24rpx;
  271. color: #666666;
  272. }
  273. .activity-button {
  274. width: 258rpx;
  275. height: 68rpx;
  276. background: linear-gradient( 315deg, #CA9359 0%, #E2B98E 100%);
  277. border-radius: 292rpx 292rpx 292rpx 292rpx;
  278. font-family: PingFang SC, PingFang SC;
  279. font-weight: 400;
  280. font-size: 28rpx;
  281. color: #FFFFFF;
  282. line-height: 36rpx;
  283. text-align: center;
  284. font-style: normal;
  285. text-transform: none;
  286. // 文字垂直居中
  287. display: flex;
  288. align-items: center;
  289. justify-content: center;
  290. }
  291. /* 水平分割线 */
  292. .horizontal-line {
  293. width: 630rpx;
  294. height: 0rpx;
  295. border: 1rpx dashed #DDDDDD;
  296. margin: 20rpx 0 0rpx 0;
  297. }
  298. }
  299. /* 分割线样式 */
  300. .separator {
  301. height: 1px;
  302. background-color: #e0e0e0;
  303. margin: 20rpx 0;
  304. }
  305. /* 定义 CSS 变量 */
  306. :root {
  307. --nav-bar-icon-color: black;
  308. --nav-bar-arrow-size: 16px;
  309. --tab-font-size: 28rpx;
  310. }
  311. /* 确保 van-nav-bar 内部的内容能够正确适应新的高度 */
  312. /deep/ .van-nav-bar__title {
  313. font-family: PingFang SC, PingFang SC !important;
  314. font-weight: 400 !important;
  315. font-size: 36rpx !important;
  316. color: #333333 !important;
  317. text-align: center;
  318. // 加粗
  319. // font-weight: bold;
  320. }
  321. /deep/ .van-nav-bar__content {
  322. text-align: center;
  323. }
  324. /* 添加 van-tab 标题的字体大小样式 */
  325. /deep/ .van-tab__text {
  326. font-family: PingFang SC, PingFang SC;
  327. font-weight: 400;
  328. font-size: 28rpx;
  329. }
  330. </style>