course.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <view style="height: 100%; background: #F8F9FA;">
  3. <van-tabs :active="active" color="#C29556" title-active-color="#C29556" :duration="0.2" :ellipsis="false" @change="onTabChange" >
  4. <van-tab v-for="(item, index) in courseTypeList" :key="index" :name="item.id" :title="item.name">
  5. <view class="common-page" >
  6. <view class="huodong-ccontent" v-for="(item2, index2) in courseList" :key="index2" @click="toDetail(item2)" v-if="active==index" >
  7. <view class="huodong-ccontent-img">
  8. <van-image
  9. class="huodongText2-img"
  10. height="264rpx"
  11. :src="item2.cover"
  12. width="650rpx"
  13. />
  14. </view>
  15. <view class="course-content">
  16. <view class="course-title">{{item2.goods_name}}</view>
  17. <view class="course-date">
  18. <view style="padding-top: 7rpx;width:28rpx;height: 28rpx ">
  19. <van-image
  20. class="huodongText2-img"
  21. height="28rpx"
  22. src="/static/miaoshu.png"
  23. width="28rpx"
  24. style="display: flex;"
  25. />
  26. </view>
  27. <span style="padding: 0 16rpx">{{item2.remark}}</span>
  28. </view>
  29. <view class="course-price" style="position: relative;">
  30. <view style="padding-top: 8rpx;width:28rpx;height: 28rpx ">
  31. <van-image
  32. class="huodongText2-img"
  33. height="28rpx"
  34. src="/static/baoming.png"
  35. width="28rpx"
  36. style="display: flex;"
  37. />
  38. </view>
  39. <span style="padding-left: 16rpx">已报名 &nbsp;{{item2.stock_sales}}</span>
  40. <span style="position: absolute;right:20rpx;font-size: 22rpx;color:#333333;">¥<span style="font-size: 32rpx;font-weight: bold;">{{item2.price_selling}}</span></span>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </van-tab>
  46. </van-tabs>
  47. <van-toast id="van-toast"/>
  48. </view>
  49. </template>
  50. <script>
  51. import {
  52. getGoodList,getGoodCate
  53. } from "@/common/api/good.js";
  54. import Toast from "../../wxcomponents/vant/dist/toast/toast";
  55. export default {
  56. components: {
  57. },
  58. data() {
  59. return {
  60. page: 1,
  61. pageSize: 9999,
  62. active: 0,
  63. courseTypeList: [],
  64. courseList: [],
  65. GoodCateId:0,
  66. };
  67. },
  68. onLoad: function(option) {
  69. const type = option.type || 0;
  70. this.active = type * 1;
  71. this.getGoodCate();
  72. this.getGoodList();
  73. console.log(this.courseTypeList);
  74. },
  75. onShow() {
  76. this.$nextTick(() => {});
  77. },
  78. onReachBottom() {},
  79. onShareAppMessage(res) {
  80. let configs = uni.getStorageSync('configs') || {};
  81. return {
  82. title: configs.shop_share_title,
  83. imageUrl: configs.shop_share_img,
  84. path: `/subPages/course/course`
  85. };
  86. },
  87. onShareTimeline(res) {
  88. let configs = uni.getStorageSync('configs') || {};
  89. return {
  90. title: configs.shop_share_title,
  91. imageUrl: configs.shop_share_img,
  92. path: `/subPages/course/course`
  93. };
  94. },
  95. computed: {},
  96. watch: {},
  97. methods: {
  98. getGoodCate() {
  99. getGoodCate({ mark:"课程商品" }).then(({ data }) => {
  100. this.courseTypeList = data;
  101. });
  102. },
  103. toDetail(item) {
  104. console.log("跳转到详情页");
  105. uni.navigateTo({url: `/subPages/courseDetail/courseDetail?goods_code=${item.code}`,})
  106. },
  107. getGoodList() {
  108. getGoodList({ page: this.page, pageSize: this.pageSize, cateid: this.GoodCateId, mark:"课程商品" }).then(({ data }) => {
  109. this.courseList =data.list
  110. console.log(data);
  111. });
  112. },
  113. leftClick() {
  114. uni.switchTab({
  115. url: '/pages/home/index'
  116. });
  117. },
  118. onTabChange(event) {
  119. console.log(event.detail)
  120. this.active = event.detail.index; // 更新 active 的值
  121. this.GoodCateId = event.detail.name; // 更新 active 的值
  122. this.getGoodList();
  123. }
  124. },
  125. };
  126. </script>
  127. <style lang="scss" scoped>
  128. .common-page {
  129. height: 100%;
  130. padding: 30rpx;
  131. }
  132. .huodong-ccontent {
  133. position: relative; /* 相对定位 */
  134. width: 690rpx;
  135. padding: 0rpx;
  136. margin:0 auto;
  137. margin-bottom: 30rpx;
  138. background: #FFFFFF;
  139. padding-bottom: 20rpx;
  140. border-radius: 16rpx 16rpx 16rpx 16rpx;
  141. .huodong-ccontent-img{
  142. height: 284rpxrpx;
  143. width: 690rpx;
  144. padding-top: 20rpx;
  145. padding-left: 20rpx;
  146. }
  147. }
  148. .course-content {
  149. margin: 30rpx 0rpx 0rpx 30rpx;
  150. .course-title {
  151. font-family: PingFang SC, PingFang SC;
  152. font-weight: 400;
  153. font-size: 28rpx;
  154. color: #333333;
  155. line-height: 40rpx;
  156. text-align: left;
  157. font-style: normal;
  158. text-transform: none;
  159. font-weight: bold;
  160. margin-bottom: 16rpx;
  161. }
  162. .course-date {
  163. font-family: 苹方, 苹方;
  164. font-size: 26rpx;
  165. color: #666666;
  166. line-height: 40rpx;
  167. text-align: left;
  168. font-style: normal;
  169. text-transform: none;
  170. font-weight: 400;
  171. margin-bottom: 10rpx;
  172. display: flex;
  173. }
  174. .course-price {
  175. height: 44rpx;
  176. font-weight: 400;
  177. font-size: 24rpx;
  178. color: #666666;
  179. line-height: 40rpx;
  180. text-align: left;
  181. font-style: normal;
  182. text-transform: none;
  183. display: flex;
  184. //align-items: center;
  185. }
  186. }
  187. /* 分割线样式 */
  188. .separator {
  189. height: 1px;
  190. background-color: #e0e0e0;
  191. margin: 20rpx 0;
  192. }
  193. /* 定义 CSS 变量 */
  194. :root {
  195. --nav-bar-icon-color: black;
  196. --nav-bar-arrow-size: 16px;
  197. --tab-font-size: 28rpx;
  198. }
  199. /* 确保 van-nav-bar 内部的内容能够正确适应新的高度 */
  200. /deep/ .van-nav-bar__title {
  201. font-family: PingFang SC, PingFang SC !important;
  202. font-weight: 400 !important;
  203. font-size: 36rpx !important;
  204. color: #333333 !important;
  205. text-align: center;
  206. // 加粗
  207. // font-weight: bold;
  208. }
  209. /deep/ .van-nav-bar__content {
  210. text-align: center;
  211. }
  212. /* 添加 van-tab 标题的字体大小样式 */
  213. /deep/ .van-tab__text {
  214. font-family: PingFang SC, PingFang SC;
  215. font-weight: 400;
  216. font-size: 28rpx;
  217. }
  218. </style>