评论商品接口有问题

This commit is contained in:
bobobobo
2026-01-16 00:12:33 +08:00
parent d2ba0df2b5
commit 5cd2732562
164 changed files with 14318 additions and 197 deletions

View File

@@ -0,0 +1,70 @@
<script setup>
import CardInput from '../my-index/components/card-input.vue'
import { reactive } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { addProductComment } from '../../api/mall'
import { useUI } from '../../utils/use-ui'
import { navigateBack } from '../../utils/router'
const { showToast } = useUI()
const formData = reactive({
content: '',
rating: 5,
isAnonymous: false,
imageUrls: '',
productId: ''
})
const switchChange = ({ detail }) => {
formData.isAnonymous = detail.value
}
const onAdd = async () => {
const data = {
...formData,
isAnonymous: formData.isAnonymous ? 1 : 0
}
await addProductComment(data)
await showToast('添加成功', 'success')
navigateBack()
}
onLoad(e => {
formData.productId = e.productId
})
</script>
<template>
<view>
<CardInput :is-input="false" title="评论内容">
<textarea v-model="formData.content" placeholder="请输入评论内容" />
</CardInput>
<CardInput :is-input="false" title="评分">
<template #right>
<uni-rate v-model="formData.rating" />
</template>
</CardInput>
<CardInput :is-input="false" title="是否匿名">
<template #right>
<switch style="transform: scale(0.8)" @change="switchChange" />
</template>
</CardInput>
<CardInput :is-input="false" title="添加图片">
<cb-file-picker v-model="formData.imageUrls"></cb-file-picker>
</CardInput>
<bottom-view>
<cb-button @click="onAdd">确认添加</cb-button>
</bottom-view>
</view>
</template>
<style lang="scss" scoped>
page {
background: #f9f9f9;
}
</style>

View File

