日照项目的居民端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

243 lines
5.3 KiB

import { wxNavigateTo } from "@utils/promise-wx-api";
import { wxRequestPost } from "@utils/promise-wx-api";
const app = getApp();
Component({
properties: {},
data: {
customerId: "",
iniLoaded: false,
menuList: [
{
name: "表决中",
value: 0,
},
{
name: "处理中",
value: 1,
},
{
name: "已处理",
value: 2,
},
],
current: 0, // 表决中voting 已转项目turned 已关闭closed
votingUrl: "resi/hall/issue/votinglist",
ingUrl: "resi/hall/issue/processing",
// turnedUrl: "resi/hall/issue/shiftproject",
finalUrl: "resi/hall/issue/closedproject",
closedUrl: "resi/hall/issue/closedlist",
noneedUrl: "resi/hall/issue/unreslovedlist",
tabList: ["已结案", "已关闭", "无需解决"],
currentTab: 0, // 表决中voting 已转项目turned 已关闭closed
listParams: {
gridId: "",
isPage: true,
},
listIsMock: false,
showType: "list", //显示类型,map 地图 list 列表
mapList1: [],
mapList2: [],
mapList3: [],
mapList4: [],
mapList5: [],
},
lifetimes: {
attached() {
this.refreshData();
},
},
methods: {
async toList() {
this.setData({
showType: "list",
});
await this.refreshList();
},
async toMap() {
await this.refreshMap();
this.setData({
showType: "map",
});
},
async refreshData() {
await this.init();
const { showType } = this.data;
if (showType === "list") {
this.refreshList();
} else {
await this.refreshMap();
}
this.setData({
iniLoaded: true,
});
},
async refreshList() {
await this.selectComponent("#voting").refreshData();
await this.selectComponent("#turned").refreshData();
await this.selectComponent("#closed").refreshData();
this.selectComponent("#titleList").getInfo();
},
async refreshMap() {
const { gridId } = app.globalData;
const url1 = "resi/hall/issue/votinglist";
const url2 = "resi/hall/issue/processing";
const url3 = "resi/hall/issue/closedproject";
const url4 = "resi/hall/issue/closedlist";
const url5 = "resi/hall/issue/unreslovedlist";
await this.loadMapList(url1, 1);
await this.loadMapList(url2, 2);
await this.loadMapList(url3, 3);
await this.loadMapList(url4, 4);
await this.loadMapList(url5, 5);
},
// 获取地图数据
async loadMapList(url, index) {
let {
mapList1,
mapList2,
mapList3,
mapList4,
mapList5,
mapList6,
listParams,
} = this.data;
listParams.isPage = false;
listParams.pageNo = 1;
listParams.pageSize = 0;
const {
data: {
data: { code, data },
},
msg,
} = await wxRequestPost(url, listParams, {
// isMock: true
});
if (msg === "success" && code === 0) {
data.forEach((item) => {
item.name = item.issueTitle;
});
if (index === 1) {
mapList1 = data;
} else if (index === 2) {
mapList2 = data;
} else if (index === 3) {
mapList3 = data;
} else if (index === 4) {
mapList4 = data;
} else if (index === 5) {
mapList5 = data;
}
this.setData({
mapList1,
mapList2,
mapList3,
mapList4,
mapList5,
});
}
},
//点击地图
handleClickMap(e) {
// console.log(e)
const {
detail: { index },
} = e;
const {
current,
currentTab,
mapList1,
mapList2,
mapList3,
mapList4,
mapList5,
} = this.data;
let selEvent = {};
if (current === 0) {
selEvent = mapList1[index];
} else if (current === 1) {
selEvent = mapList2[index];
} else if (current === 2 && currentTab == 0) {
selEvent = mapList3[index];
} else if (current === 2 && currentTab == 1) {
selEvent = mapList4[index];
} else if (current === 2 && currentTab == 2) {
selEvent = mapList5[index];
}
wxNavigateTo("/pages/discussion/detail/index", {
issueId: selEvent.issueId,
});
},
async init() {
await app.doAfterLogin();
const { gridId } = app.globalData;
this.setData({
listParams: {
gridId,
},
});
},
handleSwiperChange(e) {
const {
detail: { current, source },
} = e;
if (source == "touch") {
this.setData({ current });
}
},
// 点击顶部菜单
handleShiftMenu(e) {
const {
detail: { value },
} = e;
this.setData({ current: value });
},
handleTapTab(e) {
console.log(e);
const {
currentTarget: {
dataset: { index },
},
} = e;
this.setData({ currentTab: index });
},
},
});