|
@@ -9,13 +9,13 @@
|
|
|
<uni-forms-item label="上传评论图片" name="file">
|
|
|
<upload :list="file" name="file" :count="6" @uplSuc="uplSuc" @uplDel="uplDel"></upload>
|
|
|
</uni-forms-item>
|
|
|
- <uni-forms-item label="商品评分" name="goods_score">
|
|
|
+ <uni-forms-item v-if="!rate_id" label="商品评分" name="goods_score">
|
|
|
<uni-rate size="18" v-model="form.goods_score" />
|
|
|
</uni-forms-item>
|
|
|
- <uni-forms-item label="发货评分" name="transport_score">
|
|
|
+ <uni-forms-item v-if="!rate_id" label="发货评分" name="transport_score">
|
|
|
<uni-rate size="18" v-model="form.transport_score" />
|
|
|
</uni-forms-item>
|
|
|
- <uni-forms-item label="店铺评分" name="shop_score">
|
|
|
+ <uni-forms-item v-if="!rate_id" label="店铺评分" name="shop_score">
|
|
|
<uni-rate size="18" v-model="form.shop_score" />
|
|
|
</uni-forms-item>
|
|
|
</uni-forms>
|
|
@@ -37,6 +37,8 @@
|
|
|
data() {
|
|
|
return {
|
|
|
id: '',
|
|
|
+ // 追加
|
|
|
+ rate_id: '',
|
|
|
user: {},
|
|
|
form: {},
|
|
|
info: {},
|
|
@@ -60,6 +62,7 @@
|
|
|
onLoad: function(e) {
|
|
|
const that = this;
|
|
|
that.$set(that, `id`, e.id || '');
|
|
|
+ that.$set(that, `rate_id`, e.rate_id || '');
|
|
|
// 监听用户是否登录
|
|
|
that.watchLogin();
|
|
|
},
|
|
@@ -80,30 +83,59 @@
|
|
|
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 res = await that.$api(`/goodsRate/${that.rate_id}`);
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ let reply = res.data;
|
|
|
+ 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',
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
},
|