uni-coods.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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&&item.state == 1" class="goods-staus">已售罄</view>
  6. <view v-if="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. this.$bindClick(function(){
  59. uni.$emit("addCart",{goodsNo:item.goodsNo,buyQty:1})
  60. })
  61. },
  62. // 商品详情
  63. toDetail(item){
  64. uni.navigateTo({
  65. url:"/pages/goods/goodsDetail?id="+item.id + "&goldLimit="+this.goldLimit
  66. })
  67. }
  68. },
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. .goods-list{
  73. display: flex;
  74. flex-wrap: wrap;
  75. justify-content: space-between;
  76. padding-top: 20upx;
  77. .goods-item{
  78. background: #FFFFFF;
  79. width: 48%;
  80. margin-bottom: 5upx;
  81. .goods-imgs{
  82. position: relative;
  83. border-radius: 28upx 28upx 0 0;
  84. overflow: hidden;
  85. .goods-staus{
  86. width: 100%;
  87. height: 100%;
  88. position: absolute;
  89. z-index: 100;
  90. border-radius: 15rpx 15rpx 0 0;
  91. background: rgba($color: #000000, $alpha: 0.4);
  92. text-align: center;
  93. line-height: 250rpx;
  94. left: 0;
  95. top: 0;
  96. color: #eee;
  97. font-size: 30upx;
  98. font-weight: bold;
  99. }
  100. }
  101. .name{
  102. padding: 10upx 0;
  103. font-weight: bold;
  104. font-size: 30rpx;
  105. }
  106. .price{
  107. display: flex;
  108. align-items: center;
  109. justify-content: space-between;
  110. padding: 15upx 0;
  111. text{
  112. color: #d42a26;
  113. font-size: 36upx;
  114. margin-right: 6upx;
  115. font-weight: bold;
  116. }
  117. >view{
  118. &:first-child{
  119. font-size: 22upx;
  120. display: flex;
  121. align-items: center;
  122. }
  123. &:last-child{
  124. &:active{
  125. opacity: 0.5;
  126. }
  127. }
  128. }
  129. }
  130. }
  131. }
  132. </style>