119 lines
2.8 KiB
Vue
119 lines
2.8 KiB
Vue
|
<template>
|
||
|
<view class="content pr" v-if="dataList">
|
||
|
<!-- 头部 -->
|
||
|
<JyCommodityHead></JyCommodityHead>
|
||
|
<!-- 轮播 -->
|
||
|
<JySwiper :list="dataList.images"></JySwiper>
|
||
|
<!-- 商品详情 -->
|
||
|
<jyCommodityContent class="p25" :commodity="dataList"></jyCommodityContent>
|
||
|
<!-- 评论 -->
|
||
|
<JyComment class="p25" :commentList="dataList.reviews"></JyComment>
|
||
|
<!-- 店铺卡片 -->
|
||
|
<JyStore class="p25 mt40 bfff" :storeInformation="dataList"></JyStore>
|
||
|
<!-- 详情 -->
|
||
|
<JyDetails class="p25 mt40"></JyDetails>
|
||
|
<!-- 精选 -->
|
||
|
<JyCherryPick></JyCherryPick>
|
||
|
<!-- 底部 -->
|
||
|
<JyCommodityFoot :commodityInformation="dataList" @heibianStar="getData" :style="{ bottom: bottomSafeAreaHeight() }"></JyCommodityFoot>
|
||
|
</view>
|
||
|
</template>
|
||
|
|
||
|
<script setup>
|
||
|
import {
|
||
|
ref,
|
||
|
reactive,
|
||
|
nextTick
|
||
|
} from 'vue'
|
||
|
import {
|
||
|
onLoad
|
||
|
} from '@dcloudio/uni-app'
|
||
|
// 头部
|
||
|
import JyCommodityHead from './components/jy-commodity-head';
|
||
|
//轮播
|
||
|
import JySwiper from './components/jy-swiper';
|
||
|
//评论
|
||
|
import JyComment from './components/jy-comment';
|
||
|
//商品详情
|
||
|
import jyCommodityContent from './components/jy-commodity-content';
|
||
|
//店铺卡片
|
||
|
import JyStore from './components/jy-store';
|
||
|
//详情
|
||
|
import JyDetails from './components/jy-details';
|
||
|
//精选
|
||
|
import JyCherryPick from '@/components/public/jy-cherry-pick';
|
||
|
//底部
|
||
|
import JyCommodityFoot from './components/jy-commodity-foot';
|
||
|
|
||
|
import {
|
||
|
bottomSafeAreaHeight
|
||
|
} from '@/components/public/Mixins.js'
|
||
|
import {
|
||
|
shop,
|
||
|
ProductBrowsingHistory
|
||
|
} from '@/api/shop.js'
|
||
|
import {
|
||
|
useStore
|
||
|
} from 'vuex'
|
||
|
//
|
||
|
import util from '@/common/js/util.js'
|
||
|
const {
|
||
|
userinfo
|
||
|
} = useStore().state
|
||
|
|
||
|
const dataList = ref(null)
|
||
|
// 获取详情
|
||
|
const getData = async () => {
|
||
|
shop.details({
|
||
|
...params,
|
||
|
userId: userinfo.userId,
|
||
|
}).then(rs => {
|
||
|
if (rs.code == 200) {
|
||
|
dataList.value = rs.data
|
||
|
console.log('dataList.value', dataList.value)
|
||
|
nextTick().then(() => {
|
||
|
Add_browsing_history()
|
||
|
});
|
||
|
return
|
||
|
}
|
||
|
util.alert({
|
||
|
content: rs.msg,
|
||
|
showCancel: false,
|
||
|
})
|
||
|
})
|
||
|
}
|
||
|
// 添加浏览记录
|
||
|
const Add_browsing_history = async () => {
|
||
|
console.log('Add_browsing_history', {
|
||
|
productId: params.productId,
|
||
|
userId: userinfo.userId,
|
||
|
isDeleted: 0
|
||
|
})
|
||
|
try {
|
||
|
const res = await ProductBrowsingHistory.add({
|
||
|
productId: params.productId,
|
||
|
userId: userinfo.userId,
|
||
|
isDeleted: 0
|
||
|
})
|
||
|
console.log('===添加浏览记录======================');
|
||
|
console.log(res);
|
||
|
console.log('====================================');
|
||
|
} catch (error) {
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const params = reactive({
|
||
|
productId: ''
|
||
|
})
|
||
|
|
||
|
onLoad(options => {
|
||
|
if (options.productId) params.productId = options.productId
|
||
|
getData()
|
||
|
})
|
||
|
</script>
|
||
|
<style lang="scss" scoped>
|
||
|
page {
|
||
|
background-color: #f6f6f6;
|
||
|
}
|
||
|
</style>
|