goodsList.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view>
  3. <view v-for="(item,index) in treatmentPackage" :key="index">
  4. <view class="goodsitem">
  5. <view class="goodsitem-img">
  6. <image :src="item.images" mode="aspectFill" style="height: 100%;width: 100%"></image>
  7. <view class="goodsitem-hot" v-if="hasHotSaleTag(item) && getHotCount(item) > 0">
  8. <image style="height: 56rpx;" src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/class/remai.png" mode="heightFix"></image>
  9. <text class="goodsitem-hot-count">{{ getHotCount(item) }}</text>
  10. </view>
  11. <!-- <view class="goodsitem-status">讲解中</view> -->
  12. </view>
  13. <view class="goodsitem-r">
  14. <view>
  15. <view class="goodsitem-title" :style="{ fontSize: fontSize(32)}">{{item.productName}}</view>
  16. <view class="goodsitem-desc ellipsis2" :style="{ fontSize: fontSize(30)}">{{item.secondName}}</view>
  17. </view>
  18. <view class="goodsitem-btnbox" @click="goBuy(item)">
  19. <view class="goodsitem-price">
  20. <view class="unit">¥</view>
  21. <text class="price">{{item.price&&item.price.toFixed(2)}}</text>
  22. </view>
  23. <view class="btn">去购买</view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view v-if="treatmentPackage.length==0">
  29. <view class="empty">
  30. <text>~暂无更多~</text>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import { getJumpStoreAppId } from "../api/courseAuto.js"
  37. import {loginByMiniApp} from "@/api/courseLook.js"
  38. import { hasHotSaleTag, getProductHotKey, clampHotSaleCount } from '../utils/productHotSale.js'
  39. export default {
  40. props: {
  41. treatmentPackage: {
  42. type: Array,
  43. default: () => [],
  44. },
  45. urlOption: [Object, String],
  46. source: String,
  47. hotCountMap: {
  48. type: Object,
  49. default: () => ({}),
  50. },
  51. },
  52. data() {
  53. return {
  54. list: [],
  55. }
  56. },
  57. computed: {
  58. fontSize() {
  59. return size=>{
  60. const value = uni.upx2px(size)
  61. const scale = uni.getStorageSync('fontScale') || 1;
  62. if(scale<1){
  63. return value + 'px';
  64. }else {
  65. return value * scale + 'px';
  66. }
  67. }
  68. }
  69. },
  70. methods: {
  71. hasHotSaleTag(item) {
  72. return hasHotSaleTag(item)
  73. },
  74. getHotCount(item) {
  75. if (!hasHotSaleTag(item)) return 0
  76. const key = getProductHotKey(item)
  77. return key ? clampHotSaleCount(this.hotCountMap[key]) : 0
  78. },
  79. goBuy(item) {
  80. //let data = uni.getStorageSync('urlInfo')
  81. uni.navigateTo({
  82. url: '/pages/shopping/productDetails?productId='+item.productId+'&companyId='+this.urlOption.companyId+ '&companyUserId='+this.urlOption.companyUserId+'&courseId='+this.urlOption.courseId+'&videoId='+this.urlOption.videoId
  83. +'&projectId='+(this.urlOption.projectId || '')+'&periodId='+ (this.urlOption.periodId || '')
  84. })
  85. },
  86. goBuy2(item) {
  87. if(item.type==3) {
  88. // 跳转商城
  89. const param = {
  90. type: item.type
  91. }
  92. getJumpStoreAppId(param,this.source).then(res=>{
  93. if(res.code==200) {
  94. if(getApp().globalData.appId == res.msg) {
  95. uni.navigateTo({
  96. url: '/pages/shopping/productDetails?productId='+item.packageId+'&companyId='+this.urlOption.companyId+ '&companyUserId='+this.urlOption.companyUserId
  97. })
  98. } else {
  99. uni.navigateToMiniProgram({
  100. appId: res.msg,
  101. path: '/pages/shopping/productDetails?productId='+item.packageId+'&companyId='+this.urlOption.companyId+ '&companyUserId='+this.urlOption.companyUserId
  102. })
  103. }
  104. }
  105. })
  106. } else {
  107. uni.navigateTo({
  108. url: '/pages_index/packageDetails?packageId='+item.packageId+'&companyId='+this.urlOption.companyId+ '&companyUserId='+this.urlOption.companyUserId
  109. })
  110. }
  111. },
  112. }
  113. }
  114. </script>
  115. <style scoped lang="scss">
  116. .empty {
  117. padding: 40rpx 24rpx;
  118. display: flex;
  119. flex-direction: column;
  120. align-items: center;
  121. color: #999;
  122. &-btn {
  123. margin-top: 24rpx;
  124. padding: 20rpx 60rpx;
  125. border-radius: 44rpx 44rpx 44rpx 44rpx;
  126. border: 2rpx solid #FF5C03;
  127. font-family: PingFang SC, PingFang SC;
  128. font-weight: 400;
  129. color: #FF5C03;
  130. }
  131. }
  132. .empty-btn-min {
  133. flex-direction: column;
  134. padding: 8rpx 15rpx !important;
  135. font-size: 28rpx !important;
  136. }
  137. .goodsitem {
  138. display: flex;
  139. padding: 24rpx;
  140. overflow: visible;
  141. min-height: 200rpx;
  142. &-img {
  143. overflow: visible;
  144. flex-shrink: 0;
  145. width: 200rpx;
  146. height: 200rpx;
  147. border-radius: 14rpx;
  148. position: relative;
  149. image {
  150. border-radius: 14rpx;
  151. overflow: hidden;
  152. }
  153. }
  154. &-hot {
  155. position: absolute;
  156. top:0;
  157. left:-20rpx;
  158. z-index: 2;
  159. display: flex;
  160. flex-direction: row;
  161. align-items: center;
  162. height: 40rpx;
  163. }
  164. &-hot-flame {
  165. font-size: 22rpx;
  166. line-height: 1;
  167. margin-right: 4rpx;
  168. }
  169. &-hot-label {
  170. font-size: 22rpx;
  171. font-weight: 600;
  172. color: #FFFFFF;
  173. line-height: 40rpx;
  174. }
  175. &-hot-count {
  176. position: absolute;
  177. left:130rpx;
  178. font-family: PingFangSC, PingFang SC;
  179. font-weight: 600;
  180. font-size: 40rpx;
  181. color: #FFFFFF;
  182. line-height: 56rpx;
  183. text-align: justify;
  184. }
  185. &-status {
  186. position: absolute;
  187. left: 0;
  188. top: 0;
  189. padding: 8rpx 15rpx;
  190. background: #FF5C03;
  191. border-radius: 14rpx 0 14rpx 0;
  192. font-size: 20rpx;
  193. color: #fff;
  194. box-sizing: border-box;
  195. text-align: center;
  196. }
  197. &-r {
  198. flex: 1;
  199. overflow: hidden;
  200. margin-left: 16rpx;
  201. display: flex;
  202. flex-direction: column;
  203. justify-content: space-between;
  204. }
  205. &-title {
  206. font-weight: bold;
  207. // font-size: 32rpx;
  208. color: #191A1B;
  209. overflow: hidden;
  210. text-overflow: ellipsis;
  211. display: -webkit-box;
  212. -webkit-line-clamp: 1;
  213. -webkit-box-orient: vertical;
  214. }
  215. &-desc {
  216. font-family: PingFang SC, PingFang SC;
  217. font-weight: 400;
  218. // font-size: 30rpx;
  219. color: #939599;
  220. margin-top: 20rpx;
  221. }
  222. &-btnbox {
  223. display: flex;
  224. align-items: center;
  225. justify-content: space-between;
  226. .btn {
  227. display: inline-block;
  228. padding: 10rpx 38rpx;
  229. border-radius: 12rpx;
  230. border: 3rpx solid #FF5C03;
  231. font-weight: bold;
  232. // font-size: 30rpx;
  233. color: #FF5C03;
  234. text-align: center;
  235. }
  236. }
  237. .unit {
  238. font-size: 32rpx;
  239. }
  240. &-price {
  241. font-family: Roboto, Roboto;
  242. font-weight: bold;
  243. font-size: 40rpx;
  244. color: #FF5C03;
  245. display: flex;
  246. align-items: flex-end;
  247. }
  248. }
  249. </style>