app-composition.vue 6.8 KB

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