goodList.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782
  1. <template>
  2. <view :style="[boxStyle]">
  3. <view>
  4. <!-- 单列 -->
  5. <view v-if="goodStyleConfig == 0">
  6. <view class="w-full flex justify-between item bg--w111-fff p-20 rd-16rpx"
  7. v-for="(item,index) in tempArr" :key="index"
  8. @tap="goDetail(item)">
  9. <easy-loadimage
  10. :image-src="item.image"
  11. :borderSrc="item.activity_frame.image"
  12. width="224rpx"
  13. height="224rpx"
  14. :borderRadius="imgStyle"></easy-loadimage>
  15. <view class="flex-1 flex-col justify-between pl-20">
  16. <view class="w-full fs-28 h-80 lh-40rpx line2"
  17. v-if="checkboxInfo.includes(0)" :style="[productStyle]">{{item.store_name}}</view>
  18. <view class="flex items-end flex-wrap mt-8 w-full" v-if="checkboxInfo.includes(1)">
  19. <BaseTag
  20. :text="label.label_name"
  21. :color="label.color"
  22. :background="label.bg_color"
  23. :borderColor="label.border_color"
  24. :circle="label.border_color ? true : false"
  25. :imgSrc="label.icon"
  26. v-for="(label, idx) in item.store_label" :key="idx"></BaseTag>
  27. </view>
  28. <view class="flex-between-center" v-if="onlyShowPrice">
  29. <baseMoney :money="item.price" symbolSize="24" integerSize="40" decimalSize="24" weight
  30. :color="priceColor"></baseMoney>
  31. <view @tap.stop="addCartChange(item, index)" v-if="!showBtn">
  32. <view class="w-96 h-56 rd-28rpx flex-center fs-24 text--w111-fff"
  33. v-if="btnStyle == 0" :style="[btnBgColor]">购买</view>
  34. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-else-if="btnStyle == 1">
  35. <view class="flex-center cart-btn">
  36. <text class="iconfont icon-ic_increase fs-26"></text>
  37. </view>
  38. </view>
  39. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-else>
  40. <view class="flex-center cart-btn">
  41. <text class="iconfont icon-ic_ShoppingCart1 fs-26"></text>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <view v-else>
  47. <view class="flex-y-center mt-4">
  48. <baseMoney :money="item.price" symbolSize="24" integerSize="40" decimalSize="24" weight
  49. :color="priceColor" v-if="checkboxInfo.includes(2)"></baseMoney>
  50. <view class="inline-block h-26 lh-28rpx rd-14rpx bg--w111-F7E9CD fs-22 ml-8"
  51. v-if="Number(item.vip_price) > 0 && item.is_vip && checkboxInfo.includes(5)">
  52. <text class="inline-block h-26 lh-28rpx svip_rd fs-18 bg--w111-484643 text--w111-FDDAA4 px-8">SVIP</text>
  53. <text class="px-8 fs-22">¥{{item.vip_price}}</text>
  54. </view>
  55. </view>
  56. <view class="flex justify-between items-end">
  57. <view class="flex-y-center">
  58. <text class="fs-22 text--w111-999" v-if="checkboxInfo.includes(3)">已售{{item.sales}}{{item.unit_name}}</text>
  59. <text class="fs-22 text--w111-999 pl-16" v-if="checkboxInfo.includes(4)">评分{{item.star}}</text>
  60. </view>
  61. <view @tap.stop="addCartChange(item, index)" v-if="!showBtn">
  62. <view class="w-96 h-56 rd-28rpx flex-center fs-24 text--w111-fff"
  63. v-if="btnStyle == 0" :style="[btnBgColor]">购买</view>
  64. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-else-if="btnStyle == 1">
  65. <view class="flex-center cart-btn">
  66. <text class="iconfont icon-ic_increase fs-26"></text>
  67. </view>
  68. </view>
  69. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-else>
  70. <view class="flex-center cart-btn">
  71. <text class="iconfont icon-ic_ShoppingCart1 fs-26"></text>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. <!-- 两列瀑布流 -->
  81. <view class="wf-page" v-if="goodStyleConfig == 1">
  82. <!-- left -->
  83. <view>
  84. <view id="left" v-if="leftList.length">
  85. <view v-for="(item,index) in leftList" :key="index" class="wf-item" @tap="goDetail(item)">
  86. <view class='pictrue'>
  87. <easy-loadimage
  88. mode="widthFix"
  89. :image-src="item.image"
  90. :borderSrc="item.activity_frame.image"
  91. width="100%"
  92. height="346rpx"
  93. :borderRadius="imgStyle"></easy-loadimage>
  94. </view>
  95. <view class="info_box">
  96. <view class="w-full line1 fs-28 text--w111-333 lh-40rpx"
  97. v-if="checkboxInfo.includes(0)" :style="[productStyle]">{{item.store_name}}</view>
  98. <view class="flex items-end flex-wrap mt-8 w-full" v-if="checkboxInfo.includes(1)">
  99. <BaseTag
  100. :text="label.label_name"
  101. :color="label.color"
  102. :background="label.bg_color"
  103. :borderColor="label.border_color"
  104. :circle="label.border_color ? true : false"
  105. :imgSrc="label.icon"
  106. v-for="(label, idx) in item.store_label" :key="idx"></BaseTag>
  107. </view>
  108. <view class="flex-between-center mt-20" v-if="onlyShowPrice">
  109. <baseMoney :money="item.price" symbolSize="24" integerSize="40" decimalSize="24" weight
  110. :color="priceColor"></baseMoney>
  111. <view @tap.stop="addCartChange(item, index)" v-if="!showBtn">
  112. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-if="btnStyle == 0">
  113. <view class="flex-center cart-btn">
  114. <text class="iconfont icon-ic_increase fs-26"></text>
  115. </view>
  116. </view>
  117. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-else>
  118. <view class="flex-center cart-btn">
  119. <text class="iconfont icon-ic_ShoppingCart1 fs-26"></text>
  120. </view>
  121. </view>
  122. </view>
  123. </view>
  124. <view v-else>
  125. <view class="flex-y-center mt-8">
  126. <baseMoney :money="item.price" symbolSize="24" integerSize="40" decimalSize="24" weight
  127. :color="priceColor" v-if="checkboxInfo.includes(2)"></baseMoney>
  128. <view class="inline-block h-26 lh-28rpx rd-14rpx bg--w111-F7E9CD fs-22 ml-8" v-if="Number(item.vip_price) > 0 && item.is_vip && checkboxInfo.includes(5)">
  129. <text class="inline-block h-26 lh-28rpx svip_rd fs-18 bg--w111-484643 text--w111-FDDAA4 px-8">SVIP</text>
  130. <text class="px-8 fs-22">¥{{item.vip_price}}</text>
  131. </view>
  132. </view>
  133. <view class="flex-between-center mt-20">
  134. <text class="fs-22 text--w111-999" v-if="checkboxInfo.includes(3)">已售{{item.sales}}{{item.unit_name}}</text>
  135. <view @tap.stop="addCartChange(item, index)" v-if="!showBtn">
  136. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-if="btnStyle == 0">
  137. <view class="flex-center cart-btn">
  138. <text class="iconfont icon-ic_increase fs-26"></text>
  139. </view>
  140. </view>
  141. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-else>
  142. <view class="flex-center cart-btn">
  143. <text class="iconfont icon-ic_ShoppingCart1 fs-26"></text>
  144. </view>
  145. </view>
  146. </view>
  147. </view>
  148. </view>
  149. </view>
  150. </view>
  151. </view>
  152. </view>
  153. <!-- right -->
  154. <view>
  155. <view id="right" v-if="rightList.length">
  156. <view v-for="(item,index) in rightList" :key="index"
  157. class="wf-item" @tap="goDetail(item)">
  158. <view class='pictrue'>
  159. <easy-loadimage
  160. mode="widthFix"
  161. :image-src="item.image"
  162. :borderSrc="item.activity_frame.image"
  163. width="100%"
  164. height="346rpx"
  165. :borderRadius="imgStyle"></easy-loadimage>
  166. </view>
  167. <view class="info_box">
  168. <view class="w-full line1 fs-28 text--w111-333 lh-40rpx"
  169. v-if="checkboxInfo.includes(0)" :style="[productStyle]">{{item.store_name}}</view>
  170. <view class="flex items-end flex-wrap mt-8 w-full" v-if="checkboxInfo.includes(1)">
  171. <BaseTag
  172. :text="label.label_name"
  173. :color="label.color"
  174. :background="label.bg_color"
  175. :borderColor="label.border_color"
  176. :circle="label.border_color ? true : false"
  177. :imgSrc="label.icon"
  178. v-for="(label, idx) in item.store_label" :key="idx"></BaseTag>
  179. </view>
  180. <view class="flex-between-center mt-20" v-if="onlyShowPrice">
  181. <baseMoney :money="item.price" symbolSize="24" integerSize="40" decimalSize="24" weight
  182. :color="priceColor"></baseMoney>
  183. <view @tap.stop="addCartChange(item, index)" v-if="!showBtn">
  184. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-if="btnStyle == 0">
  185. <view class="flex-center cart-btn">
  186. <text class="iconfont icon-ic_increase fs-26"></text>
  187. </view>
  188. </view>
  189. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-else>
  190. <view class="flex-center cart-btn">
  191. <text class="iconfont icon-ic_ShoppingCart1 fs-26"></text>
  192. </view>
  193. </view>
  194. </view>
  195. </view>
  196. <view v-else>
  197. <view class="flex-y-center mt-8">
  198. <baseMoney :money="item.price" symbolSize="24" integerSize="40" decimalSize="24" weight
  199. :color="priceColor" v-if="checkboxInfo.includes(2)"></baseMoney>
  200. <view class="inline-block h-26 lh-28rpx rd-14rpx bg--w111-F7E9CD fs-22 ml-8" v-if="Number(item.vip_price) > 0 && item.is_vip && checkboxInfo.includes(5)">
  201. <text class="inline-block h-26 lh-28rpx svip_rd fs-18 bg--w111-484643 text--w111-FDDAA4 px-8">SVIP</text>
  202. <text class="px-8 fs-22">¥{{item.vip_price}}</text>
  203. </view>
  204. </view>
  205. <view class="flex-between-center mt-20">
  206. <text class="fs-22 text--w111-999" v-if="checkboxInfo.includes(3)">已售{{item.sales}}{{item.unit_name}}</text>
  207. <view @tap.stop="addCartChange(item, index)" v-if="!showBtn">
  208. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-if="btnStyle == 0">
  209. <view class="flex-center cart-btn">
  210. <text class="iconfont icon-ic_increase fs-26"></text>
  211. </view>
  212. </view>
  213. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-else>
  214. <view class="flex-center cart-btn">
  215. <text class="iconfont icon-ic_ShoppingCart1 fs-26"></text>
  216. </view>
  217. </view>
  218. </view>
  219. </view>
  220. </view>
  221. </view>
  222. </view>
  223. </view>
  224. </view>
  225. </view>
  226. <!-- 两列展示(横向) -->
  227. <view class="pt-32 pr-24 pb-32 pl-24 bg--w111-fff rd-16rpx" v-if="goodStyleConfig == 3">
  228. <view class="grid-column-2 grid-gap-20rpx">
  229. <view class="flex" v-for="(item,index) in tempArr" :key="index" @tap="goDetail(item)">
  230. <easy-loadimage
  231. mode="widthFix"
  232. :image-src="item.image"
  233. :borderSrc="item.activity_frame.image"
  234. width="144rpx"
  235. height="144rpx"
  236. :borderRadius="imgStyle"></easy-loadimage>
  237. <view class="flex-1 pl-20">
  238. <view class="w-full fs-26 h-72 lh-36rpx line2 mb-20"
  239. v-if="checkboxInfo.includes(0)" :style="[productStyle]">{{item.store_name}}</view>
  240. <baseMoney :money="item.price" symbolSize="24" integerSize="40" decimalSize="24" weight
  241. :color="priceColor" v-if="checkboxInfo.includes(2)"></baseMoney>
  242. </view>
  243. </view>
  244. </view>
  245. </view>
  246. <!-- 三列 -->
  247. <view class="pt-32 pr-24 pb-32 pl-24 bg--w111-fff rd-16rpx" v-if="goodStyleConfig == 2">
  248. <view class="grid-column-3 grid-gap-20rpx">
  249. <view v-for="(item,index) in tempArr" :key="index" @tap="goDetail(item)">
  250. <easy-loadimage
  251. mode="widthFix"
  252. :image-src="item.image"
  253. :borderSrc="item.activity_frame.image"
  254. width="100%"
  255. height="210rpx"
  256. :borderRadius="imgStyle"></easy-loadimage>
  257. <view class="w-full fs-28 h-80 lh-40rpx line2 mt-20"
  258. v-if="checkboxInfo.includes(0)" :style="[productStyle]">{{item.store_name}}</view>
  259. <view class="flex-between-center mt-14">
  260. <baseMoney :money="item.price" symbolSize="24" integerSize="40" decimalSize="24" weight
  261. :color="priceColor" v-if="checkboxInfo.includes(2)"></baseMoney>
  262. <view @tap.stop="addCartChange(item, index)" v-if="!showBtn">
  263. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-if="btnStyle == 0">
  264. <view class="flex-center cart-btn">
  265. <text class="iconfont icon-ic_increase fs-26"></text>
  266. </view>
  267. </view>
  268. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-else>
  269. <view class="flex-center cart-btn">
  270. <text class="iconfont icon-ic_ShoppingCart1 fs-26"></text>
  271. </view>
  272. </view>
  273. </view>
  274. </view>
  275. </view>
  276. </view>
  277. </view>
  278. <!-- 大图展示 -->
  279. <view v-if="goodStyleConfig ==4">
  280. <view class="w-full item" v-for="(item,index) in tempArr" :key="index" @tap="goDetail(item)">
  281. <easy-loadimage
  282. mode="widthFix"
  283. :image-src="item.image"
  284. width="100%"
  285. height="360rpx"
  286. :borderRadius="imgStyle"></easy-loadimage>
  287. <view class="rd-b-24rpx p-24 bg--w111-fff">
  288. <view class="w-full line1 fs-28 text--w111-333 lh-40rpx mt-22"
  289. v-if="checkboxInfo.includes(0)" :style="[productStyle]">{{item.store_name}}</view>
  290. <view class="flex items-end flex-wrap mt-8 w-full" v-if="checkboxInfo.includes(1)">
  291. <BaseTag
  292. :text="label.label_name"
  293. :color="label.color"
  294. :background="label.bg_color"
  295. :borderColor="label.border_color"
  296. :circle="label.border_color ? true : false"
  297. :imgSrc="label.icon"
  298. v-for="(label, idx) in item.store_label" :key="idx"></BaseTag>
  299. </view>
  300. <view class="flex-between-center" v-if="onlyShowPrice">
  301. <baseMoney :money="item.price" symbolSize="24" integerSize="40" decimalSize="24" weight
  302. :color="priceColor"></baseMoney>
  303. <view @tap.stop="addCartChange(item, index)" v-if="!showBtn">
  304. <view class="w-96 h-56 rd-28rpx flex-center fs-24 text--w111-fff"
  305. v-if="btnStyle == 0" :style="[btnBgColor]">购买</view>
  306. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-else-if="btnStyle == 1">
  307. <view class="flex-center cart-btn">
  308. <text class="iconfont icon-ic_increase fs-26"></text>
  309. </view>
  310. </view>
  311. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-else>
  312. <view class="flex-center cart-btn">
  313. <text class="iconfont icon-ic_ShoppingCart1 fs-26"></text>
  314. </view>
  315. </view>
  316. </view>
  317. </view>
  318. <view v-else>
  319. <view class="flex-y-center mt-8">
  320. <baseMoney :money="item.price" symbolSize="24" integerSize="40" decimalSize="24" weight
  321. :color="priceColor" v-if="checkboxInfo.includes(2)"></baseMoney>
  322. <view class="inline-block h-26 lh-28rpx rd-14rpx bg--w111-F7E9CD fs-22 ml-8"
  323. v-if="Number(item.vip_price) > 0 && item.is_vip && checkboxInfo.includes(5)">
  324. <text class="inline-block h-26 lh-28rpx svip_rd fs-18 bg--w111-484643 text--w111-FDDAA4 px-8">SVIP</text>
  325. <text class="px-8 fs-22">¥{{item.vip_price}}</text>
  326. </view>
  327. </view>
  328. <view class="flex justify-between items-end">
  329. <view class="flex-y-center">
  330. <text class="fs-22 text--w111-999" v-if="checkboxInfo.includes(3)">已售{{item.sales}}{{item.unit_name}}</text>
  331. <text class="fs-22 text--w111-999 pl-16" v-if="checkboxInfo.includes(4)">评分{{item.star}}</text>
  332. </view>
  333. <view @tap.stop="addCartChange(item, index)" v-if="!showBtn">
  334. <view class="w-96 h-56 rd-28rpx flex-center fs-24 text--w111-fff"
  335. v-if="btnStyle == 0" :style="[btnBgColor]">购买</view>
  336. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-else-if="btnStyle == 1">
  337. <view class="flex-center cart-btn">
  338. <text class="iconfont icon-ic_increase fs-26"></text>
  339. </view>
  340. </view>
  341. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-else>
  342. <view class="flex-center cart-btn">
  343. <text class="iconfont icon-ic_ShoppingCart1 fs-26"></text>
  344. </view>
  345. </view>
  346. </view>
  347. </view>
  348. </view>
  349. </view>
  350. </view>
  351. </view>
  352. <!-- 横向滑动 -->
  353. <view class="pt-32 pb-32 pl-24 bg--w111-fff rd-16rpx" v-if="goodStyleConfig == 5">
  354. <scroll-view scroll-x="true" show-scrollbar="false"
  355. class="white-nowrap vertical-middle w-full">
  356. <view class="inline-block mr-20" v-for="(item,index) in tempArr" :key="index" @tap="goDetail(item)">
  357. <easy-loadimage
  358. mode="widthFix"
  359. :image-src="item.image"
  360. :borderSrc="item.activity_frame.image"
  361. width="200rpx"
  362. height="200rpx"
  363. :borderRadius="imgStyle"></easy-loadimage>
  364. <view class="w-200 fs-28 h-80 lh-40rpx line2 break_word mt-20"
  365. v-if="checkboxInfo.includes(0)" :style="[productStyle]">{{item.store_name}}</view>
  366. <view class="flex-between-center mt-8">
  367. <baseMoney :money="item.price" symbolSize="24" integerSize="40" decimalSize="24" weight
  368. :color="priceColor" v-if="checkboxInfo.includes(2)"></baseMoney>
  369. <view @tap.stop="addCartChange(item, index)" v-if="!showBtn">
  370. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-if="btnStyle == 0">
  371. <view class="flex-center cart-btn">
  372. <text class="iconfont icon-ic_increase fs-26"></text>
  373. </view>
  374. </view>
  375. <view class="rd-24rpx w-44 h-44" :style="[btnTextColor]" v-else>
  376. <view class="flex-center cart-btn">
  377. <text class="iconfont icon-ic_ShoppingCart1 fs-26"></text>
  378. </view>
  379. </view>
  380. </view>
  381. </view>
  382. </view>
  383. </scroll-view>
  384. </view>
  385. </view>
  386. <productWindow
  387. :attr="attr"
  388. :isShow='1'
  389. :iSplus='1'
  390. :iScart='1'
  391. :fangda="false"
  392. type="2"
  393. @myevent="onMyEvent"
  394. @ChangeAttr="ChangeAttr" @ChangeCartNum="ChangeCartNumDuo" @attrVal="attrVal"
  395. @iptCartNum="iptCartNum" @goCat="goCatNum" id='product-window' :is_vip="is_vip"></productWindow>
  396. </view>
  397. </template>
  398. <script>
  399. import { getProductslist, getAttr } from '@/api/store.js';
  400. import skuSelect from '@/mixins/skuSelect.js'
  401. import { toLogin } from '@/libs/login.js';
  402. import { mapGetters, mapState } from 'vuex';
  403. import { getCartCounts } from '@/api/order.js';
  404. import { goShopDetail } from '@/libs/order.js';
  405. import productWindow from '@/components/productWindow';
  406. export default {
  407. name: 'goodList',
  408. props: {
  409. dataConfig: {
  410. type: Object,
  411. default: () => {}
  412. },
  413. isSortType: {
  414. type: String | Number,
  415. default: 0
  416. }
  417. },
  418. components: {
  419. productWindow
  420. },
  421. mixins: [skuSelect],
  422. data() {
  423. return {
  424. tempArr: [],
  425. type:0,
  426. attr: {
  427. cartAttr: false,
  428. productAttr: [],
  429. productSelect: {}
  430. },
  431. id: 0,
  432. productValue: [],
  433. attrValue: '', //已选属性
  434. storeName: '', //多属性产品名称
  435. is_vip: 0, //是否是会员
  436. storeInfo: {},
  437. allList: [], // 全部列表
  438. leftList: [], // 左边列表
  439. rightList: [], // 右边列表
  440. mark: 0, // 列表标记
  441. boxHeight: [], // 下标0和1分别为左列和右列高度
  442. };
  443. },
  444. watch: {
  445. // 监听列表数据变化
  446. tempArr: {
  447. handler(nVal,oVal){
  448. // 如果数据为空或新的列表数据少于旧的列表数据(通常为下拉刷新或切换排序或使用筛选器),初始化变量
  449. if (!this.tempArr.length ||
  450. (this.tempArr.length === this.updateNum && this.tempArr.length <= this.allList.length)) {
  451. this.allList = [];
  452. this.leftList = [];
  453. this.rightList = [];
  454. this.boxHeight = [];
  455. this.mark = 0;
  456. }
  457. // 如果列表有值,调用waterfall方法
  458. if (this.tempArr.length) {
  459. this.allList = this.tempArr;
  460. this.leftList = [];
  461. this.rightList = [];
  462. this.boxHeight = [];
  463. this.allList.forEach((v, i) => {
  464. if(this.allList.length < 3 || (this.allList.length <= 7 && this.allList.length - i > 1) || (this.allList.length > 7 && this.allList.length - i > 2)) {
  465. if(i % 2){
  466. this.rightList.push(v);
  467. }else{
  468. this.leftList.push(v);
  469. }
  470. }
  471. });
  472. if(this.allList.length < 3){
  473. this.mark = this.allList.length+1;
  474. }else if(this.allList.length <= 7){
  475. this.mark = this.allList.length - 1;
  476. }else{
  477. this.mark = this.allList.length - 2;
  478. }
  479. if(this.mark < this.allList.length){
  480. this.waterFall()
  481. }
  482. }
  483. },
  484. immediate: true,
  485. deep:true
  486. },
  487. // 监听标记,当标记发生变化,则执行下一个item排序
  488. mark() {
  489. const len = this.allList.length;
  490. if (this.mark < len && this.mark !== 0 && this.boxHeight.length) {
  491. this.waterFall();
  492. }
  493. },
  494. dataConfig() {
  495. this.productslist();
  496. }
  497. },
  498. computed:{
  499. ...mapState({
  500. cartNum: state => state.indexData.cartNum
  501. }),
  502. ...mapGetters(['isLogin', 'uid', 'cartNum']),
  503. /*外层盒子样式*/
  504. boxStyle(){
  505. let borderRadius = `${this.dataConfig.fillet.val * 2}rpx`;
  506. if (this.dataConfig.fillet.type) {
  507. borderRadius =
  508. `${this.dataConfig.fillet.valList[0].val * 2}rpx ${this.dataConfig.fillet.valList[1].val * 2}rpx ${this.dataConfig.fillet.valList[2].val * 2}rpx ${this.dataConfig.fillet.valList[3].val * 2}rpx`;
  509. }
  510. return {
  511. borderRadius,
  512. padding: `${this.dataConfig.topConfig.val * 2}rpx ${this.dataConfig.prConfig.val * 2}rpx ${this.dataConfig.bottomConfig.val * 2}rpx`,
  513. marginTop: `${this.dataConfig.mbConfig.val * 2}rpx`,
  514. background: this.dataConfig.bottomBgColor.color[0].item,
  515. }
  516. },
  517. /*内层盒子样式*/
  518. // boxContentStyle() {
  519. // let borderRadius = `${this.dataConfig.fillet.val * 2}rpx`;
  520. // if (this.dataConfig.fillet.type) {
  521. // borderRadius =
  522. // `${this.dataConfig.fillet.valList[0].val * 2}rpx ${this.dataConfig.fillet.valList[1].val * 2}rpx ${this.dataConfig.fillet.valList[2].val * 2}rpx ${this.dataConfig.fillet.valList[3].val * 2}rpx`;
  523. // }
  524. // return {
  525. // borderRadius,
  526. // background: this.dataConfig.bottomBgColor.color[0].item
  527. // };
  528. // },
  529. styleConfig(){
  530. return this.dataConfig.styleConfig.tabVal
  531. },
  532. /*商品图片圆角样式*/
  533. imgStyle(){
  534. let borderRadius = `${this.dataConfig.filletImg.val * 2}rpx`;
  535. if (this.dataConfig.styleConfig.tabVal == 1) {
  536. borderRadius = `${this.dataConfig.filletImg.val * 2}rpx ${this.dataConfig.filletImg.val * 2}rpx 0 0`;
  537. }
  538. if (this.dataConfig.filletImg.type) {
  539. borderRadius =
  540. `${this.dataConfig.filletImg.valList[0].val * 2}rpx ${this.dataConfig.filletImg.valList[1].val * 2}rpx ${this.dataConfig.filletImg.valList[2].val * 2}rpx ${this.dataConfig.filletImg.valList[3].val * 2}rpx`;
  541. if (this.dataConfig.styleConfig.tabVal == 1) {
  542. borderRadius = `${this.dataConfig.filletImg.valList[0].val * 2}rpx ${this.dataConfig.filletImg.valList[1].val * 2}rpx 0 0`;
  543. }
  544. }
  545. return borderRadius
  546. },
  547. /*商品名称样式*/
  548. productStyle(){
  549. return {
  550. color: this.dataConfig.goodsNameColor.color[0].item,
  551. fontWeight: this.dataConfig.goodsName.tabVal ? 'normal' : '500'
  552. }
  553. },
  554. /* 展示信息 */
  555. checkboxInfo(){
  556. return this.dataConfig.checkboxInfo.type
  557. },
  558. /* 价格颜色 */
  559. priceColor(){
  560. return this.dataConfig.toneConfig.tabVal ? this.dataConfig.goodsPriceColor.color[0].item : 'var(--view-theme)'
  561. },
  562. /* 原价颜色 */
  563. otPriceColor(){
  564. return this.dataConfig.goodsPriceColor.color[0].item
  565. },
  566. btnStyle(){
  567. return this.dataConfig.bntStyleConfig.tabVal
  568. },
  569. showBtn(){
  570. return this.dataConfig.cartConfig.tabVal
  571. },
  572. /* 按钮颜色 */
  573. btnBgColor(){
  574. return {
  575. background: this.dataConfig.toneConfig.tabVal ? `linear-gradient(90deg,${this.dataConfig.bntBgColor.color[0].item} 0%,${this.dataConfig.bntBgColor.color[1].item} 100%)`: 'linear-gradient(90deg, var(--view-theme) 0%, var(--view-gradient) 100%)'
  576. }
  577. },
  578. btnTextColor(){
  579. return {
  580. color: this.dataConfig.toneConfig.tabVal ? this.dataConfig.bntBgColor.color[0].item: '#FFFFFF',
  581. background: this.dataConfig.toneCartConfig.tabVal ? `linear-gradient(90deg, ${this.dataConfig.bntBgColor.color[0].item} 0%, ${this.dataConfig.bntBgColor.color[1].item} 100%)` : 'linear-gradient(90deg, var(--view-theme) 0%, var(--view-gradient) 100%)',
  582. }
  583. },
  584. /*商品数量*/
  585. numberConfig(){
  586. return this.dataConfig.numberConfig.val
  587. },
  588. /*商品模板*/
  589. goodStyleConfig(){
  590. return this.dataConfig.styleConfig.tabVal
  591. },
  592. /*检索条件 0综合 1销量 2价格*/
  593. goodsSort(){
  594. return this.dataConfig.goodsSort.tabVal
  595. },
  596. /*按照什么方式选择商品 0 指定商品 1 指定品牌 2指定分类 3 商品标签 */
  597. typeConfig(){
  598. return this.dataConfig.typeConfig.activeValue
  599. },
  600. bntConfig(){
  601. return this.dataConfig.bntConfig.tabVal
  602. },
  603. onlyShowPrice(){
  604. if(this.checkboxInfo.toString() == '0,2' || this.checkboxInfo.toString() == '2,0' || this.checkboxInfo.toString() == '2'){
  605. return true
  606. }else{
  607. return false
  608. }
  609. }
  610. },
  611. created() {
  612. // #ifndef APP-PLUS
  613. // this.$eventHub.$on('product_video_observe', () => {
  614. // this.observeVideo();
  615. // });
  616. // #endif
  617. },
  618. mounted() {
  619. this.productslist();
  620. },
  621. methods: {
  622. observeVideo() {
  623. let observer = uni.createIntersectionObserver(this, { observeAll: true });
  624. observer.relativeToViewport().observe('.video', res => {
  625. if (res.intersectionRatio) {
  626. uni.createVideoContext(res.id, this).play();
  627. } else{
  628. uni.createVideoContext(res.id, this).pause();
  629. }
  630. });
  631. },
  632. productslist() {
  633. let limit = this.$config.LIMIT;
  634. let data = {};
  635. if (this.typeConfig == 1) {
  636. data = {
  637. ids: this.dataConfig.goodsList.ids.join(','),
  638. };
  639. } else {
  640. data = {
  641. priceOrder: this.goodsSort == 2 ? 'desc' : '',
  642. salesOrder: this.goodsSort == 1 ? 'desc' : '',
  643. brand_id: this.typeConfig == 2 ? this.dataConfig.brandList.brandVal.join(',') : '',
  644. store_label_id: this.typeConfig == 4 ? this.dataConfig.goodsLabel.activeValue.join(',') : '',
  645. cate_id: this.typeConfig == 3 ? this.dataConfig.classList.classVal.join(',') : '',
  646. limit: this.numberConfig
  647. };
  648. }
  649. getProductslist(data).then(res => {
  650. this.tempArr = res.data;
  651. });
  652. },
  653. goDetail(item) {
  654. goShopDetail(item, this.$store.state.app.uid).catch(res => {
  655. uni.navigateTo({
  656. url: `/pages/goods_details/index?id=${item.id}`
  657. });
  658. });
  659. },
  660. // 商品详情接口;
  661. getAttrs(id) {
  662. let that = this;
  663. getAttr(id, 0).then(res => {
  664. that.$set(that.attr, 'productAttr', res.data.productAttr);
  665. that.$set(that, 'productValue', res.data.productValue);
  666. that.$set(that, 'is_vip', res.data.storeInfo.is_vip);
  667. that.$set(that, 'storeInfo', res.data.storeInfo);
  668. that.DefaultSelect();
  669. })
  670. },
  671. addCartChange(item, index){
  672. if(this.bntConfig == 1){
  673. if(item.spec_type){
  674. this.goCartDuo(item);
  675. }else{
  676. this.goCartDan(item,index);
  677. }
  678. }else{
  679. this.goDetail(item);
  680. }
  681. },
  682. getCartNum() {
  683. let that = this;
  684. getCartCounts().then(res => {
  685. this.$store.commit('indexData/setCartNum', res.data.count)
  686. });
  687. },
  688. // 瀑布流排序
  689. waterFall() {
  690. const i = this.mark;
  691. if (i == 0) {
  692. // 初始化,从左边开始插入
  693. this.leftList.push(this.allList[i]);
  694. // 更新左边列表高度
  695. this.getViewHeight(0);
  696. } else if (i == 1) {
  697. // 第二个item插入,默认为右边插入
  698. this.rightList.push(this.allList[i]);
  699. // 更新右边列表高度
  700. this.getViewHeight(1);
  701. } else {
  702. // 根据左右列表高度判断下一个item应该插入哪边
  703. if(!this.boxHeight.length){
  704. this.rightList.length < this.leftList.length
  705. ? this.rightList.push(this.allList[i])
  706. : this.leftList.push(this.allList[i]);
  707. } else {
  708. const leftOrRight = this.boxHeight[0] > this.boxHeight[1] ? 1 : 0;
  709. if (leftOrRight) {
  710. this.rightList.push(this.allList[i])
  711. } else {
  712. this.leftList.push(this.allList[i])
  713. }
  714. }
  715. // 更新插入列表高度
  716. this.getViewHeight();
  717. }
  718. },
  719. // 获取列表高度
  720. getViewHeight() {
  721. // 使用nextTick,确保页面更新结束后,再请求高度
  722. this.$nextTick(() => {
  723. setTimeout(()=>{
  724. uni.createSelectorQuery().in(this).select('#right').boundingClientRect(res => {
  725. res ? this.boxHeight[1] = res.height : '';
  726. uni.createSelectorQuery().in(this).select('#left').boundingClientRect(res => {
  727. res ? this.boxHeight[0] = res.height : '';
  728. this.mark = this.mark + 1;
  729. }).exec();
  730. }).exec();
  731. },100)
  732. })
  733. },
  734. }
  735. };
  736. </script>
  737. <style lang="scss">
  738. $page-padding: 10px;
  739. $grid-gap: 10px;
  740. .wf-page {
  741. display: grid;
  742. grid-template-columns: 1fr 1fr;
  743. grid-gap: 20rpx;
  744. }
  745. .wf-item {
  746. width: calc((100vw - 2 * #{$page-padding} - #{$grid-gap}) / 2);
  747. padding-bottom: 20rpx;
  748. }
  749. .wf-page1 .wf-item{
  750. margin-top: 20rpx;
  751. background-color: #fff;
  752. border-radius: 20rpx;
  753. padding-bottom: 0;
  754. }
  755. .item ~ .item{
  756. margin-top: 32rpx;
  757. }
  758. .info_box{
  759. padding: 16rpx 20rpx;
  760. border-radius: 0 0 20rpx 20rpx;
  761. background-color: #fff;
  762. }
  763. .bg--w111-484643{
  764. background: linear-gradient(90deg, #484643 0%, #1F1B17 100%);
  765. }
  766. .text--w111-FDDAA4{
  767. color: #FDDAA4;
  768. }
  769. .svip_rd{
  770. border-radius: 14rpx 0 8rpx 14rpx;
  771. }
  772. .cart-btn{
  773. // background:rgba(255,255,255,0.9);
  774. width: 100%;
  775. height: 100%;
  776. }
  777. </style>