index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <!-- 路由器商品列表组件 -->
  3. <view class="diy-goods" :style="{background: itemStyle.background}">
  4. <!-- <img class="" style="width: 100%" src="@/static/background/skm.jpg" alt="" /> -->
  5. <view class="goods-list" :class="[`display__${itemStyle.display}`, `column__${itemStyle.column}`]">
  6. <scroll-view :scroll-x="itemStyle.display === 'slide'">
  7. <view class="goods-item" v-for="(dataItem, index) in dataList" :key="index" @click="buyNow(dataItem)">
  8. <!-- 单列商品 -->
  9. <block v-if="itemStyle.column === 1">
  10. <view class="dis-flex">
  11. <!-- 商品图片 -->
  12. <view class="goods-item-left">
  13. <image class="image" :src="dataItem.goods_image"></image>
  14. </view>
  15. <view class="goods-item-right">
  16. <!-- 商品名称 -->
  17. <view v-if="itemStyle.show.includes('goodsName')" class="goods-name">
  18. <text class="twoline-hide">{{ dataItem.goods_name }}</text>
  19. </view>
  20. <view class="goods-item-desc">
  21. <!-- 商品卖点 -->
  22. <view v-if="itemStyle.show.includes('sellingPoint')" class="desc-selling-point dis-flex">
  23. <text class="oneline-hide">{{ dataItem.selling_point }}</text>
  24. </view>
  25. <!-- 商品销量 -->
  26. <view v-if="itemStyle.show.includes('goodsSales')" class="desc-goods-sales dis-flex">
  27. <text>已售{{ dataItem.goods_sales }}件</text>
  28. </view>
  29. <!-- 商品价格 -->
  30. <view class="desc-footer">
  31. <text v-if="itemStyle.show.includes('goodsPrice')" class="price-x">¥{{ dataItem.goods_price_min }}</text>
  32. <text class="price-y col-9" v-if="itemStyle.show.includes('linePrice') && dataItem.line_price_min > 0">¥{{ dataItem.line_price_min }}</text>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </block>
  38. <!-- 多列商品 - new-->
  39. <block v-else>
  40. <!-- 商品图片 -->
  41. <view class="goods-image">
  42. <image class="image" mode="aspectFill" :src="dataItem.productpic"></image>
  43. <!-- {{ dataItem }} -->
  44. <view class="goods-text001" style="margin-top: 100rpx">时长:{{ dataItem.productlimit }} 月</view>
  45. <view class="goods-text001">赠送:{{ dataItem.productlimit1 }}</view>
  46. <view class="goods-text001">宽带:{{ dataItem.productdkband }}</view>
  47. <view class="goods-text001">赠送时长:{{ dataItem.productlimit }}</view>
  48. </view>
  49. <view class="detail">
  50. <!-- 商品标题 -->
  51. <view v-if="true" class="goods-name twoline-hide">
  52. <text class="twoline-hide">{{ dataItem.productname }}</text>
  53. <text class="twoline-hide twoline-xiao">介绍:{{ dataItem.productmemo }}</text>
  54. </view>
  55. <!-- 商品价格 -->
  56. <view class="detail-price oneline-hide">
  57. <text class="goods-price f-30 col-m">¥{{ dataItem.productprice1 }}</text>
  58. <text v-if="itemStyle.show.includes('linePrice') && dataItem.productprice1 > 0" class="line-price col-9 f-24">¥{{ dataItem.productprice }}</text>
  59. </view>
  60. </view>
  61. </block>
  62. </view>
  63. </scroll-view>
  64. </view>
  65. <!-- 还没上架商品 -->
  66. <empty v-if="dataList.length === 0" :isLoading="isLoading" :custom-style="{padding: '180rpx 50rpx'}" tips="还没上架商品">
  67. <template v-slot:slot>
  68. <view class="empty-ipt">
  69. <text>敬请期待</text>
  70. </view>
  71. </template>
  72. </empty>
  73. </view>
  74. </template>
  75. <script>
  76. import Empty from '@/components/empty'
  77. export default {
  78. name: 'Goods',
  79. components: {
  80. Empty
  81. },
  82. /**
  83. * 组件的属性列表
  84. * 用于组件自定义设置
  85. */
  86. props: {
  87. itemIndex: String,
  88. itemStyle: Object,
  89. params: Object,
  90. dataList: Array
  91. },
  92. /**
  93. * 组件的方法列表
  94. * 更新属性和数据的方法与更新页面数据的方法类似
  95. */
  96. methods: {
  97. /**
  98. * 跳转商品详情页
  99. */
  100. onTargetGoods(goodsId) {
  101. this.$navTo(`pages/goods/detail`, {goodsId})
  102. },
  103. // 立即购买
  104. buyNow(selectShop) {
  105. console.log('选择商品:', selectShop)
  106. // 跳转到订单结算页
  107. this.$navTo('pages/checkout/index', {
  108. mode: 'buyNow',
  109. goodsId: selectShop.productid,
  110. goodsNum: '3',
  111. goodsSkuId: '2'
  112. })
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. .diy-goods {
  119. .goods-list {
  120. padding: 4rpx;
  121. box-sizing: border-box;
  122. .twoline-xiao {
  123. color: #999;
  124. font-size: 22rpx;
  125. }
  126. .goods-item {
  127. box-sizing: border-box;
  128. padding: 6rpx;
  129. overflow: hidden;
  130. .goods-image {
  131. border-radius: 15rpx;
  132. text-align: center;
  133. color: #3a4b5f;
  134. line-height: 40rpx;
  135. position: relative;
  136. width: 100%;
  137. height: 0;
  138. padding-bottom: 100%;
  139. overflow: hidden;
  140. background-image: linear-gradient(120deg, #a1c4fd 0%, #c2e9fb 100%);
  141. &:after {
  142. content: '';
  143. display: block;
  144. margin-top: 100%;
  145. }
  146. .image {
  147. position: absolute;
  148. width: 100%;
  149. height: 100%;
  150. top: 0;
  151. left: 0;
  152. -o-object-fit: cover;
  153. object-fit: cover;
  154. }
  155. }
  156. .detail {
  157. padding: 8rpx;
  158. background: #fff;
  159. .goods-name {
  160. min-height: 68rpx;
  161. line-height: 1.3;
  162. white-space: normal;
  163. color: #484848;
  164. font-size: 26rpx;
  165. margin-bottom: 4rpx;
  166. }
  167. .detail-price {
  168. .goods-price {
  169. margin-right: 8rpx;
  170. }
  171. .line-price {
  172. text-decoration: line-through;
  173. }
  174. }
  175. }
  176. }
  177. &.display__slide {
  178. white-space: nowrap;
  179. font-size: 0;
  180. .goods-item {
  181. display: inline-block;
  182. }
  183. }
  184. &.display__list {
  185. .goods-item {
  186. float: left;
  187. }
  188. }
  189. &.column__2 {
  190. .goods-item {
  191. width: 50%;
  192. }
  193. }
  194. &.column__3 {
  195. .goods-item {
  196. width: 33.33333%;
  197. }
  198. }
  199. &.column__1 {
  200. .goods-item {
  201. width: 100%;
  202. height: 280rpx;
  203. margin-bottom: 12rpx;
  204. padding: 20rpx;
  205. box-sizing: border-box;
  206. background: #fff;
  207. line-height: 1.6;
  208. &:last-child {
  209. margin-bottom: 0;
  210. }
  211. }
  212. .goods-item-left {
  213. display: flex;
  214. width: 40%;
  215. background: #fff;
  216. align-items: center;
  217. .image {
  218. display: block;
  219. width: 240rpx;
  220. height: 240rpx;
  221. }
  222. }
  223. .goods-item-right {
  224. position: relative;
  225. width: 60%;
  226. .goods-name {
  227. margin-top: 20rpx;
  228. min-height: 68rpx;
  229. line-height: 1.3;
  230. white-space: normal;
  231. color: #484848;
  232. font-size: 26rpx;
  233. }
  234. }
  235. .goods-item-desc {
  236. margin-top: 8rpx;
  237. }
  238. .desc-selling-point {
  239. width: 400rpx;
  240. font-size: 24rpx;
  241. color: #e49a3d;
  242. }
  243. .desc-goods-sales {
  244. color: #999;
  245. font-size: 24rpx;
  246. }
  247. .desc-footer {
  248. font-size: 24rpx;
  249. .price-x {
  250. margin-right: 16rpx;
  251. color: $main-bg;
  252. font-size: 30rpx;
  253. }
  254. .price-y {
  255. text-decoration: line-through;
  256. }
  257. }
  258. }
  259. }
  260. }
  261. </style>