goods.vue 13 KB

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