goodsItemVertical.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view class="vertical-goods-itembox">
  3. <view class="choose" @click.stop="handleChoose" v-show="isOperate">
  4. <image src="@/static/image/hall/choose_icon.png" v-show="item.checked"></image>
  5. <image src="@/static/image/hall/choose_moren_icon.png" v-show="!item.checked"></image>
  6. </view>
  7. <view class="vertical-goods-item" @click="$navTo('../info?courseId='+item.courseId)">
  8. <image class="vertical-goods-item-image" :src="item.imgUrl" :lazy-load="true" mode="aspectFill"></image>
  9. <view class="vertical-goods-item-info">
  10. <text class=" vertical-goods-item-name textOne">{{item.courseName}}</text>
  11. <text class="vertical-goods-item-desc">{{item.description}}</text>
  12. <view class="vertical-goods-item-buyinfo">{{ formatNum(item.favoriteNum) }}人收藏</view>
  13. <view class="vertical-goods-item-footer">
  14. <view class="price-box">
  15. <!-- <text class="price-box-unit">¥</text>
  16. <text class="price-box-integer">300</text>
  17. <text class="price-box-decimal">.00</text>
  18. <text class="price-box-text">/日</text> -->
  19. <image class="price-box-imgEye" src="@/static/image/hall/icon_eyes.png"></image>
  20. <text class="text">{{ formatNum(item.likes) }}</text>
  21. <image class="price-box-imgZan" src="@/static/image/hall/zan_icon.png"></image>
  22. <text class="text">{{ formatNum(item.views) }}</text>
  23. </view>
  24. <view class="vertical-goods-item-footer-r" :style="{visibility: isOperate ? 'hidden':'visible'}">
  25. <view v-show="showCollect">
  26. <image src="@/static/image/liveStream/collect_orange_icon.png"></image>
  27. </view>
  28. <view class="gobuy-btn" @click.stop="canCalFav(item)">取消收藏</view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import { doFavorite } from '@/api/course'
  37. export default {
  38. props: {
  39. // 是否展示收藏
  40. showCollect: {
  41. type: Boolean,
  42. default: true
  43. },
  44. // 是否可以对其操作
  45. isOperate: {
  46. type: Boolean,
  47. default: false
  48. },
  49. item: {
  50. type: Object,
  51. default() {
  52. return { imgUrl:"",isIntegral:-1 };
  53. }
  54. },
  55. index: {
  56. type: Number,
  57. default: -1
  58. },
  59. },
  60. data() {
  61. return {
  62. }
  63. },
  64. methods: {
  65. handleChoose() {
  66. this.$emit("handleChoose",this.index);
  67. },
  68. canCalFav(item) {
  69. item.index=this.index;
  70. this.$emit("canCalFav",item);
  71. },
  72. formatNum(num){
  73. if(num>10000){
  74. return (num/10000.0).toFixed(1)+"万";
  75. }
  76. return num;
  77. },
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. @mixin u-flex($flexD, $alignI, $justifyC) {
  83. display: flex;
  84. flex-direction: $flexD;
  85. align-items: $alignI;
  86. justify-content: $justifyC;
  87. }
  88. .vertical-goods-itembox {
  89. width: 100%;
  90. padding: 20rpx 16rpx;
  91. box-sizing: border-box;
  92. background: #FFFFFF;
  93. border-radius: 16rpx 16rpx 16rpx 16rpx;
  94. overflow: hidden;
  95. @include u-flex(row, center , flex-start);
  96. .choose {
  97. margin-right: 20rpx;
  98. image{
  99. width: 36rpx;
  100. height: 36rpx;
  101. flex-shrink: 0;
  102. }
  103. }
  104. }
  105. .vertical-goods-item {
  106. flex: 1;
  107. @include u-flex(row, center , flex-start);
  108. font-family: PingFang SC, PingFang SC;
  109. font-weight: 400;
  110. overflow: hidden;
  111. &-image {
  112. width: 230rpx;
  113. height: 129rpx;
  114. margin-right: 24rpx;
  115. flex-shrink: 0;
  116. background: #FFFFFF;
  117. border-radius: 16rpx 16rpx 16rpx 16rpx;
  118. overflow: hidden;
  119. }
  120. &-info {
  121. flex: 1;
  122. @include u-flex(column, flex-start , flex-start);
  123. overflow: hidden;
  124. }
  125. &-name {
  126. width: 100%;
  127. font-weight: 500;
  128. font-size: 28rpx;
  129. color: #000000;
  130. margin-bottom: 10rpx;
  131. }
  132. &-desc {
  133. width: 100%;
  134. font-size: 24rpx;
  135. color: #999999;
  136. margin-bottom: 20rpx;
  137. display: -webkit-box;
  138. -webkit-line-clamp: 2; /* 显示的行数 */
  139. -webkit-box-orient: vertical; /* 内容会垂直堆叠 */
  140. overflow: hidden; /* 隐藏溢出的内容 */
  141. text-overflow: ellipsis; /* 当内容被裁剪时显示省略号 */
  142. }
  143. &-buyinfo {
  144. width: 100%;
  145. font-size: 22rpx;
  146. color: #E69A22;
  147. margin-bottom: 8rpx;
  148. }
  149. &-footer {
  150. width: 100%;
  151. @include u-flex(row, center , space-between);
  152. .price-box {
  153. font-family: Roboto, Roboto;
  154. font-weight: bold;
  155. font-size: 36rpx;
  156. display: flex;
  157. align-items: center;
  158. color: #FF5C03;
  159. &-unit {
  160. font-weight: 600;
  161. font-size: 20rpx;
  162. }
  163. &-integer {
  164. font-size: 36rpx;
  165. }
  166. &-decimal {
  167. font-weight: 600;
  168. font-size: 26rpx;
  169. }
  170. &-text {
  171. font-family: PingFang SC, PingFang SC;
  172. font-weight: 500;
  173. font-size: 22rpx;
  174. }
  175. .buynum {
  176. font-weight: 400;
  177. font-size: 22rpx;
  178. color: #757575;
  179. line-height: 22rpx;
  180. margin-left: 16rpx;
  181. }
  182. &-imgEye {
  183. width: 32rpx;
  184. height: 22rpx;
  185. margin-right: 8rpx;
  186. flex-shrink: 0;
  187. }
  188. &-imgZan{
  189. width: 32rpx;
  190. height: 32rpx;
  191. margin-left: 8rpx;
  192. margin-right: 8rpx;
  193. flex-shrink: 0;
  194. }
  195. }
  196. .gobuy-btn {
  197. width: 142rpx;
  198. height: 56rpx;
  199. background: linear-gradient( 270deg, #FF5C03 0%, #FFAC64 100%);
  200. border-radius: 0rpx 8rpx 8rpx 0rpx;
  201. font-family: PingFang SC, PingFang SC;
  202. font-weight: 500;
  203. font-size: 26rpx;
  204. color: #FFFFFF;
  205. line-height: 56rpx;
  206. text-align: center;
  207. }
  208. &-r {
  209. height: 56rpx;
  210. flex-shrink: 0;
  211. @include u-flex(row, center , flex-start);
  212. image {
  213. width: 32rpx;
  214. height: 32rpx;
  215. margin-right: 20rpx;
  216. }
  217. }
  218. .text{
  219. font-family: PingFang SC, PingFang SC;
  220. font-weight: 400;
  221. font-size: 24rpx;
  222. color: #999999;
  223. }
  224. }
  225. }
  226. </style>