1.新增商品评论页

2024.1.18 sws
master
sws 2024-01-18 19:32:51 +08:00
parent 2b5caa9d0c
commit 13a28688de
8 changed files with 553 additions and 8 deletions

View File

@ -191,6 +191,20 @@
"navigationBarTitleText": "商品收藏"
}
},
{
"path": "pages/user-goods-comments/user-goods-comments",
"style": {
"enablePullDownRefresh": true,
"navigationBarTitleText": "商品评论"
}
},
{
"path": "pages/user-goods-comments-form/user-goods-comments-form",
"style": {
"enablePullDownRefresh": true,
"navigationBarTitleText": "商品编辑"
}
},
{
"path": "pages/message/message",
"style": {

View File

@ -2,7 +2,7 @@
<view :class="theme_view">
<!-- 列表 -->
<scroll-view :scroll-y="true" class="scroll-box" @scrolltolower="scroll_lower" lower-threshold="60">
<view v-if="data_list.length > 0" class="data-list padding-horizontal-main padding-top-main">
<view v-if="data_list.length > " class="data-list padding-horizontal-main padding-top-main">
<view v-for="(item, index) in data_list" :key="index" class="item padding-main border-radius-main oh bg-white spacing-mb">
<view class="base oh br-b padding-bottom-main">
<text class="cr-base">{{ item.add_time }}</text>

View File

@ -1,3 +1,7 @@
.avatar {
width: 80rpx;
height: 80rpx;
}
.input-height {
min-height: 200rpx;
}

View File

@ -1,11 +1,11 @@
<template>
<view :class="theme_view">
<view v-if="goods_id" class="padding-main">
<form v-if="data_list_loding_status == 0" @submit="formSubmit" class="form-container">
<form v-if="data_list_loding_status == 3" @submit="formSubmit" class="form-container">
<view class="bg-white border-radius-main padding-main flex-row align-c spacing-mb">
<image v-if="data.url" class="avatar dis-block margin-right-xs" :src="data.url" mode="aspectFit"></image>
<image v-if="data.images" class="avatar dis-block margin-right-xs br-f5 padding-xs radius" :src="data.images" mode="aspectFit"></image>
<view class="flex-1 flex-width flex-row align-c">
<view class="margin-right-sm">{{$t('goods-comments.goods-comments.31ees6')}}</view>
<view class="margin-right-sm">{{ $t('goods-comments.goods-comments.31ees6') }}</view>
<uni-rate :value="rate_value" @change="rate_change_event" />
</view>
</view>
@ -13,20 +13,20 @@
<textarea name="content" @input="text_input_event" maxlength="230" auto-height :placeholder="$t('goods-comments.goods-comments.6p942c')" placeholder-class="cr-grey-9" class="wh-auto input-height" />
<view class="tr text-size-xs cr-grey-c">{{ text_num }}/230</view>
<view class="spacing-mt">
<view class="margin-bottom-main">{{$t('form.form.s14osm')}}{{ image_list.length }}/3)</view>
<view class="margin-bottom-main">{{ $t('form.form.s14osm') }}{{ image_list.length }}/3)</view>
<component-upload :propData="image_list" :propPathType="editor_path_type" @call-back="retrun_image_event"></component-upload>
</view>
<view class="tr">
<checkbox-group @change="is_anonymous_change_event">
<label class="cr-grey-9 text-size-xs">
<checkbox value="1" :checked="false" :color="theme_color" style="transform: scale(0.5)" />
<text class="pr top-xs">{{$t('form.form.2f52v3')}}</text>
<text class="pr top-xs">{{ $t('form.form.2f52v3') }}</text>
</label>
</checkbox-group>
</view>
</view>
<view class="sub-btn">
<button class="bg-main br-main cr-white round text-size" type="default" form-type="submit" hover-class="none" :loading="form_submit_loading" :disabled="form_submit_loading">{{$t('form.form.4yd066')}}</button>
<button class="bg-main br-main cr-white round text-size" type="default" form-type="submit" hover-class="none" :loading="form_submit_loading" :disabled="form_submit_loading">{{ $t('form.form.4yd066') }}</button>
</view>
</form>
<view v-else>
@ -114,14 +114,21 @@
uni.stopPullDownRefresh();
if (res.data.code == 0) {
this.setData({
data: res.data.data.data || {},
data: res.data.data.goods || {},
editor_path_type: res.data.data.editor_path_type || '',
data_list_loding_status: 3,
});
} else {
this.setData({
data_list_loding_status: 0,
});
}
},
fail: () => {
uni.stopPullDownRefresh();
this.setData({
data_list_loding_status: 2,
});
app.globalData.showToast(this.$t('common.internet_error_tips'));
},
});

