t-goods-item.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <view class="tui-goods__item" :class="{ 'tui-full__item': isList }" @tap="detail">
  3. <view class="tui-image__box" :class="{ 'tui-full__imgbox': isList }">
  4. <image class="tui-goods__img" :class="{ 'tui-full__img': isList }" :src="item.img" mode="widthFix"></image>
  5. </view>
  6. <view class="tui-goods__content" :class="{ 'tui-full__content': isList }">
  7. <view class="tui-goods__title">{{ item.name || '' }}</view>
  8. <view class="tui-tag__box" v-if="item.newGuest && !isList">
  9. <tui-tag plain size="24rpx" type="red" padding="8rpx 12rpx">新客专享</tui-tag>
  10. </view>
  11. <view class="tui-box__bottom">
  12. <view class="tui-price__box">
  13. <view class="tui-price">
  14. <view class="tui-price__small">¥</view>
  15. <view class="tui-price__large">{{ integerPrice }}</view>
  16. <view class="tui-price__small">.{{ decimalPrice }}</view>
  17. </view>
  18. <view class="tui-price__original">¥{{ item.factory || '0.00' }}</view>
  19. </view>
  20. <view :style="{ opacity: item.subscribe && status==3 ? 0.5 : 1 }">
  21. <tui-button :width="status == 3 ? '146rpx' : '144rpx'" :height="status == 3 ? '60rpx' : '50rpx'"
  22. :size="status == 3 ? 26 : 24" :type="status == 1 ? 'gray' : 'danger'" :disabled="status == 1"
  23. :plain="status == 3">
  24. {{getBtnText(status,item.subscribe) }}
  25. </tui-button>
  26. </view>
  27. </view>
  28. </view>
  29. <image v-if="item.newGuest && isList" src="https://thorui.cn/images/mall/img_seckill_newguest.png"
  30. class="tui-img__newguest" mode="widthFix"></image>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. name: 'tGoodsItem',
  36. props: {
  37. item: {
  38. type: Object,
  39. default () {
  40. return {};
  41. }
  42. },
  43. //是否为列表展示
  44. isList: {
  45. type: Boolean,
  46. default: false
  47. },
  48. //status:1-已结束,2-正在进行,3-即将开枪
  49. status: {
  50. type: Number,
  51. default: 2
  52. }
  53. },
  54. computed: {
  55. integerPrice: function() {
  56. let price = this.item.sale || '0.00';
  57. if (~price.indexOf('.')) {
  58. return price.split('.')[0];
  59. }
  60. return price;
  61. },
  62. decimalPrice: function() {
  63. let price = this.item.sale || '0.00';
  64. if (~price.indexOf('.')) {
  65. return price.split('.')[1];
  66. }
  67. return '00';
  68. }
  69. },
  70. data() {
  71. return {};
  72. },
  73. methods: {
  74. getBtnText(status, subscribe) {
  75. status = status || 1;
  76. let text = ['活动已结束', '立即抢购', '立即预约'][status - 1];
  77. if (status == 3 && subscribe) {
  78. text = '取消预约';
  79. }
  80. return text;
  81. },
  82. detail() {
  83. //项目中应该传id
  84. this.tui.href(`../seckillDetail/seckillDetail?status=${this.status}`)
  85. }
  86. }
  87. };
  88. </script>
  89. <style scoped>
  90. .tui-goods__item {
  91. width: 100%;
  92. padding: 20rpx 20rpx 36rpx;
  93. box-sizing: border-box;
  94. border-radius: 12rpx;
  95. background-color: #fff;
  96. margin-bottom: 4%;
  97. position: relative;
  98. }
  99. .tui-full__item {
  100. display: flex;
  101. margin-bottom: 20rpx !important;
  102. padding: 20rpx !important;
  103. }
  104. .tui-img__newguest {
  105. position: absolute;
  106. width: 96rpx;
  107. height: 32rpx;
  108. left: 0;
  109. top: 8rpx;
  110. }
  111. .tui-image__box {
  112. width: 100%;
  113. height: 300rpx;
  114. }
  115. .tui-full__imgbox {
  116. width: 240rpx !important;
  117. height: 240rpx !important;
  118. margin-right: 20rpx;
  119. }
  120. .tui-goods__img {
  121. max-width: 100%;
  122. max-height: 300rpx;
  123. display: block;
  124. border-radius: 8rpx;
  125. }
  126. .tui-full__img {
  127. max-height: 240rpx !important;
  128. }
  129. .tui-goods__content {
  130. width: 100%;
  131. padding-top: 16rpx;
  132. }
  133. .tui-full__content {
  134. height: 240rpx;
  135. display: flex;
  136. flex-direction: column;
  137. justify-content: space-between;
  138. padding-top: 0 !important;
  139. }
  140. .tui-goods__title {
  141. font-size: 26rpx;
  142. font-weight: 400;
  143. color: #333;
  144. word-break: break-all;
  145. overflow: hidden;
  146. text-overflow: ellipsis;
  147. display: -webkit-box;
  148. -webkit-box-orient: vertical;
  149. -webkit-line-clamp: 2;
  150. margin-bottom: 20rpx;
  151. }
  152. .tui-tag__box {
  153. display: flex;
  154. padding-bottom: 25rpx;
  155. }
  156. .tui-box__bottom {
  157. width: 100%;
  158. display: flex;
  159. align-items: center;
  160. justify-content: space-between;
  161. }
  162. .tui-price__box {
  163. display: flex;
  164. flex-direction: column;
  165. align-items: center;
  166. justify-content: center;
  167. }
  168. .tui-price {
  169. display: flex;
  170. align-items: flex-end;
  171. color: #eb0909;
  172. }
  173. .tui-price__small {
  174. font-size: 24rpx;
  175. line-height: 24rpx;
  176. }
  177. .tui-price__large {
  178. font-size: 34rpx;
  179. line-height: 32rpx;
  180. font-weight: 600;
  181. }
  182. .tui-price__original {
  183. font-size: 24rpx;
  184. line-height: 24rpx;
  185. text-decoration: line-through;
  186. color: #999;
  187. padding-top: 10rpx;
  188. }
  189. </style>