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.
147 lines
3.0 KiB
147 lines
3.0 KiB
// subpages/mine/pages/task/task.js
|
|
import {
|
|
wxRequestPost,
|
|
wxNavigateTo,
|
|
wxGetUserProfile,
|
|
} from "@utils/promise-wx-api";
|
|
import { nextTick } from "@utils/tools";
|
|
|
|
const app = getApp();
|
|
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
iniLoaded: false,
|
|
info: {},
|
|
taskList: [],
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: async function (options) {
|
|
// await app.doAfterLogin();
|
|
await this.getInfo();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: async function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: async function () {
|
|
await this.getTaskList();
|
|
this.setData({
|
|
iniLoaded: true,
|
|
});
|
|
},
|
|
handleBack() {
|
|
wx.navigateBack({
|
|
delta: 1,
|
|
});
|
|
},
|
|
async handleFinishTask(e) {
|
|
const index = e.currentTarget.dataset.index;
|
|
const { taskList } = this.data;
|
|
const item = taskList[index];
|
|
if (item.finishFlag == "已完成") return false;
|
|
if (item.linkPage === "group") {
|
|
const pages = getCurrentPages();
|
|
let index = pages.findIndex((item) => item.route == "pages/main/index");
|
|
if (index !== -1) {
|
|
wx.navigateBack({
|
|
delta: pages.length - index - 1,
|
|
});
|
|
|
|
await nextTick(100);
|
|
|
|
app.switchTab("group");
|
|
} else {
|
|
wxNavigateTo("/pages/main/index", {
|
|
tab: "group",
|
|
});
|
|
}
|
|
} else if (item.linkPage === "heart") {
|
|
wxNavigateTo("/pages/heartNew/heartNew");
|
|
}
|
|
},
|
|
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({
|
|
info: data,
|
|
});
|
|
}
|
|
},
|
|
async getTaskList() {
|
|
const {
|
|
data: {
|
|
data: { code, data },
|
|
},
|
|
msg,
|
|
} = await wxRequestPost(
|
|
"point/resi/point/mytasklist",
|
|
{
|
|
type: "all",
|
|
},
|
|
{
|
|
// isMock: true,
|
|
// isQuiet: false,
|
|
}
|
|
);
|
|
|
|
if (msg === "success" && code === 0) {
|
|
this.setData({
|
|
taskList: data,
|
|
});
|
|
}
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {},
|
|
});
|
|
|