uni-coods.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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="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. goldLimit: {
  36. type: [Number,String],
  37. default: 0
  38. },
  39. list:{
  40. type: Array,
  41. default: function(){
  42. return []
  43. }
  44. }
  45. },
  46. data() {
  47. return {
  48. loadingImg: '/static/loading.gif',
  49. errorImg: '/static/imgError.png',
  50. timer: null,
  51. finger: {x:0,y:0},
  52. linePos: null
  53. }
  54. },
  55. methods: {
  56. // 加入购物车
  57. addCart(item) {
  58. uni.$emit("addCart",{goodsNo:item.goodsNo,buyQty:1})
  59. },
  60. // 商品详情
  61. toDetail(item){
  62. uni.navigateTo({
  63. url:"/pages/goods/goodsDetail?id="+item.id + "&goldLimit="+this.goldLimit
  64. })
  65. }
  66. },
  67. }
  68. </script>
  69. <style lang="scss" scoped>
  70. .goods-list{
  71. display: flex;
  72. flex-wrap: wrap;
  73. justify-content: space-between;
  74. padding-top: 20upx;
  75. .goods-item{
  76. background: #FFFFFF;
  77. width: 48%;
  78. margin-bottom: 5upx;
  79. .goods-imgs{
  80. position: relative;
  81. border-radius: 28upx 28upx 0 0;
  82. overflow: hidden;
  83. .goods-staus{
  84. width: 100%;
  85. height: 100%;
  86. position: absolute;
  87. z-index: 100;
  88. border-radius: 15rpx 15rpx 0 0;
  89. background: rgba($color: #000000, $alpha: 0.4);
  90. text-align: center;
  91. line-height: 250rpx;
  92. left: 0;
  93. top: 0;
  94. color: #eee;
  95. font-size: 30upx;
  96. font-weight: bold;
  97. }
  98. }
  99. .name{
  100. padding: 10upx 0;
  101. font-weight: bold;
  102. font-size: 30rpx;
  103. }
  104. .price{
  105. display: flex;
  106. align-items: center;
  107. justify-content: space-between;
  108. padding: 15upx 0;
  109. text{
  110. color: #d42a26;
  111. font-size: 36upx;
  112. margin-right: 6upx;
  113. font-weight: bold;
  114. }
  115. >view{
  116. &:first-child{
  117. font-size: 22upx;
  118. display: flex;
  119. align-items: center;
  120. }
  121. &:last-child{
  122. &:active{
  123. opacity: 0.5;
  124. }
  125. }
  126. }
  127. }
  128. }
  129. }
  130. </style>