【订单详情】

1、订单评价的接入
pull/1/MERGE
YunaiV 2023-08-13 21:44:29 +08:00
parent cf73be8270
commit c7323c1900
4 changed files with 86 additions and 117 deletions

View File

@ -49,3 +49,7 @@ export function getOrderItem(id) {
id
});
}
export function createOrderItemComment(data) {
return request.post("app-api/trade/order/item/create-comment", data);
}

View File

@ -19,7 +19,7 @@
</view>
<view class='money font-color'>{{ fen2yuan(item.price) }}</view>
<!-- 评价状态 -->
<view class='evaluate' v-if='item.replyStatus === false && evaluate === 2' @click.stop="evaluateTap(item)">
<view class='evaluate' v-if='item.commentStatus === false && evaluate === 2' @click.stop="evaluateTap(item)">
评价
</view>
<view class='evaluate' v-else-if="item.replyStatus === true">已评价</view>
@ -72,10 +72,9 @@
}
},
methods: {
// TODO
evaluateTap(item) {
uni.navigateTo({
url: "/pages/users/goods_comment_con/index?unique=" + item.attrId + "&orderId=" + this.orderId + '&id=' + item.id
url: "/pages/users/goods_comment_con/index?orderItemId=" + item.id
})
},
jumpCon: function(id) {

View File

@ -4,16 +4,20 @@
<view class='evaluate-con pad30'>
<view class='goodsStyle acea-row row-between borRadius14'>
<view class='pictrue'>
<image :src='productInfo.image'></image>
<image :src='orderItem.picUrl'></image>
</view>
<view class='text acea-row row-between'>
<view>
<view class='name line2'>{{productInfo.storeName}}</view>
<view class='attr line1' v-if="productInfo.sku">{{productInfo.sku}}</view>
<view class='name line2'>{{ orderItem.spuName }}</view>
<view class='attr line1'>
<text v-for="(property, propertyIndex) in orderItem.properties" :key="propertyIndex" style="padding-right: 10rpx;">
{{ property.valueName }} 
</text>
</view>
</view>
<view class='money'>
<view>{{productInfo.truePrice}}</view>
<view class='num'>x{{productInfo.cartNum}}</view>
<view>{{ fen2yuan(orderItem.price) }}</view>
<view class='num'>x{{ orderItem.count }}</view>
</view>
</view>
</view>
@ -21,7 +25,8 @@
<view class='item acea-row row-middle' v-for="(item,indexw) in scoreList" :key="indexw">
<view>{{item.name}}</view>
<view class='starsList'>
<text @click="stars(indexn, indexw)" v-for="(itemn, indexn) in item.stars" :key="indexn" class='iconfont' :class="item.index >= indexn? 'icon-shitixing':'icon-kongxinxing'"></text>
<text @click="stars(indexn, indexw)" v-for="(itemn, indexn) in item.stars" :key="indexn"
class='iconfont' :class="item.index >= indexn? 'icon-shitixing':'icon-kongxinxing'" />
</view>
<text class='evaluate'>{{item.index === -1 ? "" : item.index + 1 + "分"}}</text>
</view>
@ -32,7 +37,7 @@
<image :src='item'></image>
<text class='iconfont icon-guanbi1' @click='DelPic(index)'></text>
</view>
<view class='pictrue acea-row row-center-wrapper row-column' @click='uploadpic' v-if="picsPath.length < 8">
<view class='pictrue acea-row row-center-wrapper row-column' @click='uploadpic' v-if="picsPath.length <= 8">
<text class='iconfont icon-icon25201'></text>
<view>上传图片</view>
</view>
@ -42,56 +47,31 @@
</view>
</view>
</form>
<!-- #ifdef MP -->
<!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
<!-- #endif -->
</view>
</template>
<script>
import {
orderProduct,
orderComment
} from '@/api/order.js';
import {
toLogin
} from '@/libs/login.js';
import {
mapGetters
} from "vuex";
// #ifdef MP
import authorize from '@/components/Authorize';
// #endif
export default {
components: {
// #ifdef MP
authorize
// #endif
},
import * as OrderApi from '@/api/trade/order.js';
import { toLogin } from '@/libs/login.js';
import { mapGetters } from "vuex";
import * as Util from '@/utils/util.js';
export default {
data() {
return {
pics: [],
picsPath: [],
scoreList: [{
name: "商品质量",
stars: ["", "", "", "", ""],
index: -1
},
{
name: "服务态度",
stars: ["", "", "", "", ""],
index: -1
}
],
orderId: '',
productId: 0, //id
evaluateId: 0, //id
unique: '',
productInfo: {},
cart_num: 0,
isAuto: false, //
isShowAuth: false, //
id: 0//id
name: "商品质量",
stars: ["", "", "", "", ""],
index: -1
}, {
name: "服务态度",
stars: ["", "", "", "", ""],
index: -1
}],
orderItemId: 0, //
orderItem: {},
};
},
computed: mapGetters(['isLogin']),
@ -99,68 +79,51 @@
isLogin: {
handler: function(newV, oldV) {
if (newV) {
this.getOrderProduct();
this.getOrderItem();
}
},
deep: true
}
},
onLoad(options) {
if (!options.unique || !options.orderId ) return this.$util.Tips({
title: '缺少参数'
}, {
tab: 3,
url: 1
});
this.unique = Number(options.unique) || 0;
this.orderId = options.orderId || 0;
this.evaluateId = Number(options.id) || 0;
if (this.isLogin) {
this.getOrderProduct();
} else {
toLogin();
}
if (!this.isLogin) {
toLogin();
return
}
//
if (!options.orderItemId) {
return this.$util.Tips({
title: '缺少参数'
}, {
tab: 3,
url: 1
});
}
this.orderItemId = Number(options.orderItemId || 0);
this.getOrderItem()
},
methods: {
onLoadFun() {
this.getOrderProduct();
},
//
authColse: function(e) {
this.isShowAuth = e
},
/**
* 获取某个产品详情
*
* 获得订单项
*/
getOrderProduct: function() {
let that = this;
orderProduct({
orderId: that.evaluateId,
uni: that.unique
}).then(res => {
that.$set(that, 'productInfo', res.data);
// that.$set(that, 'cart_num', res.data.cartNum);
// that.$set(that, 'productId', res.data.productId);
});
getOrderItem: function() {
OrderApi.getOrderItem(this.orderItemId).then(res => {
this.orderItem = res.data;
})
},
stars: function(indexn, indexw) {
this.scoreList[indexw].index = indexn;
},
/**
* 删除图片
*
*/
DelPic: function(index) {
let that = this,
pic = this.picsPath[index];
that.picsPath.splice(index, 1);
that.pics.splice(index, 1);
this.picsPath.splice(index, 1);
this.pics.splice(index, 1);
},
/**
* 上传文件
*
*/
uploadpic: function() {
let that = this;
@ -181,41 +144,46 @@
* 立即评价
*/
formSubmit: function(e) {
let formId = e.detail.formId,
value = e.detail.value,
that = this,
product_score = that.scoreList[0].index + 1 === 0 ? "" : that.scoreList[0].index + 1,
service_score = that.scoreList[1].index + 1 === 0 ? "" : that.scoreList[1].index + 1;
if (!value.comment) return that.$util.Tips({
title: '请填写你对宝贝的心得!'
});
value.productScore = product_score;
value.serviceScore = service_score;
value.pics = that.pics.length>0?JSON.stringify(that.pics):'';
value.productId = that.productInfo.productId;
value.orderNo = that.orderId;
value.unique = that.unique;
value.sku = that.productInfo.sku;
const value = e.detail.value;
const descriptionScores = this.scoreList[0].index + 1 === 0 ? "" : this.scoreList[0].index + 1;
const benefitScores = this.scoreList[1].index + 1 === 0 ? "" : this.scoreList[1].index + 1;
if (!value.comment) {
return this.$util.Tips({
title: '请填写你对宝贝的心得!'
});
}
//
uni.showLoading({
title: "正在发布评论……"
});
orderComment(value).then(res => {
OrderApi.createOrderItemComment({
anonymous: false, // TODO
orderItemId: this.orderItemId,
descriptionScores: descriptionScores,
benefitScores: benefitScores,
content: value.comment,
picUrls: this.pics
}).then(res => {
uni.hideLoading();
return that.$util.Tips({
return this.$util.Tips({
title: '感谢您的评价!',
icon: 'success'
}, '/pages/order_details/index?order_id=' + that.orderId);
}, '/pages/order_details/index?order_id=' + this.orderItem.orderId);
}).catch(err => {
uni.hideLoading();
return that.$util.Tips({
return this.$util.Tips({
title: err
});
});
}
},
fen2yuan(price) {
return Util.fen2yuan(price)
},
}
}
</script>
<style lang="scss" scoped>
.goodsStyle .text .name, .attr{
//width: 496rpx;

View File

@ -438,8 +438,6 @@ export default {
let count = opt.count || 1,
sizeType = opt.sizeType || ['compressed'],
sourceType = opt.sourceType || ['album', 'camera'],
is_load = opt.is_load || true,
uploadUrl = opt.url || '',
inputName = opt.name || 'pics',
pid = opt.pid,
model = opt.model;
@ -468,13 +466,13 @@ export default {
},
success: function(res) {
uni.hideLoading();
if (res.statusCode == 403) {
if (res.statusCode === 403) {
that.Tips({
title: res.data
});
} else {
let data = res.data ? JSON.parse(res.data) : {};
if (data.code == 200) {
if (data.code === 200) {
data.data.localPath = localPath;
successCallback && successCallback(data)
} else {