猎豆优选小程序

horizontalGood.vue 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <!-- 横向商品 -->
  2. <template>
  3. <view class="goods-item-wrap" @click="onClickGoodsItem(goodInfo)">
  4. <view class="lt-wrap">
  5. <u-lazy-load class="goods-item-img" :image="goodInfo.img" img-mode="widthFix" border-radius="10" />
  6. </view>
  7. <view class="rt-wrap">
  8. <view class="title">
  9. <image class="shop-icon" v-if="goodInfo.shop_type == 0" src="/static/imgs/icon-tb.png" />
  10. <image class="shop-icon" v-else-if="goodInfo.shop_type == 1" src="/static/imgs/icon-tmall.png" />
  11. <image class="shop-icon" v-else-if="goodInfo.shop_type == 4" src="/static/imgs/jd-icon.png" />
  12. <image class="shop-icon" v-else-if="goodInfo.shop_type == 6" src="/static/imgs/pdd-icon.png" />
  13. <image class="shop-icon" v-else-if="goodInfo.shop_type == 5" src="/static/imgs/icon-dy.png" />
  14. <text>{{ goodInfo.title }}</text>
  15. </view>
  16. <view class="shop-wrap flex-center-between">
  17. <view class="flex-center">
  18. <image class="shop-icon" src="/static/imgs/shop.png" />
  19. <view class="shop-name" :style="goodInfo.volume > 100 ? 'max-width: 260rpx' : ''">{{ goodInfo.shop_title }}</view>
  20. </view>
  21. <view class="salesVolume" v-if="goodInfo.volume > 100">
  22. 销量{{ $NumberHandle({value:goodInfo.volume,comma:true}) }}+
  23. </view>
  24. </view>
  25. <view class="price-wrap">
  26. <text class="price">{{ goodInfo.discount_price }}</text>
  27. <text class="start-price">¥{{goodInfo.price }}</text>
  28. </view>
  29. <view class="btm-wrap">
  30. <view v-if="goodInfo.coupon_price > 0 && goodInfo.shop_type != 5" class="coupon-wrap">
  31. <text class="label">券</text>
  32. <text class="value">¥{{ goodInfo.coupon_price }}</text>
  33. </view>
  34. <view v-if="user_level > 1 && goodInfo.commission_price > 0" class="coupon-wrap commission-wrap">
  35. <text class="label">返</text>
  36. <text class="value">¥{{ goodInfo.commission_price }}</text>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. const app = getApp()
  44. export default {
  45. name:"horizontalGood",
  46. props:{
  47. goodInfo:{
  48. type: Object
  49. },
  50. path:{
  51. type: String,
  52. default: ''
  53. }
  54. },
  55. data() {
  56. return {
  57. user_level: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo').user_level : '', // 当前用户等级
  58. };
  59. },
  60. methods:{
  61. onClickGoodsItem(goodsItem) {
  62. try{ app.categoryNew_countBuy({shop_type: goodsItem.shop_type, type:0,path:this.path}) }catch(e){} ; // 数据上报
  63. if (goodsItem.shop_type == 4) { // 京东
  64. const { goods_id = ''} = goodsItem
  65. uni.navigateTo({
  66. url: `/pages/subPackages/home/jdGoodsDetail?goods_id=${encodeURIComponent(goods_id)}`
  67. })
  68. } else if (goodsItem.shop_type == 6) { // 拼多多
  69. const { goods_id = ''} = goodsItem
  70. if(!goods_id){
  71. uni.showToast({ title: 'goods_id错误', icon: 'none' })
  72. return
  73. }
  74. uni.navigateTo({
  75. url: `/pages/subPackages/pdd/goodsDetail?goods_id=${encodeURIComponent(goods_id)}`
  76. })
  77. } else if (goodsItem.shop_type == 5) { // 抖音
  78. const { goods_id = ''} = goodsItem
  79. uni.navigateTo({
  80. url: `/pages/subPackages/dy/goodsDetail?goods_id=${encodeURIComponent(goods_id)}`
  81. })
  82. }else {
  83. const { img = '', goods_id = '', coupon_price = '', discount_price = '', price = '', is_coupon = '', commission_rate = '', is_high_commission = '', coupon_end_time = '', coupon_start_time = '' } = goodsItem
  84. uni.navigateTo({
  85. url: `/pages/subPackages/home/goodsDetail?img=${encodeURIComponent(img)}&goods_id=${encodeURIComponent(goods_id)}&coupon_price=${encodeURIComponent(coupon_price)}&discount_price=${encodeURIComponent(discount_price)}&price=${encodeURIComponent(price)}&is_coupon=${encodeURIComponent(is_coupon)}&commission_rate=${encodeURIComponent(commission_rate)}&is_high_commission=${encodeURIComponent(is_high_commission)}&coupon_end_time=${encodeURIComponent(coupon_end_time)}&coupon_start_time=${encodeURIComponent(coupon_start_time)}`
  86. })
  87. }
  88. },
  89. }
  90. }
  91. </script>
  92. <style scoped lang="scss">
  93. .salesVolume{
  94. background: url('~@/static/imgs/huo-bg.png') no-repeat;
  95. background-size: 100%;
  96. width: 160rpx;
  97. line-height: 28rpx;
  98. color: #FF4040;
  99. font-size: 20rpx;
  100. line-height: 42rpx;
  101. text-align: center;
  102. padding-left: 10rpx;
  103. }
  104. .flex-center{
  105. display: flex;
  106. align-items: center;
  107. }
  108. .flex-center-between{
  109. display: flex;
  110. align-items: center;
  111. justify-content: space-between;
  112. }
  113. .goods-item-wrap {
  114. padding: 28rpx;
  115. display: flex;
  116. align-items: center;
  117. background-color: #fff;
  118. .lt-wrap {
  119. width: 220rpx;
  120. height: 220rpx;
  121. border-radius: 10rpx;
  122. overflow: hidden;
  123. .goods-item-img {
  124. width: 100%;
  125. height: 100%;
  126. vertical-align: middle; // 解决图片下边框缝隙问题
  127. }
  128. }
  129. .rt-wrap {
  130. margin-left: 20rpx;
  131. flex: 1;
  132. .title {
  133. font-size: 30rpx;
  134. color: #1A1A1A;
  135. line-height: 42rpx;
  136. // 超出两行省略号
  137. word-break: break-all;
  138. overflow: hidden;
  139. -webkit-line-clamp: 2;
  140. text-overflow: ellipsis;
  141. display: -webkit-box;
  142. -webkit-box-orient: vertical;
  143. font-weight: bold;
  144. .shop-icon{
  145. width: 30rpx;
  146. height: 30rpx;
  147. border-radius: 6rpx;
  148. display: inline-block;
  149. margin-right: 6rpx;
  150. margin-top: -7rpx;
  151. vertical-align: middle;//解决图片下边框间隙问题
  152. }
  153. }
  154. .shop-wrap {
  155. margin-top: 8rpx;
  156. display: flex;
  157. align-items: center;
  158. .shop-icon {
  159. width: 26rpx;
  160. height: 26rpx;
  161. vertical-align: middle;//解决图片下边框间隙问题
  162. }
  163. .shop-name {
  164. margin-left: 6rpx;
  165. font-size: 24rpx;
  166. line-height: 34rpx;
  167. color: #AAAAAA;
  168. flex: 1;
  169. max-width: 400rpx;
  170. white-space: nowrap;
  171. overflow: hidden;
  172. text-overflow: ellipsis;
  173. }
  174. }
  175. .price-wrap {
  176. margin-top: 10rpx;
  177. display: flex;
  178. align-items: center;
  179. .price {
  180. font-size: 36rpx;
  181. line-height: 50rpx;
  182. color: #FF4040;
  183. font-weight: bold;
  184. }
  185. .start-price {
  186. margin-left: 10rpx;
  187. font-size: 24rpx;
  188. color: #999999;
  189. line-height: 34rpx;
  190. text-decoration: line-through;
  191. }
  192. }
  193. .btm-wrap {
  194. display: flex;
  195. align-items: center;
  196. margin-top: 10rpx;
  197. .coupon-wrap {
  198. display: flex;
  199. align-items: center;
  200. width: 144rpx;
  201. height: 36rpx;
  202. background-image: url("~@/static/imgs/bg-quan-small.png");
  203. background-repeat: no-repeat;
  204. background-size: 100% 100%;
  205. color: #FF4040;
  206. font-size: 25rpx;
  207. line-height: 36rpx;
  208. .label {
  209. width: 46rpx;
  210. text-align: center;
  211. }
  212. .value {
  213. flex: 1;
  214. text-align: center;
  215. }
  216. }
  217. .commission-wrap {
  218. background-image: url("~@/static/imgs/fan.png");
  219. color: #AE4300;
  220. margin-left: 12rpx;
  221. }
  222. }
  223. }
  224. }
  225. </style>