u-ordinary-list.vue 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145
  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': '346rpx'"
  277. height="346rpx"
  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 && 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: 'cart'
  517. },
  518. // 按钮样式
  519. buyBtnStyle: {
  520. type: Number
  521. },
  522. // 按钮文案
  523. buyBtnText: {
  524. type: String
  525. },
  526. // text按钮颜色
  527. buttonColor: {
  528. type: String
  529. },
  530. // 文本对齐方式 1 左对齐 2 居中
  531. textStyle: {
  532. type: Number
  533. },
  534. // 商品封面图宽高比例 1-1 3-2
  535. goodsCoverProportion: {
  536. type: String
  537. },
  538. // 原价显示
  539. isUnderLinePrice: {
  540. type: Boolean,
  541. default: true
  542. },
  543. // 是否显示规格
  544. isShowAttr: {
  545. type: Boolean,
  546. default: false
  547. },
  548. isBuy: {
  549. type: Boolean,
  550. default: true
  551. },
  552. // 预览接口
  553. previewUrl: {
  554. type: String
  555. },
  556. // 支付接口
  557. submitUrl: {
  558. type: String
  559. },
  560. // 载入间隔
  561. addTime: {
  562. type: Number,
  563. default: 0
  564. },
  565. // 分页加载
  566. pagination: {
  567. type: Boolean,
  568. default: false
  569. },
  570. reset: {
  571. type: Boolean,
  572. default: false
  573. }
  574. },
  575. computed: {
  576. ...mapState({
  577. // 全局设置
  578. appSetting: function(state) {
  579. return state.mallConfig.mall.setting
  580. },
  581. // 小程序图片
  582. appImg: function(state) {
  583. return state.mallConfig.__wxapp_img.mall;
  584. },
  585. // 全局显示购物车
  586. isShowCart: function(state) {
  587. return !this.isDIY && state.mallConfig.mall.setting.is_show_cart && this.showBuyBtn;
  588. },
  589. // 全局显示商品名称
  590. isShowGoodsName: function(state) {
  591. return !this.isDIY && state.mallConfig.mall.setting.is_show_goods_name;
  592. }
  593. }),
  594. ...mapGetters('mallConfig',{
  595. getVideo: 'getVideo'
  596. }),
  597. // 获取商品数组
  598. copyList() {
  599. if (!this.is_show_off) return [];
  600. if (this.showCat) {
  601. return this.catList[this.activeCurrent].goodsList;
  602. } else {
  603. return this.list;
  604. }
  605. },
  606. // 商品样式
  607. goodsStyleObject: function() {
  608. let str = '';
  609. this.goodsStyle === 2 ? str += 'u-is-border ' : '';
  610. this.goodsStyle !== 3 ? str += 'u-white-back': '';
  611. return str;
  612. },
  613. // 商品封面图是否填充
  614. mode: function() {
  615. let str = '';
  616. this.fill === 1 ? str = 'aspectFill' : str = 'aspectFit';
  617. return str;
  618. },
  619. // 售罄图片
  620. sellOutPic: function() {
  621. return this.appSetting.is_use_stock === '1' ? this.appImg.plugins_out : this.appSetting.sell_out_pic;
  622. },
  623. // 角标弧度
  624. tagLeftTop: function() {
  625. return this.listStyle === -1 || this.listStyle === 0 || this.listStyle === 2 || this.listStyle === 3 ? 'u-goods-tag-radius' : '';
  626. },
  627. // 文字按钮样式
  628. buyBtnClass: function() {
  629. let buyBtnClass = ``;
  630. if (this.buyBtnStyle == 2 || this.buyBtnStyle == 4) {
  631. buyBtnClass += `u-text-btn-border `;
  632. }
  633. if (this.buyBtnStyle == 4 || this.buyBtnStyle == 3) {
  634. buyBtnClass += `u-text-btn-radius`;
  635. }
  636. return buyBtnClass;
  637. },
  638. // 按钮样式
  639. btnStyle: function() {
  640. let btnStyle = ``;
  641. if (this.buyBtnStyle == 1 || this.buyBtnStyle == 3) {
  642. btnStyle += `background-color: ${this.buttonColor};color: #ffffff;`;
  643. } else {
  644. btnStyle += `border-color: ${this.buttonColor};color: ${this.buttonColor};`;
  645. }
  646. return btnStyle;
  647. },
  648. // 文本对齐方式
  649. textAlign: function() {
  650. return this.textStyle === 2 ? 'u-text-align' : null;
  651. },
  652. // 插件对齐方式
  653. pluginAlign: function() {
  654. return this.textStyle === 2 ? 'dir-left-nowrap main-center' : null;
  655. },
  656. // 一行一个图片高度
  657. coverPicHeight: function() {
  658. return this.goodsCoverProportion === '1-1' ? '702rpx' : '468rpx';
  659. },
  660. // 商品列表样式
  661. goodsListClass: function() {
  662. if (this.listStyle === 2) {
  663. return 'dir-left-wrap main-between u-goods-list';
  664. } else if (this.listStyle === 3) {
  665. return 'dir-left-wrap main-left u-one-line-three-list';
  666. } else if (this.listStyle === 0) {
  667. return 'u-swipe-left-right-list';
  668. } else if (this.borderShow === 1) {
  669. return 'u-goods-list u-bottom-border';
  670. } else {
  671. return 'u-goods-list';
  672. }
  673. }
  674. },
  675. data() {
  676. return {
  677. // 当前选中分类
  678. activeCurrent: 0,
  679. // 是否展示
  680. is_show_off: true,
  681. // 规格商品
  682. attrGoods: {
  683. goods: {},
  684. attrShow: 0
  685. },
  686. // 临时列表
  687. tempList: [],
  688. // 商品数组
  689. goodsList: []
  690. }
  691. },
  692. methods: {
  693. // 复制而不是引用对象和数组
  694. cloneData(data) {
  695. return JSON.parse(JSON.stringify(data));
  696. },
  697. // 循环载入
  698. splitData() {
  699. if (!this.tempList.length) return;
  700. let item = this.tempList[0];
  701. this.goodsList.push(item);
  702. this.tempList.splice(0, 1);
  703. if (this.tempList.length) {
  704. setTimeout(() => {
  705. this.splitData();
  706. }, this.addTime);
  707. }
  708. },
  709. // 切换分类
  710. changeNav(index) {
  711. this.goodsList = [];
  712. this.activeCurrent = index;
  713. this.tempList = this.cloneData(this.copyList);
  714. this.splitData();
  715. },
  716. // 是否展示售罄
  717. isShowStock(goods) {
  718. return this.appSetting.is_show_stock === 1 && goods.goods_stock === 0 ? 1: 0;
  719. },
  720. // 是否展示购物按钮
  721. isShowBuyBtn(goods) {
  722. return this.showBuyBtn && goods.goods_stock !== 0 && goods.is_negotiable !== 1 ? 1 : 0;
  723. },
  724. // 是否展示会员价
  725. isShowMemPrice(goods) {
  726. return (goods.level_show === 1 || goods.level_show === 2) && goods.is_negotiable !== 1 ? 1 : 0;
  727. },
  728. // 是否展示超级会员价
  729. isShowVip(goods) {
  730. return goods.vip_card_appoint && goods.vip_card_appoint.discount && goods.is_negotiable !== 1 ? 1 : 0;
  731. },
  732. // 是否显示原价
  733. isShowOriginalPrice(goods) {
  734. return this.isUnderLinePrice && goods.is_negotiable !== 1 ? 1 : 0;
  735. },
  736. // 购买按钮点击事件
  737. buyProduct(goods) {
  738. if(this.isBuy) {
  739. if (this.isShowAttr) {
  740. this.attrGoods.goods = goods;
  741. this.attrGoods.attrShow = Math.random();
  742. } else {
  743. uni.showLoading({
  744. text: '',
  745. mask: true
  746. });
  747. this.$request({
  748. url: this.$api.goods.attr,
  749. data: {
  750. id: goods.id,
  751. mch_id: goods.mch_id
  752. }
  753. }).then(e => {
  754. uni.hideLoading();
  755. if (e.code === 0) {
  756. let data = Object.assign(goods, e.data);
  757. this.$emit('buyProduct', {
  758. goods: data,
  759. attrShow: Math.random()
  760. });
  761. } else {
  762. uni.showToast({
  763. title: e.msg,
  764. icon: 'none'
  765. })
  766. }
  767. })
  768. }
  769. }else {
  770. this.router(goods);
  771. }
  772. },
  773. // 路由跳转
  774. router(goods) {
  775. // #ifdef MP-BAIDU
  776. uni.navigateTo({
  777. url: goods.page_url
  778. });
  779. // #endif
  780. // #ifndef MP-BAIDU
  781. if (goods.video_url && this.getVideo == 1 && !(goods.sign === 'lottery' || goods.sign === 'bargain' || goods.sign === 'wholesale')) {
  782. let id = goods.id;
  783. if (goods.sign === 'advance') {
  784. id = goods.goods_id;
  785. } else if (goods.sign === 'gift') {
  786. id = id + '&is_share=1';
  787. }
  788. uni.navigateTo({
  789. url: `/pages/goods/video?goods_id=${id}&sign=${goods.sign}`
  790. });
  791. } else {
  792. uni.navigateTo({
  793. url: goods.page_url
  794. });
  795. }
  796. // #endif
  797. },
  798. empty() {
  799. this.goodsList = [];
  800. }
  801. },
  802. watch: {
  803. catList: {
  804. handler(newValue) {
  805. if (!this.showCat) return;
  806. !this.$validation.array(newValue) || this.$validation.isEmpty(newValue) ? this.is_show_off = false : this.is_show_off = true;
  807. },
  808. deep: true,
  809. immediate: true
  810. },
  811. copyList: {
  812. handler(nVal, oVal) {
  813. if (this.pagination && !this.reset) {
  814. let startIndex = Array.isArray(oVal) && oVal.length > 0 ? oVal.length : 0;
  815. this.tempList = this.tempList.concat(this.cloneData(nVal.slice(startIndex)));
  816. } else {
  817. this.goodsList = [];
  818. this.tempList = this.cloneData(nVal);
  819. }
  820. this.splitData();
  821. },
  822. deep: true,
  823. immediate: true
  824. }
  825. },
  826. components: {
  827. appAttr
  828. }
  829. }
  830. </script>
  831. <style scoped lang="scss">
  832. .u-des-price {
  833. display: inline-block;
  834. font-size: 19upx;
  835. color: #ffffff;
  836. border-radius: 7upx;
  837. padding: 0upx 5upx;
  838. }
  839. .u-list {
  840. width: 750upx;
  841. overflow: hidden;
  842. }
  843. .u-scroll-view {
  844. white-space: nowrap;
  845. width: 750upx;
  846. height: 99upx;
  847. padding: 0 5upx;
  848. .u-current-round {
  849. height: 56upx;
  850. padding-left: 24upx;
  851. padding-right: 24upx;
  852. border-radius: 30upx;
  853. line-height: 56upx;
  854. margin: 21.5upx 24upx;
  855. }
  856. }
  857. .u-nav-item {
  858. display: inline-block;
  859. height: 97upx;
  860. line-height: 97upx;
  861. font-size: 26upx;
  862. margin: 0 44upx;
  863. white-space: nowrap;
  864. border-bottom: 1upx solid transparent;
  865. }
  866. .u-active-current-round {
  867. color: white;
  868. }
  869. .u-default-text {
  870. color: #666666;
  871. }
  872. .u-goods-list {
  873. padding: 24upx 24upx 0 24upx;
  874. &.u-bottom-border {
  875. padding: 0;
  876. padding-top: 24upx;
  877. >.u-list-mode {
  878. padding: 16upx 24upx;
  879. margin-bottom: 0;
  880. border-radius: 0;
  881. border-bottom: 1upx solid #e2e2e2;
  882. &:last-of-type {
  883. border-bottom: 0;
  884. }
  885. }
  886. }
  887. }
  888. .u-swipe-left-right-list {
  889. padding: 24upx 0 0 24upx;
  890. }
  891. .u-is-border {
  892. border: 1upx solid #e2e2e2;
  893. }
  894. .u-white-back {
  895. background-color: #ffffff;
  896. }
  897. %background-image {
  898. background-repeat: no-repeat;
  899. background-size: cover;
  900. background-position: center;
  901. }
  902. .u-text-btn {
  903. height: 48upx;
  904. line-height: 48upx;
  905. padding: 0 20upx;
  906. font-size: 28upx;
  907. }
  908. .u-text-btn-radius {
  909. border-radius: 24upx;
  910. }
  911. .u-text-btn-border {
  912. border: 1upx solid;
  913. }
  914. .u-out-dialog {
  915. position: absolute;
  916. height: 100%;
  917. z-index: 11;
  918. top: 0;
  919. left: 0;
  920. background-color: rgba(0,0,0,.5);
  921. }
  922. .u-border-out-dialog {
  923. position: absolute;
  924. height: 100%;
  925. z-index: 11;
  926. top: 0;
  927. left: 0;
  928. background-color: rgba(0,0,0,.5);
  929. }
  930. .u-text-align {
  931. text-align: center;
  932. }
  933. .u-goods-tag {
  934. position: absolute;
  935. left: 0;
  936. top: 0;
  937. z-index: 10;
  938. width: 64upx;
  939. height: 64upx;
  940. }
  941. .u-goods-tag-radius {
  942. border-top-left-radius: 16upx;
  943. }
  944. .u-original-price {
  945. color: #999999;
  946. font-size: 22upx;
  947. text-decoration: line-through;
  948. }
  949. .u-goods-sales {
  950. color: #b5b5b5;
  951. font-size: 24upx;
  952. }
  953. .u-cart-btn-icon {
  954. width: 50upx;
  955. height: 50upx;
  956. @extend %background-image;
  957. }
  958. .u-cart-btn-icon-cart {
  959. background-image: url('../../../static/image/icon/cats.png');
  960. }
  961. .u-cart-btn-icon-add {
  962. background-image: url('../../../static/image/icon/add-to.png');
  963. }
  964. .u-goods-name {
  965. color: #353535;
  966. }
  967. .u-original-margin {
  968. margin-left: 10upx;
  969. }
  970. .u-price-margin {
  971. margin-top: 5upx;
  972. // width: 209rpx;
  973. }
  974. .u-list-mode {
  975. margin-bottom: 32upx;
  976. border-radius: 16upx;
  977. .u-right {
  978. height: 220upx;
  979. padding: 28upx 24upx 15upx 20upx;
  980. }
  981. .u-left {
  982. position: relative;
  983. }
  984. .u-out-dialog {
  985. width: 220upx;
  986. border-radius: 16upx;
  987. }
  988. .u-dialog-img {
  989. border-radius: 16upx;
  990. width: 220upx;
  991. height: 220upx;
  992. }
  993. .u-goods-name {
  994. font-size: 28upx;
  995. line-height: 38upx;
  996. }
  997. .u-goods-price {
  998. font-size: 30upx;
  999. }
  1000. }
  1001. .u-swipe-left-right {
  1002. padding-bottom: 24upx;
  1003. white-space: nowrap;
  1004. .u-goods {
  1005. display: inline-block;
  1006. border-radius: 16upx;
  1007. padding-bottom: 16upx;
  1008. margin-right: 16upx;
  1009. }
  1010. .u-top {
  1011. position: relative;
  1012. margin-bottom: 8upx;
  1013. }
  1014. .u-out-dialog {
  1015. width: 200upx;
  1016. border-radius: 16upx 16upx 0 0;
  1017. overflow: hidden;
  1018. }
  1019. .u-dialog-img {
  1020. width: 200upx;
  1021. height: 200upx;
  1022. }
  1023. .u-bottom {
  1024. padding: 0 10upx;
  1025. }
  1026. .u-goods-name {
  1027. font-size: 23upx;
  1028. line-height: 33upx;
  1029. margin-bottom: 8upx;
  1030. padding: 0 10upx 0 10upx;
  1031. }
  1032. .u-goods-price {
  1033. font-size: 23upx;
  1034. }
  1035. .u-member-margin {
  1036. margin-bottom: 8upx;
  1037. }
  1038. .u-content-height {
  1039. width: 200upx;
  1040. height: calc(100% - 208upx);
  1041. }
  1042. }
  1043. .u-one-per-line {
  1044. margin-bottom: 24upx;
  1045. border-radius: 0 0 16upx 16upx;
  1046. .u-top {
  1047. position: relative;
  1048. width: 100%;
  1049. }
  1050. .u-out-dialog {
  1051. width: 100%;
  1052. }
  1053. .u-dialog-img {
  1054. width: 100%;
  1055. height: 100%;
  1056. }
  1057. .u-bottom {
  1058. padding: 0 24upx 21upx 24upx;
  1059. margin-top: 16upx;
  1060. }
  1061. .u-goods-name {
  1062. padding: 30upx 24upx 0 24upx;
  1063. font-size: 28upx;
  1064. line-height: 38upx;
  1065. }
  1066. .u-goods-price {
  1067. font-size: 28upx;
  1068. }
  1069. .u-member-margin {
  1070. margin-left: 10upx;
  1071. }
  1072. }
  1073. .u-one-line-two {
  1074. width: 346upx;
  1075. margin-bottom: 25upx;
  1076. border-radius: 16upx;
  1077. .u-top {
  1078. width: 346upx;
  1079. height: 346upx;
  1080. position: relative;
  1081. }
  1082. .u-out-dialog, .u-dialog-img {
  1083. width: 346upx;
  1084. height: 346upx;
  1085. border-radius: 16upx 16upx 0 0;
  1086. }
  1087. .u-border-out-dialog, .u-border-dialog-img {
  1088. width: 344upx;
  1089. height: 346upx;
  1090. border-radius: 16upx 16upx 0 0;
  1091. }
  1092. .u-bottom {
  1093. padding-bottom: 15upx;
  1094. }
  1095. .u-goods-name {
  1096. margin-top: 20upx;
  1097. font-size: 28upx;
  1098. padding: 0 24upx;
  1099. line-height: 38upx;
  1100. }
  1101. .u-price {
  1102. padding: 0 24upx;
  1103. }
  1104. .u-goods-price {
  1105. font-size: 28upx;
  1106. }
  1107. }
  1108. .u-one-line-three-list {
  1109. padding: 24upx 9upx 0 24upx;
  1110. }
  1111. .u-one-line-three {
  1112. width: 224upx;
  1113. margin:0 15upx 16upx 0;
  1114. border-radius: 16upx;
  1115. .u-top {
  1116. position: relative;
  1117. }
  1118. .u-top, .u-out-dialog, .u-dialog-img {
  1119. width: 224upx;
  1120. height: 224upx;
  1121. border-right: 16upx 16upx 0 0;
  1122. }
  1123. .u-goods-name {
  1124. font-size: 26upx;
  1125. margin-top: 10upx;
  1126. line-height: 36upx;
  1127. }
  1128. .u-bottom {
  1129. padding: 0 10upx 15upx 10upx;
  1130. }
  1131. .u-goods-price {
  1132. font-size: 25upx;
  1133. }
  1134. .u-cart-btn-icon {
  1135. width: 45upx;
  1136. height: 45upx;
  1137. }
  1138. .u-goods-sales {
  1139. font-size: 22upx;
  1140. }
  1141. }
  1142. </style>