s-goods-column.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  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. if (props.data.discountPrice === null && props.data.vipPrice === null) {
  471. // 如果两个值都为 null,则不展示任何内容
  472. return '';
  473. } else if (props.data.discountPrice === null) {
  474. // 如果 discountPrice 为 null,展示 vipPrice
  475. return '会员价';
  476. } else if (props.data.vipPrice === null) {
  477. // 如果 vipPrice 为 null,展示 discountPrice
  478. return '限时优惠';
  479. } else if (props.data.discountPrice < props.data.vipPrice) {
  480. return '限时优惠';
  481. } else if (props.data.discountPrice > props.data.vipPrice) {
  482. return '会员价';
  483. }
  484. }
  485. // 组件样式
  486. const elStyles = computed(() => {
  487. return {
  488. background: props.background,
  489. 'border-top-left-radius': props.topRadius + 'px',
  490. 'border-top-right-radius': props.topRadius + 'px',
  491. 'border-bottom-left-radius': props.bottomRadius + 'px',
  492. 'border-bottom-right-radius': props.bottomRadius + 'px',
  493. };
  494. });
  495. // 格式化销量、库存信息
  496. const salesAndStock = computed(() => {
  497. let text = [];
  498. if (props.goodsFields.salesCount?.show) {
  499. text.push(formatSales(props.data.sales_show_type, props.data.salesCount));
  500. }
  501. if (props.goodsFields.stock?.show) {
  502. text.push(formatStock(props.data.stock_show_type, props.data.stock));
  503. }
  504. return text.join(' | ');
  505. });
  506. // 返回事件
  507. const emits = defineEmits(['click', 'getHeight']);
  508. const onClick = () => {
  509. emits('click');
  510. };
  511. // 获取卡片实时高度
  512. const { proxy } = getCurrentInstance();
  513. const elId = `sheep_${Math.ceil(Math.random() * 10e5).toString(36)}`;
  514. function getGoodsPriceCardWH() {
  515. if (props.size === 'md') {
  516. const view = uni.createSelectorQuery().in(proxy);
  517. view.select(`#${elId}`).fields({
  518. size: true,
  519. scrollOffset: true,
  520. });
  521. view.exec((data) => {
  522. let totalHeight = 0;
  523. const goodsPriceCard = data[0];
  524. if (props.data.image_wh) {
  525. totalHeight =
  526. (goodsPriceCard.width / props.data.image_wh.w) * props.data.image_wh.h +
  527. goodsPriceCard.height;
  528. } else {
  529. totalHeight = goodsPriceCard.width;
  530. }
  531. emits('getHeight', totalHeight);
  532. });
  533. }
  534. }
  535. onMounted(() => {
  536. nextTick(() => {
  537. getGoodsPriceCardWH();
  538. });
  539. });
  540. </script>
  541. <style lang="scss" scoped>
  542. .tag-icon-box {
  543. position: absolute;
  544. left: 0;
  545. top: 0;
  546. z-index: 2;
  547. .tag-icon {
  548. width: 72rpx;
  549. height: 44rpx;
  550. }
  551. }
  552. .seckill-tag {
  553. position: absolute;
  554. left: 0;
  555. top: 0;
  556. z-index: 2;
  557. width: 68rpx;
  558. height: 38rpx;
  559. background: linear-gradient(90deg, #ff5854 0%, #ff2621 100%);
  560. border-radius: 10rpx 0px 10rpx 0px;
  561. font-size: 24rpx;
  562. font-weight: 500;
  563. color: #ffffff;
  564. line-height: 32rpx;
  565. }
  566. .groupon-tag {
  567. position: absolute;
  568. left: 0;
  569. top: 0;
  570. z-index: 2;
  571. width: 68rpx;
  572. height: 38rpx;
  573. background: linear-gradient(90deg, #fe832a 0%, #ff6600 100%);
  574. border-radius: 10rpx 0px 10rpx 0px;
  575. font-size: 24rpx;
  576. font-weight: 500;
  577. color: #ffffff;
  578. line-height: 32rpx;
  579. }
  580. .goods-img {
  581. width: 100%;
  582. height: 100%;
  583. background-color: #f5f5f5;
  584. }
  585. .price-unit {
  586. margin-right: -4px;
  587. }
  588. .sales-text {
  589. display: table;
  590. font-size: 24rpx;
  591. transform: scale(0.8);
  592. margin-left: 0rpx;
  593. color: #c4c4c4;
  594. }
  595. .activity-tag {
  596. font-size: 20rpx;
  597. color: #ff0000;
  598. line-height: 30rpx;
  599. padding: 0 10rpx;
  600. border: 1px solid rgba(#ff0000, 0.25);
  601. border-radius: 4px;
  602. flex-shrink: 0;
  603. }
  604. .goods-origin-price {
  605. font-size: 20rpx;
  606. color: #c4c4c4;
  607. line-height: 36rpx;
  608. text-decoration: line-through;
  609. }
  610. // xs
  611. .xs-goods-card {
  612. overflow: hidden;
  613. // max-width: 375rpx;
  614. background-color: $white;
  615. position: relative;
  616. .xs-img-box {
  617. width: 128rpx;
  618. height: 128rpx;
  619. margin-right: 20rpx;
  620. }
  621. .xs-goods-title {
  622. font-size: 26rpx;
  623. color: #333;
  624. font-weight: 500;
  625. }
  626. .xs-goods-price {
  627. font-size: 30rpx;
  628. color: $red;
  629. }
  630. }
  631. // sm
  632. .sm-goods-card {
  633. overflow: hidden;
  634. // width: 223rpx;
  635. // width: 100%;
  636. background-color: $white;
  637. position: relative;
  638. .sm-img-box {
  639. // width: 228rpx;
  640. width: 100%;
  641. height: 208rpx;
  642. }
  643. .sm-goods-content {
  644. padding: 20rpx 16rpx;
  645. box-sizing: border-box;
  646. }
  647. .sm-goods-title {
  648. font-size: 26rpx;
  649. color: #333;
  650. }
  651. .sm-goods-price {
  652. font-size: 30rpx;
  653. color: $red;
  654. }
  655. }
  656. // md
  657. .md-goods-card {
  658. overflow: hidden;
  659. width: 100%;
  660. position: relative;
  661. z-index: 1;
  662. background-color: $white;
  663. position: relative;
  664. .md-img-box {
  665. width: 100%;
  666. }
  667. .md-goods-title {
  668. font-size: 26rpx;
  669. color: #333;
  670. width: 100%;
  671. }
  672. .md-goods-subtitle {
  673. font-size: 24rpx;
  674. font-weight: 400;
  675. color: #999999;
  676. }
  677. .md-goods-price {
  678. font-size: 30rpx;
  679. color: $red;
  680. line-height: 36rpx;
  681. }
  682. .cart-box {
  683. width: 54rpx;
  684. height: 54rpx;
  685. background: linear-gradient(90deg, #fe8900, #ff5e00);
  686. border-radius: 50%;
  687. position: absolute;
  688. bottom: 50rpx;
  689. right: 20rpx;
  690. z-index: 2;
  691. .cart-icon {
  692. width: 30rpx;
  693. height: 30rpx;
  694. }
  695. }
  696. }
  697. // lg
  698. .lg-goods-card {
  699. overflow: hidden;
  700. position: relative;
  701. z-index: 1;
  702. background-color: $white;
  703. height: 280rpx;
  704. .lg-img-box {
  705. width: 280rpx;
  706. height: 280rpx;
  707. margin-right: 20rpx;
  708. }
  709. .lg-goods-title {
  710. font-size: 28rpx;
  711. font-weight: 500;
  712. color: #333333;
  713. // line-height: 36rpx;
  714. // width: 410rpx;
  715. }
  716. .lg-goods-subtitle {
  717. font-size: 24rpx;
  718. font-weight: 400;
  719. color: #999999;
  720. // line-height: 30rpx;
  721. // width: 410rpx;
  722. }
  723. .lg-goods-price {
  724. font-size: 30rpx;
  725. color: $red;
  726. line-height: 36rpx;
  727. }
  728. .buy-box {
  729. position: absolute;
  730. bottom: 20rpx;
  731. right: 20rpx;
  732. z-index: 2;
  733. width: 120rpx;
  734. height: 50rpx;
  735. background: linear-gradient(90deg, #fe8900, #ff5e00);
  736. border-radius: 25rpx;
  737. font-size: 24rpx;
  738. color: #ffffff;
  739. }
  740. .tag-box {
  741. width: 100%;
  742. }
  743. }
  744. // sl
  745. .sl-goods-card {
  746. overflow: hidden;
  747. position: relative;
  748. z-index: 1;
  749. width: 100%;
  750. background-color: $white;
  751. .sl-goods-content {
  752. padding: 20rpx 20rpx;
  753. box-sizing: border-box;
  754. }
  755. .sl-img-box {
  756. width: 100%;
  757. height: 360rpx;
  758. }
  759. .sl-goods-title {
  760. font-size: 26rpx;
  761. color: #333;
  762. font-weight: 500;
  763. }
  764. .sl-goods-subtitle {
  765. font-size: 24rpx;
  766. font-weight: 400;
  767. color: #999999;
  768. line-height: 30rpx;
  769. }
  770. .sl-goods-price {
  771. font-size: 30rpx;
  772. color: $red;
  773. line-height: 36rpx;
  774. }
  775. .buy-box {
  776. position: absolute;
  777. bottom: 20rpx;
  778. right: 20rpx;
  779. z-index: 2;
  780. width: 148rpx;
  781. height: 50rpx;
  782. background: linear-gradient(90deg, #fe8900, #ff5e00);
  783. border-radius: 25rpx;
  784. font-size: 24rpx;
  785. color: #ffffff;
  786. }
  787. }
  788. .card {
  789. width: fit-content;
  790. height: fit-content;
  791. padding: 2rpx 10rpx;
  792. background-color: red;
  793. color: #ffffff;
  794. font-size: 24rpx;
  795. }
  796. .card2 {
  797. width: fit-content;
  798. height: fit-content;
  799. padding: 2rpx 10rpx;
  800. background-color: rgb(255, 242, 241);
  801. color: #ff2621;
  802. font-size: 24rpx;
  803. margin-left: 5rpx;
  804. }
  805. .iconBox {
  806. width: 100%;
  807. height: fit-content;
  808. margin-top: 10rpx;
  809. display: flex;
  810. justify-content: flex-start;
  811. }
  812. </style>