detail.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. <template>
  2. <app-layout>
  3. <view v-if="!goods" class="u-goods-detail"></view>
  4. <template class="detail" v-if="goods">
  5. <!--商品轮播图-->
  6. <app-goods-banner
  7. v-bind:picList="goods.pic_url"
  8. v-bind:share="goods.share"
  9. v-bind:isCart="false"
  10. v-bind:videoUrl="goods.video_url"
  11. v-bind:goods_id="goods.id"
  12. sign="advance"
  13. ></app-goods-banner>
  14. <!--商品公告-->
  15. <detail-ad
  16. v-if="goods.advanceGoods.end_prepayment_at"
  17. v-bind:sales="goods.sales"
  18. v-bind:d="d"
  19. v-bind:h="h"
  20. v-bind:m="m"
  21. v-bind:s="s"
  22. v-bind:theme="getTheme"
  23. ></detail-ad>
  24. <!-- 详情标题 -->
  25. <app-name v-bind:name="goods.name"></app-name>
  26. <view v-if="goods.subtitle" class="goods-subtitle">
  27. <view class="t-omit-three">{{goods.subtitle}}</view>
  28. </view>
  29. <!--商品价格-->
  30. <detail-price-share
  31. v-if="goods.attr.length > 0"
  32. v-bind:url="url"
  33. v-bind:original_price="goods.original_price"
  34. v-bind:attr="goods.attr"
  35. v-bind:price_min="goods.price_min"
  36. v-bind:price_max="goods.price_max"
  37. v-bind:group_max_member_price="goods.group_max_member_price"
  38. v-bind:group_min_member_price="goods.group_min_member_price"
  39. v-bind:end_prepayment_at="goods.advanceGoods.end_prepayment_at"
  40. v-bind:pay_limit="goods.advanceGoods.pay_limit"
  41. v-bind:level_show="goods.level_show"
  42. v-bind:cats="goods.goodsWarehouse && goods.goodsWarehouse.cats"
  43. v-bind:goodsId="goods.id"
  44. v-bind:is_vip_card_user="goods.vip_card_appoint.is_vip_card_user"
  45. v-bind:discount="goods.vip_card_appoint.discount"
  46. v-bind:theme="getTheme"
  47. v-bind:has-poster-nav="true"
  48. v-bind:poster-config="poster_config + `&goods_id=` + goods.id"
  49. v-bind:poster-generate="poster_generate + `&goods_id=` + goods.id"
  50. v-bind:goods="goods"
  51. @share="hShareAppMessage"
  52. ></detail-price-share>
  53. <view class="bd-info-extra">
  54. <bd-info-extra :unit="goods.unit" :theme="getTheme" :min-number="goods.min_number" :limit-buy="goods.limit_buy" :goods="goods"></bd-info-extra>
  55. </view>
  56. <!--商品会员-->
  57. <view class="join-member" v-if="goods.level_show === 2">
  58. <app-join-member
  59. v-bind:member-min-price="`${goods.group_min_member_price}`"
  60. v-bind:member-max-price="`${goods.group_min_member_price}`"
  61. v-bind:price="`${goods.original_price}`"
  62. ></app-join-member>
  63. </view>
  64. <!--超级会员卡-->
  65. <view class="detail-vip" v-if="goods.vip_card_appoint.discount > 0">
  66. <app-vip-card top="0" background="#fff"></app-vip-card>
  67. </view>
  68. <template v-if="goods.advanceGoods.ladder_rules.length>0">
  69. <detail-discount
  70. v-bind:url="url"
  71. v-bind:ladder_rules="goods.advanceGoods.ladder_rules"
  72. v-bind:sales="goods.sales"
  73. ></detail-discount>
  74. </template>
  75. <bd-coupon @change="setCoupon" :theme="getTheme" :coupons="goods.goods_coupon_center"></bd-coupon>
  76. <bd-xbc
  77. :coAttr="is_open"
  78. :attr-list="select_attr_group"
  79. :type="goods.type"
  80. :guarantee-title="goods.guarantee_title"
  81. :guarantee-pic="goods.guarantee_pic"
  82. :param_content="goods.param_content"
  83. :param_name="goods.param_name"
  84. :services="goods.services"
  85. :attr-groups="goods.attr_groups"
  86. :goods-stock="goods.goods_stock"
  87. @openAttr="close_attr(false)"
  88. ></bd-xbc>
  89. <detail-attr
  90. v-if="!active && goods.attr.length>0"
  91. v-bind:theme="getTheme"
  92. v-bind:height="110"
  93. v-bind:cover_pic="goods.cover_pic"
  94. v-bind:attr="goods.attr"
  95. v-bind:attr_groups="goods.attr_groups"
  96. v-bind:goods_stock="goods.goods_stock"
  97. v-bind:attr_deposit="attr_deposit"
  98. v-bind:attr_swell_deposit="attr_swell_deposit"
  99. v-bind:attr_stock="attr_stock"
  100. v-bind:attr_price="attr_price"
  101. v-bind:attr_price_member="attr_price_member"
  102. v-bind:level_show="goods.level_show"
  103. v-bind:attr_pic_url="attr_pic_url"
  104. @select_attr="select_attr"
  105. @close_attr="close_attr"
  106. v-bind:num="num"
  107. v-bind:detail="goods"
  108. @change_num="change_num"
  109. @change_num_data="change_num_data"
  110. ></detail-attr>
  111. <bd-hc
  112. :integral="goods.goods_marketing_award.integral"
  113. :coupon="goods.goods_marketing_award.coupon"
  114. :card="goods.goods_marketing_award.card"
  115. :balance="goods.goods_marketing_award.balance"
  116. :theme="getTheme"
  117. ></bd-hc>
  118. <bd-kb
  119. :limit="goods.goods_marketing.limit"
  120. :express="goods.express"
  121. :shipping="goods.goods_marketing.shipping"
  122. :pickup="goods.goods_marketing.pickup"
  123. ></bd-kb>
  124. <bd-comments :goods-id="goods.id"></bd-comments>
  125. <bd-detail :detail="goods.detail"></bd-detail>
  126. <!-- 相关推荐 -->
  127. <app-related-suggestion-product text="您或许会喜欢" sign="advance" v-bind:theme="getTheme" v-bind:list="list"></app-related-suggestion-product>
  128. <!-- 空白格 -->
  129. <view class="safe-area-inset-bottom">
  130. <view :class="full_reduce ? 'u-bottom-height-1' : 'u-bottom-height-0'"></view>
  131. </view>
  132. <view v-if="is_open == 1" class="safe-area-inset-bottom u-bottom-fixed">
  133. <view v-if="full_reduce && active">
  134. <app-goods-full-reduce
  135. :theme="getTheme"
  136. :full_reduce="full_reduce"
  137. >
  138. </app-goods-full-reduce>
  139. </view>
  140. <detail-bottom-button
  141. v-bind:theme="getTheme"
  142. @close_attr="close_attr"
  143. v-bind:favorite="goods.favorite"
  144. v-bind:active="active"
  145. v-bind:goods_id="goods.id"
  146. @favorite="favorite"
  147. v-bind:detail="goods"
  148. v-bind:num="num"
  149. v-bind:buttonDisabled="buttonDisabled"
  150. v-bind:end_prepayment_at="goods.advanceGoods.end_prepayment_at"
  151. @request="request_detail"
  152. ></detail-bottom-button>
  153. </view>
  154. <app-close v-if="showClose" :modal="false" @update="getMall"></app-close>
  155. <!-- 快捷导航 -->
  156. <app-quick-navigation></app-quick-navigation>
  157. </template>
  158. </app-layout>
  159. </template>
  160. <script>
  161. import { mapState, mapGetters } from'vuex';
  162. import appGoodsBanner from '../../../components/page-component/goods/app-goods-banner.vue';
  163. import detailAd from '../components/detail-ad.vue';
  164. import detailPriceShare from '../components/detail-price-share.vue';
  165. import detailBottomButton from '../components/detail-bottom-button.vue';
  166. import detailAttr from '../components/detail-attr.vue';
  167. import appJoinMember from '../../../components/page-component/app-join-member/app-join-member.vue';
  168. import appRelatedSuggestionProduct from '../../../components/page-component/app-related-suggestion-product/app-related-suggestion-product.vue';
  169. import detailDiscount from '../components/detail-discount.vue';
  170. import detailVip from '../components/detail-vip.vue';
  171. import appVipCard from '../../../components/page-component/app-vip-card/app-vip-card.vue';
  172. import appName from '../../../components/page-component/app-goods-detail/app-name.vue';
  173. import appQuickNavigation from '../../../components/page-component/app-quick-navigation/app-quick-navigation.vue';
  174. import appGoodsFullReduce from '../../../components/page-component/goods/app-goods-full-reduce.vue';
  175. import appClose from '@/components/basic-component/app-close/app-close.vue';
  176. import bdDetail from '@/components/page-component/goods/bd-detail.vue';
  177. import bdComments from '@/components/page-component/goods/bd-comments.vue';
  178. import bdKb from '@/components/page-component/goods/bd-kb.vue';
  179. import bdHc from '@/components/page-component/goods/bd-hc.vue';
  180. import bdCoupon from '@/components/page-component/goods/bd-coupon.vue';
  181. import bdXbc from '@/components/page-component/goods/bd-xbc.vue';
  182. import bdInfoExtra from '@/components/page-component/goods/bd-info-extra.vue';
  183. export default {
  184. name: "detail",
  185. data() {
  186. return {
  187. showClose: false,
  188. is_open: 0,
  189. full_reduce: null,
  190. active: true,
  191. attr_deposit: '0',
  192. attr_swell_deposit: '0',
  193. attr_stock: 0,
  194. attr_price: '0',
  195. attr_price_member: 0,
  196. url: '',
  197. level_show: 0,
  198. loading: false,
  199. select_attr_group: [],
  200. zhe: false,
  201. list: [],
  202. num: 1,
  203. shareShow: false,
  204. attr_pic_url: '',
  205. goods_id: -1,
  206. d: 0,
  207. h: 0,
  208. m: 0,
  209. s: 0,
  210. end_time: -1,
  211. buttonDisabled: false,
  212. poster_config: this.$api.advance.poster_config,
  213. poster_generate: this.$api.advance.poster_generate,
  214. goods: null
  215. }
  216. },
  217. onLoad(data) {
  218. this.goods_id = data.id;
  219. // #ifdef MP-WEIXIN
  220. wx.showShareMenu({
  221. menus: ['shareAppMessage', 'shareTimeline']
  222. })
  223. // #endif
  224. },
  225. onShow() {
  226. this.showClose = false;
  227. setTimeout(()=>{
  228. this.showClose = true;
  229. })
  230. this.$nextTick(() => {
  231. this.request_detail({id: this.goods_id});
  232. this.$request({
  233. url: this.$api.advance.goods_list,
  234. data: {
  235. goods_id: this.goods_id,
  236. }
  237. }).then(response => {
  238. if (response.code === 0) {
  239. this.list = response.data.list;
  240. } else if (response.code === 1) {
  241. uni.showModal({
  242. title: '提示',
  243. content: response.msg,
  244. });
  245. }
  246. });
  247. })
  248. },
  249. onHide() {
  250. clearInterval(this.end_time);
  251. },
  252. onUnload() {
  253. clearInterval(this.end_time);
  254. },
  255. // #ifdef MP
  256. onShareAppMessage() {
  257. return this.hShareAppMessage();
  258. },
  259. // #endif
  260. methods: {
  261. hShareAppMessage(s = false) {
  262. let { app_share_title, name, id, app_share_pic, subtitle, pic_url} = this.goods;
  263. return this.$shareAppMessage({
  264. path: '/plugins/advance/detail/detail',
  265. title: app_share_title ? app_share_title : name,
  266. imageUrl: app_share_pic ? app_share_pic : pic_url[0].pic_url,
  267. desc: subtitle,
  268. params: { id }
  269. }, s);
  270. },
  271. getMall(e) {
  272. this.is_open = e.is_open;
  273. },
  274. request_detail(data) {
  275. this.$request({
  276. url: this.$api.advance.detail,
  277. data: {
  278. id: data.id
  279. },
  280. method: 'get'
  281. }).then(res => {
  282. if (res.code === 0) {
  283. this.goods = res.data.detail;
  284. if (this.goods.goods_activity) {
  285. this.full_reduce = this.goods.goods_activity.full_reduce;
  286. }
  287. this.goods.num = 1;
  288. this.loading = true;
  289. this.url = `${this.$api.advance.poster}&goods_id=${this.goods.id}`;
  290. this.getTime(this.goods.advanceGoods.end_prepayment_at);
  291. this.set_attr_active();
  292. // #ifdef H5
  293. this.hShareAppMessage();
  294. // #endif
  295. } else if (res.code === 1) {
  296. uni.hideLoading();
  297. uni.showModal({
  298. content: res.msg,
  299. showCancel: false,
  300. success() {
  301. uni.navigateBack();
  302. }
  303. });
  304. }
  305. });
  306. },
  307. open_share() {
  308. this.shareShow = true;
  309. },
  310. change_num(data) {
  311. this.num += data;
  312. },
  313. change_num_data(data) {
  314. this.num = data;
  315. },
  316. favorite(data) {
  317. this.goods.favorite = data;
  318. },
  319. select_attr({data, item}) {
  320. let attr_groups = this.goods.attr_groups;
  321. let str = ':';
  322. let sd = 0;
  323. for (let i = 0; i < attr_groups.length;i++) {
  324. let attr_list = this.goods.attr_groups[i].attr_list;
  325. for (let j = 0; j < attr_list.length; j++) {
  326. if (attr_groups[i].attr_group_id === data && attr_list[j].attr_id === item) {
  327. this.$set(this.goods.attr_groups[i].attr_list[j], 'active', true);
  328. } else if (attr_groups[i].attr_group_id === data && attr_list[j].attr_id !== item){
  329. this.$set(this.goods.attr_groups[i].attr_list[j], 'active', false);
  330. }
  331. if (this.goods.attr_groups[i].attr_list[j].active) {
  332. sd = this.goods.attr_groups[i].attr_list[j].attr_id;
  333. str += `:${sd}`;
  334. }
  335. }
  336. }
  337. let result = str.substr(2);
  338. this.get_price_stock(result);
  339. },
  340. set_attr_active() {
  341. let item = 0;
  342. let str = ':';
  343. for (let i = 0; i < this.goods.attr_groups.length;i++) {
  344. for (let j = 0; j < this.goods.attr_groups[i].attr_list.length; j++) {
  345. if (j !== 0) {
  346. this.$set(this.goods.attr_groups[i].attr_list[j], 'active', false);
  347. } else if (j === 0) {
  348. item = this.goods.attr_groups[i].attr_list[j].attr_id;
  349. str += `:${item}`;
  350. this.$set(this.goods.attr_groups[i].attr_list[j], 'active', true);
  351. }
  352. }
  353. }
  354. this.get_price_stock(str.substr(2));
  355. },
  356. get_price_stock(data) {
  357. let attr = this.goods.attr;
  358. for (let i = 0; i < attr.length;i++) {
  359. if (attr[i].sign_id === data) {
  360. this.select_attr_group = attr[i].attr_list;
  361. let { deposit, swell_deposit, stock, price, price_member, pic_url } = attr[i];
  362. this.attr_deposit = deposit;
  363. this.attr_swell_deposit = swell_deposit;
  364. this.attr_stock = stock;
  365. this.attr_price = price;
  366. this.attr_price_member = price_member;
  367. this.attr_pic_url = pic_url;
  368. }
  369. }
  370. this.attr_stock == 0 ? this.buttonDisabled = true : this.buttonDisabled = false;
  371. },
  372. close_attr(data) {
  373. if (!this.goods.buy_goods_auth) {
  374. this.$tips.showToast({
  375. title: '您暂无权限购买该商品',
  376. icon: 'none'
  377. });
  378. return;
  379. }
  380. this.active = data;
  381. },
  382. getTime(end_prepayment_at) {
  383. let time = new Date(end_prepayment_at.replace(/-/g, '/')).getTime() - (new Date()).getTime();
  384. this.d = parseInt((time/1000/60/60/24));
  385. this.h = parseInt((time/1000/60/60)%24);
  386. this.m = parseInt((time/1000/60)%60);
  387. this.s = parseInt((time/1000)%60);
  388. this.end_time = setInterval(() => {
  389. let now = new Date().getTime();
  390. let timelog = new Date(end_prepayment_at.replace(/-/g, '/')).getTime();
  391. let time = timelog - now;
  392. if (time > 0) {
  393. let day = parseInt((time/1000/60/60/24));
  394. let hou = parseInt((time/1000/60/60)%24);
  395. let min = parseInt((time/1000/60)%60);
  396. let sec = parseInt((time/1000)%60);
  397. this.d = day;
  398. this.h = hou;
  399. this.m = min;
  400. this.s = sec;
  401. } else {
  402. clearInterval(this.end_time);
  403. }
  404. }, 1000);
  405. },
  406. setCoupon(index) {
  407. this.$set(this.goods.goods_coupon_center[index], 'is_receive', 1);
  408. }
  409. },
  410. components: {
  411. 'app-goods-banner': appGoodsBanner,
  412. 'detail-ad': detailAd,
  413. 'detail-price-share': detailPriceShare,
  414. 'detail-bottom-button': detailBottomButton,
  415. 'detail-attr': detailAttr,
  416. 'app-join-member': appJoinMember,
  417. 'app-related-suggestion-product': appRelatedSuggestionProduct,
  418. 'detail-discount': detailDiscount,
  419. 'detail-vip': detailVip,
  420. 'app-name': appName,
  421. 'app-vip-card': appVipCard,
  422. 'app-quick-navigation': appQuickNavigation,
  423. appGoodsFullReduce,
  424. appClose,
  425. bdDetail,
  426. bdComments,
  427. bdKb,
  428. bdHc,
  429. bdCoupon,
  430. bdXbc,
  431. bdInfoExtra,
  432. },
  433. computed: {
  434. ...mapGetters('mallConfig',{
  435. vip: 'getVip',
  436. getTheme: 'getTheme'
  437. }),
  438. ...mapGetters('user', {
  439. is_vip: 'is_vip'
  440. }),
  441. ...mapState({
  442. mall: state => state.mallConfig.mall
  443. }),
  444. },
  445. // #ifdef MP-WEIXIN
  446. onShareTimeline() {
  447. let { app_share_title, name, id } = this.goods;
  448. return this.$shareTimeline({
  449. title: app_share_title ? app_share_title : name,
  450. query: { id }
  451. });
  452. }
  453. // #endif
  454. }
  455. </script>
  456. <style scoped lang="scss">
  457. .goods-subtitle {
  458. padding: 0 #{20rpx};
  459. font-size: 24rpx;
  460. background-color: #ffffff;
  461. color: #999999;
  462. width: 702upx;
  463. margin: 0 24upx;
  464. }
  465. .join-member {
  466. background-color: #ffffff;
  467. padding: 0 #{24rpx};
  468. }
  469. .border-top {
  470. border-top: #{1rpx} solid #e2e2e2;
  471. }
  472. .zhe {
  473. height: #{80rpx};
  474. background-color: white;
  475. width: #{750rpx};
  476. padding: 0 #{24rpx};
  477. margin-top: #{20rpx};
  478. .symbol {
  479. width: #{116rpx};
  480. font-size: #{20rpx};
  481. color: #ff4544;
  482. border: #{1rpx} solid #ff4544;
  483. border-radius: #{4rpx};
  484. text-align: center;
  485. }
  486. .image {
  487. width: #{12rpx};
  488. height: #{22rpx};
  489. }
  490. .content {
  491. width: #{520rpx};
  492. font-size: #{21rpx};
  493. color: #666666;
  494. word-break: break-all;
  495. text-overflow: ellipsis;
  496. display: -webkit-box;
  497. -webkit-box-orient: vertical;
  498. -webkit-line-clamp: 1;
  499. overflow: hidden;
  500. margin-left: #{12rpx};
  501. }
  502. }
  503. .detail-vip {
  504. padding: 20upx;
  505. background-color: #ffffff;
  506. width: 702upx;
  507. margin: 0 24upx 0 24upx;
  508. border-radius: 0 0 15upx 15upx;
  509. }
  510. .u-bottom-fixed {
  511. position: fixed;
  512. bottom: 0;
  513. left: 0;
  514. width: 100%;
  515. z-index: 1601;
  516. background-color: #ffffff;
  517. }
  518. .u-bottom-height-0 {
  519. height: 110upx;
  520. }
  521. .u-bottom-height-1 {
  522. height: 190upx;
  523. }
  524. .goods-margin {
  525. margin-top: 20upx;
  526. }
  527. .bd-info-extra {
  528. padding: 0 #{20rpx};
  529. background-color: #ffffff;
  530. width: 702upx;
  531. margin: 0 24upx;
  532. }
  533. </style>