1
0

goods.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. <template>
  2. <app-layout>
  3. <uni-nav-bar fixed="true" :background-color="titleBg" left-icon="back" @click-left="back"></uni-nav-bar>
  4. <view v-if="!detail" class="u-goods-detail"></view>
  5. <template v-if="detail">
  6. <!--商品轮播图-->
  7. <app-banner :videoUrl="detail.video_url" :share="detail.share" :picList="detail.pic_url" :goods_id="goods_id" sign="miaosha"></app-banner>
  8. <!-- 秒杀时间 -->
  9. <app-goods-time :day="day" :second="second" :minute="minute" :hour="hour" :theme="getTheme" :miaosha_status="miaosha_status"
  10. :item="detail"></app-goods-time>
  11. <bd-info :theme="themeObject" :name="detail.name" :is-negotiable="detail.is_negotiable" :subtitle="detail.subtitle"
  12. :level-show="detail.level_show" :price="detail.price" :original-price="detail.original_price" :price-max="detail.price_max"
  13. :price-min="detail.price_min" :price-member-max="detail.price_member_max" :price-member-min="detail.price_member_min"
  14. :discount='discount' :is-vip-card-user="is_vip_card_user" :sales="detail.sales" :unit="detail.unit" :is-sales="detail.is_sales"
  15. :is-vip="is_vip" :flash-sale="flash_sale" :goods-id="detail.id" :extra-quick-share="detail.extra_quick_share"
  16. :app-share-pic="detail.app_share_pic" :app-share-title="detail.app_share_title" :poster-config="poster_config"
  17. :poster-generate="poster_generate" :has-poster-nav="true" v-bind:goods="detail" :share-url="url" :isShowPrice="false">
  18. </bd-info>
  19. <view class="join-member" v-if="detail.level_show === 2">
  20. <view class="bd-vip" @click="goToMember">
  21. <image style="height: 72rpx;width: 100%;" :src="root+'/web/statics/img/app/common/vip.png'" alt="">
  22. </view>
  23. <!--<app-join-member
  24. v-bind:member-min-price="`${detail.group_min_member_price}`"
  25. v-bind:member-max-price="`${detail.group_min_member_price}`"
  26. v-bind:price="`${detail.original_price}`"
  27. ></app-join-member>-->
  28. </view>
  29. <bd-coupon @change="setCoupon" :theme="themeObject" :coupons="detail.goods_coupon_center"></bd-coupon>
  30. <bd-xbc :coAttr="is_open" :attr-list="selectAttr.attr_list" :type="detail.type" :guarantee-title="detail.guarantee_title"
  31. :guarantee-pic="detail.guarantee_pic" :param_content="detail.param_content" :param_name="detail.param_name"
  32. :services="detail.services" :attr-groups="detail.attr_groups" @openAttr="takeCart"></bd-xbc>
  33. <bd-hc :integral="detail.goods_marketing_award.integral" :coupon="detail.goods_marketing_award.coupon" :card="detail.goods_marketing_award.card"
  34. :balance="detail.goods_marketing_award.balance" :theme="themeObject"></bd-hc>
  35. <bd-kb :limit="detail.goods_marketing.limit" :express="detail.express" :shipping="detail.goods_marketing.shipping"
  36. :pickup="detail.goods_marketing.pickup"></bd-kb>
  37. <bd-comments :goods-id="detail.id"></bd-comments>
  38. <bd-detail :detail="detail.detail"></bd-detail>
  39. <!-- 相关推荐 -->
  40. <app-related-suggestion-product :theme="getTheme" :list="list"></app-related-suggestion-product>
  41. <!-- 底部空格 -->
  42. <view class="safe-area-inset-bottom">
  43. <view class="u-bottom-height" :class="full_reduce ? 'u-bottom-height-1' : 'u-bottom-height-0'"></view>
  44. </view>
  45. <!-- 底部按钮 -->
  46. <view v-if="is_open == 1" class="safe-area-inset-bottom u-bottom-fixed">
  47. <view v-if="full_reduce">
  48. <app-goods-full-reduce :theme="getTheme" :full_reduce="full_reduce">
  49. </app-goods-full-reduce>
  50. </view>
  51. <view class="buttons dir-left-nowrap">
  52. <view class="app-home dir-top-nowrap main-center cross-center" @click="router('/pages/index/index')">
  53. <image src="../../../static/image/icon/index.png"></image>
  54. <text>首页</text>
  55. </view>
  56. <view class="app-home dir-top-nowrap main-center cross-center little box-grow-0" @click="setFavorite">
  57. <image class="app-icon" :src="favorite ? '../../../static/image/icon/icon-favorite-active.png' : '../../../static/image/icon/icon-favorite.png'"></image>
  58. <text class="app-text">收藏</text>
  59. </view>
  60. <view class="app-home dir-top-nowrap main-center cross-center little box-grow-0" @click="kefu">
  61. <image class="app-icon" :src="root+'/web/statics/img/app/common/icon-kefu.png'"></image>
  62. <text class="app-text">客服</text>
  63. </view>
  64. <view v-if="detail.goods_stock > 0" class="app-button dir-left-nowrap">
  65. <template v-if="miaosha_status === 1">
  66. <view style="height: 80%;" class="app-join-cart box-grow-1 cart-btn" @click="takeCart" :class="getTheme === 'a' || getTheme === 'b' || getTheme === 'f' ? getTheme + '-s-back '+ 'text ' + getTheme : getTheme + '-s-back '+ getTheme + '-m-text ' + getTheme">
  67. 加入购物车
  68. </view>
  69. <view style="height: 80%;" @click="takeCart" :class="[getTheme + '-m-back', getTheme, 'box-grow-1', 'app-buy']"
  70. class="buy-btn">
  71. 立即购买
  72. </view>
  73. </template>
  74. <view class="notStart box-grow-1" v-else-if="miaosha_status === 2">
  75. 活动未开始
  76. </view>
  77. <view class="app-over box-grow-1" v-else-if="miaosha_status === 0">
  78. 活动已结束
  79. </view>
  80. </view>
  81. <view class="app-button dir-left-nowrap" v-else>
  82. <view class="app-over box-grow-1" style="background-color: #CDCDCD;">
  83. 已售罄
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <!--商品规格-->
  89. <u-attr v-if="miaosha_status === 1" v-model="show" :themeObject="themeObject" :goods="detail" :checked="selectAttr"
  90. @check="attrtap" :leftFunc="true" @leftFunc="leftFunc" :rightFunc="true" @rightFunc="rightFunc">
  91. </u-attr>
  92. </template>
  93. <app-close v-if="showClose" :modal="false" @update="getMall"></app-close>
  94. </app-layout>
  95. </template>
  96. <script>
  97. import {
  98. mapGetters,
  99. mapState
  100. } from 'vuex';
  101. import appBanner from '../../../components/page-component/goods/app-goods-banner.vue';
  102. import appGoodsTime from '../components/app-goods-time.vue';
  103. import appRelatedSuggestionProduct from '../../../components/page-component/app-related-suggestion-product/app-related-suggestion-product.vue';
  104. import appGoodsFullReduce from "../../../components/page-component/goods/app-goods-full-reduce";
  105. import uAttr from '../../../components/page-component/goods/u-attr.vue';
  106. import bdInfo from '@/components/page-component/goods/bd-info';
  107. import bdCoupon from '@/components/page-component/goods/bd-coupon.vue';
  108. import bdXbc from '@/components/page-component/goods/bd-xbc.vue';
  109. import bdKb from '@/components/page-component/goods/bd-kb.vue';
  110. import bdHc from '@/components/page-component/goods/bd-hc.vue';
  111. import bdDetail from '@/components/page-component/goods/bd-detail.vue';
  112. import bdComments from '@/components/page-component/goods/bd-comments.vue';
  113. import appClose from '@/components/basic-component/app-close/app-close.vue';
  114. import uniNavBar from '@/components/page-component/uni-plugins/uni-nav-bar.vue';
  115. import routeJump from "../../../core/routeJump";
  116. export default {
  117. name: 'goods',
  118. data() {
  119. return {
  120. showClose: false,
  121. is_open: 0,
  122. detail: null,
  123. full_reduce: null,
  124. cartShow: false,
  125. miaosha_status: -1,
  126. miaosha_time: 0,
  127. selectAttr: null,
  128. url: '',
  129. show: false,
  130. list: [],
  131. miaosha_buy_count: 0,
  132. goods_id: -1,
  133. is_activity: 0,
  134. hour: 0,
  135. minute: 0,
  136. second: 0,
  137. day: 0,
  138. time: -1,
  139. is_vip_card_user: 0,
  140. discount: null,
  141. is_vip: false,
  142. loading: false,
  143. flash_sale: null,
  144. poster_config: this.$api.miaosha.poster_config,
  145. poster_generate: this.$api.miaosha.poster_generate,
  146. favorite: '',
  147. titleBg: 'rgba(255,255,255,0)',
  148. name: '',
  149. root: this.$siteInfo.root,
  150. }
  151. },
  152. onPageScroll: function(e) {
  153. this.titleBg = 'rgba(255,255,255,' + e.scrollTop / 300 + ')';
  154. },
  155. onLoad(options) {
  156. this.goods_id = options.id;
  157. if (options.is_activity) {
  158. this.is_activity = options.is_activity
  159. }
  160. // #ifdef MP-WEIXIN
  161. wx.showShareMenu({
  162. menus: ['shareAppMessage', 'shareTimeline']
  163. })
  164. // #endif
  165. },
  166. onShow() {
  167. this.showClose = false;
  168. setTimeout(() => {
  169. this.showClose = true;
  170. })
  171. this.$showLoading();
  172. this.$nextTick(() => {
  173. let that = this;
  174. this.$request({
  175. url: this.$api.miaosha.goods_detail,
  176. data: {
  177. id: this.goods_id,
  178. is_activity: this.is_activity
  179. }
  180. }).then(response => {
  181. this.$hideLoading();
  182. if (response.code === 0) {
  183. let {
  184. detail,
  185. miaosha_status,
  186. miaosha_time,
  187. miaosha_buy_count
  188. } = response.data;
  189. this.detail = detail;
  190. if (detail.goods_activity) {
  191. this.full_reduce = detail.goods_activity.full_reduce;
  192. }
  193. this.flash_sale = detail.plugin_extra.flash_sale;
  194. this.miaosha_status = miaosha_status;
  195. this.miaosha_buy_count = miaosha_buy_count;
  196. this.loading = true;
  197. this.url = `${this.$api.miaosha.poster}&goods_id=${this.detail.id}`;
  198. this.poster_config = `${this.poster_config}&goods_id=${this.detail.id}`;
  199. this.poster_generate = `${this.poster_generate}&goods_id=${this.detail.id}`;
  200. this.favorite = detail.favorite
  201. this.name = detail.name
  202. this.getTime(miaosha_time);
  203. console.log(detail)
  204. } else {
  205. uni.showToast({
  206. title: response.msg,
  207. icon: 'none'
  208. })
  209. }
  210. this.$request({
  211. url: this.$api.goods.new_recommend,
  212. data: {
  213. goods_id: this.detail.id,
  214. }
  215. }).then(response => {
  216. if (response.code === 0) {
  217. this.list = response.data.list;
  218. if (that.detail.vip_card_appoint.discount) {
  219. that.is_vip = true;
  220. that.discount = that.detail.vip_card_appoint.discount
  221. }
  222. that.is_vip_card_user = that.detail.vip_card_appoint.is_vip_card_user
  223. }
  224. })
  225. });
  226. })
  227. },
  228. onHide() {
  229. clearInterval(this.time);
  230. },
  231. onUnload() {
  232. clearInterval(this.time);
  233. },
  234. computed: {
  235. ...mapGetters('mallConfig', {
  236. getTheme: 'getTheme',
  237. }),
  238. ...mapState({
  239. mall: state => state.mallConfig.mall
  240. }),
  241. themeObject: function() {
  242. return {
  243. back: this.getTheme + '-m-back ' + this.getTheme,
  244. theme: this.getTheme,
  245. color: this.getTheme + '-m-text ' + this.getTheme,
  246. sBack: this.getTheme + '-s-back ' + this.getTheme
  247. }
  248. },
  249. root() {
  250. return this.$siteInfo.root
  251. }
  252. },
  253. onShareAppMessage() {
  254. return this.$shareAppMessage({
  255. path: '/plugins/miaosha/goods/goods',
  256. title: this.detail.app_share_title ? this.detail.app_share_title : this.detail.name,
  257. imageUrl: this.detail.app_share_pic ? this.detail.app_share_pic : '',
  258. params: {
  259. id: this.detail.id
  260. }
  261. });
  262. },
  263. // #ifdef MP-WEIXIN
  264. onShareTimeline() {
  265. return this.$shareTimeline({
  266. title: this.detail.app_share_title ? this.detail.app_share_title : this.detail.name,
  267. query: {
  268. id: this.detail.id
  269. }
  270. });
  271. },
  272. // #endif
  273. methods: {
  274. back() {
  275. routeJump({
  276. open_type: 'back',
  277. })
  278. },
  279. getMall(e) {
  280. this.is_open = e.is_open;
  281. },
  282. async request({
  283. url,
  284. data
  285. }) {
  286. const response = await this.$request({
  287. url: url,
  288. data: data,
  289. });
  290. if (response.code === 0) {
  291. return response.data;
  292. }
  293. },
  294. attrtap(data) {
  295. console.log(data)
  296. this.selectAttr = data;
  297. },
  298. takeCart() {
  299. this.show = true;
  300. console.log(this.selectAttr)
  301. },
  302. leftFunc(number) {
  303. this.$request({
  304. url: this.$api.miaosha.add_cart,
  305. method: 'post',
  306. data: {
  307. miaosha_goods_id: this.selectAttr.goods_id,
  308. attr_id: this.selectAttr.id,
  309. num: number
  310. }
  311. }).then(response => {
  312. uni.showToast({
  313. title: response.msg,
  314. icon: 'none'
  315. })
  316. });
  317. },
  318. rightFunc(data) {
  319. uni.navigateTo({
  320. url: `/pages/order-submit/order-submit?mch_list=${JSON.stringify([data])}&preview_url=${encodeURIComponent(this.$api.miaosha.order_preview)}&submit_url=${encodeURIComponent(this.$api.miaosha.order_submit)}`
  321. });
  322. },
  323. getTime(newValue) {
  324. newValue = newValue - 1;
  325. this.day = parseInt(newValue / 3600 / 24);
  326. this.hour = parseInt(newValue / 3600 % 24);
  327. this.minute = parseInt(newValue / 60 % 60);
  328. this.second = parseInt(newValue % 60);
  329. clearInterval(this.time);
  330. this.time = setInterval(() => {
  331. newValue = newValue - 1;
  332. if (newValue < 0) {
  333. clearInterval(this.time);
  334. }
  335. this.day = parseInt(newValue / 3600 / 24);
  336. this.hour = parseInt(newValue / 3600 % 24);
  337. this.minute = parseInt(newValue / 60 % 60);
  338. this.second = parseInt(newValue % 60);
  339. }, 1000);
  340. },
  341. setCoupon(index) {
  342. this.$set(this.detail.goods_coupon_center[index], 'is_receive', 1);
  343. },
  344. router(url) {
  345. uni.navigateTo({
  346. url: url
  347. })
  348. },
  349. setFavorite() {
  350. let url = this.$api.user.favorite_add;
  351. let favorite = true;
  352. if (this.favorite) {
  353. url = this.$api.user.favorite_remove;
  354. favorite = false;
  355. }
  356. this.favorite = favorite;
  357. this.$request({
  358. url: url,
  359. data: {
  360. goods_id: this.detail.id
  361. }
  362. }).then(response => {
  363. if (response.code === 0) {} else {
  364. uni.showModal({
  365. title: '提示',
  366. content: response.msg,
  367. showCancel: false
  368. });
  369. }
  370. });
  371. },
  372. kefu() {
  373. uni.navigateTo({
  374. url: "/pages/web/web?url=" + this.mall.setting.web_service_url
  375. })
  376. },
  377. },
  378. components: {
  379. 'app-banner': appBanner,
  380. 'app-goods-time': appGoodsTime,
  381. 'app-related-suggestion-product': appRelatedSuggestionProduct,
  382. uAttr,
  383. appGoodsFullReduce,
  384. bdInfo,
  385. bdCoupon,
  386. bdXbc,
  387. bdKb,
  388. bdHc,
  389. bdDetail,
  390. bdComments,
  391. appClose,
  392. uniNavBar
  393. }
  394. }
  395. </script>
  396. <style scoped lang="scss">
  397. .app-goods {
  398. background-color: #f7f7f7;
  399. }
  400. .join-member {
  401. background-color: #ffffff;
  402. padding: 0 #{24rpx};
  403. box-sizing: border-box;
  404. }
  405. .buttons {
  406. width: #{750rpx};
  407. height: #{110rpx};
  408. padding: 0 20rpx;
  409. .app-home {
  410. width: 14%;
  411. height: #{110rpx};
  412. background-color: white;
  413. image {
  414. width: #{40rpx};
  415. height: #{40rpx};
  416. }
  417. text {
  418. font-size: #{18rpx};
  419. color: #707070;
  420. }
  421. }
  422. .app-button {
  423. width: 86%;
  424. height: #{110rpx};
  425. text-align: center;
  426. line-height: #{110rpx};
  427. .app-join-cart {
  428. height: #{110rpx};
  429. }
  430. .app-buy {
  431. height: #{110rpx};
  432. color: white;
  433. }
  434. .notStart {
  435. height: #{110rpx};
  436. background-color: #cccccc;
  437. color: #FFFFFF;
  438. }
  439. .app-over {
  440. height: #{110rpx};
  441. background: #666;
  442. color: #FFFFFF;
  443. }
  444. }
  445. }
  446. .text {
  447. color: #ffffff;
  448. }
  449. .u-bottom-fixed {
  450. position: fixed;
  451. bottom: 0;
  452. left: 0;
  453. width: 100%;
  454. z-index: 1602;
  455. background-color: #ffffff;
  456. }
  457. .u-bottom-height-0 {
  458. height: 110upx;
  459. }
  460. .u-bottom-height-1 {
  461. height: 190upx;
  462. }
  463. .goods-margin {
  464. margin-top: 20upx;
  465. }
  466. .cart-btn {
  467. height: 90%;
  468. border-top-left-radius: #{30rpx};
  469. border-bottom-left-radius: #{30rpx};
  470. position: relative;
  471. transform: translateY(-50%);
  472. top: 50%;
  473. background: linear-gradient(to right, #A494F6, #BC8AE7, #E674B2);
  474. color: #ffffff;
  475. display: flex;
  476. align-items: center;
  477. justify-content: center;
  478. }
  479. .cart-btn:after {
  480. content: "";
  481. position: absolute;
  482. right: 0;
  483. height: 60%;
  484. background: #ffffff;
  485. width: 1px;
  486. top: 50%;
  487. transform: translateY(-50%);
  488. }
  489. .buy-btn {
  490. height: 90%;
  491. border-top-right-radius: #{30rpx};
  492. border-bottom-right-radius: #{30rpx};
  493. position: relative;
  494. transform: translateY(-50%);
  495. top: 50%;
  496. background: linear-gradient(to right, #E674B2, #FE3666);
  497. display: flex;
  498. align-items: center;
  499. justify-content: center;
  500. }
  501. </style>