goodList.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <view class="index-product-wrapper" :style="{ marginTop: mbConfig + 'rpx', background: themeColor,borderRadius: bgStyle+'rpx'}" v-if="tempArr.length">
  3. <!-- 单列 -->
  4. <block v-if="itemStyle == 0">
  5. <view class="list-box animated listA" :class="tempArr.length > 0 ? 'fadeIn on' : ''">
  6. <view class="item" v-for="(item, index) in tempArr" :key="index" @click="goDetail(item)">
  7. <view class="pictrue" :class="'cont'+conStyle">
  8. <easy-loadimage mode="widthFix" :image-src="item.image"></easy-loadimage>
  9. </view>
  10. <view class="text-info" style="display: flex; flex-direction: column; justify-content: space-between;">
  11. <view>
  12. <view v-if="titleShow" class="title line2">{{ item.store_name }}</view>
  13. <view class="merchant_info">
  14. <view v-if="item.merchant && item.merchant.type_name" :style="'background:'+labelColor" class="merchant_type">{{item.merchant.type_name}}</view>
  15. <view class="txt" :style="'border-color:'+priceColor+';color:'+priceColor+';'" v-if="item.issetCoupon && couponShow">领券</view>
  16. <view class="txt delivery" v-if="item.delivery_free">包邮</view>
  17. </view>
  18. </view>
  19. <view v-if="priceShow" class="price" :style="'color:'+priceColor">
  20. <text>¥</text>
  21. {{ item.price }}
  22. <view v-if="opriceShow" class="ot-price">{{item.ot_price}}</view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </block>
  28. <!-- 两列 -->
  29. <block v-if="itemStyle == 1">
  30. <view class="list-box animated" :class="tempArr.length > 0 ? 'fadeIn on' : ''">
  31. <view class="item" v-for="(item, index) in tempArr" :key="index" @click="goDetail(item)" :style="'border-radius:'+bgStyle+'rpx;'">
  32. <view class="pictrue picture1" :class="'cont'+conStyle">
  33. <!-- <image :src="item.image" mode=""></image> -->
  34. <easy-loadimage mode="widthFix" :image-src="item.image"></easy-loadimage>
  35. </view>
  36. <view class="text-info" style="background:#fff;">
  37. <view v-if="titleShow" class="title line2">{{ item.store_name }}</view>
  38. <view v-if="priceShow" class="price" :style="'color:'+priceColor">
  39. <text>¥</text>
  40. {{ item.price }}
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </block>
  46. <!-- 三列 -->
  47. <block v-if="itemStyle == 2">
  48. <view class="list-box animated listB" :class="tempArr.length > 0 ? 'fadeIn on' : ''">
  49. <view class="item" v-for="(item, index) in tempArr" :key="index" @click="goDetail(item)" :style="'border-radius:'+bgStyle+'rpx;'">
  50. <view class="pictrue" :class="'cont'+conStyle">
  51. <!-- <image :src="item.image" mode=""></image> -->
  52. <easy-loadimage mode="widthFix" :image-src="item.image"></easy-loadimage>
  53. </view>
  54. <view class="text-info" style="display: flex; flex-direction: column; justify-content: space-between;">
  55. <view v-if="titleShow" class="title line2">{{ item.store_name }}</view>
  56. <view v-if="priceShow || opriceShow" class="price">
  57. <view v-if="priceShow" :style="'color:'+priceColor">
  58. <text>¥</text>
  59. {{ item.price }}
  60. </view>
  61. <view v-if="opriceShow" class="old-price">
  62. <text>¥</text>
  63. {{ item.ot_price }}
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. </block>
  70. <!--大图-->
  71. <block v-if="itemStyle == 3">
  72. <view class="list-box animated listC" :class="tempArr.length > 0 ? 'fadeIn on' : ''">
  73. <view class="item" v-for="(item, index) in tempArr" :key="index" @click="goDetail(item)" :style="'border-radius:'+bgStyle+'rpx;'">
  74. <view class="pictrue" :class="'cont'+conStyle">
  75. <easy-loadimage mode="widthFix" :image-src="item.image"></easy-loadimage>
  76. </view>
  77. <view class="text-info" style="display: flex; flex-direction: column; justify-content: space-between;">
  78. <view v-if="titleShow" class="title line2">{{ item.store_name }}</view>
  79. <view v-if="priceShow || opriceShow" class="price">
  80. <view v-if="priceShow" :style="'color:'+priceColor">
  81. <text>¥</text>
  82. {{ item.price }}
  83. </view>
  84. <view v-if="opriceShow" class="old-price">
  85. <text>¥</text>
  86. {{ item.ot_price }}
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </block>
  93. </view>
  94. </template>
  95. <script>
  96. import { getProductslist } from '@/api/store.js';
  97. export default {
  98. name: 'goodList',
  99. props: {
  100. dataConfig: {
  101. type: Object,
  102. default: () => {}
  103. },
  104. merId: {
  105. type: String || Number,
  106. default: ''
  107. }
  108. },
  109. data() {
  110. return {
  111. tempArr: [],
  112. // imgStyle:this.dataConfig.imgStyle.type,
  113. mbConfig: this.dataConfig.mbConfig.val*2,
  114. numConfig: this.dataConfig.numConfig.val > 10 ? 10 : this.dataConfig.numConfig.val,
  115. themeColor: this.dataConfig.themeColor.color[0].item,
  116. priceColor: this.dataConfig.fontColor.color[0].item,
  117. labelColor: this.dataConfig.labelColor.color[0].item,
  118. itemStyle: this.dataConfig.itemStyle.type,
  119. sortType: this.dataConfig.goodsSort.type,
  120. conStyle: this.dataConfig.conStyle.type,
  121. bgStyle: this.dataConfig.bgStyle.type ? '20' : '0',
  122. type: this.dataConfig.tabConfig.tabVal || 0,
  123. selectId: this.dataConfig.selectConfig.activeValue || 0,
  124. productIds: this.dataConfig.goodsList.ids || [],
  125. titleShow: this.dataConfig.titleShow.val,
  126. opriceShow: this.dataConfig.opriceShow.val,
  127. priceShow: this.dataConfig.priceShow.val,
  128. couponShow: this.dataConfig.couponShow.val
  129. };
  130. },
  131. created() {
  132. console.log(this.dataConfig, 'this.dataConfi');
  133. },
  134. mounted() {
  135. this.productslist();
  136. },
  137. methods: {
  138. productslist() {
  139. let data = {};
  140. if (this.type == 1) {
  141. data = {
  142. mer_id: this.merId,
  143. product_ids: this.productIds.toString(),
  144. type: 1
  145. };
  146. } else {
  147. data = {
  148. mer_id: this.merId,
  149. order: this.sortType == 2 ? 'price_asc' : this.sortType == 1 ? 'sales' : '',
  150. cate_pid: this.selectId.toString(),
  151. limit: this.numConfig,
  152. type: 1
  153. };
  154. }
  155. getProductslist(data).then(res => {
  156. this.tempArr = res.data.list;
  157. });
  158. },
  159. goDetail(item) {
  160. this.$emit('detail', item);
  161. }
  162. }
  163. };
  164. </script>
  165. <style lang="scss">
  166. .index-product-wrapper {
  167. margin: 30rpx 20rpx 0 20rpx;
  168. .list-box {
  169. display: flex;
  170. flex-wrap: wrap;
  171. justify-content: space-between;
  172. padding: 20rpx 20rpx 0;
  173. .item {
  174. width: 328rpx;
  175. margin-bottom: 20rpx;
  176. overflow: hidden;
  177. position: relative;
  178. &.on {
  179. border-radius: 0;
  180. }
  181. .pictrue_log {
  182. width: 92rpx;
  183. height: 44rpx;
  184. font-size: 26rpx;
  185. line-height: 44rpx;
  186. }
  187. .pictrue,/deep/image,/deep/.easy-loadimage,/deep/uni-image {
  188. width: 100%;
  189. // height: 346rpx;
  190. display: block;
  191. }
  192. .picture1,/deep/.picture1 image,/deep/.picture1 .easy-loadimage,/deep/.picture1 uni-image {
  193. height: 346rpx;
  194. }
  195. .cont1,/deep/.cont1 image,/deep/.cont1 .easy-loadimage,/deep/.cont1 uni-image{
  196. border-radius: 16rpx;
  197. }
  198. .text-info {
  199. padding: 10rpx 20rpx 15rpx;
  200. .title {
  201. color: #222222;
  202. }
  203. .old-price {
  204. margin-top: 4rpx;
  205. font-size: 26rpx;
  206. color: #999;
  207. text-decoration: line-through;
  208. text {
  209. margin-right: 2px;
  210. font-size: 20rpx;
  211. }
  212. }
  213. .price {
  214. display: flex;
  215. margin-top: 20rpx;
  216. font-size: 36rpx;
  217. font-weight: 550;
  218. text {
  219. padding-bottom: 4rpx;
  220. font-size: 26rpx;
  221. font-weight: normal;
  222. }
  223. .ot-price{
  224. color: #aaa;
  225. font-size: 26rpx;
  226. text-decoration: line-through;
  227. margin-left: 6rpx;
  228. font-weight: normal;
  229. margin-top: 10rpx;
  230. }
  231. }
  232. }
  233. }
  234. .merchant_info{
  235. display: flex;
  236. align-items: center;
  237. margin-top: 20rpx;
  238. .merchant_type{
  239. color: #fff;
  240. line-height: 30rpx;
  241. padding: 0 10rpx;
  242. border-radius: 2rpx;
  243. font-size: 9rpx;
  244. }
  245. .txt {
  246. display: flex;
  247. align-items: center;
  248. justify-content: center;
  249. width: 56rpx;
  250. height: 28rpx;
  251. margin-left: 15rpx;
  252. border: 1px solid $theme-color;
  253. border-radius: 4rpx;
  254. font-size: 20rpx;
  255. font-weight: normal;
  256. &.delivery{
  257. color: #FF9000;
  258. border-color: #FF9000;
  259. }
  260. }
  261. }
  262. &.on {
  263. display: flex;
  264. }
  265. &.listA {
  266. .item {
  267. display: flex;
  268. width: 100%;
  269. .pictrue,/deep/image,/deep/.easy-loadimage,/deep/uni-image {
  270. width: 220rpx;
  271. height: 220rpx;
  272. }
  273. .text-info {
  274. width: 490rpx;
  275. }
  276. }
  277. }
  278. &.listB {
  279. justify-content: inherit;
  280. .item {
  281. width: 31.3%;
  282. margin-right: 3.05%;
  283. .pictrue,/deep/image,/deep/.easy-loadimage,/deep/uni-image {
  284. height: 220rpx;
  285. }
  286. &:nth-child(3n) {
  287. margin-right: 0;
  288. }
  289. .price{
  290. display: flex;
  291. font-size: 20rpx;
  292. .old-price{
  293. font-weight: normal;
  294. }
  295. }
  296. .text-info{
  297. padding: 10rpx 4rpx;
  298. }
  299. }
  300. }
  301. &.listC{
  302. .item{
  303. width: 100%;
  304. .pictrue,/deep/image,/deep/.easy-loadimage,/deep/uni-image{
  305. height: 320rpx;
  306. }
  307. .price{
  308. margin-top: 20rpx;
  309. font-size: 40rpx;
  310. display: flex;
  311. align-items: center;
  312. .old-price{
  313. font-weight: normal;
  314. font-size: 22rpx;
  315. margin-left: 10rpx;
  316. }
  317. }
  318. }
  319. }
  320. }
  321. }
  322. </style>