s-goods-column.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  1. <!-- 页面 -->
  2. <template>
  3. <view class="ss-goods-wrap">
  4. <!-- xs卡片:横向紧凑型,一行放两个,图片左内容右边 -->
  5. <view
  6. v-if="size === 'xs'"
  7. class="xs-goods-card ss-flex ss-col-stretch"
  8. :style="[elStyles]"
  9. @tap="onClick"
  10. >
  11. <view v-if="tagStyle.show" class="tag-icon-box">
  12. <image class="tag-icon" :src="sheep.$url.cdn(tagStyle.src || tagStyle.imgUrl)"></image>
  13. </view>
  14. <image
  15. class="xs-img-box"
  16. :src="sheep.$url.cdn(data.image || data.picUrl)"
  17. mode="aspectFit"
  18. ></image>
  19. <view
  20. v-if="goodsFields.title?.show || goodsFields.name?.show || goodsFields.price?.show"
  21. class="xs-goods-content ss-flex-col ss-row-around"
  22. >
  23. <view
  24. v-if="goodsFields.title?.show || goodsFields.name?.show"
  25. class="xs-goods-title ss-line-1"
  26. :style="[{ color: titleColor, width: titleWidth ? titleWidth + 'rpx' : '' }]"
  27. >
  28. {{ data.title || data.name }}
  29. </view>
  30. <!-- 这里是新加的会员价和限时优惠 -->
  31. <view class="iconBox" v-if="data.discountPrice || data.vipPrice || data.reward">
  32. <view class="card" v-if="iconShow">{{ iconShow }}</view>
  33. <view class="card2" v-if="data.reward">{{ data.reward.ruleDescriptions[0] }}</view>
  34. </view>
  35. <!-- 这里是新加的会员价和限时优惠结束 -->
  36. <view
  37. v-if="goodsFields.price?.show"
  38. class="xs-goods-price font-OPPOSANS"
  39. :style="[{ color: goodsFields.price.color }]"
  40. >
  41. <text class="price-unit ss-font-24">{{ priceUnit }}</text>
  42. <text v-if="iconShow == '限时优惠'">{{ fen2yuan(data.discountPrice) }}</text>
  43. <text v-else-if="iconShow == '会员价'">{{ fen2yuan(data.vipPrice) }}</text>
  44. <text v-else>{{
  45. isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price)
  46. }}</text>
  47. </view>
  48. </view>
  49. </view>
  50. <!-- sm卡片:竖向紧凑,一行放三个,图上内容下 -->
  51. <view v-if="size === 'sm'" class="sm-goods-card ss-flex-col" :style="[elStyles]" @tap="onClick">
  52. <view v-if="tagStyle.show" class="tag-icon-box">
  53. <image class="tag-icon" :src="sheep.$url.cdn(tagStyle.src || tagStyle.imgUrl)"></image>
  54. </view>
  55. <image
  56. class="sm-img-box"
  57. :src="sheep.$url.cdn(data.image || data.picUrl)"
  58. mode="aspectFill"
  59. ></image>
  60. <view
  61. v-if="goodsFields.title?.show || goodsFields.name?.show || goodsFields.price?.show"
  62. class="sm-goods-content"
  63. :style="[{ color: titleColor, width: titleWidth ? titleWidth + 'rpx' : '' }]"
  64. >
  65. <view
  66. v-if="goodsFields.title?.show || goodsFields.name?.show"
  67. class="sm-goods-title ss-line-1 ss-m-b-16"
  68. >
  69. {{ data.title || data.name }}
  70. </view>
  71. <!-- 这里是新加的会员价和限时优惠 -->
  72. <view class="iconBox" v-if="data.discountPrice || data.vipPrice || data.reward">
  73. <view class="card" v-if="iconShow">{{ iconShow }}</view>
  74. <view class="card2" v-if="data.reward">{{ data.reward.ruleDescriptions[0] }}</view>
  75. </view>
  76. <!-- 这里是新加的会员价和限时优惠结束 -->
  77. <view
  78. v-if="goodsFields.price?.show"
  79. class="sm-goods-price font-OPPOSANS"
  80. :style="[{ color: goodsFields.price.color }]"
  81. >
  82. <text class="price-unit ss-font-24">{{ priceUnit }}</text>
  83. <text v-if="iconShow == '限时优惠'">{{ fen2yuan(data.discountPrice) }}</text>
  84. <text v-else-if="iconShow == '会员价'">{{ fen2yuan(data.vipPrice) }}</text>
  85. <text v-else>{{
  86. isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price)
  87. }}</text>
  88. </view>
  89. </view>
  90. </view>
  91. <!-- md卡片:竖向,一行放两个,图上内容下 -->
  92. <view v-if="size === 'md'" class="md-goods-card ss-flex-col" :style="[elStyles]" @tap="onClick">
  93. <view v-if="tagStyle.show" class="tag-icon-box">
  94. <image class="tag-icon" :src="sheep.$url.cdn(tagStyle.src || tagStyle.imgUrl)"></image>
  95. </view>
  96. <image
  97. class="md-img-box"
  98. :src="sheep.$url.cdn(data.image || data.picUrl)"
  99. mode="widthFix"
  100. ></image>
  101. <view
  102. class="md-goods-content ss-flex-col ss-row-around ss-p-b-20 ss-p-t-20 ss-p-x-16"
  103. :id="elId"
  104. >
  105. <view
  106. v-if="goodsFields.title?.show || goodsFields.name?.show"
  107. class="md-goods-title ss-line-1"
  108. :style="[{ color: titleColor, width: titleWidth ? titleWidth + 'rpx' : '' }]"
  109. >
  110. {{ data.title || data.name }}
  111. </view>
  112. <view
  113. v-if="goodsFields.subtitle?.show || goodsFields.introduction?.show"
  114. class="md-goods-subtitle ss-m-t-16 ss-line-1"
  115. :style="[{ color: subTitleColor, background: subTitleBackground }]"
  116. >
  117. {{ data.subtitle || data.introduction }}
  118. </view>
  119. <slot name="activity">
  120. <view v-if="data.promos?.length" class="tag-box ss-flex-wrap ss-flex ss-col-center">
  121. <view
  122. class="activity-tag ss-m-r-10 ss-m-t-16"
  123. v-for="item in data.promos"
  124. :key="item.id"
  125. >
  126. {{ item.title }}
  127. </view>
  128. </view>
  129. </slot>
  130. <!-- 这里是新加的会员价和限时优惠 -->
  131. <view class="iconBox" v-if="data.discountPrice || data.vipPrice || data.reward">
  132. <view class="card" v-if="iconShow">{{ iconShow }}</view>
  133. <view class="card2" v-if="data.reward">{{ data.reward.ruleDescriptions[0] }}</view>
  134. </view>
  135. <!-- 这里是新加的会员价和限时优惠结束 -->
  136. <view class="ss-flex ss-col-bottom">
  137. <view
  138. v-if="goodsFields.price?.show"
  139. class="md-goods-price ss-m-t-16 font-OPPOSANS ss-m-r-10"
  140. :style="[{ color: goodsFields.price.color }]"
  141. >
  142. <text class="price-unit ss-font-24">{{ priceUnit }}</text>
  143. <text v-if="iconShow == '限时优惠'">{{ fen2yuan(data.discountPrice) }}</text>
  144. <text v-else-if="iconShow == '会员价'">{{ fen2yuan(data.vipPrice) }}</text>
  145. <text v-else>{{
  146. isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price)
  147. }}</text>
  148. </view>
  149. <view
  150. v-if="
  151. (goodsFields.original_price?.show || goodsFields.marketPrice?.show) &&
  152. (data.original_price > 0 || data.marketPrice > 0)
  153. "
  154. class="goods-origin-price ss-m-t-16 font-OPPOSANS ss-flex"
  155. :style="[{ color: originPriceColor }]"
  156. >
  157. <text class="price-unit ss-font-20">{{ priceUnit }}</text>
  158. <view class="ss-m-l-8">{{ fen2yuan(data.marketPrice) }}</view>
  159. </view>
  160. </view>
  161. <view class="ss-m-t-16 ss-flex ss-col-center ss-flex-wrap">
  162. <view class="sales-text">{{ salesAndStock }}</view>
  163. </view>
  164. </view>
  165. <slot name="cart">
  166. <view class="cart-box ss-flex ss-col-center ss-row-center">
  167. <image class="cart-icon" src="/static/img/shop/tabbar/category2.png" mode="" />
  168. </view>
  169. </slot>
  170. </view>
  171. <!-- lg卡片:横向型,一行放一个,图片左内容右边 -->
  172. <view
  173. v-if="size === 'lg'"
  174. class="lg-goods-card ss-flex ss-col-stretch"
  175. :style="[elStyles]"
  176. @tap="onClick"
  177. >
  178. <view v-if="tagStyle.show" class="tag-icon-box">
  179. <image class="tag-icon" :src="sheep.$url.cdn(tagStyle.src || tagStyle.imgUrl)"></image>
  180. </view>
  181. <view v-if="seckillTag" class="seckill-tag ss-flex ss-row-center">秒杀</view>
  182. <view v-if="grouponTag" class="groupon-tag ss-flex ss-row-center">
  183. <view class="tag-icon">拼团</view>
  184. </view>
  185. <image
  186. class="lg-img-box"
  187. :src="sheep.$url.cdn(data.image || data.picUrl)"
  188. mode="aspectFill"
  189. ></image>
  190. <view class="lg-goods-content ss-flex-1 ss-flex-col ss-row-between ss-p-b-10 ss-p-t-20">
  191. <view>
  192. <view
  193. v-if="goodsFields.title?.show || goodsFields.name?.show"
  194. class="lg-goods-title ss-line-2"
  195. :style="[{ color: titleColor }]"
  196. >
  197. {{ data.title || data.name }}
  198. </view>
  199. <view
  200. v-if="goodsFields.subtitle?.show || goodsFields.introduction?.show"
  201. class="lg-goods-subtitle ss-m-t-10 ss-line-1"
  202. :style="[{ color: subTitleColor, background: subTitleBackground }]"
  203. >
  204. {{ data.subtitle || data.introduction }}
  205. </view>
  206. </view>
  207. <view>
  208. <slot name="activity">
  209. <view v-if="data.promos?.length" class="tag-box ss-flex ss-col-center">
  210. <view class="activity-tag ss-m-r-10" v-for="item in data.promos" :key="item.id">
  211. {{ item.title }}
  212. </view>
  213. </view>
  214. </slot>
  215. <!-- 这里是新加的会员价和限时优惠 -->
  216. <view class="iconBox" v-if="data.discountPrice || data.vipPrice || data.reward">
  217. <view class="card" v-if="iconShow">{{ iconShow }}</view>
  218. <view class="card2" v-if="data.reward">{{ data.reward.ruleDescriptions[0] }}</view>
  219. </view>
  220. <!-- 这里是新加的会员价和限时优惠结束 -->
  221. <view class="ss-flex ss-col-bottom ss-m-t-10">
  222. <view
  223. v-if="goodsFields.price?.show"
  224. class="lg-goods-price ss-m-r-12 ss-flex ss-col-bottom font-OPPOSANS"
  225. :style="[{ color: goodsFields.price.color }]"
  226. >
  227. <text class="ss-font-24">{{ priceUnit }}</text>
  228. {{ isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price) }}
  229. </view>
  230. <view
  231. v-if="
  232. (goodsFields.original_price?.show || goodsFields.marketPrice?.show) &&
  233. (data.original_price > 0 || data.marketPrice > 0)
  234. "
  235. class="goods-origin-price ss-flex ss-col-bottom font-OPPOSANS"
  236. :style="[{ color: originPriceColor }]"
  237. >
  238. <text class="price-unit ss-font-20">{{ priceUnit }}</text>
  239. <text v-if="iconShow == '限时优惠'">{{ fen2yuan(data.discountPrice) }}</text>
  240. <text v-else-if="iconShow == '会员价'">{{ fen2yuan(data.vipPrice) }}</text>
  241. <text v-else>{{
  242. isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price)
  243. }}</text>
  244. </view>
  245. </view>
  246. <view class="ss-m-t-8 ss-flex ss-col-center ss-flex-wrap">
  247. <view class="sales-text">{{ salesAndStock }}</view>
  248. </view>
  249. </view>
  250. </view>
  251. <slot name="cart">
  252. <view class="buy-box ss-flex ss-col-center ss-row-center" v-if="buttonShow"> 去购买 </view>
  253. </slot>
  254. </view>
  255. <!-- sl卡片:竖向型,一行放一个,图片上内容下边 -->
  256. <view v-if="size === 'sl'" class="sl-goods-card ss-flex-col" :style="[elStyles]" @tap="onClick">
  257. <view v-if="tagStyle.show" class="tag-icon-box">
  258. <image class="tag-icon" :src="sheep.$url.cdn(tagStyle.src || tagStyle.imgUrl)"></image>
  259. </view>
  260. <image
  261. class="sl-img-box"
  262. :src="sheep.$url.cdn(data.image || data.picUrl)"
  263. mode="aspectFill"
  264. ></image>
  265. <view class="sl-goods-content">
  266. <view>
  267. <view
  268. v-if="goodsFields.title?.show || goodsFields.name?.show"
  269. class="sl-goods-title ss-line-1"
  270. :style="[{ color: titleColor }]"
  271. >
  272. {{ data.title || data.name }}
  273. </view>
  274. <view
  275. v-if="goodsFields.subtitle?.show || goodsFields.introduction?.show"
  276. class="sl-goods-subtitle ss-m-t-16"
  277. :style="[{ color: subTitleColor, background: subTitleBackground }]"
  278. >
  279. {{ data.subtitle || data.introduction }}
  280. </view>
  281. </view>
  282. <view>
  283. <slot name="activity">
  284. <view v-if="data.promos?.length" class="tag-box ss-flex ss-col-center ss-flex-wrap">
  285. <view
  286. class="activity-tag ss-m-r-10 ss-m-t-16"
  287. v-for="item in data.promos"
  288. :key="item.id"
  289. >
  290. {{ item.title }}
  291. </view>
  292. </view>
  293. </slot>
  294. <!-- 这里是新加的会员价和限时优惠 -->
  295. <view class="iconBox" v-if="data.discountPrice || data.vipPrice || data.reward">
  296. <view class="card" v-if="iconShow">{{ iconShow }}</view>
  297. <view class="card2" v-if="data.reward">{{ data.reward.ruleDescriptions[0] }}</view>
  298. </view>
  299. <!-- 这里是新加的会员价和限时优惠结束 -->
  300. <view v-if="goodsFields.price?.show" class="ss-flex ss-col-bottom font-OPPOSANS">
  301. <view class="sl-goods-price ss-m-r-12" :style="[{ color: goodsFields.price.color }]">
  302. <text class="price-unit ss-font-24">{{ priceUnit }}</text>
  303. <text v-if="iconShow == '限时优惠'">{{ fen2yuan(data.discountPrice) }}</text>
  304. <text v-else-if="iconShow == '会员价'">{{ fen2yuan(data.vipPrice) }}</text>
  305. <text v-else>{{
  306. isArray(data.price) ? fen2yuan(data.price[0]) : fen2yuan(data.price)
  307. }}</text>
  308. </view>
  309. <view
  310. v-if="
  311. (goodsFields.original_price?.show || goodsFields.marketPrice?.show) &&
  312. (data.original_price > 0 || data.marketPrice > 0)
  313. "
  314. class="goods-origin-price ss-m-t-16 font-OPPOSANS ss-flex"
  315. :style="[{ color: originPriceColor }]"
  316. >
  317. <text class="price-unit ss-font-20">{{ priceUnit }}</text>
  318. <view class="ss-m-l-8">{{ fen2yuan(data.marketPrice) }}</view>
  319. </view>
  320. </view>
  321. <view class="ss-m-t-16 ss-flex ss-flex-wrap">
  322. <view class="sales-text">{{ salesAndStock }}</view>
  323. </view>
  324. </view>
  325. </view>
  326. <slot name="cart">
  327. <view class="buy-box ss-flex ss-col-center ss-row-center">去购买</view>
  328. </slot>
  329. </view>
  330. </view>
  331. </template>
  332. <script setup>
  333. /**
  334. * 商品卡片
  335. *
  336. * @property {Array} size = [xs | sm | md | lg | sl ] - 列表数据
  337. * @property {String} tag - md及以上才有
  338. * @property {String} img - 图片
  339. * @property {String} background - 背景色
  340. * @property {String} topRadius - 上圆角
  341. * @property {String} bottomRadius - 下圆角
  342. * @property {String} title - 标题
  343. * @property {String} titleColor - 标题颜色
  344. * @property {Number} titleWidth = 0 - 标题宽度,默认0,单位rpx
  345. * @property {String} subTitle - 副标题
  346. * @property {String} subTitleColor - 副标题颜色
  347. * @property {String} subTitleBackground - 副标题背景
  348. * @property {String | Number} price - 价格
  349. * @property {String} priceColor - 价格颜色
  350. * @property {String | Number} originPrice - 原价/划线价
  351. * @property {String} originPriceColor - 原价颜色
  352. * @property {String | Number} sales - 销售数量
  353. * @property {String} salesColor - 销售数量颜色
  354. *
  355. * @slots activity - 活动插槽
  356. * @slots cart - 购物车插槽,默认包含文字,背景色,文字颜色 || 图片 || 行为
  357. *
  358. * @event {Function()} click - 点击卡片
  359. *
  360. */
  361. import { computed, reactive, getCurrentInstance, onMounted, nextTick, ref } from 'vue';
  362. import sheep from '@/sheep';
  363. import { fen2yuan, formatSales } from '@/sheep/hooks/useGoods';
  364. import { formatStock } from '@/sheep/hooks/useGoods';
  365. import goodsCollectVue from '@/pages/user/goods-collect.vue';
  366. import { isArray } from 'lodash-es';
  367. // 数据
  368. const state = reactive({});
  369. // 接收参数
  370. const props = defineProps({
  371. goodsFields: {
  372. type: [Array, Object],
  373. default() {
  374. return {
  375. // 商品价格
  376. price: {
  377. show: true,
  378. },
  379. // 库存
  380. stock: {
  381. show: true,
  382. },
  383. // 商品名称
  384. name: {
  385. show: true,
  386. },
  387. // 商品介绍
  388. introduction: {
  389. show: true,
  390. },
  391. // 市场价
  392. marketPrice: {
  393. show: true,
  394. },
  395. // 销量
  396. salesCount: {
  397. show: true,
  398. },
  399. };
  400. },
  401. },
  402. tagStyle: {
  403. type: Object,
  404. default: () => ({}),
  405. },
  406. data: {
  407. type: Object,
  408. default: () => ({}),
  409. },
  410. size: {
  411. type: String,
  412. default: 'sl',
  413. },
  414. background: {
  415. type: String,
  416. default: '',
  417. },
  418. topRadius: {
  419. type: Number,
  420. default: 0,
  421. },
  422. bottomRadius: {
  423. type: Number,
  424. default: 0,
  425. },
  426. titleWidth: {
  427. type: Number,
  428. default: 0,
  429. },
  430. titleColor: {
  431. type: String,
  432. default: '#333',
  433. },
  434. priceColor: {
  435. type: String,
  436. default: '',
  437. },
  438. originPriceColor: {
  439. type: String,
  440. default: '#C4C4C4',
  441. },
  442. priceUnit: {
  443. type: String,
  444. default: '¥',
  445. },
  446. subTitleColor: {
  447. type: String,
  448. default: '#999999',
  449. },
  450. subTitleBackground: {
  451. type: String,
  452. default: '',
  453. },
  454. buttonShow: {
  455. type: Boolean,
  456. default: true,
  457. },
  458. seckillTag: {
  459. type: Boolean,
  460. default: false,
  461. },
  462. grouponTag: {
  463. type: Boolean,
  464. default: false,
  465. },
  466. });
  467. //判断限时优惠和会员价标签内容暂时导致页面出错,又舍不得丢,等着把新的数据整合到商品信息中,也用起来
  468. const iconShow = handle();
  469. function handle() {
  470. debugger;
  471. if (props.data.discountPrice === null && props.data.vipPrice === null) {
  472. // 如果两个值都为 null,则不展示任何内容
  473. return '';
  474. } else if (props.data.discountPrice === null) {
  475. // 如果 discountPrice 为 null,展示 vipPrice
  476. return '会员价';
  477. } else if (props.data.vipPrice === null) {
  478. // 如果 vipPrice 为 null,展示 discountPrice
  479. return '限时优惠';
  480. } else if (props.data.discountPrice < props.data.vipPrice) {
  481. return '限时优惠';
  482. } else if (props.data.discountPrice > props.data.vipPrice) {
  483. return '会员价';
  484. }
  485. }
  486. // 组件样式
  487. const elStyles = computed(() => {
  488. return {
  489. background: props.background,
  490. 'border-top-left-radius': props.topRadius + 'px',
  491. 'border-top-right-radius': props.topRadius + 'px',
  492. 'border-bottom-left-radius': props.bottomRadius + 'px',
  493. 'border-bottom-right-radius': props.bottomRadius + 'px',
  494. };
  495. });
  496. // 格式化销量、库存信息
  497. const salesAndStock = computed(() => {
  498. let text = [];
  499. if (props.goodsFields.salesCount?.show) {
  500. text.push(formatSales(props.data.sales_show_type, props.data.salesCount));
  501. }
  502. if (props.goodsFields.stock?.show) {
  503. text.push(formatStock(props.data.stock_show_type, props.data.stock));
  504. }
  505. return text.join(' | ');
  506. });
  507. // 返回事件
  508. const emits = defineEmits(['click', 'getHeight']);
  509. const onClick = () => {
  510. emits('click');
  511. };
  512. // 获取卡片实时高度
  513. const { proxy } = getCurrentInstance();
  514. const elId = `sheep_${Math.ceil(Math.random() * 10e5).toString(36)}`;
  515. function getGoodsPriceCardWH() {
  516. if (props.size === 'md') {
  517. const view = uni.createSelectorQuery().in(proxy);
  518. view.select(`#${elId}`).fields({
  519. size: true,
  520. scrollOffset: true,
  521. });
  522. view.exec((data) => {
  523. let totalHeight = 0;
  524. const goodsPriceCard = data[0];
  525. if (props.data.image_wh) {
  526. totalHeight =
  527. (goodsPriceCard.width / props.data.image_wh.w) * props.data.image_wh.h +
  528. goodsPriceCard.height;
  529. } else {
  530. totalHeight = goodsPriceCard.width;
  531. }
  532. emits('getHeight', totalHeight);
  533. });
  534. }
  535. }
  536. onMounted(() => {
  537. nextTick(() => {
  538. getGoodsPriceCardWH();
  539. });
  540. });
  541. </script>
  542. <style lang="scss" scoped>
  543. .tag-icon-box {
  544. position: absolute;
  545. left: 0;
  546. top: 0;
  547. z-index: 2;
  548. .tag-icon {
  549. width: 72rpx;
  550. height: 44rpx;
  551. }
  552. }
  553. .seckill-tag {
  554. position: absolute;
  555. left: 0;
  556. top: 0;
  557. z-index: 2;
  558. width: 68rpx;
  559. height: 38rpx;
  560. background: linear-gradient(90deg, #ff5854 0%, #ff2621 100%);
  561. border-radius: 10rpx 0px 10rpx 0px;
  562. font-size: 24rpx;
  563. font-weight: 500;
  564. color: #ffffff;
  565. line-height: 32rpx;
  566. }
  567. .groupon-tag {
  568. position: absolute;
  569. left: 0;
  570. top: 0;
  571. z-index: 2;
  572. width: 68rpx;
  573. height: 38rpx;
  574. background: linear-gradient(90deg, #fe832a 0%, #ff6600 100%);
  575. border-radius: 10rpx 0px 10rpx 0px;
  576. font-size: 24rpx;
  577. font-weight: 500;
  578. color: #ffffff;
  579. line-height: 32rpx;
  580. }
  581. .goods-img {
  582. width: 100%;
  583. height: 100%;
  584. background-color: #f5f5f5;
  585. }
  586. .price-unit {
  587. margin-right: -4px;
  588. }
  589. .sales-text {
  590. display: table;
  591. font-size: 24rpx;
  592. transform: scale(0.8);
  593. margin-left: 0rpx;
  594. color: #c4c4c4;
  595. }
  596. .activity-tag {
  597. font-size: 20rpx;
  598. color: #ff0000;
  599. line-height: 30rpx;
  600. padding: 0 10rpx;
  601. border: 1px solid rgba(#ff0000, 0.25);
  602. border-radius: 4px;
  603. flex-shrink: 0;
  604. }
  605. .goods-origin-price {
  606. font-size: 20rpx;
  607. color: #c4c4c4;
  608. line-height: 36rpx;
  609. text-decoration: line-through;
  610. }
  611. // xs
  612. .xs-goods-card {
  613. overflow: hidden;
  614. // max-width: 375rpx;
  615. background-color: $white;
  616. position: relative;
  617. .xs-img-box {
  618. width: 128rpx;
  619. height: 128rpx;
  620. margin-right: 20rpx;
  621. }
  622. .xs-goods-title {
  623. font-size: 26rpx;
  624. color: #333;
  625. font-weight: 500;
  626. }
  627. .xs-goods-price {
  628. font-size: 30rpx;
  629. color: $red;
  630. }
  631. }
  632. // sm
  633. .sm-goods-card {
  634. overflow: hidden;
  635. // width: 223rpx;
  636. // width: 100%;
  637. background-color: $white;
  638. position: relative;
  639. .sm-img-box {
  640. // width: 228rpx;
  641. width: 100%;
  642. height: 208rpx;
  643. }
  644. .sm-goods-content {
  645. padding: 20rpx 16rpx;
  646. box-sizing: border-box;
  647. }
  648. .sm-goods-title {
  649. font-size: 26rpx;
  650. color: #333;
  651. }
  652. .sm-goods-price {
  653. font-size: 30rpx;
  654. color: $red;
  655. }
  656. }
  657. // md
  658. .md-goods-card {
  659. overflow: hidden;
  660. width: 100%;
  661. position: relative;
  662. z-index: 1;
  663. background-color: $white;
  664. position: relative;
  665. .md-img-box {
  666. width: 100%;
  667. }
  668. .md-goods-title {
  669. font-size: 26rpx;
  670. color: #333;
  671. width: 100%;
  672. }
  673. .md-goods-subtitle {
  674. font-size: 24rpx;
  675. font-weight: 400;
  676. color: #999999;
  677. }
  678. .md-goods-price {
  679. font-size: 30rpx;
  680. color: $red;
  681. line-height: 36rpx;
  682. }
  683. .cart-box {
  684. width: 54rpx;
  685. height: 54rpx;
  686. background: linear-gradient(90deg, #fe8900, #ff5e00);
  687. border-radius: 50%;
  688. position: absolute;
  689. bottom: 50rpx;
  690. right: 20rpx;
  691. z-index: 2;
  692. .cart-icon {
  693. width: 30rpx;
  694. height: 30rpx;
  695. }
  696. }
  697. }
  698. // lg
  699. .lg-goods-card {
  700. overflow: hidden;
  701. position: relative;
  702. z-index: 1;
  703. background-color: $white;
  704. height: 280rpx;
  705. .lg-img-box {
  706. width: 280rpx;
  707. height: 280rpx;
  708. margin-right: 20rpx;
  709. }
  710. .lg-goods-title {
  711. font-size: 28rpx;
  712. font-weight: 500;
  713. color: #333333;
  714. // line-height: 36rpx;
  715. // width: 410rpx;
  716. }
  717. .lg-goods-subtitle {
  718. font-size: 24rpx;
  719. font-weight: 400;
  720. color: #999999;
  721. // line-height: 30rpx;
  722. // width: 410rpx;
  723. }
  724. .lg-goods-price {
  725. font-size: 30rpx;
  726. color: $red;
  727. line-height: 36rpx;
  728. }
  729. .buy-box {
  730. position: absolute;
  731. bottom: 20rpx;
  732. right: 20rpx;
  733. z-index: 2;
  734. width: 120rpx;
  735. height: 50rpx;
  736. background: linear-gradient(90deg, #fe8900, #ff5e00);
  737. border-radius: 25rpx;
  738. font-size: 24rpx;
  739. color: #ffffff;
  740. }
  741. .tag-box {
  742. width: 100%;
  743. }
  744. }
  745. // sl
  746. .sl-goods-card {
  747. overflow: hidden;
  748. position: relative;
  749. z-index: 1;
  750. width: 100%;
  751. background-color: $white;
  752. .sl-goods-content {
  753. padding: 20rpx 20rpx;
  754. box-sizing: border-box;
  755. }
  756. .sl-img-box {
  757. width: 100%;
  758. height: 360rpx;
  759. }
  760. .sl-goods-title {
  761. font-size: 26rpx;
  762. color: #333;
  763. font-weight: 500;
  764. }
  765. .sl-goods-subtitle {
  766. font-size: 24rpx;
  767. font-weight: 400;
  768. color: #999999;
  769. line-height: 30rpx;
  770. }
  771. .sl-goods-price {
  772. font-size: 30rpx;
  773. color: $red;
  774. line-height: 36rpx;
  775. }
  776. .buy-box {
  777. position: absolute;
  778. bottom: 20rpx;
  779. right: 20rpx;
  780. z-index: 2;
  781. width: 148rpx;
  782. height: 50rpx;
  783. background: linear-gradient(90deg, #fe8900, #ff5e00);
  784. border-radius: 25rpx;
  785. font-size: 24rpx;
  786. color: #ffffff;
  787. }
  788. }
  789. .card {
  790. width: fit-content;
  791. height: fit-content;
  792. padding: 2rpx 10rpx;
  793. background-color: red;
  794. color: #ffffff;
  795. font-size: 24rpx;
  796. }
  797. .card2 {
  798. width: fit-content;
  799. height: fit-content;
  800. padding: 2rpx 10rpx;
  801. background-color: rgb(255, 242, 241);
  802. color: #ff2621;
  803. font-size: 24rpx;
  804. margin-left: 5rpx;
  805. }
  806. .iconBox {
  807. width: 100%;
  808. height: fit-content;
  809. margin-top: 10rpx;
  810. display: flex;
  811. justify-content: flex-start;
  812. }
  813. </style>