@@ -1,5 +1,8 @@
<script setup>
import { ref, reactive } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { getProductCommentList } from '@/api/mall'
import { navigateTo } from '../../utils/router'
const topNav = ref([
{ name: '全部', id: '1' },
@@ -11,61 +14,97 @@
const formData = reactive({
type: '1'
})
const productId = ref('')
const listData = ref([])
const paging = ref(null)
const onTop = id => {
formData.type = id
}
const getList = async (pageNum, pageSize) => {
try {
const res = await getProductCommentList({
productId: productId.value,
pageNum,
pageSize
})
paging.value.complete(res.rows)
} catch (err) {
paging.value.complete(false)
}
}
onLoad(e => {
productId.value = e.productId
})
onShow(() => {
getList()
})
</script>
<template>
<view class="comment-box">
<view class="top-options">
<view
v-for="(item, index) in topNav"
:key="index"
:class="{ active: item.id === formData.type }"
class="text"
@click="onTop(item.id)"
>
{{ item.name }}
</view>
</view>
<z-paging
ref="paging"
v-model="listData"
:default-page-size="15"
safe-area-inset-bottom
use-safe-area-placeholder
:auto="false"
@query="getList"
>
<view class="comment-box">
<!-- <view class="top-options">
<view
v-for="(item, index) in topNav"
:key="index"
:class="{ active: item.id === formData.type }"
class="text"
@click="onTop(item.id)"
>
{{ item.name }}
</view>
</view> -->
<!-- 卡片位置 -->
<view class="card-box">
<image
src="/static/images/public/random1.png"
mode="scaleToFill"
class="avatar"
></image>
<!-- 右边 -->
<view class="right-box">
<text class="name">名字</text>
<view class="rate-box">
<view class="date">
<text>2022-2-2</text>
<text>重庆市</text>
<!-- 卡片位置 -->
<view v-for="item in listData" :key="item.id" class="card-box">
<image
:src="item.avatar || '/static/images/public/random1.png'"
mode="scaleToFill"
class="avatar"
></image>
<!-- 右边 -->
<view class="right-box">
<view class="name_box">
<text class="name">{{ item.userName }}</text>
<uni-rate readonly :size="24" :value="item.rating" />
</view>
<view class="star">
<view class="rate-box">
<view class="date">
<text>{{ item.createTime }}</text>
<!-- <text>重庆市</text> -->
</view>
<!-- <view class="star">
<view class="like">
<uni-icons
type="hand-up"
size="16"
color="#74747480"
></uni-icons>
22
<text v-if="item.likeCount">{{ item.likeCount }}</text>
</view>
<uni-icons
type="chat"
size="16"
color="#74747480"
></uni-icons>
</view> -->
</view>
</view>
<text class="content">
视频讲的真好全面升级讲的真的全面老师 徒弟吗
</text>
<view class="img-box">
<text class="content">
{{ item.content }}
</text>
<!-- <view class="img-box">
<image
v-for="item in 5"
src="/static/images/public/random1.png"
@@ -79,10 +118,21 @@
<text>内容</text>
</view>
<text class="expand">共三条回复></text>
</view> -->
</view>
</view>
</view>
</view>
<!-- 底部按钮 -->
<template #bottom>
<bottom-view position="absolute">
<cb-button
@click="navigateTo('/pages/mall/add-comment', { productId })"
>
确认添加
</cb-button>
</bottom-view>
</template>
</z-paging>
</template>
<style lang="scss" scoped>
@@ -96,6 +146,7 @@
.avatar {
width: 64rpx;
height: 64rpx;
border-radius: 64rpx;
flex-shrink: 0;
margin-right: 16rpx;
}
@@ -109,10 +160,16 @@
text-align: left;
font-style: normal;
text-transform: none;
.name {
font-size: 28rpx;
color: #333333;
.name_box {
display: flex;
align-items: center;
justify-content: space-between;
.name {
font-size: 28rpx;
color: #333333;
}
}
.rate-box {
display: flex;
align-items: center;

View File

@@ -5,7 +5,7 @@
import { formatRMB } from '@/utils'
import { getUserAddress } from '@/api'
import { getUserPayPwd } from '@/api/my-index'
import { navigateTo, redirectTo } from '@/utils/router'
import { navigateTo, navigateBack, redirectTo } from '@/utils/router'
import { useUI } from '@/utils/use-ui'
import { useUserStore } from '@/stores/user'
@@ -14,6 +14,8 @@
const viewData = ref({})
/** 分享二维码进入 拼团ID */
const groupId = ref('')
/** 单价 */
const priceData = ref(0)
const formData = reactive({
@@ -40,6 +42,7 @@
loading: true
})
const tixian = ref(null)
const originalPrice = ref(0)
/** 获取用户地址 */
const userRess = async () => {
@@ -62,9 +65,13 @@
const getData = async productId => {
const res = await getProductDetail(productId)
viewData.value = res.data
const { id, price, stockQuantity } = res.data.skuList.find(
v => v.isDefault == 1
)
const {
id,
price,
stockQuantity,
originalPrice: nub
} = res.data.skuList.find(v => v.isDefault == 1)
originalPrice.value = nub
formData.maxNum = stockQuantity
formData.spec = id
priceData.value = price
@@ -83,6 +90,7 @@
formData.total = item.price
priceData.value = item.price
formData.maxNum = item.stockQuantity
originalPrice.value = item.originalPrice
}
// 提交订单
@@ -104,6 +112,7 @@
const submit = async e => {
const data = {
groupId: groupId.value,
payPassword: e.join(''),
addressId: topRessData.id,
productId: viewData.value.id,
@@ -114,10 +123,8 @@
tixian.value.close()
const res = await addOrder(data)
await refreshUserInfo()
redirectTo('/pages/shop-together/detail', {
id: res.data.groupId,
type: 'add'
})
await showToast('订单提交成功', 'success')
navigateBack()
}
onShow(() => {
@@ -125,6 +132,7 @@
})
onLoad(async e => {
groupId.value = e?.groupId || ''
await getData(e.productId)
})
</script>
@@ -165,7 +173,7 @@
</text>
<view class="line-box">
<view class="rmb-box">
<text>¥{{ viewData.originalPrice || '' }}</text>
<text>¥{{ originalPrice }}</text>
<text>¥{{ priceData }}</text>
</view>
<!-- 添加数量 -->

View File

@@ -6,6 +6,8 @@
const viewData = ref({})
const productId = ref('')
// 分享二维码进入
const groupId = ref('')
/** 评论数量 */
const commentNum = ref(0)
const getData = async productId => {
@@ -39,12 +41,14 @@
const onConfirm = () => {
navigateTo('/pages/mall/confirm-order', {
productId: productId.value
productId: productId.value,
groupId: groupId.value
})
}
onLoad(async e => {
productId.value = e.productId
groupId.value = e?.groupId || ''
await getData(e.productId)
await getComment(e.productId)
})

View File

@@ -21,7 +21,10 @@
topNavOptions.value = res.data
}
const getListData = async (pageNum, pageSize) => {
const getListData = async (pageNum, pageSize, state) => {
if (state === 1) {
cardList.value = []
}
try {
const res = await getProductList({
pageNum,
@@ -38,7 +41,7 @@
const onTop = value => {
formData.type = value
formData.name = ''
getListData(1, formData.pageSize)
getListData(1, formData.pageSize, 1)
}
const onGo = item => {
@@ -47,7 +50,6 @@
onLoad(async () => {
await categoryList()
// await getListData(1, formData.pageSize)
})
</script>
@@ -67,7 +69,8 @@
<view class="top-box">
<cb-search
v-model="formData.name"
@search="getListData()"
placeholder="搜索热门商品"
@search="getListData(1, formData.pageSize, 1)"
></cb-search>
<view class="top-options">
<view
@@ -124,6 +127,7 @@
@import '@/styles/top-selector.scss';
.mall-list {
.top-box {
background: #ffffff;
padding: 24rpx;
}