123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- noticeList: [
- {
- id: 1,
- address: '安平镇安坪村安平小区12栋304室',
- content: '水表漏水 11111',
- contact: '张三',
- phone: '13800138000',
- date: '2024-03-15',
- type: '水表漏水',
- hasAttachment: true,
- attachments: [
- '/static_file/background.png',
- '/static_file/card.png'
- ],
- isReplied: true,
- replyTime: '2025-3-12 12:10',
- replyContent: '建议增加线上开票功能,线下开票太麻烦了'
- },
- {
- id: 2,
- address: '安平镇安坪村安平小区12栋305室',
- content: '水管漏水 2222',
- contact: '李四',
- phone: '13900139000',
- date: '2024-03-14',
- type: '水表漏水',
- hasAttachment: false,
- attachments: [],
- isReplied: false,
- replyTime: '',
- replyContent: ''
- },
- {
- id: 3,
- address: '安平镇安坪村安平小区12栋306室',
- content: '3333',
- contact: '王五',
- phone: '13700137000',
- date: '2024-03-13',
- type: '水表漏水',
- hasAttachment: true,
- attachments: [
- '/static_file/add.png'
- ],
- isReplied: true,
- replyTime: '2025-3-10 09:30',
- replyContent: '已经对相关人员进行培训,感谢您的反馈'
- }
- ],
- imageList: [], // 存储图片路径的数组
- showCustomPreview: false, // 是否显示自定义预览
- currentPreviewImages: [], // 当前预览的图片数组
- currentPreviewIndex: 0 // 当前预览的图片索引
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.getNoticeList()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- },
- // 获取列表数据
- getNoticeList() {
- // wx.request({
- // url: 'YOUR_API_URL',
- // success: (res) => {
- // this.setData({
- // noticeList: res.data
- // })
- // }
- // })
- },
- previewImage: function(e) {
- // 获取当前点击项的id
- const id = e.currentTarget.dataset.id;
- // 根据id找到对应的投诉建议项
- const item = this.data.noticeList.find(item => item.id === id);
- // 确保有附件
- if (item && item.hasAttachment && item.attachments.length > 0) {
- this.setData({
- showCustomPreview: true,
- currentPreviewImages: item.attachments,
- currentPreviewIndex: 0
- });
- } else {
- console.log('没有找到附件或附件为空');
- }
- },
- // 关闭预览
- closePreview: function() {
- this.setData({
- showCustomPreview: false
- });
- },
- // 切换预览图片
- changePreviewImage: function(e) {
- const direction = e.currentTarget.dataset.direction;
- let newIndex = this.data.currentPreviewIndex;
-
- if (direction === 'prev') {
- newIndex = newIndex > 0 ? newIndex - 1 : this.data.currentPreviewImages.length - 1;
- } else {
- newIndex = newIndex < this.data.currentPreviewImages.length - 1 ? newIndex + 1 : 0;
- }
-
- this.setData({
- currentPreviewIndex: newIndex
- });
- },
- // 防止点击图片内容时关闭预览
- preventBubble: function() {
- return;
- },
- // 跳转到详情页
- goToDetail(e) {
- const id = e.currentTarget.dataset.id;
- const item = this.data.noticeList.find(item => item.id === id);
-
- // 统一使用预览模式,传递isReplied参数
- wx.navigateTo({
- url: `/pages/baoxiudj/baoxiudj?id=${id}&mode=preview&isReplied=${item.isReplied ? 'true' : 'false'}`
- });
- },
- // 跳转到表单页
- goToForm() {
- wx.navigateTo({
- url: '/pages/baoxiudj/baoxiudj'
- })
- },
- // 返回上一页
- goBack() {
- wx.navigateBack()
- },
- // 假设您从服务器获取数据的函数
- getDataFromServer: function() {
- // 示例:从服务器获取数据
- wx.request({
- url: 'your_api_url',
- success: (res) => {
- // 假设返回的数据中包含图片数组
- const images = res.data.images || [];
- this.setData({
- imageList: images
- });
- }
- });
- }
- })
|