View File

@ -0,0 +1,16 @@
.avatar {
width: 80rpx;
height: 80rpx;
}
.input-height {
min-height: 200rpx;
}
.sub-btn {
padding: 40rpx 66rpx;
}
.sub-btn button {
height: 88rpx;
line-height: 88rpx;
padding: 0;
}

View File

@ -0,0 +1,223 @@
<template>
<view :class="theme_view">
<view v-if="goods_id" class="padding-main">
<form v-if="data_list_loding_status == 3" @submit="formSubmit" class="form-container">
<view class="bg-white border-radius-main padding-main flex-row align-c spacing-mb">
<image v-if="goods_images" class="avatar dis-block margin-right-xs br-f5 padding-xs radius" :src="goods_images" mode="aspectFit"></image>
<view class="flex-1 flex-width flex-row align-c">
<view class="margin-right-sm">{{ $t('goods-comments.goods-comments.31ees6') }}</view>
<uni-rate :value="rate_value" @change="rate_change_event" />
</view>
</view>
<view class="bg-white border-radius-main padding-main">
<textarea name="content" @input="text_input_event" maxlength="230" :value="content" auto-height :placeholder="$t('goods-comments.goods-comments.6p942c')" placeholder-class="cr-grey-9" class="wh-auto input-height" />
<view class="tr text-size-xs cr-grey-c">{{ text_num }}/230</view>
<view class="tr">
<checkbox-group @change="is_anonymous_change_event">
<label class="cr-grey-9 text-size-xs">
<checkbox :value="is_anonymous" :checked="is_anonymous === '1' ? true : false" :color="theme_color" style="transform: scale(0.5)" />
<text class="pr top-xs">{{ $t('form.form.2f52v3') }}</text>
</label>
</checkbox-group>
</view>
</view>
<view class="sub-btn">
<button class="bg-main br-main cr-white round text-size" type="default" form-type="submit" hover-class="none" :loading="form_submit_loading" :disabled="form_submit_loading">{{ $t('form.form.4yd066') }}</button>
</view>
</form>
<view v-else>
<!-- 提示信息 -->
<component-no-data :propStatus="data_list_loding_status"></component-no-data>
</view>
</view>
<view v-else>
<!-- 提示信息 -->
<component-no-data propStatus="0"></component-no-data>
</view>
</view>
</template>
<script>
const app = getApp();
import componentNoData from '@/components/no-data/no-data';
const theme_color = app.globalData.get_theme_color();
export default {
data() {
return {
theme_view: app.globalData.get_theme_value_view(),
theme_color: theme_color,
goods_images: '',
rate_value: 0,
goods_id: '',
is_anonymous: '0',
content: '',
text_num: 0,
theme_color: theme_color,
data_list_loding_status: 1,
data_list_loding_msg: this.$t('form.form.bniyyt'),
form_submit_loading: false,
};
},
components: {
componentNoData,
},
onLoad(params) {
//
app.globalData.page_event_onload_handle(params);
//
if (params !== null && params.id) {
this.setData({
goods_id: params.id,
});
this.get_data_list();
}
},
onShow() {
//
app.globalData.page_event_onshow_handle();
//
this.init();
},
//
onPullDownRefresh() {
this.init();
},
//
onUnload: function () {},
methods: {
init() {
var user = app.globalData.get_user_info(this, 'init');
if (user != false) {
//
if (app.globalData.user_is_need_login(user)) {
uni.redirectTo({
url: '/pages/login/login?event_callback=init',
});
return false;
}
} else {
//
this.setData({
data_list_loding_status: 2,
data_list_loding_msg: this.$t('form.form.8l3ul5'),
});
}
},
get_data_list() {
uni.request({
url: app.globalData.get_request_url('detail', 'usergoodscomments'),
method: 'POST',
data: { id: this.goods_id },
success: (res) => {
uni.stopPullDownRefresh();
var data = res.data.data || null;
if (res.data.code == 0 && data !== null) {
this.setData({
goods_images: (data.goods || null) !== null ? data.goods.images : '',
rate_value: data.rating || '',
content: data.content || '',
text_num: data.content ? data.content.length : 0,
is_anonymous: data.is_anonymous,
data_list_loding_status: 3,
});
} else {
this.setData({
data_list_loding_status: 0,
});
}
},
fail: () => {
uni.stopPullDownRefresh();
this.setData({
data_list_loding_status: 2,
});
app.globalData.showToast(this.$t('common.internet_error_tips'));
},
});
},
//
formSubmit(e) {
//
var validation = [
{ fields: 'rating', msg: this.$t('goods-comments.goods-comments.pe5p52') },
{ fields: 'content', msg: this.$t('goods-comments.goods-comments.1wut9j') },
];
var validate = {
rating: this.rate_value,
content: e.detail.value.content,
};
if (app.globalData.fields_check(validate, validation)) {
uni.showLoading({
title: this.$t('buy.buy.r79t77'),
});
this.setData({
form_submit_loading: true,
});
var newData = {
id: this.goods_id,
is_anonymous: this.is_anonymous,
...validate,
};
//
uni.request({
url: app.globalData.get_request_url('save', 'usergoodscomments'),
method: 'POST',
data: newData,
dataType: 'json',
success: (res) => {
uni.hideLoading();
if (res.data.code == 0) {
app.globalData.showToast(res.data.msg, 'success');
setTimeout(function () {
app.globalData.page_back_prev_event();
}, 2000);
} else {
this.setData({
form_submit_loading: false,
});
if (app.globalData.is_login_check(res.data)) {
app.globalData.showToast(res.data.msg);
} else {
app.globalData.showToast(this.$t('common.sub_error_retry_tips'));
}
}
},
fail: () => {
uni.hideLoading();
this.setData({
form_submit_loading: false,
});
app.globalData.showToast(this.$t('common.internet_error_tips'));
},
});
}
},
text_input_event(e) {
this.setData({
text_num: e.detail.cursor,
});
},
rate_change_event(e) {
this.setData({
rate_value: e.value,
});
},
is_anonymous_change_event(e) {
this.setData({
is_anonymous: e.detail.value.length > 0 ? e.detail.value[0] : 0,
});
},
},
};
</script>
<style>
@import './user-goods-comments-form.css';
</style>

