From 4f178171c22fc76961ae2de803a718af1edaa7b0 Mon Sep 17 00:00:00 2001 From: sx <2427911852@qq.com> Date: Sat, 15 Feb 2025 08:59:41 +0800 Subject: [PATCH] =?UTF-8?q?2025.02.14=20=E4=BB=A3=E7=A0=81=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jiuyi2/common/js/config.js | 4 +- jiuyi2/components/index/indexVideo.vue | 14 +- jiuyi2/components/index/proDetailAlt.vue | 136 ++++ jiuyi2/components/shop/detail/detail.vue | 597 +++++++++++++++++- jiuyi2/components/shop/detail/footerMenu.vue | 57 ++ jiuyi2/pages/index/index.nvue | 19 +- jiuyi2/pages/release/commodity.vue | 5 + .../components/jy-commodity-foot/index.vue | 195 ------ jiuyi2/pages/shop/commodity/index.vue | 479 +------------- jiuyi2/vite.config.js | 5 +- 10 files changed, 847 insertions(+), 664 deletions(-) create mode 100644 jiuyi2/components/index/proDetailAlt.vue create mode 100644 jiuyi2/components/shop/detail/footerMenu.vue delete mode 100644 jiuyi2/pages/shop/commodity/components/jy-commodity-foot/index.vue diff --git a/jiuyi2/common/js/config.js b/jiuyi2/common/js/config.js index 000f8b79..33b5e2b4 100644 --- a/jiuyi2/common/js/config.js +++ b/jiuyi2/common/js/config.js @@ -6,8 +6,8 @@ const config = { // host: 'h5api', // #endif // #ifndef H5 - host: 'http://91f.xyz:8080', - // host: 'http://25f49356.r24.cpolar.top', + // host: 'http://91f.xyz:8080', + host: 'http://8vtja7.natappfree.cc', // #endif // 支付方式配置 payType: { diff --git a/jiuyi2/components/index/indexVideo.vue b/jiuyi2/components/index/indexVideo.vue index d6cbc10d..7e93a6b8 100644 --- a/jiuyi2/components/index/indexVideo.vue +++ b/jiuyi2/components/index/indexVideo.vue @@ -69,9 +69,10 @@ default: 0, }, }) + // const emit = defineEmits(['showTime', 'showComment', 'showCollect', 'showFastCollect', 'showShareFirend', 'onPlay', - 'onPause', 'like', 'detailMenu', 'onEnd', 'longtap', 'dataCenter' + 'onPause', 'like', 'detailMenu', 'onEnd', 'longtap', 'dataCenter', 'showProduct' ]) // 视频上下文对象 @@ -458,11 +459,17 @@ videoCtx.value.playbackRate(2) } - // + // 前往数据中心 function handleData() { emit('dataCenter', props.item) } + // 点击商品广告 + function handleShowProduct() { + console.log('handleShowProduct') + emit('showProduct', props.item) + } + // defineExpose({ play, @@ -620,7 +627,8 @@ - + diff --git a/jiuyi2/components/index/proDetailAlt.vue b/jiuyi2/components/index/proDetailAlt.vue new file mode 100644 index 00000000..fced38ba --- /dev/null +++ b/jiuyi2/components/index/proDetailAlt.vue @@ -0,0 +1,136 @@ + + + + + \ No newline at end of file diff --git a/jiuyi2/components/shop/detail/detail.vue b/jiuyi2/components/shop/detail/detail.vue index 945f75e1..052819b3 100644 --- a/jiuyi2/components/shop/detail/detail.vue +++ b/jiuyi2/components/shop/detail/detail.vue @@ -2,11 +2,604 @@ /** * 商品详情 */ + + import { + ref, + reactive, + nextTick, + getCurrentInstance, + computed, + onMounted, + onUnmounted, + defineProps, + } from 'vue' + import { + useStore + } from 'vuex' + // 接口地址 + import api from '@/api/index.js' + // + import util from '@/common/js/util.js' + + // 传参 + const props = defineProps({ + id: { + type: [Number, String], + default: '' + }, + detail: { + type: Object, + default: {} + }, + }) + + const { + proxy + } = getCurrentInstance() + // 在这里设置swiper高度补足多端差异 + const bannerHeight = ref('800rpx') + // 轮播图详情 + const bannerIndex = ref(0) + // 商品评论 + const comment = reactive({ + list: [], + total: 0, + }) + // 最近购买订单列表 + const recentOrderList = ref([]) + // + const menuFn = { + // 店铺 + store() { + link('/pages/shop/store/index') + }, + // 客服 + customerService() { + link('/pages/news/question-answer/index') + }, + // 收藏 + heibianStar() { + // + } + } + // 已选择的规格下标 + const spaceIndex = ref(0) + // 数量 + const payNum = ref(1) + // 当前选择的规格 + const currentSpec = computed(() => { + let spec = props.detail.specs || [] + return spec[spaceIndex.value] || {} + }) + // 应付总价 + const total = computed(() => { + let price = parseFloat(props.detail.price) * 100 + let result = parseInt(price * payNum.value) / 100 + return result + }) + // 详情 + const banner = computed(() => { + let result = [] + if (props.detail.sliderImage) result = props.detail.sliderImage.split(',') + return result + }) + // 当前登录的用户信息 + const userinfo = computed(() => { + return uni.$store.state.userinfo + }) + + onMounted(() => { + // 获取商品评论 + getProComment() + // 获取最近购买 + getRecentOrder() + }) + + + // 获取最近购买 + function getRecentOrder() { + api.shop.recentOrder({ + query: { + // 产品id + productId: props.id, + } + }).then(rs => { + if (rs.code == 200) { + // 结果 + const result = rs.data + let list = [] + // + for (let i = 0; i < result.length / 2; i++) { + if (!result[i * 2 + 1]) break + list.push([result[i * 2], result[i * 2 + 1]]) + } + recentOrderList.value = list + return + } + util.alert({ + content: rs.msg, + showCancel: false, + }) + }) + } + + // 获取商品评论 + function getProComment() { + api.shop.getProComment({ + query: { + // 产品id + productId: props.id, + pageNum: 1, + pageSize: 2, + } + }).then(rs => { + if (rs.code == 200) { + comment.list = rs.rows + comment.total = rs.total + return + } + util.alert({ + content: rs.msg, + showCancel: false, + }) + }) + } + + /** + * 跳转路径 + * @param {Object} url + */ + function link(url) { + uni.navigateTo({ + url, + }) + } + + // 收藏店铺 + function handleCollectStore() { + api.shop.followShop({ + data: { + shopId: props.detail.merId, + status: { + 0: 1, + 1: 0, + } [props.detail.isFollow] + } + }).then(rs => { + if (rs.code == 200) { + // 关注状态 + props.detail.isFollow = { + 0: 1, + 1: 0, + } [props.detail.isFollow] + // 关注数量 + props.detail.merFollowNumber = rs.data + return + } + util.alert({ + content: rs.msg, + showCancel: false, + }) + }) + } + + // 商品收藏 + function handleCollect() { + util.isLogin().then(rs => { + // + api.shop.addProductCollect({ + data: { + productId: id.value, + status: { + 0: 1, + 1: 0, + } [props.detail.isCollect] + } + }).then(rs => { + if (rs.code == 200) { + // 关注状态 + props.detail.isCollect = { + 0: 1, + 1: 0, + } [props.detail.isCollect] + // 关注数量 + props.detail.collectNumber = rs.data + return + } + util.alert({ + content: rs.msg, + showCancel: false, + }) + }) + }).catch(() => { + // 登录 + uni.navigateTo({ + url: '/pages/login/loginPhone' + }) + }) + } + + // 获取店铺信息 + function getShop() { + api.shop.shopDetail({ + query: { + shopId: props.detail.merId + } + }).then(rs => { + if (rs.code == 200) { + Object.assign(props.detail, {}, rs.data) + return + } + util.alert({ + content: rs.msg, + showCancel: false, + }) + }) + } + + /** + * 立即下单 + */ + function handlePay(event) { + // 产生待付款订单 + api.shop.addOrder({ + data: [{ + // 地址id + addressId: event.address.id, + // 产品id + productId: props.detail.id, + // 规格id + attrValueId: event.spec.id, + // 数量 + payNum: event.payNum, + // 0-普通订单,1-视频号订单 + orderType: 0, + // 分享人id + // shareId: userinfo.id, + }], + }).then(rs => { + if (rs.code === 200) { + // 跳转 + if (rs.data && rs.data[0]) uni.navigateTo({ + url: util.setUrl('/pages/shop/commodity/payment', { + orderId: rs.data[0].orderId, + }) + }) + return + } + util.alert({ + content: rs.msg, + showCancel: false, + }) + }) + } - \ No newline at end of file diff --git a/jiuyi2/components/shop/detail/footerMenu.vue b/jiuyi2/components/shop/detail/footerMenu.vue new file mode 100644 index 00000000..c09622ea --- /dev/null +++ b/jiuyi2/components/shop/detail/footerMenu.vue @@ -0,0 +1,57 @@ + + + + + \ No newline at end of file diff --git a/jiuyi2/pages/index/index.nvue b/jiuyi2/pages/index/index.nvue index 8ab5db7c..5581a503 100644 --- a/jiuyi2/pages/index/index.nvue +++ b/jiuyi2/pages/index/index.nvue @@ -45,6 +45,8 @@ import fastCollect from '@/components/index/fastCollect.vue'; // 青少年模式 import teen from '@/components/index/teen.vue' + // 产品详情弹窗 + import productAlt from '@/components/index/proDetailAlt.vue' const { proxy @@ -208,6 +210,8 @@ viewSize.width = option.size.width }) }, 50) + // + proxy.$refs.productAltRef.init() }) onShow(() => { @@ -273,6 +277,7 @@ // 获取推荐视频 function getRecList() { console.log('getRecList') + return // 获取首页分页视频 api.video.homeVideo({ query: { @@ -669,6 +674,15 @@ function showAlarm() { proxy.$refs.timeRef.open() } + + /** + * 打开产品弹窗 + * @param {Object} item 视频列表项 + */ + function handleShowProduct(item) { + // 打开产品详情弹窗 + proxy.$refs.productAltRef.init(item.productId) + } diff --git a/jiuyi2/pages/release/commodity.vue b/jiuyi2/pages/release/commodity.vue index 9ca842cb..7137774e 100644 --- a/jiuyi2/pages/release/commodity.vue +++ b/jiuyi2/pages/release/commodity.vue @@ -319,11 +319,16 @@ 添加链接到视频 + 再第几秒展示 + + + + diff --git a/jiuyi2/pages/shop/commodity/components/jy-commodity-foot/index.vue b/jiuyi2/pages/shop/commodity/components/jy-commodity-foot/index.vue deleted file mode 100644 index 1ec72dc0..00000000 --- a/jiuyi2/pages/shop/commodity/components/jy-commodity-foot/index.vue +++ /dev/null @@ -1,195 +0,0 @@ - - - - - \ No newline at end of file diff --git a/jiuyi2/pages/shop/commodity/index.vue b/jiuyi2/pages/shop/commodity/index.vue index e21f1cc7..8c72c7cf 100644 --- a/jiuyi2/pages/shop/commodity/index.vue +++ b/jiuyi2/pages/shop/commodity/index.vue @@ -24,31 +24,19 @@ import apex from './components/jy-commodity-head'; // 商品列表 import productList from '@/components/shop/productList/productList' + // 产品详情 + import proDetail from '@/components/shop/detail/detail' //底部 - import JyCommodityFoot from './components/jy-commodity-foot'; + import footerMenu from '@/components/shop/detail/footerMenu'; + const { proxy } = getCurrentInstance() const store = useStore() - // 产品详情 - const detail = reactive({}) // 产品id const id = ref('') - // 轮播图详情 - const bannerIndex = ref(0) - // 商品评论 - const comment = reactive({ - list: [], - total: 0, - }) - // 最近购买订单列表 - const recentOrderList = ref([]) - // 详情 - const banner = computed(() => { - let result = [] - if (detail.sliderImage) result = detail.sliderImage.split(',') - return result - }) + // 产品详情 + const detail = reactive({}) // 当前登录的用户信息 const userinfo = computed(() => { return store.state.userinfo @@ -60,10 +48,6 @@ getDetail() // 添加商品浏览记录 addBrowsing() - // 获取商品评论 - getProComment() - // 获取最近购买 - getRecentOrder() // 开启监听 addListener() }) @@ -96,75 +80,6 @@ uni.$off('commodityDetail') } - // 获取最近购买 - function getRecentOrder() { - api.shop.recentOrder({ - query: { - // 产品id - productId: id.value, - } - }).then(rs => { - if (rs.code == 200) { - // 结果 - const result = rs.data - let list = [] - // - for (let i = 0; i < result.length / 2; i++) { - if (!result[i * 2 + 1]) break - list.push([result[i * 2], result[i * 2 + 1]]) - } - recentOrderList.value = list - return - } - util.alert({ - content: rs.msg, - showCancel: false, - }) - }) - } - - // 获取商品评论 - function getProComment() { - api.shop.getProComment({ - query: { - // 产品id - productId: id.value, - pageNum: 1, - pageSize: 2, - } - }).then(rs => { - if (rs.code == 200) { - comment.list = rs.rows - comment.total = rs.total - return - } - util.alert({ - content: rs.msg, - showCancel: false, - }) - }) - } - - // 添加商品浏览记录 - function addBrowsing() { - // 验证登录 - util.isLogin(() => { - try { - // 添加浏览记录 - api.shop.addBrowsing({ - data: { - userId: userinfo.value.id, - goodsId: id.value - }, - }).then(rs => { - if (rs.code != 200) console.log('addbrows err', rs.msg) - }) - } catch (ev) { - console.log('addBrowsing', ev) - } - }) - } - // 获取详情 function getDetail() { api.shop.productDetail({ @@ -185,94 +100,18 @@ }) } - /** - * 跳转路径 - * @param {Object} url - */ - function link(url) { - uni.navigateTo({ - url, - }) - } - - // 收藏店铺 - function handleCollectStore() { - api.shop.followShop({ - data: { - shopId: detail.merId, - status: { - 0: 1, - 1: 0, - } [detail.isFollow] - } - }).then(rs => { - if (rs.code == 200) { - // 关注状态 - detail.isFollow = { - 0: 1, - 1: 0, - } [detail.isFollow] - // 关注数量 - detail.merFollowNumber = rs.data - return - } - util.alert({ - content: rs.msg, - showCancel: false, - }) - }) - } - - // 商品收藏 - function handleCollect() { - util.isLogin().then(rs => { - // - api.shop.addProductCollect({ + // 添加商品浏览记录 + function addBrowsing() { + // 验证登录 + util.isLogin(() => { + // 添加浏览记录 + api.shop.addBrowsing({ data: { - productId: id.value, - status: { - 0: 1, - 1: 0, - } [detail.isCollect] - } + userId: userinfo.value.id, + goodsId: id.value + }, }).then(rs => { - if (rs.code == 200) { - // 关注状态 - detail.isCollect = { - 0: 1, - 1: 0, - } [detail.isCollect] - // 关注数量 - detail.collectNumber = rs.data - return - } - util.alert({ - content: rs.msg, - showCancel: false, - }) - }) - }).catch(() => { - // 登录 - uni.navigateTo({ - url: '/pages/login/loginPhone' - }) - }) - } - - // 获取店铺信息 - function getShop() { - api.shop.shopDetail({ - query: { - shopId: detail.merId - } - }).then(rs => { - if (rs.code == 200) { - Object.assign(detail, {}, rs.data) - return - } - util.alert({ - content: rs.msg, - showCancel: false, + if (rs.code != 200) console.log('addbrows err', rs.msg) }) }) } @@ -289,160 +128,10 @@ \ No newline at end of file diff --git a/jiuyi2/vite.config.js b/jiuyi2/vite.config.js index 91f94ecf..82f957a3 100644 --- a/jiuyi2/vite.config.js +++ b/jiuyi2/vite.config.js @@ -3,9 +3,8 @@ import { } from 'vite'; import uni from '@dcloudio/vite-plugin-uni'; -let target = 'http://91f.xyz:8080' -// let target = 'http://25f49356.r24.cpolar.top' -// let target = 'http://25f49356.r24.cpolar.top' +// let target = 'http://91f.xyz:8080' +let target = 'http://8vtja7.natappfree.cc' export default defineConfig({ plugins: [uni()],