goodList.vue 34 KB

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