goods.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <app-layout>
  3. <view class="app-details" v-if="loading">
  4. <view>
  5. <app-quick-navigation></app-quick-navigation>
  6. </view>
  7. <view class="app-banner">
  8. <app-goods-banner
  9. :picList="item.pic_url"
  10. :isCart="isCart"
  11. :share="item.share"
  12. :goods_id="item.id"
  13. :video-url="item.video_url"
  14. sign="booking"
  15. ></app-goods-banner>
  16. </view>
  17. <!-- 详情标题 -->
  18. <view class="goods-name">
  19. <app-name :name="item.name"></app-name>
  20. </view>
  21. <view class="app-price">
  22. <app-goods-price
  23. :is_vip_card_user="is_vip_card_user"
  24. :discount='discount'
  25. :goods="item"
  26. :shareUrl="url"
  27. ></app-goods-price>
  28. </view>
  29. <view class="vip-card">
  30. <app-vip-card background="#fff" top="0" v-if="is_vip"></app-vip-card>
  31. </view>
  32. <view class="merchant-guarantee" v-if="item.services.length > 0">
  33. <app-goods-service :list="item.services" :border="false"></app-goods-service>
  34. </view>
  35. <view class="app-attr">
  36. <app-attr :goods="item"
  37. :attrGroupList="item.attr_group"
  38. @attrtap="attrtap"
  39. :cartShow="cartShow"
  40. ref="attr"
  41. :selectAttr="selectAttr"
  42. buyText="立即预约"
  43. :previewUrl="previewUrl"
  44. :submitUrl="submitUrl"
  45. plugin="booking"
  46. :show="show"
  47. >
  48. <app-goods-attr
  49. slot="button"
  50. :attr-groups="item.attr_group"
  51. :selectAttr="selectAttr"
  52. :attr="item.attr"
  53. ></app-goods-attr>
  54. </app-attr>
  55. </view>
  56. <view v-if="item.store.length > 0">
  57. <app-store :store_id="item.store[0].id"
  58. :address="item.store[0].address"
  59. :name="item.store[0].name"
  60. :business_hours="item.store[0].business_hours"
  61. :storeNum="item.store.length"
  62. :goods_id="item.id"
  63. ></app-store>
  64. </view>
  65. <view class="goods-detail">
  66. <app-goods-detail :goods="item"></app-goods-detail>
  67. </view>
  68. <view class="app-recommend">
  69. <app-related-suggestion-product sign="booking" :list="list" ></app-related-suggestion-product>
  70. </view>
  71. <view>
  72. <app-empty-bottom backgroundColor="#f7f7f7" :height="Number(110)"></app-empty-bottom>
  73. </view>
  74. <view class="app-buttons">
  75. <app-iphone-x>
  76. <view slot="empty-area">
  77. <view class="app-reservation-button dir-left-nowrap" >
  78. <view class="app-back-home">
  79. <app-jump-button form arrangement="column" open_type="redirect" url="/pages/index/index">
  80. <image class="app-image" src="../../../static/image/icon/index.png"></image>
  81. <text class="app-home">首页</text>
  82. </app-jump-button>
  83. </view>
  84. <view class="app-jump" v-if="item.goods_num == 0" style="background-color: #CDCDCD;color: #fff;">已售罄</view>
  85. <view class="app-jump" v-else>
  86. <app-form-id @click="reservationNow">
  87. 立即预约
  88. </app-form-id>
  89. </view>
  90. </view>
  91. </view>
  92. </app-iphone-x>
  93. </view>
  94. </view>
  95. </app-layout>
  96. </template>
  97. <script>
  98. import { mapState } from 'vuex';
  99. import appGoodsBanner from '../../../components/page-component/goods/app-goods-banner.vue';
  100. import appGoodsPrice from '../../../components/page-component/goods/app-goods-price.vue';
  101. import appGoodsAttr from '../../../components/page-component/goods/app-goods-attr.vue';
  102. import appAttr from '../../../components/page-component/app-attr/app-attr.vue';
  103. import appStore from '../components/app-store.vue';
  104. import appRelatedSuggestionProduct from '../../../components/page-component/app-related-suggestion-product/app-related-suggestion-product.vue';
  105. import appGoodsDetail from '../../../components/page-component/goods/app-goods-detail.vue';
  106. import appQuickNavigation from "../../../components/page-component/app-quick-navigation/app-quick-navigation.vue";
  107. import appIphonexBottom from '../../../components/page-component/app-iphonex-bottom/app-iphonex-bottom.vue';
  108. import appIphoneX from '../../../components/basic-component/app-iphone-x/app-iphone-x.vue';
  109. import appGoodsService from '../../../components/page-component/goods/app-goods-service.vue';
  110. import AppVipCard from '../../../components/page-component/app-vip-card/app-vip-card';
  111. import appName from '../../../components/page-component/app-goods-detail/app-name.vue';
  112. import appEmptyBottom from '../../../components/basic-component/app-empty-bottom/app-empty-bottom.vue';
  113. export default {
  114. name: 'details',
  115. components: {
  116. 'app-goods-banner': appGoodsBanner,
  117. 'app-goods-price': appGoodsPrice,
  118. 'app-goods-attr': appGoodsAttr,
  119. 'app-attr': appAttr,
  120. 'app-store': appStore,
  121. 'app-related-suggestion-product': appRelatedSuggestionProduct,
  122. 'app-goods-detail': appGoodsDetail,
  123. 'app-quick-navigation': appQuickNavigation,
  124. 'app-iphone-bottom': appIphonexBottom,
  125. 'app-iphone-x': appIphoneX,
  126. 'app-goods-service': appGoodsService,
  127. 'app-name': appName,
  128. 'app-vip-card': AppVipCard,
  129. 'app-empty-bottom': appEmptyBottom,
  130. },
  131. data() {
  132. return {
  133. item: null,
  134. selectAttr: {},
  135. activeIndex: 0,
  136. list: [],
  137. submitUrl: this.$api.book.order_submit,
  138. previewUrl: this.$api.book.order_preview,
  139. url: '',
  140. cartShow: false,
  141. isCart: false,
  142. is_vip: false,
  143. is_vip_card_user: 0,
  144. discount: null,
  145. show: 0,
  146. loading: false,
  147. }
  148. },
  149. onShareAppMessage() {
  150. return this.$shareAppMessage({
  151. path: '/plugins/book/goods/goods',
  152. title: this.item.app_share_title ? this.item.app_share_title : this.item.name,
  153. imageUrl: this.item.app_share_pic ? this.item.app_share_pic : '',
  154. params: {
  155. goods_id: this.item.id,
  156. }
  157. });
  158. },
  159. onLoad(options) {
  160. let _this = this;
  161. uni.getLocation({
  162. type:'wgs84',
  163. success:function(res){
  164. let goods_id = options.goods_id;
  165. _this.$request({
  166. url: _this.$api.book.detail,
  167. data: {
  168. goods_id: goods_id,
  169. latitude: res.latitude,
  170. longitude: res.longitude,
  171. },
  172. }).then(response => {
  173. if (response.code === 0) {
  174. _this.loading = true;
  175. _this.item = response.data.list;
  176. _this.item.id = _this.item.goods_id;
  177. _this.url = `${_this.$api.book.poster}&goods_id=${_this.item.goods_id}`;
  178. _this.requestFun(goods_id);
  179. if(_this.item.vip_card_appoint.discount > 0) {
  180. _this.is_vip = true;
  181. _this.discount = _this.item.vip_card_appoint.discount
  182. }
  183. _this.is_vip_card_user = _this.item.vip_card_appoint.is_vip_card_user
  184. }
  185. })
  186. },
  187. fail:function(e){
  188. console.log(e);
  189. uni.showModal({
  190. title: '提示',
  191. content: '请开启位置权限',
  192. success: function() {
  193. uni.navigateBack();
  194. }
  195. });
  196. },
  197. complete:function(res){
  198. }
  199. });
  200. },
  201. methods: {
  202. attrtap(data) {
  203. if (data !== null) {
  204. this.selectAttr = data;
  205. } else {
  206. this.selectAttr = {};
  207. }
  208. },
  209. requestFun(goods_id) {
  210. this.$request({
  211. url: this.$api.goods.new_recommend,
  212. data: {
  213. goods_id: goods_id,
  214. page: this.page,
  215. }
  216. }).then(response => {
  217. if (response.code === 0) {
  218. if (response.data.list.length > 0) {
  219. this.list = [...this.list, ...response.data.list];
  220. } else {
  221. this.over = true;
  222. }
  223. }
  224. })
  225. },
  226. reservationNow() {
  227. this.show = Math.random();
  228. }
  229. },
  230. computed: {
  231. ...mapState({
  232. mall: state => state.mallConfig.mall,
  233. }),
  234. ...mapState('gConfig',{
  235. iphone: (data) => {
  236. return data.iphone;
  237. },
  238. iphoneHeight: (state) =>{
  239. return state.iphoneHeight;
  240. },
  241. })
  242. }
  243. }
  244. </script>
  245. <style scoped lang="scss">
  246. .vip-card {
  247. padding: 0 #{20rpx};
  248. background-color: #fff;
  249. }
  250. .merchant-guarantee {
  251. margin-top: #{20rpx};
  252. }
  253. .app-details {
  254. background-color: #f7f7f7;
  255. width: #{750rpx};
  256. padding-bottom: #{100rpx};
  257. .app-banner {
  258. width: 100%;
  259. }
  260. .app-attr {
  261. width: 100%;
  262. margin-bottom: #{20rpx};
  263. margin-top: #{20rpx};
  264. }
  265. .app-rich-evaluation {
  266. background-color: white;
  267. width: #{750rpx};
  268. .app-nav {
  269. width: #{750rpx};
  270. height: #{100rpx};
  271. border-bottom: #{1rpx} solid #e2e2e2;
  272. >view {
  273. text-align: center;
  274. }
  275. text {
  276. text-align: center;
  277. height: #{100rpx};
  278. line-height: #{100rpx};
  279. border-bottom-width: #{1rpx};
  280. border-bottom-style: solid;
  281. border-bottom-color: transparent;
  282. display: inline-block;
  283. }
  284. .app-active-color {
  285. border-bottom-color: #ff4544;
  286. color: #ff4544;
  287. }
  288. }
  289. }
  290. .app-reservation-button {
  291. width: #{750rpx};
  292. height: #{100rpx};
  293. background-color:white;
  294. border-top: #{1rpx} solid #e9e9e9;
  295. .app-back-home {
  296. width: #{110rpx};
  297. height: #{100rpx};
  298. .app-image {
  299. width: #{40rpx};
  300. height: #{40rpx};
  301. }
  302. .app-home {
  303. font-size: #{18rpx};
  304. color: #888888;
  305. }
  306. }
  307. .app-jump {
  308. width: #{640rpx};
  309. height: #{110rpx};
  310. line-height: #{100rpx};
  311. background-color: #ff4544;
  312. color: #ffffff;
  313. font-size: #{32rpx};
  314. text-align: center;
  315. }
  316. }
  317. }
  318. </style>