订单评价:接入完成

pull/28/head
YunaiV 2023-12-14 22:00:36 +08:00
parent 3efb8ecf27
commit 3497261f26
5 changed files with 63 additions and 120 deletions

View File

@ -3,35 +3,34 @@
<s-layout title="评价"> <s-layout title="评价">
<view> <view>
<view v-for="(item, index) in state.orderInfo.items" :key="item.id"> <view v-for="(item, index) in state.orderInfo.items" :key="item.id">
<view v-if="item.btns.includes('comment')"> <view>
<view class="commont-from-wrap"> <view class="commont-from-wrap">
<!-- 评价商品 --> <!-- 评价商品 -->
<s-goods-item :img="item.goods_image" :title="item.goods_title" :skuText="item.goods_sku_text" <s-goods-item
:price="item.goods_price" :num="item.goods_num"></s-goods-item> :img="item.picUrl"
:title="item.spuName"
:skuText="item.properties.map((property) => property.valueName).join(' ')"
:price="item.payPrice"
:num="item.count"
/>
</view> </view>
<view class="form-item"> <view class="form-item">
<!-- 评分 --> <!-- 评分 -->
<view class="star-box ss-flex ss-col-center"> <view class="star-box ss-flex ss-col-center">
<view class="star-title ss-m-r-40"> <view class="star-title ss-m-r-40">商品质量</view>
<!-- {{ rateMap[state.commentList[index].level] }} --> <uni-rate v-model="state.commentList[index].descriptionScores" />
商品质量
</view>
<uni-rate v-model="state.commentList[index].level" />
</view> </view>
<view class="star-box ss-flex ss-col-center"> <view class="star-box ss-flex ss-col-center">
<view class="star-title ss-m-r-40"> <view class="star-title ss-m-r-40">服务态度</view>
<!-- {{ rateMap[state.commentList[index].level] }} --> <uni-rate v-model="state.commentList[index].benefitScores" />
服务态度
</view>
<uni-rate v-model="state.commentList[index].level2" />
</view> </view>
<!-- 评价 --> <!-- 评价 -->
<view class="area-box"> <view class="area-box">
<uni-easyinput :inputBorder="false" type="textarea" maxlength="120" autoHeight <uni-easyinput :inputBorder="false" type="textarea" maxlength="120" autoHeight
v-model="state.commentList[index].content" v-model="state.commentList[index].content"
placeholder="宝贝满足你的期待吗?说说你的使用心得,分享给想买的他们吧~"></uni-easyinput> placeholder="宝贝满足你的期待吗?说说你的使用心得,分享给想买的他们吧~" />
<!-- TODO 芋艿文件上传 -->
<view class="img-box"> <view class="img-box">
<s-uploader v-model:url="state.commentList[index].images" fileMediatype="image" <s-uploader v-model:url="state.commentList[index].images" fileMediatype="image"
limit="9" mode="grid" :imageStyles="{ width: '168rpx', height: '168rpx' }" /> limit="9" mode="grid" :imageStyles="{ width: '168rpx', height: '168rpx' }" />
@ -41,6 +40,7 @@
</view> </view>
</view> </view>
</view> </view>
<!-- TODO 芋艿是否匿名 -->
<su-fixed bottom placeholder> <su-fixed bottom placeholder>
<view class="foot_box ss-flex ss-row-center ss-col-center"> <view class="foot_box ss-flex ss-row-center ss-col-center">
@ -54,113 +54,49 @@
<script setup> <script setup>
import sheep from '@/sheep'; import sheep from '@/sheep';
import { import { onLoad } from '@dcloudio/uni-app';
onLoad import { reactive } from 'vue';
} from '@dcloudio/uni-app'; import OrderApi from '@/sheep/api/trade/order';
import {
computed,
reactive
} from 'vue';
const state = reactive({ const state = reactive({
orderInfo: {}, orderInfo: {},
commentList: [], commentList: [],
orderId: null id: null
}); });
const rateMap = {
1: '糟糕',
2: '差评',
3: '一般',
4: '良好',
5: '好评',
};
async function onSubmit() { async function onSubmit() {
// //
// console.log(state.orderInfo); for (const comment of state.commentList) {
// return; await OrderApi.createOrderItemComment(comment);
let obj = {
anonymous: false,
benefitScores: state.commentList[0].level2,
content: state.commentList[0].content,
descriptionScores: state.commentList[0].level,
orderItemId: state.commentList[0].item_id,
picUrls: 'https://t7.baidu.com/it/u=2531125946,3055766435&fm=193&f=GIF'
} }
const { //
code
} = await sheep.$api.order.comment(obj);
if (code === 0) {
sheep.$router.back(); sheep.$router.back();
} }
}
onLoad(async (options) => { onLoad(async (options) => {
let id = ''; if (!options.id) {
if (options.orderSN) { sheep.$helper.toast(`缺少订单信息,请检查`);
id = options.orderSN; return
}
if (options.id) {
id = options.id;
}
if (options.orderId) {
state.orderId = options.orderId
} }
state.id = options.id;
const res = await sheep.$api.order.detail(id); const { code, data } = await sheep.$api.order.detail(state.id);
if (res.code === 0) { if (code !== 0) {
let obj = {
10: ['待发货', '等待买家付款', ["apply_refund"]],
30: ['待评价', '等待买家评价', ["express", "comment"]]
}
res.data.status_text = obj[res.data.status][0];
res.data.status_desc = obj[res.data.status][1];
res.data.btns = obj[res.data.status][2];
res.data.address = {
province_name: res.data.receiverAreaName.split(' ')[0],
district_name: res.data.receiverAreaName.split(' ')[2],
city_name: res.data.receiverAreaName.split(' ')[1],
address: res.data.receiverDetailAddress,
consignee: res.data.receiverName,
mobile: res.data.receiverMobile,
}
res.data.pay_fee = res.data.payPrice / 100
res.data.create_time = sheep.$helper.timeFormat(res.data.createTime, 'yyyy-mm-dd hh:MM:ss')
res.data.order_sn = res.data.no
res.data.id = res.data.id
res.data.goods_amount = res.data.totalPrice / 100
res.data.dispatch_amount = res.data.deliveryPrice / 100
res.data.pay_types_text = res.data.payChannelName.split(',')
res.data.items = res.data.items.map(ite => {
return {
...ite,
btns: obj[res.data.status][2],
goods_title: ite.spuName,
goods_num: ite.count,
goods_price: ite.price / 100,
goods_image: ite.picUrl,
goods_sku_text: ite.properties.reduce((it0, it1) => it0 + it1.valueName + ' ', '')
}
})
if (res.data.btns.includes('comment')) {
state.orderInfo = res.data;
state.orderInfo.items.forEach((item) => {
if (item.btns.includes('comment')) {
state.commentList.push({
item_id: item.id,
level: 5,
content: '',
images: [],
});
}
});
console.log(state.orderInfo.items, '循环')
return;
}
}
sheep.$helper.toast('无待评价订单'); sheep.$helper.toast('无待评价订单');
return
}
//
data.items.forEach((item) => {
state.commentList.push({
anonymous: false,
orderItemId: item.id,
descriptionScores: 5,
benefitScores: 5,
content: '',
picUrls: []
});
});
state.orderInfo = data;
}); });
</script> </script>

