app-recommended-product-list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <template>
  2. <view class="app-recommended-product-list dir-left-nowrap">
  3. <scroll-view scroll-y class="app-classification" :style="{height: `${height - 110}rpx`}" :class="theme">
  4. <text class="app-class-item"
  5. v-for="(item, index) in catList" :key="index"
  6. :class="activeIndex === index ? theme + '-m-text ' + theme + ' ' + theme + '-m-border' : 'default-text'"
  7. @click="goClass(index)"
  8. >{{item.menuName}}</text>
  9. </scroll-view>
  10. <view class="app-product">
  11. <scroll-view class="app-product-scroll" :scroll-into-view="`scroll-${activeIndex}`" :style="{height: `${height - 110}rpx`}" scroll-y>
  12. <block v-for="(page, number) in catList" :key="number">
  13. <view class="app-product-class-item">
  14. <text class="app-class-name" :id="`scroll-${number}`">{{page.menuName}}</text>
  15. <view class="app-product-item"
  16. v-for="(item, index) in page.goodsList"
  17. :key="index"
  18. :class="{'app-product-border': index !== getLength(page.goodsList), 'app-margin-top': index !== 0,'have-bg': goodsStyle < 3}"
  19. >
  20. <view class="app-product-border-all"
  21. :class="{'app-product-border-all-item': goodsStyle === 2}"
  22. >
  23. <view @click="jump_router(item)" >
  24. <view class="out-dialog" v-if="item.goods_stock == 0 && appSetting.is_show_stock == '1'">
  25. <image :src="appSetting.is_use_stock == '1' ? appImg.plugins_out : appSetting.sell_out_pic"></image>
  26. </view>
  27. <view class="dir-left-nowrap main-between cross-top">
  28. <image lazy-load="true" class="app-tag-icon" :src="goodsTagPicUrl" v-if="showGoodsTag"></image>
  29. <view style="border-radius: 16rpx;">
  30. <app-image borderRadius="16rpx" :img-src="item.cover_pic" width="160rpx" height="160rpx"
  31. :mode="fill === 1 ? 'aspectFill' : 'aspectFit'"></app-image>
  32. </view>
  33. <view class="app-product-content dir-top-nowrap main-between"
  34. :class="{'dir-top-nowrap': !showGoodsName, 'main-right': !showGoodsName}"
  35. >
  36. <text class="app-product-name" v-if="showGoodsName">{{item.name}}</text>
  37. <view class="app-price-buttons main-between cross-bottom" :class="{'dir-right-nowrap': !showGoodsPrice , 'dir-left-nowrap': showGoodsPrice}">
  38. <view class="price">
  39. <view v-if="item.is_level == 1 && item.is_negotiable != 1" style="height: 32rpx;margin-bottom: 8rpx;">
  40. <app-member-price :price="item.level_price"></app-member-price>
  41. </view>
  42. <app-sup-vip :is_vip_card_user="item.vip_card_appoint.is_vip_card_user" v-if="item.vip_card_appoint.discount" :discount="item.vip_card_appoint.discount"></app-sup-vip>
  43. <text class="app-price" v-if="showGoodsPrice" :class="theme + '-m-text ' + theme">{{item.price_content}}</text>
  44. </view>
  45. <template v-if="showBuyBtn && item.price_content !== '面议'">
  46. <button class="app-product-button"
  47. @click.stop="buyProduct(item)"
  48. v-if="buyBtn === 'text'" :style="btnStyle"
  49. :class="{
  50. 'app-button-filling': buyBtnStyle === 1,
  51. 'app-button-line' : buyBtnStyle === 2 ,
  52. 'app-button-fillet' : buyBtnStyle === 3,
  53. 'app-button-rounded-lines': buyBtnStyle === 4,
  54. }"
  55. >{{buyBtnText}}</button>
  56. <icon @click.stop="buyProduct(item)"
  57. class="app-button-icon app-product-button-cart"
  58. :class="theme+ '-m-back ' + theme"
  59. v-if="buyBtn === 'cart' && item.goods_stock != 0"
  60. ></icon>
  61. <icon @click.stop="buyProduct(item)"
  62. class="app-button-icon app-product-button-add"
  63. :class="theme+ '-m-back ' + theme"
  64. v-if="buyBtn === 'add' && item.goods_stock != 0"
  65. ></icon>
  66. </template>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </block>
  75. </scroll-view>
  76. </view>
  77. <view>
  78. <app-attr
  79. :goods="goods"
  80. :attrGroupList="goods.attr_groups"
  81. :show="show"
  82. :selectAttr="selectAttr"
  83. @attr="attr"
  84. :theme="theme"
  85. ></app-attr>
  86. </view>
  87. </view>
  88. </template>
  89. <script>
  90. import { mapState, mapGetters } from "vuex";
  91. import appAttr from '../../../components/page-component/app-attr/app-attr.vue';
  92. export default {
  93. name: 'app-recommended-product-list',
  94. data() {
  95. return {
  96. scrollIndex: 0,
  97. height: 0,
  98. activeIndex: 0,
  99. cartIndex: -1,
  100. show: false,
  101. selectAttr: {},
  102. goods: {},
  103. }
  104. },
  105. props: {
  106. catList: {
  107. type: Array,
  108. default: function() {
  109. return []
  110. }
  111. },
  112. fill: {
  113. type: Number,
  114. default: function() {
  115. return 1;
  116. }
  117. },
  118. buyBtnText: {
  119. type: String,
  120. default: function() {
  121. return '';
  122. }
  123. },
  124. buyBtnStyle: {
  125. type: Number,
  126. default: function() {
  127. return 4;
  128. }
  129. },
  130. showBuyBtn: {
  131. type: Boolean,
  132. default: function() {
  133. return true;
  134. }
  135. },
  136. showGoodsPrice: {
  137. type: Boolean,
  138. default: function() {
  139. return true;
  140. }
  141. },
  142. buyBtn: {
  143. type: String,
  144. default: function() {
  145. return 'cart';
  146. }
  147. },
  148. goodsStyle: {
  149. type: Number,
  150. default: function() {
  151. return 1;
  152. }
  153. },
  154. goodsTagPicUrl: {
  155. type: String,
  156. default: function() {
  157. return '';
  158. }
  159. },
  160. showGoodsTag: {
  161. type: Boolean,
  162. default: function() {
  163. return true;
  164. }
  165. },
  166. showGoodsName: {
  167. type: Boolean,
  168. default: function() {
  169. return true;
  170. }
  171. },
  172. buttonColor: {
  173. type: String,
  174. default() {
  175. return '';
  176. }
  177. },
  178. theme: String
  179. },
  180. computed: {
  181. ...mapState({
  182. appImg: state => state.mallConfig.__wxapp_img.mall,
  183. appSetting: state => state.mallConfig.mall.setting,
  184. }),
  185. ...mapGetters('mallConfig',{
  186. getVideo: 'getVideo'
  187. }),
  188. btnStyle() {
  189. let btnStyle = ``;
  190. if (this.buyBtnStyle === 1 || this.buyBtnStyle === 3) {
  191. btnStyle += `background-color: ${this.buttonColor};color: #ffffff;`;
  192. } else {
  193. btnStyle += `border-color: ${this.buttonColor};color: ${this.buttonColor};`;
  194. }
  195. return btnStyle;
  196. },
  197. },
  198. created() {
  199. let _this = this;
  200. wx.getSystemInfo({
  201. success: function(res) {
  202. _this.height = (750/res.windowWidth) * res.windowHeight;
  203. }
  204. })
  205. },
  206. methods: {
  207. getLength(data) {
  208. return data.length -1;
  209. },
  210. buyProduct(data) {
  211. if (data.mch_id === 0) {
  212. this.$request({
  213. url: this.$api.goods.detail,
  214. data: {
  215. id: data.id,
  216. }
  217. }).then(res => {
  218. if (res.code === 0) {
  219. this.goods = res.data.goods;
  220. this.show = Math.random();
  221. }
  222. })
  223. } else {
  224. this.$request({
  225. url: this.$api.mch.goods_detail,
  226. data: {
  227. mch_id: data.mch_id,
  228. id: data.id,
  229. }
  230. }).then(res => {
  231. if (res.code === 0) {
  232. this.goods = res.data.goods;
  233. this.show = Math.random();
  234. }
  235. })
  236. }
  237. },
  238. goClass(index) {
  239. this.activeIndex = index;
  240. },
  241. attr(data) {},
  242. jump_router(data) {
  243. // #ifndef MP-BAIDU
  244. if (data.video_url && this.getVideo == 1) {
  245. uni.navigateTo({
  246. url: `/pages/goods/video?goods_id=${data.id}&sign=${data.sign}`
  247. });
  248. } else {
  249. uni.navigateTo({
  250. url: data.page_url
  251. });
  252. }
  253. // #endif
  254. // #ifdef MP-BAIDU
  255. uni.navigateTo({
  256. url: data.page_url
  257. });
  258. // #endif
  259. }
  260. },
  261. components: {
  262. 'app-attr': appAttr
  263. }
  264. }
  265. </script>
  266. <style lang="scss">
  267. .default-text {
  268. color: #353535;
  269. }
  270. .app-class-item {
  271. display: inline-block;
  272. width: #{158rpx};
  273. line-height: #{104rpx};
  274. font-size: #{26rpx};
  275. text-align: center;
  276. border-left: #{2rpx} solid transparent;
  277. }
  278. .app-recommended-product-list {
  279. width: #{750rpx};
  280. height: #{100%};
  281. .app-classification {
  282. width: #{160rpx};
  283. height: #{100%};
  284. }
  285. .app-product {
  286. height: #{100%};
  287. padding-left: #{24rpx};
  288. padding-top: #{4rpx};
  289. .app-product-class-item {
  290. width: #{750-160-24rpx};
  291. .app-class-name {
  292. display: inline-block;
  293. width: #{750-160-24rpx};
  294. padding-top: #{40rpx};
  295. padding-bottom: #{36rpx};
  296. font-size: #{24rpx};
  297. color: #666666;
  298. }
  299. .app-product-item {
  300. width: #{750-160-24-12rpx};
  301. border-radius: #{16rpx};
  302. &.have-bg {
  303. background-color: #fff;
  304. }
  305. position: relative;
  306. .app-tag-icon {
  307. position: absolute;
  308. top: 0;
  309. left: 0;
  310. width: #{55rpx};
  311. height: #{55rpx};
  312. z-index: 1000;
  313. }
  314. .out-dialog {
  315. width: #{160rpx};
  316. height: #{160rpx};
  317. position: absolute;
  318. z-index: 10;
  319. background-color: rgba(0,0,0,.5);
  320. image {
  321. width: #{160rpx};
  322. height: #{160rpx};
  323. border-radius: #{16rpx};
  324. }
  325. }
  326. .app-product-image {
  327. /* #ifndef MP-ALIPAY */
  328. width: #{150rpx};
  329. /* #endif */
  330. /* #ifdef MP-ALIPAY */
  331. width: #{136rpx};
  332. /* #endif */
  333. /* #ifndef MP-ALIPAY */
  334. height: #{150rpx};
  335. /* #endif */
  336. /* #ifdef MP-ALIPAY */
  337. height: #{136rpx};
  338. /* #endif */
  339. }
  340. .app-product-content {
  341. width: #{750-160-24-152-20rpx};
  342. min-height: #{160upx};
  343. padding: 0 #{21rpx} #{23rpx};
  344. .app-product-name {
  345. font-size: #{28rpx};
  346. color: #353535;
  347. padding-top: #{15rpx};
  348. display: -webkit-box;
  349. -webkit-box-orient: vertical;
  350. -webkit-line-clamp: 2;
  351. overflow: hidden;
  352. width: #{750-160-24-152-20-24rpx};
  353. margin-bottom: #{10rpx};
  354. }
  355. .app-price-buttons {
  356. width: #{750-160-24-152-20-24-24rpx};
  357. .app-price {
  358. font-size: #{28rpx};
  359. }
  360. .app-product-button {
  361. display: inline-block;
  362. padding: 0 #{20rpx};
  363. height: #{48rpx};
  364. font-size: #{28rpx};
  365. color: #ffffff;
  366. line-height: #{48rpx};
  367. border-radius: 0;
  368. margin: 0;
  369. }
  370. .app-button-filling {
  371. }
  372. .app-button-fillet {
  373. border-radius: #{20rpx} !important;
  374. }
  375. .app-button-line {
  376. }
  377. .app-button-rounded-lines {
  378. border-radius: #{20rpx} !important;
  379. }
  380. .app-product-button-cart {
  381. background-image: url("../../../static/image/icon/goods-cart.png");
  382. }
  383. .app-product-button-add {
  384. background-image: url("../../../static/image/icon/add-to.png");
  385. }
  386. }
  387. }
  388. .app-product-border-all {
  389. width: #{750-160-24-12rpx};
  390. border-radius: #{10rpx};
  391. }
  392. .app-product-border-all-item {
  393. border: #{1rpx} solid #e2e2e2;
  394. }
  395. .app-button-icon {
  396. background-repeat: no-repeat;
  397. background-size: 100% 100%;
  398. width: #{36rpx};
  399. height: #{36rpx};
  400. }
  401. }
  402. .app-product-border {
  403. border-bottom-color: #e2e2e2;
  404. }
  405. .app-margin-top {
  406. margin-top: #{24rpx};
  407. }
  408. }
  409. }
  410. }
  411. .app-volume {
  412. margin: #{8rpx 0};
  413. font-size: #{22rpx};
  414. color: #666666;
  415. }
  416. </style>