master
gongfuxiang 2024-12-18 17:15:20 +08:00
commit afaa5f2648
4 changed files with 272 additions and 128 deletions

View File

@ -4,7 +4,7 @@
<view v-if="propIsTerse" class="content margin-top cp">
<block v-if="data != null && data_field.length > 0">
<block v-for="(item, index) in data_field" :key="index">
<view v-if="(item.is_hide || 0) == 0 " class="single-text margin-top-xs">
<view v-if="(item.is_hide || 0) == 0" class="single-text margin-top-xs">
<text class="cr-grey margin-right-xl">{{ item.name }}</text>
<text class="cr-base">
<block v-if="item.type == 'images'">
@ -18,8 +18,8 @@
</view>
</block>
<view v-if="propIsItemShowMax > 0 && propIsItemShowMax < data_field.length" @tap.stop="item_more_event" class="margin-top-sm tc">
<text class="cr-grey-c margin-right-sm">{{$t('common.view_more')}}</text>
<iconfont :name="'icon-arrow-'+(more_status ? 'top' : 'bottom')" size="28rpx" color="#ccc"></iconfont>
<text class="cr-grey-c margin-right-sm">{{ $t('common.view_more') }}</text>
<iconfont :name="'icon-arrow-' + (more_status ? 'top' : 'bottom')" size="28rpx" color="#ccc"></iconfont>
</view>
</block>
<slot></slot>
@ -27,11 +27,11 @@
<!-- 详情面板数据 -->
<view v-else class="padding-horizontal-main padding-top-main">
<view class="panel-item padding-main border-radius-main bg-white spacing-mb">
<view v-if="(propTitle || null) != null" class="br-b padding-bottom-main fw-b text-size">{{propTitle}}</view>
<view v-if="(propTitle || null) != null" class="br-b padding-bottom-main fw-b text-size">{{ propTitle }}</view>
<view class="panel-content oh">
<block v-if="data != null && data_field.length > 0">
<block v-for="(item, index) in data_field" :key="index">
<view v-if="(item.is_hide || 0) == 0 " class="item br-b-f5 oh padding-vertical-main">
<view v-if="(item.is_hide || 0) == 0" class="item br-b-f5 oh padding-vertical-main">
<view class="title fl padding-right-main cr-grey">{{ item.name }}</view>
<view class="content fl br-l padding-left-main">
<block v-if="item.type == 'images'">
@ -45,8 +45,8 @@
</view>
</block>
<view v-if="propIsItemShowMax > 0 && propIsItemShowMax < data_field.length" @tap="item_more_event" class="margin-top-sm tc">
<text class="cr-grey-c margin-right-sm">{{$t('common.view_more')}}</text>
<iconfont :name="'icon-arrow-'+(more_status ? 'top' : 'bottom')" size="28rpx" color="#ccc"></iconfont>
<text class="cr-grey-c margin-right-sm">{{ $t('common.view_more') }}</text>
<iconfont :name="'icon-arrow-' + (more_status ? 'top' : 'bottom')" size="28rpx" color="#ccc"></iconfont>
</view>
</block>
<slot></slot>
@ -57,18 +57,18 @@
</template>
<script>
const app = getApp();
import componentNoData from "@/components/no-data/no-data";
import componentNoData from '@/components/no-data/no-data';
export default {
data() {
return {
theme_view: app.globalData.get_theme_value_view(),
data: null,
data_field: [],
more_status: false
more_status: false,
};
},
components: {
componentNoData
componentNoData,
},
props: {
//
@ -115,24 +115,19 @@
propIsTerse: {
type: Boolean,
default: false,
}
},
},
//
watch: {
//
propData(value, old_value) {
this.data = this.value;
},
//
propDataField(value, old_value) {
this.data_field = this.value;
}
propData(value, old_value) {
this.data = value;
},
},
//
created: function(e) {
created: function (e) {
this.setData({
data: this.propData
data: this.propData,
});
this.data_field_handle(this.propDataField);
},
@ -143,15 +138,15 @@
var exclude = (this.propExcludeField || null) == null ? [] : this.propExcludeField.split(',');
var temp_data = [];
var index = 0;
for(var i in data) {
if((exclude.length == 0 && appoint.length > 0 && appoint.indexOf(data[i]['field']) != -1) || (appoint.length == 0 && (exclude.length == 0 || exclude.indexOf(data[i]['field']) == -1))) {
data[i]['is_hide'] = (data[i]['is_hide'] || 0) == 0 ? ((index >= this.propIsItemShowMax && this.propIsItemShowMax > 0) ? 1 : 0) : 0;
for (var i in data) {
if ((exclude.length == 0 && appoint.length > 0 && appoint.indexOf(data[i]['field']) != -1) || (appoint.length == 0 && (exclude.length == 0 || exclude.indexOf(data[i]['field']) == -1))) {
data[i]['is_hide'] = (data[i]['is_hide'] || 0) == 0 ? (index >= this.propIsItemShowMax && this.propIsItemShowMax > 0 ? 1 : 0) : 0;
temp_data.push(data[i]);
index++;
}
}
this.setData({
data_field: temp_data
data_field: temp_data,
});
},
@ -164,10 +159,10 @@
item_more_event(e) {
this.data_field_handle(this.data_field);
this.setData({
more_status: !this.more_status
more_status: !this.more_status,
});
}
}
},
},
};
</script>
<style scoped>