View File

@ -16,7 +16,7 @@
:scrollable="false" :scrollable="false"
@change="onTabsChange" @change="onTabsChange"
:current="state.currentTab" :current="state.currentTab"
></su-tabs> />
</view> </view>
<view class="list-icon" @tap="state.iconStatus = !state.iconStatus"> <view class="list-icon" @tap="state.iconStatus = !state.iconStatus">
<text v-if="state.iconStatus" class="sicon-goods-list"></text> <text v-if="state.iconStatus" class="sicon-goods-list"></text>

View File

@ -232,7 +232,7 @@
<button <button
class="ss-reset-button cancel-btn" class="ss-reset-button cancel-btn"
v-if="state.orderInfo.buttons?.includes('comment')" v-if="state.orderInfo.buttons?.includes('comment')"
@tap="onComment(state.orderInfo.id, state.orderInfo)" @tap="onComment(state.orderInfo.id)"
> >
评价 评价
</button> </button>
@ -362,10 +362,9 @@
// #endif // #endif
// //
function onComment(orderSN, orderId) { function onComment(id) {
sheep.$router.go('/pages/goods/comment/add', { sheep.$router.go('/pages/goods/comment/add', {
orderSN, id
orderId,
}); });
} }

View File

@ -55,7 +55,7 @@
取消订单 取消订单
</button> </button>
<button v-if="order.buttons.includes('comment')" class="tool-btn ss-reset-button" <button v-if="order.buttons.includes('comment')" class="tool-btn ss-reset-button"
@tap.stop="onComment(order.order_sn)"> @tap.stop="onComment(order.id)">
评价 评价
</button> </button>
<button v-if="order.buttons.includes('delete')" class="delete-btn ss-reset-button" <button v-if="order.buttons.includes('delete')" class="delete-btn ss-reset-button"
@ -164,10 +164,10 @@
}); });
} }
// TODO //
function onComment(orderSN) { function onComment(id) {
sheep.$router.go('/pages/goods/comment/add', { sheep.$router.go('/pages/goods/comment/add', {
orderSN, id,
}); });
} }

View File

@ -90,6 +90,14 @@ const OrderApi = {
}, },
}); });
}, },
// 创建单个评论
createOrderItemComment: (data) => {
return request2({
url: `/app-api/trade/order/item/create-comment`,
method: 'POST',
data,
});
},
}; };
export default OrderApi; export default OrderApi;