1
0

u-ordinary-list.vue 47 KB

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