评论商品接口有问题

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

@@ -217,7 +217,7 @@
.address-form {
:deep(.uni-easyinput__content) {
border-radius: 34rpx;
border-radius: 16rpx;
}
}
}

View File

@@ -90,7 +90,7 @@
.discover-box {
padding: 32rpx 24rpx;
.card-box {
padding: 20rpx 32rpx;
padding: 20rpx 0;
display: flex;
justify-content: space-between;
align-items: center;

View File

@@ -161,6 +161,22 @@
getData()
}
const formatNumberWithWan = num => {
if (num < 10000) {
return num.toString()
}
// 保留小数:根据需求可调整 toFixed 的位数
let wan = num / 10000
// 如果是整数万,不显示小数;否则保留两位小数(或你想要的位数)
if (wan % 1 === 0) {
return wan + '万'
} else {
return wan.toFixed(2).replace(/\.?0+$/, '') + '万' // 去掉不必要的尾随零
}
}
onLoad(() => {
const now = new Date()
currentYear.value = now.getFullYear()
@@ -184,7 +200,7 @@
<view class="public-header—box">
<view class="integral-box">
<text>我的积分</text>
<text>{{ userInfo.totalPoints }}</text>
<text>{{ formatNumberWithWan(userInfo.totalPoints) }}</text>
</view>
<image
src="/static/images/discover/calendar.png"

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;
}

View File

@@ -82,6 +82,7 @@
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
.right-box {
display: flex;
align-items: center;

View File

@@ -1,17 +1,48 @@
<script setup>
import { navigateTo } from '@/utils/router'
// import { onLoad } from '@dcloudio/uni-app'
// import { ref } from 'vue'
// import { getUserServiceList } from '@/api/my-index'
import TUIChatEngine, {
TUIConversationService,
TUIFriendService
} from '@tencentcloud/chat-uikit-engine-lite'
import { TUIGlobal } from '@tencentcloud/universal-api'
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'
import { getUserServiceFree } from '@/api/my-index'
// const list = ref([])
// const getList = async () => {
// const res = await getUserServiceList()
// list.value = res.data
// }
// onLoad(() => {
// getList()
// })
const customerData = ref({})
const getList = async () => {
const res = await getUserServiceFree()
customerData.value = res?.data || {}
}
const handleSwitchConversation = async () => {
// 在这里可以添加提交验证信息的逻辑
let source = 'AddSource_Type_Web' // 来源渠道
// #ifdef H5
source = 'AddSource_Type_H5'
// #endif
// 判断是否为 App5+ App
// #ifdef APP-PLUS
source = 'AddSource_Type_App'
// #endif
await TUIFriendService.addFriend({
to: customerData.value.imUserId,
source,
remark: customerData.value.nickname,
type: TUIChatEngine.TYPES.SNS_ADD_TYPE_BOTH
})
TUIConversationService.switchConversation(
`C2C${customerData.value.imUserId}`
)
TUIGlobal?.navigateTo({
url: `/TUIKit/components/TUIChat/index?id=${customerData.value.id}`
})
}
onLoad(() => {
getList()
})
</script>
<template>
@@ -28,7 +59,13 @@
>
第三方客服
</button>
<!-- <button>APP客服</button> -->
<button
v-if="customerData?.imUserId"
class="btn"
@click="handleSwitchConversation"
>
APP客服
</button>
</view>
</view>
</template>
@@ -70,16 +107,16 @@
background: linear-gradient(0deg, #00d993 0%, #00d9c5 100%);
border-radius: 16rpx;
box-sizing: border-box;
&:nth-child(2) {
background: #ffffff;
color: #00d993;
border: 2rpx solid #00d993;
}
&::after {
display: none;
}
}
.btn {
background: #ffffff;
color: #00d993;
border: 2rpx solid #00d993;
}
}
}
</style>

View File

@@ -1,7 +1,7 @@
<script setup>
import { useAuthUser } from '@/composables/useAuthUser'
const { userInfo } = useAuthUser()
const { userInfo, tencentUserSig } = useAuthUser()
</script>
<template>
@@ -19,7 +19,13 @@
<text>ID: {{ userInfo.userId }}</text>
</view>
</view>
<view class="code-img">二维码</view>
<view class="code-img">
<l-qrcode
:value="`/pages/adduser/index?id=${tencentUserSig.userId}`"
size="240"
/>
</view>
<text class="bottom-text">邀请码{{ userInfo.invitationCode }}</text>
</view>
</template>
@@ -30,6 +36,13 @@
flex-direction: column;
align-items: center;
.bottom-text {
font-size: 38rpx;
color: #333333;
margin-top: 10rpx;
font-weight: 600;
}
.top-img {
width: 480rpx;
display: flex;
@@ -60,7 +73,9 @@
}
.code-img {
background: rgb(165, 136, 136);
display: flex;
justify-content: center;
align-items: center;
width: 480rpx;
height: 480rpx;
}

View File

@@ -22,7 +22,10 @@
const onShare = () => {
// productId
navigateTo('/pages/shop-together/share')
navigateTo('/pages/shop-together/share', {
id: viewData.value.id,
productId: viewData.value.productId
})
}
onLoad(e => {
@@ -39,10 +42,12 @@
<view class="state-box">发起人</view>
<view class="left-box">
<image
src="https://wx1.sinaimg.cn/mw690/92eeb099gy1i29hl0ne80j21jk2bcash.jpg"
mode="scaleToFill"
v-if="topUser?.avatar"
:src="topUser?.avatar"
mode="aspectFill"
class="avatar"
></image>
<uni-icons v-else type="contact-filled" size="64"></uni-icons>
<view class="name-box">
<text>{{ topUser.userName }}</text>
<text>ID:{{ topUser.userId }}</text>
@@ -68,7 +73,12 @@
class="left-img"
></image>
<view class="right-content">
<text class="product-name">{{ viewData.productName }}</text>
<view>
<text class="product-name">{{ viewData.productName }}</text>
<text v-if="viewData.activityType" class="num-box">
{{ viewData.activityType }} 人拼团
</text>
</view>
<view class="line-box">
<view class="rmb-box">
<text></text>

View File

@@ -39,7 +39,12 @@
class="left-img"
></image>
<view class="right-content">
<text class="product-name">{{ item.productName }}</text>
<view>
<text class="product-name">{{ item.productName }}</text>
<text v-if="item.activityType" class="num-box">
{{ item.activityType }}人拼团
</text>
</view>
<view class="line-box">
<view class="rmb-box">
<text></text>

View File

@@ -1,15 +1,39 @@
<script setup></script>
<script setup>
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'
import { useUI } from '../../utils/use-ui'
const { showToast } = useUI()
const groupId = ref('')
const productId = ref('')
const qrcodeRef = ref(null)
onLoad(e => {
groupId.value = e.id
productId.value = e.productId
// /pages/mall/detail
})
</script>
<template>
<view class="share-box">
<nav-bar title="拼单" targetColor="transparent"></nav-bar>
<view class="code-box">
<view class="code-content">
<view class="code">二维码</view>
<view class="btn-box">
<text>分享二维码</text>
<text>保存到本地</text>
<view class="code">
<l-qrcode
ref="qrcodeRef"
:value="`/pages/mall/detail?productId=${productId}&groupId=${groupId}`"
size="160"
/>
</view>
<!-- <view class="btn-box">
<text>分享二维码</text>
<text @click="onCode">保存到本地</text>
</view> -->
</view>
</view>
</view>
@@ -26,7 +50,7 @@
background-repeat: no-repeat;
.code-box {
padding-top: 20vh;
padding-top: 24vh;
display: flex;
justify-content: center;
@@ -40,15 +64,17 @@
justify-content: center;
align-items: center;
.code {
display: flex;
justify-content: center;
align-items: center;
width: 332rpx;
height: 332rpx;
background: rgb(202, 118, 118);
}
.btn-box {
margin-top: 60rpx;
width: 332rpx;
display: flex;
justify-content: space-between;
justify-content: center;
font-weight: bold;
font-size: 28rpx;
color: #ffffff;