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.
274 lines
6.1 KiB
274 lines
6.1 KiB
import {
|
|
wxRequestPost,
|
|
wxNavigateTo,
|
|
wxGetUserProfile,
|
|
} from "@utils/promise-wx-api";
|
|
|
|
const app = getApp();
|
|
let task = null;
|
|
|
|
Component({
|
|
data: {
|
|
iniLoaded: false,
|
|
|
|
currentGrid: "",
|
|
myInfo: {},
|
|
|
|
role: {
|
|
registered_resi: false,
|
|
warmhearted: false,
|
|
partymember: false,
|
|
},
|
|
|
|
badgeList: [
|
|
// {
|
|
// isOpened: "1", //是否点亮 1:点亮 0:未点亮
|
|
// badgeId: "63484",
|
|
// badgeIcon: "R4r5gzdUgr",
|
|
// badgeType: '', //徽章类型: party:党员认证【目前只有党员认证】
|
|
// },
|
|
],
|
|
taskList: [],
|
|
taskItem: {},
|
|
taskIndex: 0,
|
|
|
|
npcInfo: {
|
|
isNpc: true, //true:人大代表;false:不是人大代表;此列用来判断是否显示@我
|
|
redDot: true, //展示红点:true;隐藏:false
|
|
},
|
|
|
|
isParty: false,
|
|
},
|
|
|
|
pageLifetimes: {
|
|
show() {
|
|
this.refreshData();
|
|
},
|
|
},
|
|
|
|
lifetimes: {
|
|
// 页面初始化
|
|
async attached() {
|
|
await app.doAfterLogin();
|
|
this.init();
|
|
this.setData({
|
|
isParty: app.globalData.userRoleList.indexOf("partymember") !== -1,
|
|
});
|
|
},
|
|
detached: function () {},
|
|
},
|
|
|
|
methods: {
|
|
async init() {
|
|
// 更新角色权限,这里他应该已经是居民了
|
|
await app.doAfterLogin();
|
|
|
|
await this.getInfo();
|
|
await this.getBadgeList();
|
|
await this.getTaskList();
|
|
await this.getNpcInfo();
|
|
this.taskInterval();
|
|
this.setData({
|
|
iniLoaded: true,
|
|
});
|
|
},
|
|
|
|
async refreshData() {
|
|
await app.doAfterLogin();
|
|
this.getInfo();
|
|
},
|
|
|
|
onUnload() {
|
|
clearInterval(task);
|
|
},
|
|
|
|
pionts() {
|
|
// /subpages/points/pages/points/index"
|
|
wx.navigateTo({
|
|
url: "/subpages/points/pages/moral/index",
|
|
});
|
|
},
|
|
|
|
async confirm() {
|
|
const { msg: msgU, data: dataU } = await wxGetUserProfile({
|
|
desc: "用于完善居民信息",
|
|
});
|
|
if (msgU == "success") {
|
|
// 同意授权,更新用户信息
|
|
let params = {
|
|
nickName: dataU.userInfo.nickName,
|
|
gender: dataU.userInfo.gender,
|
|
avatarUrl: dataU.userInfo.avatarUrl,
|
|
province: dataU.userInfo.province,
|
|
country: dataU.userInfo.country,
|
|
city: dataU.userInfo.city,
|
|
};
|
|
const {
|
|
data: {
|
|
data: { code, data },
|
|
},
|
|
msg,
|
|
} = await wxRequestPost("epmetuser/user/updatewxuserinfo", params, {
|
|
// isMock: true
|
|
});
|
|
|
|
if (msg === "success" && code === 0) {
|
|
console.log("更新微信用户信息成功");
|
|
wxNavigateTo("/subpages/mine/pages/register/resident/index", {
|
|
from: "badge",
|
|
});
|
|
}
|
|
}
|
|
},
|
|
|
|
logout() {
|
|
app.logout();
|
|
},
|
|
|
|
handleTapBadge(e) {
|
|
wxNavigateTo("/subpages/mine/pages/badge/index");
|
|
},
|
|
|
|
previewImg() {
|
|
const {
|
|
myInfo: { userHeadPhoto },
|
|
} = this.data;
|
|
wx.previewImage({
|
|
urls: [userHeadPhoto],
|
|
});
|
|
},
|
|
|
|
async getInfo() {
|
|
let customerId = app.globalData.customerId,
|
|
gridId = app.globalData.gridId;
|
|
const {
|
|
data: {
|
|
data: { code, data },
|
|
},
|
|
msg,
|
|
} = await wxRequestPost(
|
|
"resi/mine/mine/profile",
|
|
{
|
|
customerId,
|
|
gridId,
|
|
},
|
|
{
|
|
// isMock: true,
|
|
isQuiet: false,
|
|
}
|
|
);
|
|
|
|
if (msg === "success" && code === 0) {
|
|
console.log("data:", data);
|
|
this.setData({
|
|
myInfo: data,
|
|
|
|
role: {
|
|
registered_resi: data.roleList.indexOf("普通居民") >= 0,
|
|
warmhearted: data.roleList.indexOf("热心居民") >= 0,
|
|
partymember: data.roleList.indexOf("党员") >= 0,
|
|
},
|
|
});
|
|
}
|
|
},
|
|
|
|
//获取人大代表信息
|
|
async getNpcInfo() {
|
|
const {
|
|
data: {
|
|
data: { code, data },
|
|
},
|
|
msg,
|
|
} = await wxRequestPost(
|
|
"data/aggregator/epmetuser/mentionme",
|
|
{},
|
|
{
|
|
// isMock: true,
|
|
isQuiet: false,
|
|
}
|
|
);
|
|
|
|
if (msg === "success" && code === 0) {
|
|
let { npcInfo } = this.data;
|
|
npcInfo = data;
|
|
this.setData({
|
|
npcInfo,
|
|
});
|
|
}
|
|
},
|
|
|
|
async getBadgeList() {
|
|
let customerId = app.globalData.customerId;
|
|
const {
|
|
data: {
|
|
data: { code, data },
|
|
},
|
|
msg,
|
|
} = await wxRequestPost(
|
|
"resi/mine/badge/list",
|
|
{
|
|
customerId,
|
|
},
|
|
{
|
|
// isMock: true,
|
|
// isQuiet: false,
|
|
}
|
|
);
|
|
|
|
if (msg === "success" && code === 0) {
|
|
this.setData({
|
|
badgeList: data,
|
|
});
|
|
}
|
|
},
|
|
handleFinishTask() {
|
|
//
|
|
const { taskItem } = this.data;
|
|
|
|
if (taskItem.linkPage === "group") {
|
|
wxNavigateTo("/pages/main/index", {
|
|
tab: "group",
|
|
});
|
|
} else if (taskItem.linkPage === "heart") {
|
|
wxNavigateTo("/pages/heartNew/heartNew");
|
|
}
|
|
},
|
|
taskInterval() {
|
|
task = setInterval(() => {
|
|
let { taskList, taskIndex } = this.data;
|
|
if (taskIndex === taskList.length - 1) taskIndex = -1;
|
|
// else taskIndex = taskIndex + 1
|
|
|
|
this.setData({
|
|
taskItem: taskList[taskIndex],
|
|
taskIndex: taskIndex + 1,
|
|
});
|
|
}, 10000);
|
|
},
|
|
async getTaskList() {
|
|
const {
|
|
data: {
|
|
data: { code, data },
|
|
},
|
|
msg,
|
|
} = await wxRequestPost(
|
|
"point/resi/point/mytasklist",
|
|
{
|
|
type: "unfinished",
|
|
},
|
|
{
|
|
// isMock: true,
|
|
// isQuiet: false,
|
|
}
|
|
);
|
|
|
|
if (msg === "success" && code === 0) {
|
|
this.setData({
|
|
taskList: data,
|
|
taskItem: data[0],
|
|
taskIndex: 1,
|
|
});
|
|
}
|
|
},
|
|
},
|
|
});
|
|
|