添加意见反馈页面
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
// 定义反馈数据类型
|
||||
interface FeedbackData {
|
||||
type: string;
|
||||
content: string;
|
||||
contact: string;
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
// 选中的反馈类型
|
||||
selectedType: '',
|
||||
|
||||
// 反馈内容
|
||||
feedbackContent: '',
|
||||
contentLength: 0,
|
||||
|
||||
// 联系方式
|
||||
contactInfo: '',
|
||||
|
||||
// 是否可以提交(验证条件)
|
||||
canSubmit: false
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
// 初始化
|
||||
},
|
||||
|
||||
// 选择反馈类型
|
||||
selectType(e: { currentTarget: { dataset: { type: string } } }) {
|
||||
const type = e.currentTarget.dataset.type;
|
||||
this.setData({
|
||||
selectedType: type
|
||||
}, () => {
|
||||
this.checkSubmitable();
|
||||
});
|
||||
},
|
||||
|
||||
// 反馈内容变化
|
||||
onContentChange(e: { detail: { value: string } }) {
|
||||
const content = e.detail.value;
|
||||
this.setData({
|
||||
feedbackContent: content,
|
||||
contentLength: content.length
|
||||
}, () => {
|
||||
this.checkSubmitable();
|
||||
});
|
||||
},
|
||||
|
||||
// 联系方式变化
|
||||
onContactChange(e: { detail: { value: string } }) {
|
||||
this.setData({
|
||||
contactInfo: e.detail.value
|
||||
});
|
||||
},
|
||||
|
||||
// 检查是否可以提交
|
||||
checkSubmitable() {
|
||||
const { selectedType, feedbackContent } = this.data;
|
||||
const canSubmit = selectedType !== '' && feedbackContent.trim().length >= 5;
|
||||
this.setData({ canSubmit });
|
||||
},
|
||||
|
||||
// 提交反馈
|
||||
submitFeedback() {
|
||||
const { selectedType, feedbackContent, contactInfo } = this.data;
|
||||
|
||||
// 构建反馈数据
|
||||
const feedbackData: FeedbackData = {
|
||||
type: selectedType,
|
||||
content: feedbackContent,
|
||||
contact: contactInfo
|
||||
};
|
||||
|
||||
// 模拟提交到服务器
|
||||
wx.showLoading({
|
||||
title: '提交中...',
|
||||
mask: true
|
||||
});
|
||||
|
||||
// 模拟网络请求延迟
|
||||
setTimeout(() => {
|
||||
wx.hideLoading();
|
||||
|
||||
// 显示提交成功提示
|
||||
wx.showToast({
|
||||
title: '反馈提交成功',
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
success: () => {
|
||||
// 2秒后返回上一页
|
||||
setTimeout(() => {
|
||||
wx.navigateBack();
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
}, 1500);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user