u-ordinary-list.vue 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150
  1. <template>
  2. <view class="u-list" v-show="is_show_off">
  3. <!--分类-->
  4. <template v-if="showCat && catList.length > 1">
  5. <scroll-view scroll-x v-bind:class="[theme, 'u-scroll-view', 'dir-left-nowrap']">
  6. <text
  7. v-for="(item, index) in catList"
  8. v-bind:key="index"
  9. v-bind:class="[
  10. catStyle === 2 && activeCurrent === index ?
  11. 'u-active-current-round ' + theme + '-m-back ' + theme :
  12. catStyle === 1 && activeCurrent === index ?
  13. 'u-active-current '+ theme + '-m-text ' + theme + ' ' + theme+ '-m-border': 'u-default-text',
  14. catStyle === 2 ? 'u-current-round' : '',
  15. 'u-nav-item'
  16. ]"
  17. v-on:click="changeNav(index)"
  18. >
  19. {{item.menuName}}
  20. </text>
  21. </scroll-view>
  22. </template>
  23. <!--商品列表-->
  24. <view v-bind:class="goodsListClass">
  25. <!--列表模式-->
  26. <template v-if="listStyle === -1 || (!listStyle && listStyle !== 0)">
  27. <block v-for="(goods, index) in goodsList" v-bind:key="index">
  28. <view
  29. v-bind:class="[goodsStyleObject, 'main-between', 'u-list-mode', 'dir-left-nowrap']"
  30. hover-class="goods-hover-class"
  31. v-on:click.stop="router(goods)"
  32. >
  33. <view class="box-grow-0 u-left">
  34. <!-- 售罄 -->
  35. <view
  36. v-if="isShowStock(goods)"
  37. class="u-out-dialog"
  38. >
  39. <image
  40. class="u-dialog-img"
  41. v-bind:src="sellOutPic"
  42. ></image>
  43. </view>
  44. <!-- 角标 -->
  45. <image
  46. v-if="showGoodsTag"
  47. v-bind:class="[tagLeftTop, 'u-goods-tag']"
  48. v-bind:src="goodsTagPicUrl"
  49. ></image>
  50. <!-- 商品封面图 -->
  51. <app-image
  52. borderRadius="16rpx"
  53. width="220rpx"
  54. height="220rpx"
  55. v-bind:img-src="goods.cover_pic"
  56. v-bind:mode="mode"
  57. ></app-image>
  58. </view>
  59. <view class="box-grow-1 u-right dir-top-nowrap main-between">
  60. <view
  61. v-if="(isDIY && showGoodsName) || isShowGoodsName"
  62. v-bind:class="[
  63. goods.vip_card_appoint.discount || ((goods.level_show === 1 || goods.level_show === 2) && goods.is_negotiable !== 1) ? 't-omit' : 't-omit-two',
  64. 'box-grow-0', 'u-goods-name'
  65. ]"
  66. >
  67. {{goods.name}}
  68. </view>
  69. <view class="box-grow-1 dir-left-nowrap cross-bottom">
  70. <view class="box-grow-1">
  71. <view v-if="isShowMemPrice(goods)" class="u-price-margin">
  72. <app-member-price
  73. v-bind:price="goods.level_price"
  74. :theme="themeObject"
  75. ></app-member-price>
  76. </view>
  77. <view v-if="isShowVip(goods)" class="u-price-margin">
  78. <app-sup-vip
  79. v-bind:is_vip_card_user="goods.vip_card_appoint.is_vip_card_user"
  80. v-bind:discount="goods.vip_card_appoint.discount"
  81. ></app-sup-vip>
  82. </view>
  83. <view
  84. v-if="showGoodsPrice || isShowOriginalPrice(goods)"
  85. v-bind:class="goods.is_sales === 1 ? 'dir-left-nowrap main-left cross-center' : 'dir-top-nowrap'"
  86. >
  87. <text v-if="showGoodsPrice" class="u-goods-price" v-bind:class="[theme + '-m-text ', theme]">{{goods.price_content}}</text>
  88. <text
  89. v-if="isShowOriginalPrice(goods)"
  90. v-bind:class="[goods.is_sales === 1 ? 'u-original-margin' : '', 'u-original-price']"
  91. >{{goods.original_price}}</text>
  92. </view>
  93. <view v-if="goods.is_sales === 1 && goods.is_negotiable !== 1" class="u-goods-sales">{{goods.sales}}</view>
  94. </view>
  95. <template v-if="isShowCart && goods.goods_stock !== 0 && goods.is_negotiable !== 1 || (isDIY && isShowBuyBtn(goods))">
  96. <view
  97. v-if="buyBtn === 'text'"
  98. v-on:click.stop="buyProduct(goods)"
  99. v-bind:style="btnStyle"
  100. v-bind:class="[buyBtnClass, 'u-text-btn', theme + '-m-back', theme]"
  101. >{{buyBtnText}}</view>
  102. <!-- <view
  103. v-else
  104. v-on:click.stop="buyProduct(goods)"
  105. v-bind:class="['u-cart-btn-icon', 'box-grow-0', 'u-cart-btn-icon-' + buyBtn, theme + '-m-back', theme]"
  106. ></view> -->
  107. </template>
  108. </view>
  109. </view>
  110. </view>
  111. </block>
  112. </template>
  113. <!--左右滑动-->
  114. <template v-else-if="listStyle === 0">
  115. <scroll-view scroll-x class="u-swipe-left-right ">
  116. <view class="dir-left-nowrap">
  117. <block v-for="(goods, index) in goodsList" v-bind:key="index">
  118. <view v-bind:class="goodsStyleObject" hover-class="goods-hover-class" v-on:click.stop="router(goods)" class="u-goods" >
  119. <view class="u-top">
  120. <!-- 售罄 -->
  121. <view
  122. v-if="isShowStock(goods)"
  123. class="u-out-dialog"
  124. >
  125. <image
  126. class="u-dialog-img"
  127. v-bind:src="sellOutPic"
  128. ></image>
  129. </view>
  130. <!-- 角标 -->
  131. <image
  132. v-if="showGoodsTag"
  133. v-bind:class="[tagLeftTop, 'u-goods-tag']"
  134. v-bind:src="goodsTagPicUrl"
  135. ></image>
  136. <!-- 商品封面图 -->
  137. <app-image
  138. borderRadius="16rpx 16rpx 0 0"
  139. width="200rpx"
  140. height="200rpx"
  141. v-bind:img-src="goods.cover_pic"
  142. v-bind:mode="mode"
  143. ></app-image>
  144. </view>
  145. <view class="u-content-height dir-top-nowrap main-between">
  146. <view
  147. v-if="showGoodsName"
  148. v-bind:class="[textAlign, 'u-goods-name', 't-omit-two']"
  149. style="font-size: 28rpx;"
  150. >
  151. {{goods.name}}
  152. </view>
  153. <view class="u-bottom">
  154. <view v-if="isShowMemPrice(goods)" v-bind:class="[pluginAlign, 'u-member-margin']">
  155. <app-member-price
  156. :theme="themeObject"
  157. v-bind:price="goods.level_price"
  158. ></app-member-price>
  159. </view>
  160. <view v-if="isShowVip(goods)" v-bind:class="[pluginAlign, 'u-member-margin']">
  161. <app-sup-vip
  162. v-bind:is_vip_card_user="goods.vip_card_appoint.is_vip_card_user"
  163. v-bind:discount="goods.vip_card_appoint.discount"
  164. ></app-sup-vip>
  165. </view>
  166. <view
  167. v-if="showGoodsPrice || isShowOriginalPrice(goods)"
  168. v-bind:class="[textAlign, 'dir-top-nowrap']"
  169. >
  170. <text v-if="showGoodsPrice" class="u-goods-price" v-bind:class="[theme + '-m-text', theme]" style="font-size: 28rpx;">{{goods.price_content}}</text>
  171. <text
  172. v-if="isShowOriginalPrice(goods)"
  173. class="u-original-price"
  174. >{{goods.original_price}}</text>
  175. </view>
  176. </view>
  177. </view>
  178. </view>
  179. </block>
  180. </view>
  181. </scroll-view>
  182. </template>
  183. <!--一行一个-->
  184. <template v-else-if="listStyle === 1">
  185. <block v-for="(goods, index) in goodsList" v-bind:key="index">
  186. <view hover-class="goods-hover-class" v-bind:class="goodsStyleObject" v-on:click.stop="router(goods)" class="u-one-per-line" >
  187. <view class="u-top">
  188. <!-- 售罄 -->
  189. <view v-if="isShowStock(goods)" class="u-out-dialog">
  190. <image class="u-dialog-img" v-bind:src="sellOutPic"></image>
  191. </view>
  192. <!-- 角标 -->
  193. <image
  194. v-if="showGoodsTag"
  195. v-bind:class="[tagLeftTop, 'u-goods-tag']"
  196. v-bind:src="goodsTagPicUrl"
  197. ></image>
  198. <!-- 商品封面图 -->
  199. <app-image
  200. width="100%"
  201. v-bind:img-src="goods.cover_pic"
  202. v-bind:height="coverPicHeight"
  203. v-bind:mode="mode"
  204. ></app-image>
  205. </view>
  206. <view v-if="showGoodsName" v-bind:class="[textAlign, 'u-goods-name', 't-omit']" >
  207. {{goods.name}}
  208. </view>
  209. <view class="u-bottom dir-left-nowrap cross-center">
  210. <view v-bind:class="[theme + '-m-text ', theme, 'box-grow-1', 'u-price']">
  211. <view v-bind:class="[textStyle === 2 ? 'main-center' : '', 'dir-left-nowrap', 'cross-center']">
  212. <view v-if="showGoodsPrice" class="u-goods-price">
  213. {{goods.price_content}}
  214. </view>
  215. <view v-if="isShowMemPrice(goods)" class="u-member-margin">
  216. <app-member-price
  217. :theme="themeObject"
  218. v-bind:price="goods.level_price"
  219. ></app-member-price>
  220. </view>
  221. <view v-if="isShowVip(goods)" class="u-member-margin">
  222. <app-sup-vip
  223. v-bind:is_vip_card_user="goods.vip_card_appoint.is_vip_card_user"
  224. v-bind:discount="goods.vip_card_appoint.discount"
  225. ></app-sup-vip>
  226. </view>
  227. </view>
  228. <view v-bind:class="[textAlign, 'u-original-price']" v-if="isShowOriginalPrice(goods)">
  229. ¥{{goods.original_price}}
  230. </view>
  231. </view>
  232. <template v-if="isShowBuyBtn(goods) === 1 && textStyle !== 2">
  233. <view
  234. v-if="buyBtn === 'text'"
  235. v-on:click.stop="buyProduct(goods)"
  236. v-bind:class="[buyBtnClass, 'u-text-btn', 'box-grow-0']"
  237. v-bind:style="btnStyle"
  238. >{{buyBtnText}}</view>
  239. <!-- <view
  240. v-else
  241. v-on:click.stop="buyProduct(goods)"
  242. v-bind:class="['u-cart-btn-icon', 'box-grow-0', 'u-cart-btn-icon-' + buyBtn, theme + '-m-back', theme]"
  243. ></view> -->
  244. </template>
  245. </view>
  246. </view>
  247. </block>
  248. </template>
  249. <!--一行两个-->
  250. <template v-else-if="listStyle === 2">
  251. <block v-for="(goods, index) in goodsList" v-bind:key="index">
  252. <view
  253. hover-class="goods-hover-class"
  254. v-on:click.stop="router(goods)"
  255. v-bind:class="[goodsStyleObject, 'u-one-line-two', 'dir-top-nowrap']"
  256. >
  257. <view class="u-top box-grow-0">
  258. <!-- 售罄 -->
  259. <view
  260. v-if="isShowStock(goods)"
  261. :class="goodsStyle !== 2 ? 'u-out-dialog' : 'u-border-out-dialog'"
  262. >
  263. <image
  264. :class="goodsStyle !== 2 ? 'u-dialog-img' : 'u-border-dialog-img'"
  265. v-bind:src="sellOutPic"
  266. ></image>
  267. </view>
  268. <!-- 角标 -->
  269. <image
  270. v-if="showGoodsTag"
  271. v-bind:class="[tagLeftTop, 'u-goods-tag']"
  272. v-bind:src="goodsTagPicUrl"
  273. ></image>
  274. <!-- 商品封面图 -->
  275. <app-image
  276. borderRadius="16rpx 16rpx 0 0"
  277. :width="goodsStyle === 2 ? '344rpx': '360rpx'"
  278. height="220rpx"
  279. v-bind:img-src="goods.cover_pic"
  280. v-bind:mode="mode"
  281. ></app-image>
  282. </view>
  283. <view v-bind:class="['u-bottom', 'box-grow-1', 'dir-top-nowrap', showGoodsName ? 'main-between' : 'main-right']">
  284. <view v-if="(isDIY && showGoodsName) || isShowGoodsName" v-bind:class="[textAlign, 'u-goods-name', 't-omit-two']">
  285. {{goods.name}}
  286. </view>
  287. <view class="box-grow-0 u-price dir-left-nowrap cross-bottom main-between" >
  288. <view class="box-grow-1">
  289. <view v-if="goods.sign == 'pick' && activity" class="u-margin dir-left-nowrap cross-bottom">
  290. <text :class="[themeObject.back, 'u-des-price']">
  291. {{activity.rule_price}}元任选{{activity.rule_num}}件
  292. </text>
  293. </view>
  294. <view v-if="goods.sign === 'advance'" class="u-margin dir-left-nowrap cross-bottom">
  295. <text :class="[themeObject.back, 'u-des-price']">
  296. 定金¥{{goods.deposit}}抵¥{{goods.swell_deposit}}
  297. </text>
  298. </view>
  299. <view v-if="goods.sign === 'flash_sale'" class="u-margin dir-left-nowrap cross-bottom">
  300. <text v-if="goods.discount_type === 1" :class="[themeObject.back, 'u-des-price']">{{goods.min_discount}}折
  301. </text>
  302. <text v-if="goods.discount_type === 2" :class="[themeObject.back, 'u-des-price']">减{{goods.min_discount}}元
  303. </text>
  304. </view>
  305. <view
  306. v-if="isShowMemPrice(goods)"
  307. v-bind:class="[pluginAlign, 'u-price-margin']"
  308. >
  309. <app-member-price :theme="themeObject" v-bind:price="goods.level_price"></app-member-price>
  310. </view>
  311. <view
  312. v-if="isShowVip(goods)"
  313. v-bind:class="[pluginAlign, 'u-price-margin']"
  314. >
  315. <app-sup-vip
  316. v-bind:is_vip_card_user="goods.vip_card_appoint.is_vip_card_user"
  317. v-bind:discount="goods.vip_card_appoint.discount"
  318. ></app-sup-vip>
  319. </view>
  320. <view v-if="showGoodsPrice || isShowOriginalPrice(goods)"
  321. v-bind:class="[goods.is_sales === 1 ? 'dir-left-nowrap main-left cross-center' : 'dir-top-nowrap', 'u-price-margin' , goods.is_sales === 1 ? pluginAlign : null]">
  322. <text v-if="showGoodsPrice" v-bind:class="[theme + '-m-text ', theme, 't-omit', 'u-goods-price', textAlign]">
  323. {{goods.price_content}}
  324. </text>
  325. <text v-if="isShowOriginalPrice(goods)" v-bind:class="[goods.is_sales === 1 ? 'u-original-margin' : '', 'u-original-price', textAlign]">
  326. ¥{{goods.original_price}}
  327. </text>
  328. </view>
  329. <view v-if="goods.is_sales === 1 && 0 && goods.is_negotiable !== 1" v-bind:class="[textAlign, 'u-goods-sales', !showGoodsPrice ? 'u-price-margin' : '']">{{goods.sales}}</view>
  330. </view>
  331. <template v-if="isShowCart && goods.goods_stock !== 0 && goods.is_negotiable !== 1 || (isDIY && isShowBuyBtn(goods) === 1 && textStyle !== 2)">
  332. <view
  333. v-if="buyBtn === 'text'"
  334. v-bind:class="[buyBtnClass, 'u-text-btn', 'box-grow-0']"
  335. v-bind:style="btnStyle"
  336. v-on:click.stop="buyProduct(goods)"
  337. >{{buyBtnText}}</view>
  338. <!-- <view
  339. v-else
  340. v-bind:class="['u-cart-btn-icon', 'box-grow-0', 'u-cart-btn-icon-' + buyBtn, theme + '-m-back', theme]"
  341. v-on:click.stop="buyProduct(goods)"
  342. ></view> -->
  343. </template>
  344. </view>
  345. </view>
  346. </view>
  347. </block>
  348. </template>
  349. <!--一行三个-->
  350. <template v-else-if="listStyle === 3">
  351. <block v-for="(goods, index) in goodsList" v-bind:key="index">
  352. <view
  353. hover-class="goods-hover-class"
  354. v-on:click.stop="router(goods)"
  355. v-bind:class="[goodsStyleObject, 'u-one-line-three', 'dir-top-nowrap', 'box-grow-0']"
  356. >
  357. <view class="u-top box-grow-0">
  358. <!-- 售罄 -->
  359. <view
  360. v-if="isShowStock(goods)"
  361. class="u-out-dialog"
  362. >
  363. <image
  364. class="u-dialog-img"
  365. v-bind:src="sellOutPic"
  366. ></image>
  367. </view>
  368. <!-- 角标 -->
  369. <image
  370. v-if="showGoodsTag"
  371. v-bind:class="[tagLeftTop, 'u-goods-tag']"
  372. v-bind:src="goodsTagPicUrl"
  373. ></image>
  374. <!-- 商品封面图 -->
  375. <app-image
  376. borderRadius="16rpx 16rpx 0 0"
  377. :width="goodsStyle === 2 ? '222rpx' : '224rpx'"
  378. height="224rpx"
  379. v-bind:img-src="goods.cover_pic"
  380. v-bind:mode="mode"
  381. ></app-image>
  382. </view>
  383. <view class="u-bottom box-grow-1 dir-top-nowrap main-between">
  384. <view v-if="(isDIY && showGoodsName) || isShowGoodsName" v-bind:class="[textAlign, 'box-grow-0', 'u-goods-name', 't-omit-two']">
  385. {{goods.name}}
  386. </view>
  387. <view class="box-grow-1 dir-top-nowrap main-right">
  388. <view
  389. v-if="isShowMemPrice(goods)"
  390. v-bind:class="[pluginAlign, 'u-price-margin']"
  391. >
  392. <app-member-price :theme="themeObject" v-bind:price="goods.level_price"></app-member-price>
  393. </view>
  394. <view
  395. v-if="isShowVip(goods)"
  396. v-bind:class="[pluginAlign, 'u-price-margin']"
  397. >
  398. <app-sup-vip
  399. v-bind:is_vip_card_user="goods.vip_card_appoint.is_vip_card_user"
  400. v-bind:discount="goods.vip_card_appoint.discount"
  401. ></app-sup-vip>
  402. </view>
  403. <view class="box-grow-0 u-price-margin dir-left-nowrap cross-center" v-bind:class="[!showGoodsPrice && textStyle !== 2 ? 'main-right' : 'main-between', textStyle === 2 ? 'main-center' : '']">
  404. <view v-if="showGoodsPrice || isShowOriginalPrice(goods)" :class="[theme + '-m-text', theme, 'u-goods-price']">
  405. <view v-if="showGoodsPrice" v-bind:class="textAlign">{{goods.price_content}}</view>
  406. <view v-if="isShowOriginalPrice(goods)" v-bind:class="[textAlign, 'u-original-price']">¥{{goods.original_price}}</view>
  407. <view v-if="!isDIY && goods.is_sales === 1 && goods.is_negotiable !== 1" v-bind:class="['u-goods-sales']">{{goods.sales}}</view>
  408. </view>
  409. <!-- <view
  410. v-if="isShowCart && goods.goods_stock !== 0 && goods.is_negotiable !== 1 || (isDIY && isShowBuyBtn(goods) && textStyle !== 2)"
  411. v-on:click.stop="buyProduct(goods)"
  412. v-bind:class="['u-cart-btn-icon', 'box-grow-0', 'u-cart-btn-icon-' + buyBtn, theme + '-m-back', theme]"
  413. >
  414. </view> -->
  415. <!-- <view v-if="isDIY && isShowBuyBtn(goods) === 0 && textStyle !== 2 && showBuyBtn" class="u-cart-btn-icon"></view> -->
  416. </view>
  417. </view>
  418. </view>
  419. </view>
  420. </block>
  421. </template>
  422. </view>
  423. <!--购物车-->
  424. <template v-if="isShowAttr">
  425. <app-attr
  426. :goods="attrGoods.goods"
  427. :previewUrl="previewUrl"
  428. :submitUrl="submitUrl"
  429. :attrGroupList="attrGoods.goods.attr_groups"
  430. :theme="theme"
  431. :show="attrGoods.attrShow"
  432. ></app-attr>
  433. </template>
  434. </view>
  435. </template>
  436. <script>
  437. import { mapGetters, mapState } from "vuex";
  438. import appAttr from "../../../components/page-component/app-attr/app-attr.vue";
  439. export default {
  440. name: "u-goods-list",
  441. props: {
  442. // 活动信息
  443. activity: {
  444. type: Object
  445. },
  446. // 是否为DIY
  447. isDIY: {
  448. type: Boolean,
  449. default: false
  450. },
  451. // 是否显示分类
  452. showCat: {
  453. type: Boolean
  454. },
  455. // 分裂列表
  456. catList: {
  457. type: Array
  458. },
  459. // 分类样式
  460. catStyle: {
  461. type: Number
  462. },
  463. // 主题色
  464. theme: {
  465. type: String
  466. },
  467. themeObject: {
  468. type: Object
  469. },
  470. // 商品列表
  471. list: {
  472. type: Array
  473. },
  474. // 列表样式 -1 列表模式 0 左右滑动 1 一行一个 2 一行两个 3 一行三个
  475. listStyle: {
  476. type: [Number , Boolean]
  477. },
  478. // 列表模式显示分割线 1 显示 0 不显示
  479. borderShow: {
  480. type: Number
  481. },
  482. // 商品样式 1 白底无边框 2 白底有边框 3 无底无边框
  483. goodsStyle: {
  484. type: Number
  485. },
  486. // 商品封面图是否填充 0 留白 1 填充
  487. fill: {
  488. type: Number,
  489. default: 1
  490. },
  491. // 商品右上角角标 url
  492. goodsTagPicUrl: {
  493. type: String
  494. },
  495. // 是否展示角标 0 不展示 1 展示
  496. showGoodsTag: {
  497. type: Number
  498. },
  499. // 是否展示商品名称 0 不展示 1 展示
  500. showGoodsName: {
  501. type: Number,
  502. default: 1
  503. },
  504. // 是否展示商品价格 0 不展示 1 展示
  505. showGoodsPrice: {
  506. type: Number,
  507. default: 1
  508. },
  509. // 显示购买按钮 0 不展示 1 展示
  510. showBuyBtn: {
  511. type: Number,
  512. default: 1
  513. },
  514. // 购买按钮样式 cart 购物车 add 加号 text 文字
  515. buyBtn: {
  516. type: String,
  517. default: 'text'
  518. },
  519. // 按钮样式
  520. buyBtnStyle: {
  521. type: Number
  522. },
  523. // 按钮文案
  524. buyBtnText: {
  525. type: String,
  526. default: '加入购物车'
  527. },
  528. // text按钮颜色
  529. buttonColor: {
  530. type: String
  531. },
  532. // 文本对齐方式 1 左对齐 2 居中
  533. textStyle: {
  534. type: Number
  535. },
  536. // 商品封面图宽高比例 1-1 3-2
  537. goodsCoverProportion: {
  538. type: String
  539. },
  540. // 原价显示
  541. isUnderLinePrice: {
  542. type: Boolean,
  543. default: true
  544. },
  545. // 是否显示规格
  546. isShowAttr: {
  547. type: Boolean,
  548. default: false
  549. },
  550. isBuy: {
  551. type: Boolean,
  552. default: true
  553. },
  554. // 预览接口
  555. previewUrl: {
  556. type: String
  557. },
  558. // 支付接口
  559. submitUrl: {
  560. type: String
  561. },
  562. // 载入间隔
  563. addTime: {
  564. type: Number,
  565. default: 0
  566. },
  567. // 分页加载
  568. pagination: {
  569. type: Boolean,
  570. default: false
  571. },
  572. reset: {
  573. type: Boolean,
  574. default: false
  575. }
  576. },
  577. computed: {
  578. ...mapState({
  579. // 全局设置
  580. appSetting: function(state) {
  581. return state.mallConfig.mall.setting
  582. },
  583. // 小程序图片
  584. appImg: function(state) {
  585. return state.mallConfig.__wxapp_img.mall;
  586. },
  587. // 全局显示购物车
  588. isShowCart: function(state) {
  589. return !this.isDIY && state.mallConfig.mall.setting.is_show_cart && this.showBuyBtn;
  590. },
  591. // 全局显示商品名称
  592. isShowGoodsName: function(state) {
  593. return !this.isDIY && state.mallConfig.mall.setting.is_show_goods_name;
  594. }
  595. }),
  596. ...mapGetters('mallConfig',{
  597. getVideo: 'getVideo'
  598. }),
  599. // 获取商品数组
  600. copyList() {
  601. if (!this.is_show_off) return [];
  602. if (this.showCat) {
  603. return this.catList[this.activeCurrent].goodsList;
  604. } else {
  605. return this.list;
  606. }
  607. },
  608. // 商品样式
  609. goodsStyleObject: function() {
  610. let str = '';
  611. this.goodsStyle === 2 ? str += 'u-is-border ' : '';
  612. this.goodsStyle !== 3 ? str += 'u-white-back': '';
  613. return str;
  614. },
  615. // 商品封面图是否填充
  616. mode: function() {
  617. let str = '';
  618. this.fill === 1 ? str = 'aspectFill' : str = 'aspectFit';
  619. return str;
  620. },
  621. // 售罄图片
  622. sellOutPic: function() {
  623. return this.appSetting.is_use_stock === '1' ? this.appImg.plugins_out : this.appSetting.sell_out_pic;
  624. },
  625. // 角标弧度
  626. tagLeftTop: function() {
  627. return this.listStyle === -1 || this.listStyle === 0 || this.listStyle === 2 || this.listStyle === 3 ? 'u-goods-tag-radius' : '';
  628. },
  629. // 文字按钮样式
  630. buyBtnClass: function() {
  631. let buyBtnClass = ``;
  632. if (this.buyBtnStyle == 2 || this.buyBtnStyle == 4) {
  633. buyBtnClass += `u-text-btn-border `;
  634. }
  635. if (this.buyBtnStyle == 4 || this.buyBtnStyle == 3) {
  636. buyBtnClass += `u-text-btn-radius`;
  637. }
  638. return buyBtnClass;
  639. },
  640. // 按钮样式
  641. btnStyle: function() {
  642. let btnStyle = ``;
  643. if (this.buyBtnStyle == 1 || this.buyBtnStyle == 3) {
  644. btnStyle += `background-color: ${this.buttonColor};color: #ffffff;`;
  645. } else {
  646. btnStyle += `border-color: ${this.buttonColor};color: ${this.buttonColor};`;
  647. }
  648. return btnStyle;
  649. },
  650. // 文本对齐方式
  651. textAlign: function() {
  652. return this.textStyle === 2 ? 'u-text-align' : null;
  653. },
  654. // 插件对齐方式
  655. pluginAlign: function() {
  656. return this.textStyle === 2 ? 'dir-left-nowrap main-center' : null;
  657. },
  658. // 一行一个图片高度
  659. coverPicHeight: function() {
  660. return this.goodsCoverProportion === '1-1' ? '702rpx' : '468rpx';
  661. },
  662. // 商品列表样式
  663. goodsListClass: function() {
  664. if (this.listStyle === 2) {
  665. return 'dir-left-wrap main-between u-goods-list';
  666. } else if (this.listStyle === 3) {
  667. return 'dir-left-wrap main-left u-one-line-three-list';
  668. } else if (this.listStyle === 0) {
  669. return 'u-swipe-left-right-list';
  670. } else if (this.borderShow === 1) {
  671. return 'u-goods-list u-bottom-border';
  672. } else {
  673. return 'u-goods-list';
  674. }
  675. }
  676. },
  677. data() {
  678. return {
  679. // 当前选中分类
  680. activeCurrent: 0,
  681. // 是否展示
  682. is_show_off: true,
  683. // 规格商品
  684. attrGoods: {
  685. goods: {},
  686. attrShow: 0
  687. },
  688. // 临时列表
  689. tempList: [],
  690. // 商品数组
  691. goodsList: []
  692. }
  693. },
  694. methods: {
  695. // 复制而不是引用对象和数组
  696. cloneData(data) {
  697. return JSON.parse(JSON.stringify(data));
  698. },
  699. // 循环载入
  700. splitData() {
  701. if (!this.tempList.length) return;
  702. let item = this.tempList[0];
  703. this.goodsList.push(item);
  704. this.tempList.splice(0, 1);
  705. if (this.tempList.length) {
  706. setTimeout(() => {
  707. this.splitData();
  708. }, this.addTime);
  709. }
  710. },
  711. // 切换分类
  712. changeNav(index) {
  713. this.goodsList = [];
  714. this.activeCurrent = index;
  715. this.tempList = this.cloneData(this.copyList);
  716. this.splitData();
  717. },
  718. // 是否展示售罄
  719. isShowStock(goods) {
  720. return this.appSetting.is_show_stock === 1 && goods.goods_stock === 0 ? 1: 0;
  721. },
  722. // 是否展示购物按钮
  723. isShowBuyBtn(goods) {
  724. return this.showBuyBtn && goods.goods_stock !== 0 && goods.is_negotiable !== 1 ? 1 : 0;
  725. },
  726. // 是否展示会员价
  727. isShowMemPrice(goods) {
  728. return (goods.level_show === 1 || goods.level_show === 2) && goods.is_negotiable !== 1 ? 1 : 0;
  729. },
  730. // 是否展示超级会员价
  731. isShowVip(goods) {
  732. return goods.vip_card_appoint && goods.vip_card_appoint.discount && goods.is_negotiable !== 1 ? 1 : 0;
  733. },
  734. // 是否显示原价
  735. isShowOriginalPrice(goods) {
  736. return false
  737. //return this.isUnderLinePrice && goods.is_negotiable !== 1 ? 1 : 0;
  738. },
  739. // 购买按钮点击事件
  740. buyProduct(goods) {
  741. if(this.isBuy) {
  742. if (this.isShowAttr) {
  743. this.attrGoods.goods = goods;
  744. this.attrGoods.attrShow = Math.random();
  745. } else {
  746. uni.showLoading({
  747. text: '',
  748. mask: true
  749. });
  750. this.$request({
  751. url: this.$api.goods.attr,
  752. data: {
  753. id: goods.id,
  754. mch_id: goods.mch_id
  755. }
  756. }).then(e => {
  757. uni.hideLoading();
  758. if (e.code === 0) {
  759. let data = Object.assign(goods, e.data);
  760. this.$emit('buyProduct', {
  761. goods: data,
  762. attrShow: Math.random()
  763. });
  764. } else {
  765. uni.showToast({
  766. title: e.msg,
  767. icon: 'none'
  768. })
  769. }
  770. })
  771. }
  772. }else {
  773. this.router(goods);
  774. }
  775. },
  776. // 路由跳转
  777. router(goods) {
  778. // #ifdef MP-BAIDU
  779. uni.navigateTo({
  780. url: goods.page_url
  781. });
  782. // #endif
  783. // #ifndef MP-BAIDU
  784. if (goods.video_url && this.getVideo == 1 && !(goods.sign === 'lottery' || goods.sign === 'bargain' || goods.sign === 'wholesale')) {
  785. let id = goods.id;
  786. if (goods.sign === 'advance') {
  787. id = goods.goods_id;
  788. } else if (goods.sign === 'gift') {
  789. id = id + '&is_share=1';
  790. }
  791. uni.navigateTo({
  792. url: `/pages/goods/video?goods_id=${id}&sign=${goods.sign}`
  793. });
  794. } else {
  795. uni.navigateTo({
  796. url: goods.page_url
  797. });
  798. }
  799. // #endif
  800. },
  801. empty() {
  802. this.goodsList = [];
  803. }
  804. },
  805. watch: {
  806. catList: {
  807. handler(newValue) {
  808. if (!this.showCat) return;
  809. !this.$validation.array(newValue) || this.$validation.isEmpty(newValue) ? this.is_show_off = false : this.is_show_off = true;
  810. },
  811. deep: true,
  812. immediate: true
  813. },
  814. copyList: {
  815. handler(nVal, oVal) {
  816. if (this.pagination && !this.reset) {
  817. let startIndex = Array.isArray(oVal) && oVal.length > 0 ? oVal.length : 0;
  818. this.tempList = this.tempList.concat(this.cloneData(nVal.slice(startIndex)));
  819. } else {
  820. this.goodsList = [];
  821. this.tempList = this.cloneData(nVal);
  822. }
  823. this.splitData();
  824. },
  825. deep: true,
  826. immediate: true
  827. }
  828. },
  829. components: {
  830. appAttr
  831. }
  832. }
  833. </script>
  834. <style scoped lang="scss">
  835. .u-des-price {
  836. display: inline-block;
  837. font-size: 19upx;
  838. color: #ffffff;
  839. border-radius: 7upx;
  840. padding: 0upx 5upx;
  841. }
  842. .u-list {
  843. width: 750upx;
  844. overflow: hidden;
  845. }
  846. .u-scroll-view {
  847. white-space: nowrap;
  848. width: 750upx;
  849. height: 99upx;
  850. padding: 0 5upx;
  851. .u-current-round {
  852. height: 56upx;
  853. padding-left: 24upx;
  854. padding-right: 24upx;
  855. border-radius: 30upx;
  856. line-height: 56upx;
  857. margin: 21.5upx 24upx;
  858. }
  859. }
  860. .u-nav-item {
  861. display: inline-block;
  862. height: 97upx;
  863. line-height: 97upx;
  864. font-size: 26upx;
  865. margin: 0 44upx;
  866. white-space: nowrap;
  867. border-bottom: 1upx solid transparent;
  868. }
  869. .u-active-current-round {
  870. color: white;
  871. }
  872. .u-default-text {
  873. color: #666666;
  874. }
  875. .u-goods-list {
  876. padding: 0 #{5rpx};
  877. &.u-bottom-border {
  878. padding: 0;
  879. padding-top: 24upx;
  880. >.u-list-mode {
  881. padding: 16upx 24upx;
  882. margin-bottom: 0;
  883. border-radius: 0;
  884. border-bottom: 1upx solid #e2e2e2;
  885. &:last-of-type {
  886. border-bottom: 0;
  887. }
  888. }
  889. }
  890. }
  891. .u-swipe-left-right-list {
  892. padding: 24upx 0 0 24upx;
  893. }
  894. .u-is-border {
  895. border: 1upx solid #e2e2e2;
  896. }
  897. .u-white-back {
  898. background-color: #ffffff;
  899. }
  900. %background-image {
  901. background-repeat: no-repeat;
  902. background-size: cover;
  903. background-position: center;
  904. }
  905. .u-text-btn {
  906. height: 48upx;
  907. line-height: 48upx;
  908. padding: 0 20upx;
  909. font-size: 28upx;
  910. color: #999;
  911. font-size: #{24rpx};
  912. }
  913. .u-text-btn-radius {
  914. border-radius: 24upx;
  915. }
  916. .u-text-btn-border {
  917. border: 1upx solid;
  918. }
  919. .u-out-dialog {
  920. position: absolute;
  921. height: 100%;
  922. z-index: 11;
  923. top: 0;
  924. left: 0;
  925. background-color: rgba(0,0,0,.5);
  926. }
  927. .u-border-out-dialog {
  928. position: absolute;
  929. height: 100%;
  930. z-index: 11;
  931. top: 0;
  932. left: 0;
  933. background-color: rgba(0,0,0,.5);
  934. }
  935. .u-text-align {
  936. text-align: center;
  937. }
  938. .u-goods-tag {
  939. position: absolute;
  940. left: 0;
  941. top: 0;
  942. z-index: 10;
  943. width: 64upx;
  944. height: 64upx;
  945. }
  946. .u-goods-tag-radius {
  947. border-top-left-radius: 16upx;
  948. }
  949. .u-original-price {
  950. color: #999999;
  951. font-size: 22upx;
  952. text-decoration: line-through;
  953. }
  954. .u-goods-sales {
  955. color: #b5b5b5;
  956. font-size: 24upx;
  957. }
  958. .u-cart-btn-icon {
  959. width: 50upx;
  960. height: 50upx;
  961. @extend %background-image;
  962. }
  963. .u-cart-btn-icon-cart {
  964. background-image: url('../../../static/image/icon/cats.png');
  965. }
  966. .u-cart-btn-icon-add {
  967. background-image: url('../../../static/image/icon/add-to.png');
  968. }
  969. .u-goods-name {
  970. color: #353535;
  971. }
  972. .u-original-margin {
  973. margin-left: 10upx;
  974. }
  975. .u-price-margin {
  976. margin-top: 5upx;
  977. // width: 209rpx;
  978. }
  979. .u-list-mode {
  980. margin-bottom: 32upx;
  981. border-radius: 16upx;
  982. .u-right {
  983. height: 220upx;
  984. padding: 28upx 24upx 15upx 20upx;
  985. }
  986. .u-left {
  987. position: relative;
  988. }
  989. .u-out-dialog {
  990. width: 220upx;
  991. border-radius: 16upx;
  992. }
  993. .u-dialog-img {
  994. border-radius: 16upx;
  995. width: 220upx;
  996. height: 220upx;
  997. }
  998. .u-goods-name {
  999. font-size: 28upx;
  1000. line-height: 38upx;
  1001. }
  1002. .u-goods-price {
  1003. font-size: 30upx;
  1004. }
  1005. }
  1006. .u-swipe-left-right {
  1007. padding-bottom: 24upx;
  1008. white-space: nowrap;
  1009. .u-goods {
  1010. display: inline-block;
  1011. border-radius: 16upx;
  1012. padding-bottom: 16upx;
  1013. margin-right: 16upx;
  1014. }
  1015. .u-top {
  1016. position: relative;
  1017. margin-bottom: 8upx;
  1018. }
  1019. .u-out-dialog {
  1020. width: 200upx;
  1021. border-radius: 16upx 16upx 0 0;
  1022. overflow: hidden;
  1023. }
  1024. .u-dialog-img {
  1025. width: 200upx;
  1026. height: 200upx;
  1027. }
  1028. .u-bottom {
  1029. padding: 0 10upx;
  1030. }
  1031. .u-goods-name {
  1032. font-size: 23upx;
  1033. line-height: 33upx;
  1034. margin-bottom: 8upx;
  1035. padding: 0 10upx 0 10upx;
  1036. }
  1037. .u-goods-price {
  1038. font-size: 23upx;
  1039. }
  1040. .u-member-margin {
  1041. margin-bottom: 8upx;
  1042. }
  1043. .u-content-height {
  1044. width: 200upx;
  1045. height: calc(100% - 208upx);
  1046. }
  1047. }
  1048. .u-one-per-line {
  1049. margin-bottom: 24upx;
  1050. border-radius: 0 0 16upx 16upx;
  1051. .u-top {
  1052. position: relative;
  1053. width: 100%;
  1054. }
  1055. .u-out-dialog {
  1056. width: 100%;
  1057. }
  1058. .u-dialog-img {
  1059. width: 100%;
  1060. height: 100%;
  1061. }
  1062. .u-bottom {
  1063. padding: 0 24upx 21upx 24upx;
  1064. margin-top: 16upx;
  1065. }
  1066. .u-goods-name {
  1067. padding: 30upx 24upx 0 24upx;
  1068. font-size: 28upx;
  1069. line-height: 38upx;
  1070. }
  1071. .u-goods-price {
  1072. font-size: 28upx;
  1073. }
  1074. .u-member-margin {
  1075. margin-left: 10upx;
  1076. }
  1077. }
  1078. .u-one-line-two {
  1079. width: 360upx;
  1080. margin-bottom: 25upx;
  1081. border-radius: 16upx;
  1082. .u-top {
  1083. width: 360upx;
  1084. height: 200upx;
  1085. position: relative;
  1086. }
  1087. .u-out-dialog, .u-dialog-img {
  1088. width: 360upx;
  1089. height: 346upx;
  1090. border-radius: 16upx 16upx 0 0;
  1091. }
  1092. .u-border-out-dialog, .u-border-dialog-img {
  1093. width: 360upx;
  1094. height: 346upx;
  1095. border-radius: 16upx 16upx 0 0;
  1096. }
  1097. .u-bottom {
  1098. padding-bottom: 15upx;
  1099. }
  1100. .u-goods-name {
  1101. margin-top: 20upx;
  1102. font-size: 28upx;
  1103. padding: 0 24upx;
  1104. line-height: 38upx;
  1105. }
  1106. .u-price {
  1107. padding: 0 24upx;
  1108. }
  1109. .u-goods-price {
  1110. font-size: 28upx;
  1111. }
  1112. }
  1113. .u-one-line-three-list {
  1114. padding: 24upx 9upx 0 24upx;
  1115. }
  1116. .u-one-line-three {
  1117. width: 224upx;
  1118. margin:0 15upx 16upx 0;
  1119. border-radius: 16upx;
  1120. .u-top {
  1121. position: relative;
  1122. }
  1123. .u-top, .u-out-dialog, .u-dialog-img {
  1124. width: 224upx;
  1125. height: 224upx;
  1126. border-right: 16upx 16upx 0 0;
  1127. }
  1128. .u-goods-name {
  1129. font-size: 26upx;
  1130. margin-top: 10upx;
  1131. line-height: 36upx;
  1132. }
  1133. .u-bottom {
  1134. padding: 0 10upx 15upx 10upx;
  1135. }
  1136. .u-goods-price {
  1137. font-size: 25upx;
  1138. }
  1139. .u-cart-btn-icon {
  1140. width: 45upx;
  1141. height: 45upx;
  1142. }
  1143. .u-goods-sales {
  1144. font-size: 22upx;
  1145. }
  1146. }
  1147. </style>