app-composition.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <view class="app-composition dir-left-nowrap">
  3. <view @click.stop="open">
  4. <view class="app-composition-goods" :class="item.goods_list.length == 2 ? 'two' : item.goods_list.length == 3 ? 'three' : item.goods_list.length == 4 ? 'four': 'five'" v-if="item.type == 1">
  5. <image :src="goods.cover_pic" v-for="goods in item.goods_list" :key="goods.id"></image>
  6. </view>
  7. <view class="app-composition-goods" :class="item.goods_list.length == 1 ? 'two' : item.goods_list.length == 2 ? 'three' : item.goods_list.length == 3 ? 'four': 'five'" v-if="item.type == 2">
  8. <image :src="goods.cover_pic" v-for="goods in item.host_list" :key="goods.id"></image>
  9. <image :src="goods.cover_pic" v-for="goods in item.goods_list" :key="goods.id"></image>
  10. </view>
  11. <slot></slot>
  12. </view>
  13. <view @click.stop="toDetail" class="app-composition-right">
  14. <view class="dir-left-nowrap cross-center app-composition-info">
  15. <view class="app-composition-type" v-if="item.type == 1 && !large">固定</view>
  16. <view class="app-composition-type" v-if="item.type == 2 && !large">搭配</view>
  17. <view class="app-composition-name t-omit" :class="large ? 'long-name' : ''">{{item.name}}</view>
  18. </view>
  19. <view class="app-composition-type" v-if="item.type == 1 && large">固定套餐</view>
  20. <view class="app-composition-type" v-if="item.type == 2 && large">搭配套餐</view>
  21. <view class="app-composition-price">
  22. 套餐价<text>¥{{item.min_composition_price}}</text>
  23. </view>
  24. <view class="app-composition-discount">
  25. 最多可省<text>¥{{item.max_discount}}</text>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import {mapState} from 'vuex';
  32. export default {
  33. name: "app-composition",
  34. props: {
  35. item: {
  36. type: Object
  37. },
  38. large: Boolean
  39. },
  40. data() {
  41. return {
  42. }
  43. },
  44. created() {
  45. let that = this;
  46. },
  47. methods: {
  48. open(e) {
  49. this.$emit('click', e);
  50. },
  51. toDetail(e) {
  52. this.$emit('look', e);
  53. }
  54. }
  55. }
  56. </script>
  57. <style scoped lang="scss">
  58. .app-composition {
  59. .app-composition-goods {
  60. width: #{288rpx};
  61. height: #{140rpx};
  62. flex-shrink: 0;
  63. margin-right: #{24rpx};
  64. position: relative;
  65. &.two {
  66. image {
  67. position: absolute;
  68. width: #{140rpx};
  69. height: #{140rpx};
  70. border-radius: #{8rpx};
  71. top: 0;
  72. }
  73. image:first-of-type {
  74. left: 0;
  75. }
  76. image:last-of-type {
  77. right: 0;
  78. }
  79. }
  80. &.three {
  81. image {
  82. position: absolute;
  83. width: #{140rpx};
  84. height: #{66rpx};
  85. border-radius: #{8rpx};
  86. }
  87. image:first-of-type {
  88. left: 0;
  89. top: 0;
  90. height: #{140rpx};
  91. width: #{140rpx};
  92. }
  93. image:nth-child(2) {
  94. top: 0;
  95. right: 0;
  96. }
  97. image:last-of-type {
  98. bottom: 0;
  99. right: 0;
  100. }
  101. }
  102. &.four {
  103. image {
  104. position: absolute;
  105. width: #{66rpx};
  106. height: #{66rpx};
  107. border-radius: #{8rpx};
  108. }
  109. image:first-of-type {
  110. left: 0;
  111. top: 0;
  112. height: #{140rpx};
  113. width: #{140rpx};
  114. }
  115. image:nth-child(2) {
  116. top: 0;
  117. right: 0;
  118. width: #{140rpx};
  119. }
  120. image:nth-child(3) {
  121. right: #{74rpx};
  122. bottom: 0;
  123. }
  124. image:last-of-type {
  125. right: 0;
  126. bottom: 0;
  127. }
  128. }
  129. &.five {
  130. image {
  131. position: absolute;
  132. width: #{66rpx};
  133. height: #{66rpx};
  134. border-radius: #{8rpx};
  135. }
  136. image:first-of-type {
  137. left: 0;
  138. top: 0;
  139. height: #{140rpx};
  140. width: #{140rpx};
  141. }
  142. image:nth-child(2) {
  143. top: 0;
  144. right: #{74rpx};
  145. }
  146. image:nth-child(3) {
  147. right: 0;
  148. top: 0;
  149. }
  150. image:nth-child(4) {
  151. right: #{74rpx};
  152. bottom: 0;
  153. }
  154. image:last-of-type {
  155. right: 0;
  156. bottom: 0;
  157. }
  158. }
  159. }
  160. .app-composition-right {
  161. width: #{342rpx};
  162. }
  163. .app-composition-info {
  164. height: #{44rpx};
  165. width: #{342rpx};
  166. .app-composition-type {
  167. font-size: #{22rpx};
  168. display: block;
  169. margin: 0 #{16rpx} 0 0;
  170. }
  171. .app-composition-name {
  172. height: #{44rpx};
  173. line-height: #{44rpx};
  174. width: #{260rpx};
  175. font-size: #{28rpx};
  176. color: #353535;
  177. &.long-name {
  178. width: #{342rpx};
  179. }
  180. }
  181. }
  182. .app-composition-type {
  183. padding: 0 #{12rpx};
  184. height: #{40rpx};
  185. line-height: #{36rpx};
  186. flex-shrink: 0;
  187. border: #{2rpx} solid #f39800;
  188. border-radius: #{20rpx};
  189. margin: #{14rpx} 0 0;
  190. font-size: #{22rpx};
  191. color: #f39800;
  192. display: inline-block;
  193. }
  194. .app-composition-price {
  195. color: #999999;
  196. font-size: #{24rpx};
  197. margin: #{14rpx} 0 #{10rpx};
  198. text {
  199. font-size: #{28rpx};
  200. color: #ff4544;
  201. }
  202. }
  203. .app-composition-discount {
  204. color: #999999;
  205. font-size: #{24rpx};
  206. }
  207. }
  208. </style>