uni-coods.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view class="goods-list">
  3. <view class="goods-item" v-for="item in list" :key="item.id">
  4. <view class="goods-imgs" @click="toDetail(item)">
  5. <view v-if="item.inventoryQty == 0" class="goods-staus">已售罄</view>
  6. <view v-if="item.delFlage == 0 || item.state == 0" class="goods-staus">已失效</view>
  7. <u-lazy-load
  8. img-mode="scaleToFill"
  9. :height="imgHeight"
  10. :image="item.homeImage+'?x-oss-process=image/resize,m_pad,h_252,w_325,color_ffffff'"
  11. :loading-img="loadingImg"
  12. :error-img="errorImg">
  13. </u-lazy-load>
  14. </view>
  15. <view class="name ellipsis-two" @click="toDetail(item)">{{item.name}}</view>
  16. <view class="price">
  17. <view>
  18. <text>{{item.sellGold}}</text>
  19. <u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
  20. </view>
  21. <view @click.stop="addCart(item)" v-if="item.inventoryQty > 0">
  22. <u-image mode="scaleToFill" width="45rpx" height="45rpx" src="/static/addCart.png"></u-image>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. props: {
  31. imgHeight: {
  32. type: Number,
  33. default: 250
  34. },
  35. list:{
  36. type: Array,
  37. default: function(){
  38. return []
  39. }
  40. }
  41. },
  42. data() {
  43. return {
  44. loadingImg: '/static/loading.gif',
  45. errorImg: '/static/imgError.png',
  46. timer: null,
  47. finger: {x:0,y:0},
  48. linePos: null
  49. }
  50. },
  51. methods: {
  52. // 加入购物车
  53. addCart(item) {
  54. uni.$emit("addCart",{goodsNo:item.goodsNo,buyQty:1})
  55. },
  56. // 商品详情
  57. toDetail(item){
  58. uni.navigateTo({
  59. url:"/pages/goods/goodsDetail?id="+item.id
  60. })
  61. }
  62. },
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. .goods-list{
  67. display: flex;
  68. flex-wrap: wrap;
  69. justify-content: space-between;
  70. padding-top: 20upx;
  71. .goods-item{
  72. background: #FFFFFF;
  73. width: 48%;
  74. margin-bottom: 5upx;
  75. .goods-imgs{
  76. position: relative;
  77. border-radius: 28upx 28upx 0 0;
  78. overflow: hidden;
  79. .goods-staus{
  80. width: 100%;
  81. height: 100%;
  82. position: absolute;
  83. z-index: 100;
  84. border-radius: 15rpx 15rpx 0 0;
  85. background: rgba($color: #000000, $alpha: 0.4);
  86. text-align: center;
  87. line-height: 250rpx;
  88. left: 0;
  89. top: 0;
  90. color: #eee;
  91. font-size: 30upx;
  92. font-weight: bold;
  93. }
  94. }
  95. .name{
  96. padding: 10upx 0;
  97. font-weight: bold;
  98. font-size: 30rpx;
  99. }
  100. .price{
  101. display: flex;
  102. align-items: center;
  103. justify-content: space-between;
  104. padding: 15upx 0;
  105. text{
  106. color: #d42a26;
  107. font-size: 36upx;
  108. margin-right: 6upx;
  109. font-weight: bold;
  110. }
  111. >view{
  112. &:first-child{
  113. font-size: 22upx;
  114. display: flex;
  115. align-items: center;
  116. }
  117. &:last-child{
  118. &:active{
  119. opacity: 0.5;
  120. }
  121. }
  122. }
  123. }
  124. }
  125. }
  126. </style>