app-recommended-product-list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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`}">
  4. <text class="app-class-item"
  5. v-for="(item, index) in catList" :key="index"
  6. :class="{'app-class-item-active': activeIndex === index}"
  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 > 0" :discount="item.vip_card_appoint.discount"></app-sup-vip>
  43. <text class="app-price" v-if="showGoodsPrice">{{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. v-if="buyBtn === 'cart' && item.goods_stock != 0"
  59. ></icon>
  60. <icon @click.stop="buyProduct(item)"
  61. class="app-button-icon app-product-button-add"
  62. v-if="buyBtn === 'add' && item.goods_stock != 0"
  63. ></icon>
  64. </template>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </block>
  73. </scroll-view>
  74. </view>
  75. <view>
  76. <app-attr
  77. :goods="goods"
  78. :attrGroupList="goods.attr_groups"
  79. :show="show"
  80. :selectAttr="selectAttr"
  81. @attr="attr"
  82. ></app-attr>
  83. </view>
  84. </view>
  85. </template>
  86. <script>
  87. import { mapState, mapGetters } from "vuex";
  88. import appAttr from '../../../components/page-component/app-attr/app-attr.vue';
  89. import appMemberPrice from "../app-member-mark/app-member-price.vue";
  90. import appSupVip from '../app-sup-vip/app-sup-vip.vue';
  91. export default {
  92. name: 'app-recommended-product-list',
  93. data() {
  94. return {
  95. scrollIndex: 0,
  96. height: 0,
  97. activeIndex: 0,
  98. cartIndex: -1,
  99. show: false,
  100. selectAttr: {},
  101. goods: {},
  102. }
  103. },
  104. props: {
  105. catList: {
  106. type: Array,
  107. default: function() {
  108. return [
  109. ]
  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 'https://www.bangdian.net/plugins/diy/assets/images/goods-tag-rx.png';
  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 '#ff4544';
  176. }
  177. },
  178. },
  179. computed: {
  180. ...mapState({
  181. appImg: state => state.mallConfig.__wxapp_img.mall,
  182. appSetting: state => state.mallConfig.mall.setting,
  183. }),
  184. ...mapGetters('mallConfig',{
  185. getVideo: 'getVideo'
  186. }),
  187. btnStyle() {
  188. let btnStyle = ``;
  189. if (this.buyBtnStyle === 1 || this.buyBtnStyle === 3) {
  190. btnStyle += `background-color: ${this.buttonColor};color: #ffffff;`;
  191. } else {
  192. btnStyle += `border-color: ${this.buttonColor};color: ${this.buttonColor};`;
  193. }
  194. return btnStyle;
  195. },
  196. },
  197. created() {
  198. let _this = this;
  199. wx.getSystemInfo({
  200. success: function(res) {
  201. _this.height = (750/res.windowWidth) * res.windowHeight;
  202. }
  203. })
  204. },
  205. methods: {
  206. getLength(data) {
  207. return data.length -1;
  208. },
  209. buyProduct(data) {
  210. if (data.mch_id === 0) {
  211. this.$request({
  212. url: this.$api.goods.detail,
  213. data: {
  214. id: data.id,
  215. }
  216. }).then(res => {
  217. if (res.code === 0) {
  218. this.goods = res.data.goods;
  219. this.show = Math.random();
  220. }
  221. })
  222. } else {
  223. this.$request({
  224. url: this.$api.mch.goods_detail,
  225. data: {
  226. mch_id: data.mch_id,
  227. id: data.id,
  228. }
  229. }).then(res => {
  230. if (res.code === 0) {
  231. this.goods = res.data.goods;
  232. this.show = Math.random();
  233. }
  234. })
  235. }
  236. },
  237. goClass(index) {
  238. this.activeIndex = index;
  239. },
  240. attr(data) {
  241. },
  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. 'app-member-price': appMemberPrice,
  264. 'app-sup-vip': appSupVip,
  265. }
  266. }
  267. </script>
  268. <style scoped lang="scss">
  269. .app-recommended-product-list {
  270. width: #{750rpx};
  271. height: #{100%};
  272. .app-classification {
  273. width: #{160rpx};
  274. height: #{100%};
  275. // background-color: #f7f7f7;
  276. .app-class-item {
  277. display: inline-block;
  278. width: #{158rpx};
  279. line-height: #{104rpx};
  280. font-size: #{26rpx};
  281. text-align: center;
  282. color: #353535;
  283. border-left: #{2rpx} solid transparent;
  284. }
  285. .app-class-item-active {
  286. border-color: #ff4544;
  287. color: #ff4544;
  288. // background-color: #ffffff;
  289. }
  290. }
  291. .app-product {
  292. height: #{100%};
  293. padding-left: #{24rpx};
  294. padding-top: #{4rpx};
  295. // background-color: #ffffff;
  296. .app-product-class-item {
  297. width: #{750-160-24rpx};
  298. .app-class-name {
  299. display: inline-block;
  300. width: #{750-160-24rpx};
  301. padding-top: #{40rpx};
  302. padding-bottom: #{36rpx};
  303. font-size: #{24rpx};
  304. color: #666666;
  305. }
  306. .app-product-item {
  307. width: #{750-160-24-12rpx};
  308. border-radius: #{16rpx};
  309. &.have-bg {
  310. background-color: #fff;
  311. }
  312. position: relative;
  313. .app-tag-icon {
  314. position: absolute;
  315. top: 0;
  316. left: 0;
  317. width: #{55rpx};
  318. height: #{55rpx};
  319. z-index: 1000;
  320. }
  321. .out-dialog {
  322. width: #{160rpx};
  323. height: #{160rpx};
  324. position: absolute;
  325. z-index: 10;
  326. background-color: rgba(0,0,0,.5);
  327. image {
  328. width: #{160rpx};
  329. height: #{160rpx};
  330. border-radius: #{16rpx};
  331. }
  332. }
  333. .app-product-image {
  334. /* #ifndef MP-ALIPAY */
  335. width: #{150rpx};
  336. /* #endif */
  337. /* #ifdef MP-ALIPAY */
  338. width: #{136rpx};
  339. /* #endif */
  340. /* #ifndef MP-ALIPAY */
  341. height: #{150rpx};
  342. /* #endif */
  343. /* #ifdef MP-ALIPAY */
  344. height: #{136rpx};
  345. /* #endif */
  346. }
  347. .app-product-content {
  348. width: #{750-160-24-152-20rpx};
  349. height: #{160upx};
  350. padding: 0 #{21rpx} #{23rpx};
  351. .app-product-name {
  352. font-size: #{28rpx};
  353. color: #353535;
  354. padding-top: #{15rpx};
  355. display: -webkit-box;
  356. -webkit-box-orient: vertical;
  357. -webkit-line-clamp: 2;
  358. overflow: hidden;
  359. width: #{750-160-24-152-20-24rpx};
  360. /* #ifndef MP-ALIPAY */
  361. height: #{75rpx};
  362. line-height: #{30rpx};
  363. /* #endif */
  364. /* #ifdef MP-ALIPAY */
  365. height: #{75rpx};
  366. line-height: #{35rpx};
  367. /* #endif */
  368. margin-bottom: #{10rpx};
  369. }
  370. .app-price-buttons {
  371. width: #{750-160-24-152-20-24-24rpx};
  372. .app-price {
  373. font-size: #{28rpx};
  374. color: #ff4544;
  375. }
  376. .app-product-button {
  377. display: inline-block;
  378. padding: 0 #{20rpx};
  379. height: #{48rpx};
  380. font-size: #{28rpx};
  381. color: #ffffff;
  382. line-height: #{48rpx};
  383. border-radius: 0;
  384. margin: 0;
  385. }
  386. .app-button-filling {
  387. }
  388. .app-button-fillet {
  389. border-radius: #{20rpx} !important;
  390. }
  391. .app-button-line {
  392. }
  393. .app-button-rounded-lines {
  394. border-radius: #{20rpx} !important;
  395. }
  396. .app-product-button-cart {
  397. background-image: url("../../../static/image/icon/shopping-cart.png");
  398. }
  399. .app-product-button-add {
  400. background-image: url("../../../static/image/icon/add-to.png");
  401. }
  402. }
  403. }
  404. .app-product-border-all {
  405. width: #{750-160-24-12rpx};
  406. border-radius: #{10rpx};
  407. }
  408. .app-product-border-all-item {
  409. border: #{1rpx} solid #e2e2e2;
  410. }
  411. .app-button-icon {
  412. background-repeat: no-repeat;
  413. background-size: 100% 100%;
  414. width: #{36rpx};
  415. height: #{36rpx};
  416. }
  417. }
  418. .app-product-border {
  419. border-bottom-color: #e2e2e2;
  420. }
  421. .app-margin-top {
  422. margin-top: #{24rpx};
  423. }
  424. }
  425. }
  426. }
  427. .app-volume {
  428. margin: #{8rpx 0};
  429. font-size: #{22rpx};
  430. color: #666666;
  431. }
  432. </style>