View File

@ -1,25 +1,53 @@
<template>
<view :class="theme_view">
<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="padding-main oh">
<view class="form-gorup border-radius-main">
<textarea class="cr-base textarea-height" name="content" maxlength="230" auto-height placeholder-class="cr-grey-9" :placeholder="$t('form.form.qt0q5u')" @input="text_input_event"></textarea>
<view class="tr text-size-xs cr-grey-c">{{ text_num }}/500</view>
<view class="spacing-mt dis-none">
<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 margin-top-sm">
<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>
</label>
</checkbox-group>
<view class="form-gorup border-radius-main oh flex-row jc-sb align-c margin-bottom-main">
<view class=""> 标题 <text class="form-group-tips-must">*</text></view>
<view class="flex-row align-c flex-1 flex-width">
<input type="text" name="title" :value="data.title" maxlength="16" placeholder-class="cr-grey-9 tr" class="cr-base tr" placeholder="请输入标题" />
</view>
</view>
<view class="form-gorup border-radius-main margin-bottom-main">
<view class="margin-bottom-sm">提问内容 <text class="form-group-tips-must">*</text></view>
<sp-editor @init="initEditor" @input="rich_text_event" @upinImage="up_in_image_event"></sp-editor>
</view>
<view class="form-gorup border-radius-main oh flex-row jc-sb align-c margin-bottom-main">
<view class=""> 提问分类 </view>
<view class="flex-row jc-e align-c flex-1 flex-width">
<picker @change="select_change_event" :value="category_id_index" :range="ask_category_list" range-key="name" name="category_id" data-field="category_id" class="margin-right-sm wh-auto tr">
<view class="uni-input cr-base picker">
<template v-if="category_id_index !== -1">
{{ ask_category_list[category_id_index].name || '' }}
</template>
</view>
</picker>
<iconfont name="icon-arrow-right" size="34rpx" color="#ccc"></iconfont>
</view>
</view>
<view v-if="is_show_email_notice == 1" class="form-gorup border-radius-main oh flex-row jc-sb align-c margin-bottom-main">
<view class=""> 回复邮件通知 </view>
<view class="flex-row align-c flex-1 flex-width">
<input type="text" name="email_notice" :value="data.email_notice" placeholder-class="cr-grey-9 tr" class="cr-base tr" placeholder="请输入邮件" />
</view>
</view>
<view v-if="is_show_mobile_notice == 1" class="form-gorup border-radius-main oh flex-row jc-sb align-c margin-bottom-main">
<view class="form-gorup-title"> 回复手机通知 </view>
<view class="flex-row align-c flex-1 flex-width">
<input type="text" name="mobile_notice" :value="data.mobile_notice" maxlength="16" placeholder-class="cr-grey-9 tr" class="cr-base tr" placeholder="请输入手机号" />
</view>
</view>
<!-- 匿名发布 -->
<!-- <view class="form-gorup border-radius-main oh flex-row jc-e align-c">
<checkbox-group @change="is_anonymous_change_event">
<label class="cr-grey-9">
<checkbox value="1" :checked="false" :color="theme_color" style="transform: scale(0.7)" />
<text class="pr top-xs">{{ $t('form.form.2f52v3') }}</text>
</label>
</checkbox-group>
</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>
</view>
</form>
@ -48,10 +76,14 @@
data_list_loding_msg: this.$t('form.form.bniyyt'),
params: {},
form_submit_loading: false,
text_num: 0,
image_list: [],
is_anonymous: '0',
editor_path_type: 'plugins_ask',
editor_path_type: '',
data: {},
ask_category_list: [],
is_show_email_notice: 0,
is_show_mobile_notice: 0,
category_id_index: -1,
};
},
@ -66,7 +98,7 @@
app.globalData.page_event_onload_handle(params);
//
this.setData({
params: params
params: params,
});
},
@ -91,10 +123,7 @@
init() {
var user = app.globalData.get_user_info(this, 'init');
if (user != false) {
//
this.setData({
data_list_loding_status: 0,
});
this.get_data_list();
} else {
//
this.setData({
@ -104,32 +133,76 @@
}
},
/**
* 表单提交
*/
//
get_data_list() {
uni.showLoading({
title: this.$t('common.loading_in_text'),
});
//
uni.request({
url: app.globalData.get_request_url('saveinfo', 'ask', 'ask'),
method: 'POST',
data: { id: this.params.id || null },
dataType: 'json',
success: (res) => {
uni.hideLoading();
var data = res.data.data;
if (res.data.code == 0) {
this.setData({
data_bottom_line_status: true,
data_list_loding_status: 3,
data: data.data || {},
ask_category_list: data.ask_category_list || [],
editor_path_type: data.editor_path_type,
is_show_email_notice: data.is_show_email_notice,
is_show_mobile_notice: data.is_show_mobile_notice,
category_id_index: (data.ask_category_list || []).length > 0 ? data.ask_category_list.findIndex((item) => item.id === data.data.category_id) : -1,
});
console.log(this.category_id_index);
} else {
this.setData({
data_list_loding_status: 0,
data_list_loding_msg: res.data.msg,
});
app.globalData.showToast(res.data.msg);
}
},
fail: () => {
uni.hideLoading();
this.setData({
data_list_loding_status: 0,
});
app.globalData.showToast(this.$t('common.internet_error_tips'));
},
});
},
//
formSubmit(e) {
//
var validation = [
{ fields: 'content', msg: this.$t('form.form.5v5bjs') },
{ fields: 'title', msg: this.$t('form.form.5v5bjs') },
];
if (app.globalData.fields_check(e.detail.value, validation)) {
const new_data = {
goods_id: this.params.goods_id || 0,
id: this.params.id || null,
...e.detail.value,
content: this.data.content,
category_id: this.data.category_id,
};
if (app.globalData.fields_check(new_data, validation)) {
uni.showLoading({
title: this.$t('buy.buy.r79t77'),
});
this.setData({
form_submit_loading: true,
});
var newData = {
goods_id: this.params.goods_id || 0,
image_list:this.image_list,
is_anonymous:this.is_anonymous,
...e.detail.value,
}
//
uni.request({
url: app.globalData.get_request_url('save', 'ask', 'ask'),
method: 'POST',
data: newData,
data: new_data,
dataType: 'json',
success: (res) => {
uni.hideLoading();
@ -159,20 +232,81 @@
});
}
},
text_input_event(e) {
this.setData({
text_num: e.detail.cursor,
// //
// is_anonymous_change_event(e) {
// this.setData({
// is_anonymous: e.detail.value.length > 0 ? e.detail.value[0] : 0,
// });
// },
initEditor(editor) {
//
editor.setContents({
html: (this.data || null) !== null ? this.data.content : '',
});
},
is_anonymous_change_event(e) {
//
rich_text_event(e) {
var new_data = this.data;
new_data.content = e.html;
this.setData({
is_anonymous: e.detail.value.length > 0 ? e.detail.value[0] : 0,
data: new_data,
});
},
//
retrun_image_event(data) {
//
up_in_image_event(tempFiles, editorCtx) {
var self = this;
// 使 uniCloud.uploadFile
tempFiles.forEach(async (item) => {
uni.showLoading({
title: self.$t('form.form.2e5rv3'),
mask: true,
});
await uni.uploadFile({
url: app.globalData.get_request_url('index', 'ueditor'),
// #ifdef APP-PLUS || H5
filePath: item.path,
// #endif
// #ifdef MP-WEIXIN
filePath: item.tempFilePath,
// #endif
name: 'upfile',
formData: {
action: 'uploadimage',
path_type: this.editor_path_type, // common
},
success: function (res) {
let data = JSON.parse(res.data);
if (res.statusCode == 200) {
//
editorCtx.insertImage({
src: data.data.url, //
// width: '50%',
alt: self.$t('common.video'),
success: function (e) {},
});
uni.hideLoading();
}
},
fail: function (e) {
app.globalData.showToast(e.errMsg);
uni.hideLoading();
},
});
});
},
//
select_change_event(e) {
var temp = this.data;
const category_id = this.ask_category_list[e.detail.value].id;
temp[e.currentTarget.dataset.field] = category_id;
this.setData({
image_list: data,
data: temp,
category_id_index: e.detail.value,
});
},
},

View File

@ -1,11 +1,3 @@
.ask-status {
padding: 4rpx 10rpx;
}
.ask-bg-green {
background-color: #5FB95E;
}
.ask-bg-yellow {
background-color: #FAAD14;
.ask-status {
padding: 4rpx 10rpx;
}

View File

@ -2,20 +2,17 @@
<view :class="theme_view">
<view class="page-bottom-fixed">
<view v-if="data_list.length > 0" class="padding-main">
<view v-for="(item, index) in data_list" :key="index">
<view :data-value="'/pages/plugins/ask/user-detail/user-detail?id=' + item.id" @tap="url_event" class="padding-main border-radius-main bg-white oh cp spacing-mb">
<view class="margin-bottom-xs flex-row jc-sb align-c">
<text class="cr-base text-size">{{ item.add_time_time }}</text>
<text class="ask-status cr-white border-radius-sm text-size-xss" :class="item.is_reply == 1 ? 'ask-bg-green' : 'ask-bg-yellow'">{{ item.is_reply == 1 ? $t('index.index.1c17n3') : $t('index.index.75l3l2') }}</text>
</view>
<view class="spacing-mt">
<view class="text-size single-text">
{{ item.title }}
</view>
<view v-if="item.title != item.content" class="margin-top-sm multi-text">
<mp-html :content="item.content" />
</view>
</view>
<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-dashed padding-bottom-main flex-row jc-sb align-c">
<text class="cr-grey-9">{{ item.add_time_time }}</text>
<text class="ask-status margin-left-xs" :class="item.is_reply == 1 ? 'cr-green' : 'cr-grey-c'">{{ item.is_reply_name }}</text>
</view>
<view :data-value="'/pages/plugins/ask/user-detail/user-detail?id=' + item.id" @tap="url_event" class="content margin-top-main cp">
<component-panel-content :propData="item" :propDataField="field_list" :propIsItemShowMax="6" propExcludeField="add_time_time,is_reply" :propIsTerse="true"></component-panel-content>
</view>
<view class="item-operation tr margin-top-main">
<button class="btn round br-grey-9 bg-white text-size-md" type="default" size="mini" @tap="delete_event" :data-value="item.id" hover-class="none">{{ $t('common.del') }}</button>
<button v-if="item.is_reply == 0" class="btn round cr-main br-main bg-white text-size-md" type="default" size="mini" :data-value="'/pages/plugins/ask/form/form?id=' + item.id" @tap="url_event" hover-class="none">{{ $t('common.edit') }}</button>
</view>
</view>
</view>
@ -28,7 +25,7 @@
<view class="bottom-fixed" :style="bottom_fixed_style">
<view class="bottom-line-exclude">
<button class="item bg-white br-main cr-main round text-size" type="default" data-value="/pages/plugins/ask/form/form" @tap="url_event" hover-class="none">{{$t('goods-detail.goods-detail.7ulh8b')}}</button>
<button class="item bg-white br-main cr-main round text-size" type="default" data-value="/pages/plugins/ask/form/form" @tap="url_event" hover-class="none">{{ $t('goods-detail.goods-detail.7ulh8b') }}</button>
</view>
</view>
</view>
@ -42,6 +39,7 @@
import componentCommon from '@/components/common/common';
import componentNoData from '@/components/no-data/no-data';
import componentBottomLine from '@/components/bottom-line/bottom-line';
import componentPanelContent from '@/components/panel-content/panel-content';
export default {
data() {
@ -62,6 +60,7 @@
componentCommon,
componentNoData,
componentBottomLine,
componentPanelContent,
},
onLoad(params) {
@ -84,7 +83,7 @@
//
app.globalData.page_share_handle();
},
//
onPullDownRefresh() {
this.setData({
@ -124,7 +123,7 @@
});
// loding
if(this.data_page > 1) {
if (this.data_page > 1) {
uni.showLoading({
title: this.$t('common.loading_in_text'),
});
@ -139,40 +138,34 @@
},
dataType: 'json',
success: (res) => {
if(this.data_page > 1) {
if (this.data_page > 1) {
uni.hideLoading();
}
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,
});
if (this.data_page <= 1) {
var temp_data_list = res.data.data.data_list;
} else {
this.setData({
data_list_loding_status: 0,
data_is_loading: 0,
});
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,
field_list: res.data.data.field_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,
@ -184,7 +177,7 @@
}
},
fail: () => {
if(this.data_page > 1) {
if (this.data_page > 1) {
uni.hideLoading();
}
uni.stopPullDownRefresh();
@ -197,6 +190,36 @@
});
},
//
delete_event(e) {
const value = e.currentTarget.dataset.value;
uni.request({
url: app.globalData.get_request_url('delete', 'ask', 'ask'),
method: 'POST',
data: {
ids: value,
},
dataType: 'json',
success: (res) => {
if (res.data.code == 0) {
this.setData({
data_page: 1,
});
this.get_data_list(1);
} else {
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: () => {
app.globalData.showToast(this.$t('common.internet_error_tips'));
},
});
},
//
scroll_lower(e) {
this.get_data_list();
@ -205,7 +228,7 @@
// url
url_event(e) {
app.globalData.url_event(e);
}
},
},
};
</script>