goods.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <app-layout>
  3. <view v-if="!goods" class="u-goods-detail"></view>
  4. <template v-if="goods">
  5. <app-goods-banner
  6. :pic-list="goods.pic_url"
  7. :share="goods.share"
  8. :goods_id="goods.id"
  9. :video-url="goods.video_url"
  10. ></app-goods-banner>
  11. <view class="bd-info">
  12. <view class="goods-name u-line-2">{{goods.name}}</view>
  13. <view v-if="goods.subtitle" class="goods-subtitle">
  14. <view class="t-omit-three">{{goods.subtitle}}</view>
  15. </view>
  16. <view class='price main-between' :style="{'color': getTheme.color}">
  17. <view class="dir-left-nowrap cross-bottom">
  18. <image class="detail-price" src='./../image/detail-price.png'></image>
  19. <view class="cross-bottom">{{goods.min_currency}}</view>
  20. <view class="goods-currency" v-if="goods.max_currency > goods.min_currency">起</view>
  21. <view>+</view>
  22. <view style="font-size: 14px">¥</view>
  23. <view>{{goods.min_price}}</view>
  24. <view class="goods-currency" v-if="goods.max_price > goods.min_price">起</view>
  25. </view>
  26. <view @click="shareClick"
  27. :style="{'background-color': getTheme.background}"
  28. class="share dir-left-nowrap main-center cross-center">
  29. <image class="share-image box-grow-0" src="/static/image/icon/icon-share-white.png"></image>
  30. <view class="share-text box-grow-0">分享</view>
  31. </view>
  32. </view>
  33. <app-share-qr-code :url="shareUrl"
  34. :has-poster-nav="true"
  35. :poster-config="poster_config + `&goods_id=` + goods.id"
  36. :poster-generate="poster_generate + `&goods_id=` + goods.id"
  37. v-model="shareShow"
  38. :goods="goods"
  39. @share="hShareAppMessage"
  40. ></app-share-qr-code>
  41. <view style="background-color: #FFFFFF;padding: 24upx; 0 0 24upx">
  42. <bd-info-extra :goods="goods" :theme="getTheme" :unit="goods.unit" :min-number="goods.min_number" :limit-buy="goods.limit_buy"></bd-info-extra>
  43. </view>
  44. </view>
  45. <bd-coupon @change="setCoupon" :theme="getTheme" :coupons="goods.goods_coupon_center"></bd-coupon>
  46. <bd-xbc
  47. :coAttr="is_open"
  48. :attr-list="selectAttr.attr_list"
  49. :type="goods.type"
  50. :guarantee-title="goods.guarantee_title"
  51. :guarantee-pic="goods.guarantee_pic"
  52. :param_content="goods.param_content"
  53. :param_name="goods.param_name"
  54. :services="goods.services"
  55. :attr-groups="goods.attr_groups"
  56. :goods-stock="goods.goods_stock"
  57. @openAttr="clickAttr"
  58. ></bd-xbc>
  59. <bd-hc
  60. :integral="goods.goods_marketing_award.integral"
  61. :coupon="goods.goods_marketing_award.coupon"
  62. :card="goods.goods_marketing_award.card"
  63. :balance="goods.goods_marketing_award.balance"
  64. :theme="getTheme"
  65. ></bd-hc>
  66. <bd-kb
  67. :limit="goods.goods_marketing.limit"
  68. :express="goods.express"
  69. :shipping="goods.goods_marketing.shipping"
  70. :pickup="goods.goods_marketing.pickup"
  71. ></bd-kb>
  72. <bd-detail :detail="goods.detail"></bd-detail>
  73. <!--空格区域-->
  74. <view class="safe-area-inset-bottom u-bottom">
  75. <view class="u-bottom-height"></view>
  76. </view>
  77. <!--底部按钮-->
  78. <view v-if="is_open == 1" class="safe-area-inset-bottom u-bottom-fixed">
  79. <view class="bd-bottom dir-left-nowrap cross-center">
  80. <view class="bd-back dir-top-nowrap main-center cross-center box-grow-0" @click="back">
  81. <image class="bd-icon" src="/static/image/icon/index.png"></image>
  82. <text class="bd-text">首页</text>
  83. </view>
  84. <bd-service :name="goods.name" :url="webUrl"></bd-service>
  85. <view v-if="goods.goods_stock === 0" class="box-grow-1 bd-btn bd-oversell-btn bd-btn-color" >
  86. 已售罄
  87. </view>
  88. <view
  89. v-else
  90. @click="clickAttr"
  91. :style="{'background': goods.buy_goods_auth ? getTheme.background_gradient_btn : '#999999','color': goods.buy_goods_auth ? getTheme.main_text : ''}"
  92. class="bd-btn box-grow-1 bd-btn-color">
  93. 立即兑换
  94. </view>
  95. </view>
  96. </view>
  97. <u-attr
  98. :goods="goods"
  99. v-model="attrShow"
  100. :theme="getTheme"
  101. :checked="selectAttr"
  102. :is_show_left="false"
  103. rightText="立即兑换"
  104. @check="onAttr"
  105. :rightFunc="true"
  106. @rightFunc="rightFunc"
  107. >
  108. <view slot="priceBefore" v-if="selectAttr">
  109. {{selectAttr.extra.value}}{{selectAttr.extra.name}} +
  110. </view>
  111. </u-attr>
  112. </template>
  113. <app-close v-if="showClose" :modal="false" @update="getMall"></app-close>
  114. </app-layout>
  115. </template>
  116. <script>
  117. import {mapGetters, mapState} from "vuex";
  118. import appGoodsBanner from "../../../components/page-component/goods/app-goods-banner.vue";
  119. import appShareQrCode from '../../../components/page-component/app-share-qr-code-poster/app-share-qr-code-poster.vue';
  120. import uAttr from '../../../components/page-component/goods/u-attr.vue';
  121. import bdCoupon from '@/components/page-component/goods/bd-coupon.vue';
  122. import bdXbc from '@/components/page-component/goods/bd-xbc.vue';
  123. import bdDetail from '@/components/page-component/goods/bd-detail.vue';
  124. import bdKb from '@/components/page-component/goods/bd-kb.vue';
  125. import bdHc from '@/components/page-component/goods/bd-hc.vue';
  126. import appClose from '@/components/basic-component/app-close/app-close.vue';
  127. import bdService from '@/components/page-component/goods/bd-service.vue';
  128. import bdInfoExtra from '@/components/page-component/goods/bd-info-extra.vue';
  129. export default {
  130. name: "goods",
  131. components: {
  132. appGoodsBanner,
  133. appShareQrCode,
  134. uAttr,
  135. bdCoupon,
  136. bdXbc,
  137. bdDetail,
  138. bdHc,
  139. bdKb,
  140. appClose,
  141. bdService,
  142. bdInfoExtra
  143. },
  144. data() {
  145. return {
  146. showClose: false,
  147. is_open: 0,
  148. goods: {
  149. id: '',
  150. name: '',
  151. cover_pic: '',
  152. price: '',
  153. },
  154. webUrl: '',
  155. selectAttr: null,
  156. shareShow: false,
  157. shareUrl: null,
  158. attrShow: false,
  159. poster_config: this.$api.step.poster_config,
  160. poster_generate: this.$api.step.poster_generate,
  161. disable: 'disable'
  162. };
  163. },
  164. computed: {
  165. ...mapState({
  166. mall: state => state.mallConfig.mall,
  167. }),
  168. ...mapGetters('mallConfig', {
  169. getTheme: 'getTheme',
  170. })
  171. },
  172. onShow() {
  173. this.showClose = false;
  174. setTimeout(()=>{
  175. this.showClose = true;
  176. })
  177. },
  178. onLoad(options) { this.$commonLoad.onload(options);
  179. this.webUrl = '/plugins/step/goods/goods?goods_id=' + options.goods_id;
  180. // #ifdef MP-WEIXIN
  181. wx.showShareMenu({
  182. menus: ['shareAppMessage', 'shareTimeline']
  183. })
  184. // #endif
  185. this.loadData(options.goods_id);
  186. },
  187. // #ifdef MP-WEIXIN
  188. onShareTimeline() {
  189. let { app_share_title, name, app_share_pic, cover_pic, id, pic_url } = this.goods;
  190. return this.$shareTimeline({
  191. title: app_share_title ? app_share_title: name,
  192. imageUrl: pic_url[0].pic_url,
  193. query: {
  194. goods_id: id
  195. }
  196. });
  197. },
  198. // #endif
  199. // #ifdef MP
  200. onShareAppMessage() {
  201. return this.hShareAppMessage();
  202. },
  203. // #endif
  204. methods: {
  205. hShareAppMessage(s = false){
  206. let { app_share_title, name, app_share_pic, cover_pic, id , subtitle} = this.goods;
  207. return this.$shareAppMessage({
  208. title: app_share_title ? app_share_title: name,
  209. imageUrl: app_share_pic ? app_share_pic: cover_pic,
  210. path: "/plugins/step/goods/goods",
  211. desc: subtitle,
  212. params: {
  213. goods_id: id
  214. }
  215. }, s);
  216. },
  217. getMall(e) {
  218. this.is_open = e.is_open;
  219. },
  220. loadData(id) {
  221. this.$showLoading();
  222. this.$request({
  223. url: this.$api.step.goods_detail,
  224. data: {
  225. id: id
  226. }
  227. }).then(response => {
  228. this.$hideLoading();
  229. if (response.code === 0) {
  230. this.goods = response.data.detail;
  231. this.shareUrl = this.$api.step.goods_poster + '&goods_id=' + id;
  232. this.goods.id = id;
  233. // #ifdef H5
  234. this.hShareAppMessage();
  235. // #endif
  236. } else {
  237. uni.showToast({
  238. title: response.msg,
  239. icon: 'none'
  240. });
  241. }
  242. }).catch(() => {
  243. this.$hideLoading();
  244. });
  245. },
  246. onAttr({item}) {
  247. this.selectAttr = item;
  248. },
  249. shareClick() {
  250. this.shareShow = true;
  251. },
  252. back() {
  253. uni.redirectTo({
  254. url: '/pages/index/index'
  255. });
  256. },
  257. clickAttr() {
  258. if (!this.goods.buy_goods_auth) {
  259. this.$tips.showToast({
  260. title: '您暂无权限购买该商品',
  261. icon: 'none'
  262. });
  263. return;
  264. }
  265. this.attrShow = true;
  266. },
  267. setCoupon(index) {
  268. this.$set(this.goods.goods_coupon_center[index], 'is_receive', 1);
  269. },
  270. rightFunc(data) {
  271. uni.navigateTo({
  272. url: `/pages/order-submit/order-submit?mch_list=${JSON.stringify([data])}&preview_url=${encodeURIComponent(this.$api.step.order_preview)}&submit_url=${encodeURIComponent(this.$api.step.order_submit)}`
  273. });
  274. }
  275. }
  276. }
  277. </script>
  278. <style scoped lang="scss">
  279. .goods-currency {
  280. font-size: #{22rpx};
  281. padding-bottom:#{2rpx};
  282. }
  283. .goods-currency+view {
  284. font-size: #{32rpx};
  285. padding: 0 #{5rpx};
  286. }
  287. .goods-name {
  288. padding: 24upx 24upx 0 24upx;
  289. background-color: #ffffff;
  290. color: $uni-important-color-black;
  291. }
  292. .goods-subtitle {
  293. padding: #{24rpx};
  294. padding-bottom: #{30rpx};
  295. font-size: 24rpx;
  296. background-color: #ffffff;
  297. color: #999999;
  298. }
  299. .bd-bottom {
  300. width: 750upx;
  301. height: 110upx;
  302. padding: 20upx 24upx;
  303. }
  304. .bd-back {
  305. width: 66upx;
  306. height: 100%;
  307. margin-right: 20upx;
  308. }
  309. .bd-icon {
  310. width: 30upx;
  311. height: 30upx;
  312. margin-bottom: 8upx;
  313. }
  314. .bd-text {
  315. font-size: 20upx;
  316. color: #888888;
  317. line-height: 1;
  318. }
  319. .bd-btn {
  320. text-align: center;
  321. line-height: 70upx;
  322. font-size: 28upx;
  323. border-radius: 35upx;
  324. }
  325. .bd-btn-color {
  326. color: #ffffff;
  327. }
  328. .bd-oversell-btn {
  329. background-color: #CDCDCD;
  330. }
  331. .price {
  332. height: #{106rpx};
  333. font-size: #{40rpx};
  334. font-family: DIN;
  335. padding-left: #{24rpx};
  336. padding-bottom: #{24rpx};
  337. background-color: #fff;
  338. position: relative;
  339. }
  340. .price .detail-price {
  341. height: #{44rpx};
  342. width: #{44rpx};
  343. display: block;
  344. float: left;
  345. margin-right: #{16rpx};
  346. }
  347. .share {
  348. margin-top: #{10rpx};
  349. height: #{48rpx};
  350. border-radius: #{40rpx} 0 0 #{40rpx};
  351. padding: 0 #{14rpx};
  352. width: #{103rpx};
  353. .share-image {
  354. width: #{22rpx};
  355. height: #{22rpx};
  356. }
  357. .share-text {
  358. font-size: #{22rpx};
  359. color: #ffffff;
  360. margin-left: #{10rpx};
  361. }
  362. }
  363. .u-bottom-fixed {
  364. position: fixed;
  365. bottom: 0;
  366. left: 0;
  367. width: 100%;
  368. z-index: 1500;
  369. background-color: #ffffff;
  370. }
  371. .u-bottom-height {
  372. height: 110upx;
  373. }
  374. .bd-info {
  375. width: 702upx;
  376. border-radius: 15upx;
  377. overflow: hidden;
  378. margin: 24upx 24upx 0 24upx;
  379. }
  380. </style>