goodsAggregation.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view class="module-page">
  3. <navbar ref="navbarRef" :config="config" backColor="#333333"></navbar>
  4. <template v-if="carouselArr && carouselArr.length > 0">
  5. <sw-swiper :list='carouselArr' :height="370" />
  6. </template>
  7. <view class="module-content">
  8. <template v-if="moduleList && moduleList.length > 0 && onEmptyDate(moduleList)">
  9. <view class="module-item" v-for="(md , mi) in moduleList">
  10. <template v-if="md.goodsList && md.goodsList.length > 0">
  11. <view class="module-title">{{md.moduleName}}</view>
  12. <view class="module-goods">
  13. <view class="goods-item" v-for="item in md.goodsList"
  14. @click="goProductDetails('/pages/index?pageType=1&type=1&id=' + item.goodsId)">
  15. <view class="goods-img lazy-img">
  16. <image class="service-img" :src="item.goodsCover" mode="aspectFill"></image>
  17. <!-- <u-image class="service-img" :src="item.goodsCover" mode="aspectFit" :lazy-load="true" /> -->
  18. </view>
  19. <view class="goods-info">
  20. <view class="goods-title">{{item.goodsTitle}}</view>
  21. <view class="goods-price">
  22. <rich-text :nodes="$mUtil.priceBigSmall(item.goodsSalePrice)"></rich-text>
  23. <!-- <text class="line-price">¥ {{ item.goodsMarketPrice }}</text> -->
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <!-- <template v-else>
  30. <EmptyDate />
  31. </template> -->
  32. </view>
  33. </template>
  34. <template v-else-if="!loading">
  35. <EmptyDate />
  36. </template>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. getGoodsAggregationInfo_Api
  43. } from "@/api/government.js"
  44. import swSwiper from "@/components/sw-swiper/sw-swiper.vue"
  45. export default {
  46. components: {
  47. swSwiper
  48. },
  49. data() {
  50. return {
  51. config: {
  52. back: false,
  53. title: '',
  54. color: 'black',
  55. backgroundColor: [1, '#fff'],
  56. statusBarFontColor: 'black',
  57. rightSlot: true
  58. },
  59. activityAggregationId: undefined,
  60. loading: true,
  61. carouselArr: [],
  62. moduleList: [],
  63. aggregationInfo: {},
  64. isvisible: false
  65. };
  66. },
  67. onLoad(opt) {
  68. this.activityAggregationId = opt.activityAggregationId;
  69. this.getGoodsAggregationInfo()
  70. },
  71. onShow() {
  72. },
  73. watch: {
  74. // init
  75. config: {
  76. handler(newVal) {
  77. try {
  78. this.$refs.navbarRef.init()
  79. } catch (e) {
  80. //TODO handle the exception
  81. }
  82. },
  83. deep: true
  84. }
  85. },
  86. methods: {
  87. // 判断是否存在数据
  88. onEmptyDate(list) {
  89. let isData = false;
  90. try {
  91. const val = list.find(el => el && el.goodsList && el.goodsList.length > 0);
  92. isData = val || false;
  93. } catch (e) {
  94. isData = false
  95. };
  96. return isData
  97. },
  98. goProductDetails(path) {
  99. uni.navigateTo({
  100. url: path
  101. })
  102. },
  103. getGoodsAggregationInfo() {
  104. this.loading = true;
  105. getGoodsAggregationInfo_Api(this.activityAggregationId).then(res => {
  106. const {
  107. aggregationName,
  108. aggregationImg,
  109. moduleList
  110. } = res.data || {};
  111. this.aggregationInfo = res.data
  112. this.config.title = aggregationName;
  113. this.moduleList = moduleList || [];
  114. const imgs = aggregationImg.split(',');
  115. this.carouselArr = imgs || [];
  116. }).finally(() => {
  117. this.loading = false;
  118. })
  119. },
  120. }
  121. }
  122. </script>
  123. <style lang="scss" scoped>
  124. .module-page {
  125. width: 100%;
  126. min-height: 100vh;
  127. background-color: #FEFEFE;
  128. }
  129. .module-content {
  130. padding: 0 30rpx;
  131. .module-item {
  132. .module-title {
  133. font-size: 28rpx;
  134. font-family: PingFang SC, PingFang SC-Bold;
  135. font-weight: 700;
  136. color: #1a1a1a;
  137. text-align: center;
  138. padding: 30rpx 0;
  139. }
  140. .module-goods {
  141. display: flex;
  142. flex-wrap: wrap;
  143. justify-content: space-between;
  144. }
  145. }
  146. .goods-item {
  147. flex-shrink: 0;
  148. width: 336rpx;
  149. height: 512rpx;
  150. margin-bottom: 38rpx;
  151. background: #ffffff;
  152. border-radius: 18rpx;
  153. overflow: hidden;
  154. box-shadow: 0 2rpx 12rpx 0 rgba(0, 0, 0, 0.1);
  155. // &:nth-child(2n) {
  156. // margin-right: 0;
  157. // }
  158. .goods-img {
  159. width: 336rpx;
  160. height: 336rpx;
  161. border-radius: 18rpx 18rpx 0 0;
  162. vertical-align: middle;
  163. .service-img {
  164. width: 100%;
  165. height: 100%;
  166. }
  167. }
  168. .goods-info {
  169. padding: 0 20rpx 20rpx;
  170. padding-top: 14rpx;
  171. // height: calc(100% - 336rpx);
  172. display: flex;
  173. flex-direction: column;
  174. justify-content: space-between;
  175. .goods-title {
  176. // height: 90rpx;
  177. margin-bottom: 10rpx;
  178. overflow: hidden;
  179. text-overflow: ellipsis;
  180. display: -webkit-box;
  181. -webkit-box-orient: vertical;
  182. -webkit-line-clamp: 2;
  183. }
  184. .goods-price {
  185. display: flex;
  186. align-items: baseline;
  187. color: #FF6600;
  188. font-size: 36rpx;
  189. .line-price {
  190. font-size: 22rpx;
  191. color: #999999;
  192. margin-left: 16rpx;
  193. text-decoration: line-through;
  194. }
  195. }
  196. }
  197. }
  198. }
  199. .topRight {
  200. margin-right: 40rpx;
  201. }
  202. </style>