|
@@ -10,13 +10,13 @@
|
|
|
<upload :list="file" name="file" :count="6" @uplSuc="uplSuc" @uplDel="uplDel"></upload>
|
|
|
</uni-forms-item>
|
|
|
<uni-forms-item label="商品评分" name="goods_score">
|
|
|
- <uni-rate size="18" v-model="form.goods_score" />
|
|
|
+ <uni-rate :readonly="readonly" size="18" v-model="form.goods_score" />
|
|
|
</uni-forms-item>
|
|
|
<uni-forms-item label="发货评分" name="transport_score">
|
|
|
- <uni-rate size="18" v-model="form.transport_score" />
|
|
|
+ <uni-rate :readonly="readonly" size="18" v-model="form.transport_score" />
|
|
|
</uni-forms-item>
|
|
|
<uni-forms-item label="店铺评分" name="shop_score">
|
|
|
- <uni-rate size="18" v-model="form.shop_score" />
|
|
|
+ <uni-rate :readonly="readonly" size="18" v-model="form.shop_score" />
|
|
|
</uni-forms-item>
|
|
|
</uni-forms>
|
|
|
<view class="btn">
|
|
@@ -37,6 +37,8 @@
|
|
|
data() {
|
|
|
return {
|
|
|
id: '',
|
|
|
+ // 追加
|
|
|
+ rate_id: '',
|
|
|
user: {},
|
|
|
form: {},
|
|
|
info: {},
|
|
@@ -55,11 +57,13 @@
|
|
|
}]
|
|
|
}
|
|
|
},
|
|
|
+ readonly: false,
|
|
|
};
|
|
|
},
|
|
|
onLoad: function(e) {
|
|
|
const that = this;
|
|
|
that.$set(that, `id`, e.id || '');
|
|
|
+ that.$set(that, `rate_id`, e.rate_id || '');
|
|
|
// 监听用户是否登录
|
|
|
that.watchLogin();
|
|
|
},
|
|
@@ -80,30 +84,56 @@
|
|
|
async onSubmit(ref) {
|
|
|
const that = this;
|
|
|
that.$refs[ref].validate().then(async params => {
|
|
|
- let reply = [{
|
|
|
- file: that.file,
|
|
|
- content: params.content,
|
|
|
- time: moment().format('YYYY-MM-DD HH:mm:ss')
|
|
|
- }];
|
|
|
- params.reply = reply;
|
|
|
- params.customer = that.user?._id;
|
|
|
- params.shop = that.info?.goods[0]?.shop;
|
|
|
- params.goods = that.info?.goods[0]?.goods[0]?.goods?._id;
|
|
|
- params.goodsSpec = that.info?.goods[0]?.goods[0]?._id;
|
|
|
- const arr = await that.$api(`/goodsRate`, 'POST', params);
|
|
|
- if (arr.errcode == '0') {
|
|
|
- uni.showToast({
|
|
|
- title: `评论成功`,
|
|
|
- icon: 'success',
|
|
|
- });
|
|
|
- uni.navigateBack({
|
|
|
- detail: 1
|
|
|
- })
|
|
|
+ if (that.rate_id) {
|
|
|
+ let reply = that.form;
|
|
|
+ let obj = {
|
|
|
+ file: that.file,
|
|
|
+ content: params.content,
|
|
|
+ time: moment().format('YYYY-MM-DD HH:mm:ss')
|
|
|
+ }
|
|
|
+ reply.reply.push(obj)
|
|
|
+ const arr = await that.$api(`/goodsRate/${that.rate_id}`, 'POST', reply)
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ uni.showToast({
|
|
|
+ title: `追加成功`,
|
|
|
+ icon: 'success',
|
|
|
+ });
|
|
|
+ uni.navigateBack({
|
|
|
+ detail: 1
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: arr.errmsg,
|
|
|
+ icon: 'none',
|
|
|
+ })
|
|
|
+ }
|
|
|
} else {
|
|
|
- uni.showToast({
|
|
|
- title: arr.errmsg,
|
|
|
- icon: 'none',
|
|
|
- })
|
|
|
+ let reply = [{
|
|
|
+ file: that.file,
|
|
|
+ content: params.content,
|
|
|
+ time: moment().format('YYYY-MM-DD HH:mm:ss')
|
|
|
+ }];
|
|
|
+ params.orderDetail = that.id
|
|
|
+ params.reply = reply;
|
|
|
+ params.customer = that.user?._id;
|
|
|
+ params.shop = that.info?.goods[0]?.shop;
|
|
|
+ params.goods = that.info?.goods[0]?.goods[0]?.goods?._id;
|
|
|
+ params.goodsSpec = that.info?.goods[0]?.goods[0]?._id;
|
|
|
+ const arr = await that.$api(`/goodsRate`, 'POST', params);
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ uni.showToast({
|
|
|
+ title: `评论成功`,
|
|
|
+ icon: 'success',
|
|
|
+ });
|
|
|
+ uni.navigateBack({
|
|
|
+ detail: 1
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: arr.errmsg,
|
|
|
+ icon: 'none',
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
},
|
|
@@ -128,13 +158,21 @@
|
|
|
async search() {
|
|
|
const that = this;
|
|
|
let user = that.user;
|
|
|
+ let res;
|
|
|
if (that.id) {
|
|
|
- let res = await that.$api(`/orderDetail/${that.id}`);
|
|
|
+ res = await that.$api(`/orderDetail/${that.id}`);
|
|
|
if (res.errcode == '0') {
|
|
|
that.$set(that, `info`, res.data.order);
|
|
|
uni.hideLoading();
|
|
|
}
|
|
|
}
|
|
|
+ if (that.rate_id) {
|
|
|
+ res = await that.$api(`/goodsRate/${that.rate_id}`);
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ that.$set(that, `form`, res.data);
|
|
|
+ that.$set(that, `readonly`, true)
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
}
|
|
|
}
|