consumerm模块完成度90%,完善消费者和商家端数据库表,商品、聊天、订单数据对接好了supabase,和商家端对接了聊天功能,安卓端编译通过了css样式,剩余几个页面在处理函数规范问题
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
<view class="products-section">
|
||||
<view v-for="(item, index) in orderItems" :key="item.id" class="product-review">
|
||||
<view class="product-header">
|
||||
<image class="product-image" :src="item.product_image || '/static/default-product.png'" />
|
||||
<image class="product-image" :src="item.product_image ?? '/static/default-product.png'" />
|
||||
<view class="product-info">
|
||||
<text class="product-name">{{ item.product_name }}</text>
|
||||
<text v-if="item.sku_specifications" class="product-spec">{{ getSpecText(item.sku_specifications) }}</text>
|
||||
@@ -46,7 +46,7 @@
|
||||
v-model="contents[index]"
|
||||
placeholder="请写下您的使用感受,分享给其他小伙伴吧"
|
||||
maxlength="500" />
|
||||
<text class="word-count">{{ contents[index]?.length || 0 }}/500</text>
|
||||
<text class="word-count">{{ contents[index]?.length ?? 0 }}/500</text>
|
||||
</view>
|
||||
|
||||
<!-- 图片上传 -->
|
||||
@@ -143,7 +143,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
|
||||
type OrderItemType = {
|
||||
@@ -163,7 +164,7 @@ type MerchantType = {
|
||||
}
|
||||
|
||||
const orderId = ref<string>('')
|
||||
const order = ref<any>(null)
|
||||
const order = ref<any>({})
|
||||
const orderItems = ref<Array<OrderItemType>>([])
|
||||
const merchant = ref<MerchantType | null>(null)
|
||||
const ratings = ref<Array<number>>([])
|
||||
@@ -185,15 +186,10 @@ const canSubmit = computed(() => {
|
||||
})
|
||||
|
||||
// 生命周期
|
||||
onMounted(() => {
|
||||
const pages = getCurrentPages()
|
||||
const currentPage = pages[pages.length - 1]
|
||||
const options = currentPage.options as any
|
||||
|
||||
if (options.orderId) {
|
||||
orderId.value = options.orderId
|
||||
loadOrderData()
|
||||
}
|
||||
onLoad((options: any) => {
|
||||
const optObj = (options instanceof UTSJSONObject) ? (options as UTSJSONObject) : (JSON.parse(JSON.stringify(options ?? {})) as UTSJSONObject)
|
||||
orderId.value = optObj.getString('orderId') ?? ''
|
||||
if (orderId.value != '') loadOrderData()
|
||||
})
|
||||
|
||||
// 加载订单数据
|
||||
@@ -226,9 +222,9 @@ const loadOrderData = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
orderItems.value = (itemsData || []).map((item: any) => ({
|
||||
orderItems.value = (itemsData ?? []).map((item: any) => ({
|
||||
...item,
|
||||
product_image: item.product?.images?.[0] || '/static/default-product.png'
|
||||
product_image: item.product?.images?.[0] ?? '/static/default-product.png'
|
||||
}))
|
||||
|
||||
// 初始化评分和内容数组
|
||||
@@ -245,7 +241,7 @@ const loadOrderData = async () => {
|
||||
.eq('id', order.value.merchant_id)
|
||||
.single()
|
||||
|
||||
if (!merchantError) {
|
||||
if (merchantError == null) {
|
||||
merchant.value = merchantData
|
||||
}
|
||||
}
|
||||
@@ -257,7 +253,7 @@ const loadOrderData = async () => {
|
||||
|
||||
// 格式化时间
|
||||
const formatTime = (timeStr?: string): string => {
|
||||
if (!timeStr) return ''
|
||||
if (timeStr == null) return ''
|
||||
const date = new Date(timeStr)
|
||||
const year = date.getFullYear()
|
||||
const month = (date.getMonth() + 1).toString().padStart(2, '0')
|
||||
@@ -267,7 +263,7 @@ const formatTime = (timeStr?: string): string => {
|
||||
|
||||
// 获取规格文本
|
||||
const getSpecText = (specs: any): string => {
|
||||
if (!specs) return ''
|
||||
if (specs == null) return ''
|
||||
if (typeof specs === 'object') {
|
||||
return Object.keys(specs)
|
||||
.map(key => `${key}: ${specs[key]}`)
|
||||
@@ -279,7 +275,7 @@ const getSpecText = (specs: any): string => {
|
||||
// 获取评分文本
|
||||
const getRatingText = (rating: number): string => {
|
||||
const texts = ['非常差', '差', '一般', '好', '非常好']
|
||||
return texts[rating - 1] || '未评价'
|
||||
return texts[rating - 1] ?? '未评价'
|
||||
}
|
||||
|
||||
// 设置商品评分
|
||||
@@ -352,7 +348,7 @@ const submitReview = async () => {
|
||||
|
||||
try {
|
||||
const userId = getCurrentUserId()
|
||||
if (!userId) {
|
||||
if (userId == '') {
|
||||
uni.showToast({
|
||||
title: '用户信息错误',
|
||||
icon: 'none'
|
||||
@@ -366,7 +362,7 @@ const submitReview = async () => {
|
||||
product_id: item.product_id,
|
||||
order_id: orderId.value,
|
||||
rating: ratings.value[index],
|
||||
content: contents.value[index] || '',
|
||||
content: contents.value[index] != '' ? contents.value[index] : '',
|
||||
images: images.value[index],
|
||||
is_anonymous: anonymous.value
|
||||
}))
|
||||
@@ -436,7 +432,7 @@ const submitReview = async () => {
|
||||
// 获取当前用户ID
|
||||
const getCurrentUserId = (): string => {
|
||||
const userStore = uni.getStorageSync('userInfo')
|
||||
return userStore?.id || ''
|
||||
return userStore?.getString('id') ?? ''
|
||||
}
|
||||
|
||||
// 返回
|
||||
@@ -449,7 +445,7 @@ const goBack = () => {
|
||||
.review-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
flex: 1;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
@@ -532,13 +528,13 @@ const goBack = () => {
|
||||
color: #333333;
|
||||
line-height: 1.4;
|
||||
margin-bottom: 5px;
|
||||
display: block;
|
||||
/* display: block; removed */
|
||||
}
|
||||
|
||||
.product-spec {
|
||||
font-size: 12px;
|
||||
color: #999999;
|
||||
display: block;
|
||||
/* display: block; removed */
|
||||
}
|
||||
|
||||
.rating-section {
|
||||
@@ -555,16 +551,17 @@ const goBack = () => {
|
||||
|
||||
.rating-stars {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
/* gap: 10px; removed */
|
||||
}
|
||||
|
||||
.rating-stars.small {
|
||||
gap: 5px;
|
||||
/* gap: 5px; removed */
|
||||
}
|
||||
|
||||
.star-icon {
|
||||
font-size: 24px;
|
||||
color: #cccccc;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.star-icon.active {
|
||||
@@ -593,7 +590,7 @@ const goBack = () => {
|
||||
}
|
||||
|
||||
.word-count {
|
||||
display: block;
|
||||
/* display: block; removed */
|
||||
text-align: right;
|
||||
font-size: 12px;
|
||||
color: #999999;
|
||||
@@ -605,7 +602,7 @@ const goBack = () => {
|
||||
}
|
||||
|
||||
.images-label {
|
||||
display: block;
|
||||
/* display: block; removed */
|
||||
font-size: 14px;
|
||||
color: #333333;
|
||||
margin-bottom: 10px;
|
||||
@@ -614,10 +611,12 @@ const goBack = () => {
|
||||
.images-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
/* gap: 10px; removed */
|
||||
}
|
||||
|
||||
.image-item {
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
width: 70px;
|
||||
height: 70px;
|
||||
border-radius: 5px;
|
||||
@@ -644,7 +643,9 @@ const goBack = () => {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.upload-btn {
|
||||
width: 70px;
|
||||
height: 70px;
|
||||
@@ -680,11 +681,11 @@ const goBack = () => {
|
||||
|
||||
.switch-label {
|
||||
font-size: 14px;
|
||||
color: #333333;
|
||||
/* display: block; removed */
|
||||
}
|
||||
|
||||
.anonymous-tip {
|
||||
display: block;
|
||||
/* display: block; removed */
|
||||
font-size: 12px;
|
||||
color: #999999;
|
||||
}
|
||||
@@ -696,7 +697,7 @@ const goBack = () => {
|
||||
}
|
||||
|
||||
.section-title {
|
||||
display: block;
|
||||
/* display: block; removed */
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: #333333;
|
||||
@@ -722,7 +723,7 @@ const goBack = () => {
|
||||
}
|
||||
|
||||
.tip-title {
|
||||
display: block;
|
||||
/* display: block; removed */
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: #333333;
|
||||
@@ -730,7 +731,7 @@ const goBack = () => {
|
||||
}
|
||||
|
||||
.tip-item {
|
||||
display: block;
|
||||
/* display: block; removed */
|
||||
font-size: 12px;
|
||||
color: #666666;
|
||||
line-height: 1.6;
|
||||
@@ -761,4 +762,4 @@ const goBack = () => {
|
||||
background-color: #cccccc;
|
||||
opacity: 0.6;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user