109 lines
2.2 KiB
JavaScript
109 lines
2.2 KiB
JavaScript
|
|
// 反馈页面逻辑
|
||
|
|
Page({
|
||
|
|
/**
|
||
|
|
* 页面的初始数据
|
||
|
|
*/
|
||
|
|
data: {
|
||
|
|
feedbackTypes: ['功能建议', 'Bug反馈', '内容纠错', '其他问题'],
|
||
|
|
selectedType: 0,
|
||
|
|
content: '',
|
||
|
|
contact: '',
|
||
|
|
navbarHeight: 0, // 导航栏高度
|
||
|
|
statusBarHeight: 0, // 状态栏高度
|
||
|
|
menuButtonInfo: {} // 胶囊按钮信息
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面加载
|
||
|
|
*/
|
||
|
|
onLoad: function(options) {
|
||
|
|
console.log('反馈页面加载');
|
||
|
|
|
||
|
|
// 获取系统信息,用于导航栏定位
|
||
|
|
const systemInfo = wx.getSystemInfoSync();
|
||
|
|
const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
|
||
|
|
|
||
|
|
this.setData({
|
||
|
|
statusBarHeight: systemInfo.statusBarHeight,
|
||
|
|
menuButtonInfo: menuButtonInfo,
|
||
|
|
// 计算导航栏高度 = 胶囊按钮底部距离 - 状态栏高度
|
||
|
|
navbarHeight: menuButtonInfo.bottom - systemInfo.statusBarHeight
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 返回上一页
|
||
|
|
*/
|
||
|
|
navigateBack: function() {
|
||
|
|
wx.navigateBack({
|
||
|
|
delta: 1
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 选择反馈类型
|
||
|
|
*/
|
||
|
|
onTypeChange: function(e) {
|
||
|
|
this.setData({
|
||
|
|
selectedType: e.detail.value
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 输入反馈内容
|
||
|
|
*/
|
||
|
|
onContentChange: function(e) {
|
||
|
|
this.setData({
|
||
|
|
content: e.detail.value
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 输入联系方式
|
||
|
|
*/
|
||
|
|
onContactChange: function(e) {
|
||
|
|
this.setData({
|
||
|
|
contact: e.detail.value
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 提交反馈
|
||
|
|
*/
|
||
|
|
submitFeedback: function() {
|
||
|
|
const { selectedType, content, contact } = this.data;
|
||
|
|
const selectedTypeText = this.data.feedbackTypes[selectedType];
|
||
|
|
|
||
|
|
// 验证反馈内容
|
||
|
|
if (!content.trim()) {
|
||
|
|
wx.showToast({
|
||
|
|
title: '请输入反馈内容',
|
||
|
|
icon: 'none'
|
||
|
|
});
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 显示加载提示
|
||
|
|
wx.showLoading({
|
||
|
|
title: '提交中...',
|
||
|
|
});
|
||
|
|
|
||
|
|
// 模拟提交反馈
|
||
|
|
setTimeout(() => {
|
||
|
|
wx.hideLoading();
|
||
|
|
|
||
|
|
// 显示成功提示
|
||
|
|
wx.showToast({
|
||
|
|
title: '反馈提交成功',
|
||
|
|
icon: 'success',
|
||
|
|
duration: 2000,
|
||
|
|
success: () => {
|
||
|
|
// 延迟返回上一页
|
||
|
|
setTimeout(() => {
|
||
|
|
this.navigateBack();
|
||
|
|
}, 1500);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}, 1000);
|
||
|
|
}
|
||
|
|
});
|