猎豆优选小程序

horizontalGood.vue 9.0KB

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