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.
495 lines
14 KiB
495 lines
14 KiB
// pages/heartNew/heartNew.js
|
|
import { wxGetUserProfile } from "@utils/promise-wx-api";
|
|
|
|
const app = getApp();
|
|
var api = require("../../utils/api.js");
|
|
|
|
Component({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
isPage: false,
|
|
|
|
statusHeight: 0, // 自定义头部状态栏高度
|
|
navigationHeight: 0, // 自定义头部导航栏高度
|
|
selectedTab: "tab0",
|
|
// banner 相关
|
|
banner: [],
|
|
indicatorDots: false, //指示点
|
|
autoplay: true, //true false,//自动播放
|
|
circular: true, //衔接滑动
|
|
interval: 4000, //自动播放间隔时长(ms)
|
|
duration: 500, //幻灯片切换时长(ms)
|
|
currentSwiper: 0,
|
|
// banner 相关end
|
|
// 列表相关
|
|
loadMoreVisible: false, //false
|
|
loadMoreType: "none", //loading none
|
|
dingdan: false, //判断订单列表隐藏
|
|
jingcai: true, //判断精彩列表隐藏
|
|
indexPage: 1,
|
|
pageSize: 10,
|
|
qkdat: false, //判断是否清空数据
|
|
actId: "", //判断返回以后是否需要刷新列表
|
|
volunteerList: [], //志愿者列表
|
|
listLength: 0, //数据长度判断是否需要加载
|
|
getImgUrl: "",
|
|
ifClickImage: false, //因为志友多多点击图片查看大图,会出现列表刷新的bug,所以加这个字段进行控制
|
|
showTip: false, //是否显示活动开始前或者活动进行中的tip,
|
|
inProgressId: "", //正在进行或即将进行的活动id
|
|
inProgressTitle: "", //正在进行?true:false
|
|
selectSubTab: "tab0",
|
|
hotLine: "", //咨询热线
|
|
actListName: "",
|
|
heartRankName: "",
|
|
actReviewName: "",
|
|
myActName: "",
|
|
customerId: "",
|
|
},
|
|
|
|
properties: {
|
|
selectedTab: {
|
|
type: String,
|
|
value: "tab0",
|
|
},
|
|
},
|
|
|
|
lifetimes: {
|
|
async ready() {
|
|
await app.doAfterLogin();
|
|
|
|
this.setData({
|
|
statusHeight: app.globalData.statusHeight,
|
|
navigationHeight: app.globalData.navHeight,
|
|
customerId: app.globalData.customerId,
|
|
selectedTab: this.data.selectedTab,
|
|
});
|
|
let params = {
|
|
customerId: app.globalData.customerId,
|
|
};
|
|
api.getHeartConfigs(params).then((res) => {
|
|
this.setData({
|
|
titleName: res.data.titleName,
|
|
hotLine: res.data.hotLine,
|
|
myActName: res.data.myActName,
|
|
heartRankName: res.data.heartRankName,
|
|
actReviewName: res.data.actReviewName,
|
|
actListName: res.data.actListName,
|
|
});
|
|
});
|
|
|
|
this.refreshData();
|
|
},
|
|
},
|
|
|
|
methods: {
|
|
onLoad() {
|
|
this.setData({
|
|
isPage: true,
|
|
});
|
|
},
|
|
|
|
async refreshData() {
|
|
await app.doAfterLogin();
|
|
|
|
this.getInProgress();
|
|
this.setData({
|
|
loadMoreVisible: true,
|
|
loadMoreType: "loading",
|
|
});
|
|
if (this.data.selectedTab == "tab1") {
|
|
//刷新活动回顾
|
|
if (this.data.ifClickImage) {
|
|
//如果为true就不可以刷新,判断完成以后重新置为false
|
|
this.setData({
|
|
ifClickImage: false,
|
|
});
|
|
} else {
|
|
this.setData({
|
|
indexPage: 1,
|
|
});
|
|
this.setData({
|
|
volunteerList: [], //列表置空
|
|
listLength: 0,
|
|
});
|
|
let parms = {
|
|
pageIndex: this.data.indexPage,
|
|
pageSize: this.data.pageSize * this.data.indexPage,
|
|
customerId: app.globalData.customerId,
|
|
};
|
|
this.getVolunteerList(parms);
|
|
}
|
|
} else {
|
|
this.updateActivityList();
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
// this.bannerListV2()
|
|
this.getInProgress();
|
|
wx.stopPullDownRefresh();
|
|
},
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
async onReachBottom() {
|
|
await app.doAfterLogin();
|
|
|
|
if (this.data.listLength === 0) {
|
|
this.setData({
|
|
loadMoreVisible: true,
|
|
loadMoreType: "none",
|
|
});
|
|
} else {
|
|
this.setData({
|
|
loadMoreVisible: true,
|
|
loadMoreType: "loading",
|
|
});
|
|
|
|
if (this.data.selectedTab == "tab0") {
|
|
this.setData({
|
|
indexPage: this.data.indexPage + 1,
|
|
});
|
|
let parms = {
|
|
pageIndex: this.data.indexPage,
|
|
pageSize: this.data.pageSize,
|
|
actType: 0,
|
|
selectedTab: this.data.selectedTab,
|
|
customerId: app.globalData.customerId,
|
|
};
|
|
this.selectComponent("#state-0").getActivityList(parms);
|
|
} else if (this.data.selectedTab == "tab1") {
|
|
this.setData({
|
|
indexPage: this.data.indexPage + 1,
|
|
});
|
|
let parms = {
|
|
pageIndex: this.data.indexPage,
|
|
pageSize: this.data.pageSize,
|
|
customerId: app.globalData.customerId,
|
|
};
|
|
this.getVolunteerList(parms);
|
|
} else if (this.data.selectedTab == "tab2") {
|
|
this.setData({
|
|
indexPage: this.data.indexPage + 1,
|
|
});
|
|
let parms = {
|
|
pageIndex: this.data.indexPage,
|
|
pageSize: this.data.pageSize,
|
|
actType: 1,
|
|
selectedTab: this.data.selectedTab,
|
|
customerId: app.globalData.customerId,
|
|
};
|
|
this.selectComponent("#state-2").getActivityList(parms);
|
|
} else if (this.data.selectedTab == "tab3") {
|
|
this.setData({
|
|
indexPage: this.data.indexPage + 1,
|
|
});
|
|
let parms = {
|
|
pageIndex: this.data.indexPage,
|
|
pageSize: this.data.pageSize,
|
|
type:
|
|
this.data.selectSubTab == "tab0"
|
|
? "auditing"
|
|
: this.data.selectSubTab == "tab1"
|
|
? "passed"
|
|
: this.data.selectSubTab == "tab2"
|
|
? "refused"
|
|
: this.data.selectSubTab == "tab3"
|
|
? "canceld"
|
|
: "auditing",
|
|
actType: 1,
|
|
selectedTab: this.data.selectedTab,
|
|
customerId: app.globalData.customerId,
|
|
};
|
|
this.selectComponent("#state-3").getMyActivityList(parms);
|
|
}
|
|
}
|
|
},
|
|
|
|
// tab 切换
|
|
async tabBarChange(e) {
|
|
await app.doAfterLogin();
|
|
|
|
this.setData({
|
|
loadMoreVisible: true,
|
|
loadMoreType: "loading",
|
|
indexPage: 1,
|
|
selectedTab: e.currentTarget.dataset.tab,
|
|
});
|
|
if (e.currentTarget.dataset.tab == "tab0") {
|
|
let parms = {
|
|
pageIndex: this.data.indexPage,
|
|
pageSize: this.data.pageSize,
|
|
actType: 0, //活动列表类型(0-招募令,1-精彩活动)
|
|
qkdat: true,
|
|
selectedTab: e.currentTarget.dataset.tab,
|
|
customerId: app.globalData.customerId,
|
|
};
|
|
this.selectComponent("#state-0").getActivityList(parms);
|
|
} else if (e.currentTarget.dataset.tab == "tab2") {
|
|
this.setData({
|
|
volunteerList: [], //列表置空
|
|
listLength: 0,
|
|
});
|
|
let parms = {
|
|
pageIndex: this.data.indexPage,
|
|
pageSize: this.data.pageSize,
|
|
customerId: app.globalData.customerId,
|
|
};
|
|
this.getVolunteerList(parms);
|
|
} else if (e.currentTarget.dataset.tab == "tab1") {
|
|
let parms = {
|
|
pageIndex: this.data.indexPage,
|
|
pageSize: this.data.pageSize,
|
|
actType: 1, //活动列表类型(0-招募令,1-精彩活动)
|
|
qkdat: true,
|
|
selectedTab: e.currentTarget.dataset.tab,
|
|
customerId: app.globalData.customerId,
|
|
};
|
|
this.selectComponent("#state-2").getActivityList(parms);
|
|
} else if (e.currentTarget.dataset.tab == "tab3") {
|
|
this.setData({
|
|
selectSubTab: "tab0",
|
|
});
|
|
let parms = {
|
|
pageIndex: this.data.indexPage,
|
|
pageSize: this.data.pageSize,
|
|
actType: 1, //活动列表类型(0-招募令,1-精彩活动)
|
|
qkdat: true,
|
|
type: "auditing",
|
|
selectedTab: e.currentTarget.dataset.tab,
|
|
customerId: app.globalData.customerId,
|
|
};
|
|
this.selectComponent("#state-3").getMyActivityList(parms);
|
|
}
|
|
this.setData({
|
|
selectedTab: e.currentTarget.dataset.tab,
|
|
});
|
|
},
|
|
// 返回以后刷新列表
|
|
updateActivityList() {
|
|
if (this.data.selectedTab === "tab0") {
|
|
let params = {
|
|
pageIndex: 1,
|
|
pageSize: this.data.indexPage * this.data.pageSize,
|
|
customerId: app.globalData.customerId,
|
|
};
|
|
this.selectComponent("#state-0").updateActivityList(params);
|
|
} else if (this.data.selectedTab === "tab2") {
|
|
let params = {
|
|
pageIndex: 1,
|
|
pageSize: this.data.indexPage * this.data.pageSize,
|
|
customerId: app.globalData.customerId,
|
|
};
|
|
this.selectComponent("#state-2").updateActivityList(params);
|
|
} else if (this.data.selectedTab === "tab3") {
|
|
let params = {
|
|
pageIndex: 1,
|
|
pageSize: this.data.indexPage * this.data.pageSize,
|
|
type:
|
|
this.data.selectSubTab == "tab0"
|
|
? "auditing"
|
|
: this.data.selectSubTab == "tab1"
|
|
? "passed"
|
|
: this.data.selectSubTab == "tab2"
|
|
? "refused"
|
|
: this.data.selectSubTab == "tab3"
|
|
? "canceld"
|
|
: "auditing",
|
|
customerId: app.globalData.customerId,
|
|
};
|
|
this.selectComponent("#state-3").updateMyActivityList(params);
|
|
}
|
|
|
|
this.setData({
|
|
actId: "",
|
|
});
|
|
},
|
|
// 志愿者列表
|
|
getVolunteerList(params) {
|
|
let that = this;
|
|
api.getVolunteerList(params).then(function (res) {
|
|
if (res.data.length !== that.data.pageSize) {
|
|
that.setData({
|
|
loadMoreVisible: true,
|
|
loadMoreType: "none",
|
|
});
|
|
}
|
|
that.setData({
|
|
listLength: res.data.length,
|
|
volunteerList: that.data.volunteerList.concat(res.data),
|
|
});
|
|
});
|
|
},
|
|
//返回上一级
|
|
goback() {
|
|
wx.navigateBack({
|
|
delta: 1,
|
|
});
|
|
},
|
|
// banner 切换
|
|
swiperChange: function (e) {
|
|
this.setData({
|
|
currentSwiper: e.detail.current,
|
|
});
|
|
},
|
|
// 通过判断列表的长度断定是否显示加载中
|
|
toActDetailDown(e) {
|
|
if (e.detail.listLength !== this.data.pageSize) {
|
|
this.setData({
|
|
loadMoreVisible: true,
|
|
loadMoreType: "none",
|
|
});
|
|
}
|
|
this.setData({
|
|
actId: e.detail.actId,
|
|
listLength: e.detail.listLength,
|
|
});
|
|
},
|
|
|
|
clickImage(e) {
|
|
this.setData({
|
|
ifClickImage: e.detail,
|
|
});
|
|
},
|
|
|
|
bannerListV2: function () {
|
|
let that = this;
|
|
let params = {
|
|
bannerType: "0",
|
|
};
|
|
api.bannerList(params).then(function (res) {
|
|
that.setData({
|
|
banner: res.data,
|
|
});
|
|
wx.stopPullDownRefresh();
|
|
});
|
|
},
|
|
// 获取配置图片
|
|
getImgUrl: function () {
|
|
//0:咨询热线
|
|
let that = this;
|
|
api.getImgUrl("0").then(function (res) {
|
|
that.setData({
|
|
getImgUrl: res.data[0],
|
|
});
|
|
});
|
|
},
|
|
|
|
//跳转志愿者认证页面
|
|
async govolunteer(e) {
|
|
const { msg, data } = await wxGetUserProfile({
|
|
desc: "用于完善居民信息",
|
|
});
|
|
if (msg == "success") {
|
|
let param = {
|
|
nickName: data.userInfo.nickName,
|
|
gender: data.userInfo.gender,
|
|
avatarUrl: data.userInfo.avatarUrl,
|
|
province: data.userInfo.province,
|
|
country: data.userInfo.country,
|
|
city: data.userInfo.city,
|
|
};
|
|
api.updateWxUserInfo(param).then((res) => {
|
|
wx.navigateTo({
|
|
url: "/subpages/heart/pages/volunteer/volunteer?from=index",
|
|
});
|
|
});
|
|
} else {
|
|
wx.showModal({
|
|
title: "提示",
|
|
content: "请先授权",
|
|
showCancel: false,
|
|
confirmText: "确定",
|
|
success: function (res) {
|
|
if (res.confirm) {
|
|
console.log("用户点击了“返回授权”");
|
|
}
|
|
},
|
|
});
|
|
}
|
|
},
|
|
|
|
//拨打电话
|
|
getPhone(e) {
|
|
// return false
|
|
wx.showModal({
|
|
title: "拨打电话",
|
|
content: "",
|
|
cancelColor: "#29B9A5",
|
|
confirmColor: "#29B9A5",
|
|
success: (res) => {
|
|
if (res.confirm) {
|
|
console.log("用户点击确定");
|
|
wx.makePhoneCall({
|
|
phoneNumber: e.currentTarget.dataset.number,
|
|
});
|
|
} else if (res.cancel) {
|
|
console.log("用户点击取消");
|
|
}
|
|
},
|
|
});
|
|
},
|
|
getInProgress() {
|
|
api.getInProgress().then((res) => {
|
|
if (res.data.length > 0) {
|
|
this.setData({
|
|
inProgressTitle: res.data[0].title,
|
|
inProgressId: res.data[0].actId,
|
|
showTip: true,
|
|
});
|
|
} else {
|
|
this.setData({
|
|
showTip: false,
|
|
});
|
|
}
|
|
});
|
|
},
|
|
subTabChange(e) {
|
|
this.setData({
|
|
loadMoreVisible: true,
|
|
loadMoreType: "loading",
|
|
indexPage: 1,
|
|
selectSubTab: e.currentTarget.dataset.subtab,
|
|
});
|
|
let params = {
|
|
pageIndex: 1,
|
|
pageSize: this.data.pageSize,
|
|
actType: 1,
|
|
type: "auditing",
|
|
actId: this.data.actId,
|
|
selectedTab: this.data.selectedTab,
|
|
customerId: app.globalData.customerId,
|
|
qkdat: true,
|
|
};
|
|
if (e.currentTarget.dataset.subtab == "tab1") {
|
|
params.type = "passed";
|
|
} else if (e.currentTarget.dataset.subtab == "tab2") {
|
|
params.type = "refused";
|
|
} else if (e.currentTarget.dataset.subtab == "tab3") {
|
|
params.type = "canceld";
|
|
}
|
|
this.selectComponent("#state-3").getMyActivityList(params);
|
|
},
|
|
goDial(e) {
|
|
const { tel } = e.target.dataset;
|
|
wx.makePhoneCall({
|
|
phoneNumber: tel,
|
|
});
|
|
},
|
|
toTipDetail(e) {
|
|
const {
|
|
target: {
|
|
dataset: { actid },
|
|
},
|
|
} = e;
|
|
wx.navigateTo({
|
|
url: `/subpages/heart/pages/heartDetail/heartDetail?id=${actid}`,
|
|
});
|
|
},
|
|
},
|
|
});
|
|
|