【订单详情】

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 id
}); });
} }
export function createOrderItemComment(data) {
return request.post("app-api/trade/order/item/create-comment", data);
}

View File

@ -19,7 +19,7 @@
</view> </view>
<view class='money font-color'>{{ fen2yuan(item.price) }}</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>
<view class='evaluate' v-else-if="item.replyStatus === true">已评价</view> <view class='evaluate' v-else-if="item.replyStatus === true">已评价</view>
@ -72,10 +72,9 @@
} }
}, },
methods: { methods: {
// TODO
evaluateTap(item) { evaluateTap(item) {
uni.navigateTo({ 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) { jumpCon: function(id) {

View File

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

View File

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