View File

@ -0,0 +1,4 @@
.goods-img {
width: 40rpx;
height: 40rpx;
}

View File

@ -0,0 +1,277 @@
<template>
<view :class="theme_view">
<!-- 列表 -->
<scroll-view :scroll-y="true" class="scroll-box" @scrolltolower="scroll_lower" lower-threshold="60">
<view v-if="data_list.length > 0" class="data-list padding-horizontal-main padding-top-main">
<view v-for="(item, index) in data_list" :key="index" class="item padding-main border-radius-main oh bg-white spacing-mb">
<view class="base oh br-b padding-bottom-main">
<text class="cr-base">{{ item.add_time_time }}</text>
<text class="fr">{{ item.rating_text }}</text>
</view>
<view class="content margin-top">
<navigator v-if="(item.goods || null) !== null" :url="item.goods.goods_url" hover-class="none">
<view class="margin-top-xs flex-row align-c">
<view class="cr-grey margin-right-xl">商品信息</view>
<view class="cr-base flex-1 flex-width flex-row align-c">
<image class="br radius margin-right-sm goods-img" :src="item.goods.images" mode="aspectFit"></image>
<text class="single-text flex-1 flex-width">{{ item.goods.title }}</text>
</view>
</view>
</navigator>
<block v-for="(fv, fi) in content_list" :key="fi">
<view class="margin-top-xs flex-row align-c">
<view class="cr-grey margin-right-xl">{{ fv.name }}</view>
<view class="cr-base flex-1 flex-width ">{{ item[fv.field] }}</view>
</view>
</block>
</view>
<view class="item-operation tr br-t padding-top-main margin-top-main">
<navigator :url="'/pages/user-goods-comments-form/user-goods-comments-form?id=' + item.id" hover-class="none" class="dis-inline-block margin-left-lg">
<button class="round bg-white br-main cr-main" type="default" size="mini" hover-class="none">{{ $t('common.edit') }}</button>
</navigator>
<button class="round bg-white br-red cr-red margin-left-lg" type="default" size="mini" hover-class="none" @tap="delete_event" :data-index="index">{{ $t('common.del') }}</button>
</view>
</view>
</view>
<view v-else>
<!-- 提示信息 -->
<component-no-data :propStatus="data_list_loding_status"></component-no-data>
</view>
<!-- 结尾 -->
<component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
</scroll-view>
</view>
</template>
<script>
const app = getApp();
import componentNoData from '@/components/no-data/no-data';
import componentBottomLine from '@/components/bottom-line/bottom-line';
export default {
data() {
return {
theme_view: app.globalData.get_theme_value_view(),
data_list: [],
data_total: 0,
data_page_total: 0,
data_page: 1,
data_list_loding_status: 1,
data_bottom_line_status: false,
data_is_loading: 0,
params: null,
content_list: [
{ name: '是否显示', field: 'is_show_text' },
{ name: '是否回复', field: 'is_reply_text' },
{ name: '是否匿名', field: 'is_anonymous_text' },
{ name: '评论内容', field: 'content' },
{ name: '回复内容', field: 'reply' },
{ name: '回复时间', field: 'reply_time_time' },
],
};
},
components: {
componentNoData,
componentBottomLine,
},
props: {},
onLoad(params) {
//
app.globalData.page_event_onload_handle(params);
//
this.setData({
params: params,
});
},
onShow() {
//
app.globalData.page_event_onshow_handle();
//
uni.$off('refresh');
//
this.init();
// 
uni.$on('refresh', (data) => {
//
this.init();
});
},
//
onPullDownRefresh() {
this.setData({
data_page: 1,
});
this.get_data_list(1);
},
methods: {
init() {
var user = app.globalData.get_user_info(this, 'init');
if (user != false) {
//
if (app.globalData.user_is_need_login(user)) {
uni.redirectTo({
url: '/pages/login/login?event_callback=init',
});
return false;
} else {
//
this.setData({
data_page: 1,
});
this.get_data_list(1);
}
} else {
this.setData({
data_list_loding_status: 0,
data_bottom_line_status: false,
});
}
},
//
get_data_list(is_mandatory) {
//
if ((is_mandatory || 0) == 0) {
if (this.data_bottom_line_status == true) {
uni.stopPullDownRefresh();
return false;
}
}
//
if (this.data_is_loading == 1) {
return false;
}
this.setData({
data_is_loading: 1,
data_list_loding_status: 1,
});
//
uni.request({
url: app.globalData.get_request_url('index', 'usergoodscomments'),
method: 'POST',
data: {
page: this.data_page,
is_more: 1,
},
dataType: 'json',
success: (res) => {
uni.stopPullDownRefresh();
if (res.data.code == 0) {
if (res.data.data.data.length > 0) {
if (this.data_page <= 1) {
var temp_data_list = res.data.data.data;
} else {
var temp_data_list = this.data_list || [];
var temp_data = res.data.data.data;
for (var i in temp_data) {
temp_data_list.push(temp_data[i]);
}
}
this.setData({
data_list: temp_data_list,
data_total: res.data.data.total,
data_page_total: res.data.data.page_total,
data_list_loding_status: 3,
data_page: this.data_page + 1,
data_is_loading: 0,
});
//
this.setData({
data_bottom_line_status: this.data_page > 1 && this.data_page > this.data_page_total,
});
} else {
this.setData({
data_list_loding_status: 0,
data_list: [],
data_bottom_line_status: false,
data_is_loading: 0,
});
}
} else {
this.setData({
data_list_loding_status: 0,
data_is_loading: 0,
});
if (app.globalData.is_login_check(res.data, this, 'get_data_list')) {
app.globalData.showToast(res.data.msg);
}
}
},
fail: () => {
uni.stopPullDownRefresh();
this.setData({
data_list_loding_status: 2,
data_is_loading: 0,
});
app.globalData.showToast(this.$t('common.internet_error_tips'));
},
});
},
//
scroll_lower(e) {
this.get_data_list();
},
//
delete_event(e) {
var index = e.currentTarget.dataset.index || 0;
var temp_data = this.data_list;
var data = temp_data[index] || null;
if (data == null) {
app.globalData.showToast(this.$t('extraction-switch.extraction-switch.613b58'));
return false;
}
uni.showModal({
title: this.$t('common.warm_tips'),
content: this.$t('recommend-list.recommend-list.54d418'),
confirmText: this.$t('common.confirm'),
cancelText: this.$t('recommend-list.recommend-list.w9460o'),
success: (result) => {
if (result.confirm) {
uni.showLoading({
title: this.$t('common.processing_in_text'),
});
uni.request({
url: app.globalData.get_request_url('delete', 'usergoodscomments'),
method: 'POST',
data: { ids: data.id },
dataType: 'json',
success: (res) => {
uni.hideLoading();
if (res.data.code == 0) {
temp_data.splice(index, 1);
this.setData({
data_list: temp_data,
});
app.globalData.showToast(res.data.msg, 'success');
} else {
app.globalData.showToast(res.data.msg);
}
},
fail: () => {
uni.hideLoading();
app.globalData.showToast(this.$t('common.internet_error_tips'));
},
});
}
},
});
},
},
};
</script>
<style>
@import './user-goods-comments.css';
</style>