goods.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. <template>
  2. <app-layout>
  3. <view>
  4. <app-quick-navigation></app-quick-navigation>
  5. </view>
  6. <view>
  7. <app-goods-banner :pic-list="goods.pic_url"
  8. :share="goods.share"
  9. :video-url="goods.video_url"
  10. :goods_id="goods.id"
  11. ></app-goods-banner>
  12. </view>
  13. <view class="goods-name t-omit-two">{{goods.name}}</view>
  14. <view class="price" v-if="goods">
  15. <app-goods-price @quickShare="quickShare" :discount='discount' :is_vip_card_user="is_vip_card_user" :goods="goods"
  16. :select-attr="selectAttr"
  17. ></app-goods-price>
  18. </view>
  19. <view class="vip-card" v-if="is_vip">
  20. <app-vip-card background="#fff" top="0"></app-vip-card>
  21. </view>
  22. <view class="merchant-guarantee" v-if="goods.services.length>0">
  23. <app-goods-service :list="goods.services"></app-goods-service>
  24. </view>
  25. <view class="attr" v-if="goods.is_negotiable == 0">
  26. <app-attr :goods="goods"
  27. :attrGroupList="goods.attr_groups"
  28. :show="attrShow"
  29. @attrtap="onAttr"
  30. >
  31. <view slot="button">
  32. <app-goods-attr :attr-groups="goods.attr_groups" :selectAttr="selectAttr" :attr="goods.attr"></app-goods-attr>
  33. </view>
  34. </app-attr>
  35. </view>
  36. <view class="marketing" v-if="goods">
  37. <app-goods-marketing :limit="goods.goods_marketing.limit"
  38. :express="goods.express"
  39. :shipping="goods.goods_marketing.shipping"
  40. :pickup="goods.goods_marketing.pickup"
  41. :card="goods.goods_marketing_award.card"
  42. :integral="goods.goods_marketing_award.integral"
  43. ></app-goods-marketing>
  44. </view>
  45. <view @click="toComposition" class="goods-composition" v-if="goods.plugin_extra && goods.plugin_extra.composition.list.length > 0">
  46. <view class="goods-composition-title">套餐组合</view>
  47. <uni-swiper-dot :current="current" :info="goods.plugin_extra.composition.list" mode="customize">
  48. <swiper @change="change" class="goods-composition-swiper" :current="current" :autoplay="true">
  49. <swiper-item v-for="item in goods.plugin_extra.composition.list" :key="item.id">
  50. <app-composition @click="toComposition(item)" @look="toComposition(item)" :item="item"></app-composition>
  51. </swiper-item>
  52. </swiper>
  53. </uni-swiper-dot>
  54. <view class="goods-composition-more main-between cross-center">
  55. <view>更多套餐组合</view>
  56. <image src="/static/image/icon/arrow-right.png"></image>
  57. </view>
  58. </view>
  59. <view v-if="goods">
  60. <app-goods-detail :goods="goods"></app-goods-detail>
  61. </view>
  62. <view class="recommend">
  63. <app-goods-recommend :goods-list="recommend_list"></app-goods-recommend>
  64. </view>
  65. <view class="bottom"></view>
  66. <view>
  67. <app-jump-button>
  68. </app-jump-button>
  69. </view>
  70. <view>
  71. <app-empty-bottom :height="Number(110)"></app-empty-bottom>
  72. </view>
  73. <view>
  74. <app-iphone-x>
  75. <view class="app-bottom dir-left-nowrap" slot="empty-area">
  76. <view class="dir-top-nowrap main-center cross-center little box-grow-0" @click="back">
  77. <image src="../../static/image/icon/index.png"></image>
  78. <view>首页</view>
  79. </view>
  80. <!-- <view class="dir-top-nowrap main-center cross-center little box-grow-0" @click="favorite">
  81. <image :src="goods.favorite ? '../../static/image/icon/icon-favorite-active.png' : '../../static/image/icon/icon-favorite.png'"></image>
  82. <view>收藏</view>
  83. </view> -->
  84. <view class="box-grow-1 dir-left-nowrap btn" v-if="goods.is_negotiable === 1">
  85. <block v-for="(item, index) in mall.setting.good_negotiable" :key="index">
  86. <template v-if="item === 'contact_tel'">
  87. <view class="box-grow-1 cross-center main-center contact-tel"
  88. :class="theme + '-background'"
  89. >
  90. <app-jump-button
  91. :number="mall.setting.contact_tel"
  92. open_type="tel"
  93. >
  94. <view>联系电话</view>
  95. </app-jump-button>
  96. </view>
  97. </template>
  98. <!-- #ifndef MP-TOUTIAO -->
  99. <template v-else-if="item === 'contact'">
  100. <view class="box-grow-1 cross-center main-center contact">
  101. <app-jump-button open_type="contact">
  102. <view>客服</view>
  103. </app-jump-button>
  104. </view>
  105. </template>
  106. <!-- #endif -->
  107. <template v-else-if="item === 'contact_web'">
  108. <view class="box-grow-1 cross-center main-center service">
  109. <app-jump-button
  110. :url="'/pages/web/web?url=' + mall.setting.web_service_url"
  111. open_type="web"
  112. >
  113. <view>客服</view>
  114. </app-jump-button>
  115. </view>
  116. </template>
  117. </block>
  118. </view>
  119. <template v-else>
  120. <view class="box-grow-1 dir-left-nowrap" style="height: 100%;" v-if="goods.goods_num == 0">
  121. <view style="width: 100%;background-color: #CDCDCD;color: #fff;" class="main-center cross-center button">已售罄</view>
  122. </view>
  123. <view class="box-grow-1 dir-left-nowrap" style="height: 100%;" v-else>
  124. <!-- <view class="main-center cross-center button"
  125. :class="theme + '-secondary-background'"
  126. @click="clickAttr">
  127. 加入购物车
  128. </view> -->
  129. <view class="main-center cross-center button buttonAttr"
  130. :class="theme + '-background'"
  131. @click="clickAttr"
  132. >立即购买
  133. </view>
  134. </view>
  135. </template>
  136. </view>
  137. </app-iphone-x>
  138. </view>
  139. </app-layout>
  140. </template>
  141. <script>
  142. import { mapState } from "vuex";
  143. import appGoodsBanner from "../../components/page-component/goods/app-goods-banner.vue";
  144. import appGoodsPrice from "../../components/page-component/goods/app-goods-price.vue";
  145. import appService from "../../components/page-component/goods/app-goods-service.vue";
  146. import appGoodsAttr from "../../components/page-component/goods/app-goods-attr.vue";
  147. import appAttr from "../../components/page-component/app-attr/app-attr.vue";
  148. import appGoodsMarketing from "../../components/page-component/goods/app-goods-marketing.vue";
  149. import appJumpButton from "../../components/basic-component/app-jump-button/app-jump-button.vue";
  150. import appGoodsList from "../../components/page-component/app-goods-list/app-goods-list.vue";
  151. import appGoodsDetail from "../../components/page-component/goods/app-goods-detail.vue";
  152. import appGoodsRecommend from "../../components/page-component/app-goods-recommend/app-goods-recommend.vue";
  153. import appQuickNavigation from "../../components/page-component/app-quick-navigation/app-quick-navigation.vue";
  154. import appIphoneX from '../../components/basic-component/app-iphone-x/app-iphone-x.vue';
  155. import appEmptyBottom from'../../components/basic-component/app-empty-bottom/app-empty-bottom.vue';
  156. import appComposition from'../../components/basic-component/app-composition/app-composition.vue';
  157. import AppVipCard from '../../components/page-component/app-vip-card/app-vip-card';
  158. import uniSwiperDot from '../../components/basic-component/uni-swiper-dot/uni-swiper-dot';
  159. export default {
  160. name: "goods",
  161. components: {
  162. appGoodsBanner,
  163. appGoodsPrice,
  164. appGoodsAttr,
  165. appAttr,
  166. appGoodsMarketing,
  167. appJumpButton,
  168. 'app-goods-list': appGoodsList,
  169. 'app-goods-service': appService,
  170. 'app-goods-detail': appGoodsDetail,
  171. 'app-goods-recommend': appGoodsRecommend,
  172. 'app-quick-navigation': appQuickNavigation,
  173. 'app-composition': appComposition,
  174. appIphoneX,
  175. appEmptyBottom,
  176. uniSwiperDot,
  177. AppVipCard
  178. },
  179. data() {
  180. return {
  181. goods: null,
  182. selectAttr: null,
  183. recommend_list: null,
  184. is_vip: false,
  185. is_vip_card_user: 0,
  186. current: 0,
  187. discount: null,
  188. attrShow: 0,
  189. shareData: null,
  190. };
  191. },
  192. computed: {
  193. ...mapState({
  194. theme: state => state.mallConfig.theme,
  195. mall: state => state.mallConfig.mall,
  196. gConfig: state => state.gConfig,
  197. }),
  198. },
  199. onLoad(options) {
  200. if (this.isLogin) {
  201. this.$store.dispatch('user/info');
  202. } else {
  203. }
  204. this.loadData(options.id);
  205. },
  206. onShareAppMessage(object) {
  207. console.log(this.shareData);
  208. if (object.from === 'button' && this.shareData) {
  209. return this.$shareAppMessage(this.shareData);
  210. }
  211. return this.$shareAppMessage({
  212. title: this.goods.app_share_title ? this.goods.app_share_title : this.goods.name,
  213. imageUrl: this.goods.app_share_pic ? this.goods.app_share_pic : '',
  214. path: '/pages/goods/goods',
  215. params: {
  216. id: this.goods.id
  217. }
  218. });
  219. },
  220. methods: {
  221. change(e) {
  222. this.current = e.detail.current;
  223. },
  224. quickShare(info) {
  225. console.log(info);
  226. this.shareData = info;
  227. },
  228. toComposition(item) {
  229. console.log(item)
  230. let id = item.id > 0 ? item.id : this.goods.plugin_extra.composition.list[0].id
  231. uni.navigateTo({
  232. url: this.goods.plugin_extra.composition.url + '?goods_id=' + this.goods.id + '&composition_id=' + id
  233. })
  234. },
  235. loadData(id) {
  236. let that = this;
  237. that.$showLoading();
  238. that.$request({
  239. url: that.$api.goods.detail,
  240. data: {
  241. id: id
  242. }
  243. }).then(response => {
  244. that.$hideLoading();
  245. if (response.code === 0) {
  246. that.goods = response.data.goods;
  247. uni.setNavigationBarTitle({
  248. title: that.goods.name
  249. });
  250. if(that.goods.vip_card_appoint.discount > 0) {
  251. that.is_vip = true;
  252. that.discount = that.goods.vip_card_appoint.discount
  253. }
  254. that.is_vip_card_user = that.goods.vip_card_appoint.is_vip_card_user;
  255. that.loadRecommend();
  256. } else {
  257. uni.showModal({
  258. title: '提示',
  259. content: response.msg,
  260. showCancel: false
  261. });
  262. }
  263. }).catch(e => {
  264. that.$hideLoading();
  265. });
  266. },
  267. onAttr(data) {
  268. this.selectAttr = data;
  269. },
  270. loadRecommend() {
  271. let that = this;
  272. this.$request({
  273. url: this.$api.goods.new_recommend,
  274. data: {
  275. goods_id: this.goods.id,
  276. type: 'goods'
  277. }
  278. }).then(response => {
  279. if (response.code === 0) {
  280. this.recommend_list = response.data.list;
  281. }
  282. });
  283. },
  284. back() {
  285. uni.reLaunch({
  286. url: '/pages/index/index'
  287. });
  288. },
  289. favorite() {
  290. let url = this.$api.user.favorite_add;
  291. let favorite = true;
  292. if (this.goods.favorite) {
  293. url = this.$api.user.favorite_remove;
  294. favorite = false;
  295. }
  296. this.goods.favorite = favorite;
  297. this.$request({
  298. url: url,
  299. data: {
  300. goods_id: this.goods.id,
  301. }
  302. }).then(response => {
  303. if (response.code === 0) {
  304. } else {
  305. uni.showModal({
  306. title: '提示',
  307. content: response.msg,
  308. showCancel: false,
  309. });
  310. }
  311. }).catch(e => {
  312. });
  313. },
  314. clickAttr() {
  315. this.attrShow = Math.random();
  316. },
  317. }
  318. }
  319. </script>
  320. <style scoped lang="scss">
  321. .goods-composition {
  322. padding: 24rpx;
  323. background-color: #fff;
  324. margin-bottom: 20rpx;
  325. .goods-composition-title {
  326. font-size: 28rpx;
  327. color: #353535;
  328. margin-bottom: 20rpx;
  329. }
  330. .goods-composition-swiper {
  331. height: 194rpx;
  332. }
  333. .goods-composition-more {
  334. margin: 0 auto;
  335. width: 226rpx;
  336. padding: 0 24rpx;
  337. height: 56rpx;
  338. line-height: 54rpx;
  339. border-radius: 28rpx;
  340. border: 2rpx solid #bbbbbb;
  341. font-size: 24rpx;
  342. color: #999999;
  343. margin-bottom: 4rpx;
  344. image {
  345. width: #{12rpx};
  346. height: #{22rpx};
  347. display: block;
  348. }
  349. }
  350. }
  351. .goods-name {
  352. padding: #{24rpx 24rpx 0 24rpx};
  353. background-color: #ffffff;
  354. color: $uni-important-color-black;
  355. font-size:36rpx;
  356. font-family:Source Han Sans CN;
  357. font-weight:500;
  358. color:rgba(62,62,62,1);
  359. }
  360. .price {
  361. padding-top: #{24rpx};
  362. background-color: #ffffff;
  363. }
  364. .vip-card {
  365. padding-bottom: #{20rpx};
  366. background-color: #fff;
  367. }
  368. .merchant-guarantee {
  369. margin-top: #{20rpx};
  370. }
  371. .attr {
  372. padding: #{24rpx} 0;
  373. background-color: #f7f7f7;
  374. }
  375. .bottom {
  376. width: 100%;
  377. height: #{110rpx};
  378. }
  379. .app-bottom {
  380. width: 100%;
  381. height: #{110rpx};
  382. font-size: $uni-font-size-general-one;
  383. background-color: #ffffff;
  384. .little {
  385. // width: #{110rpx};
  386. // width: #{30%};
  387. width: #{220rpx};
  388. height: 100%;
  389. background-color: #ffffff;
  390. font-size: #{20rpx};
  391. color: $uni-general-color-two;
  392. &:first-child {
  393. border-right: #{1rpx} solid #e2e2e2;
  394. }
  395. image {
  396. width: #{40rpx};
  397. height: #{40rpx};
  398. display: block;
  399. margin-bottom: #{10rpx};
  400. }
  401. }
  402. .btn {
  403. height: 100%;
  404. }
  405. .button {
  406. width: 50%;
  407. height: 100%;
  408. }
  409. .buttonAttr{
  410. width: 100%;
  411. height: 100%;
  412. }
  413. .service {
  414. background-color: #446dfd;
  415. color: #ffffff;
  416. }
  417. .contact-tel {
  418. background-color: #f39800;
  419. color: #ffffff;
  420. }
  421. .contact {
  422. background-color: #4cbf2a;
  423. color: #ffffff;
  424. }
  425. }
  426. </style>