u-ordinary-list.vue 32 KB

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