Files
ClassContent/项目合集/校园失物招领/min-tpl/pages/user/user.js
2024-09-27 02:06:13 +08:00

142 lines
3.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const {
user,
util
} = getApp().globalData
Page({
/**
* 页面的初始数据
*/
data: {
userInfo: {},
thingTypeArr: [
{text: '失物招领', nums: 20, path: '/pages/history/history?id=1'},
{text: '寻物启事', nums: 100, path: '/pages/history/history?id=2'},
],
listArr: [
{text: '关于', icon: 'icon-guanyu', path: '', is: false},
{text: '反馈', icon: 'icon-jianyi', path: '', is: false},
{text: '帮助', icon: 'icon-bangzhu', path: '', is: false},
{text: '协议', icon: 'icon-_buchongxieyi', path: '', is: false},
{text: '退 出 登 录', icon: 'icon-shouji', path: '', is: true},
],
StatisticsList: {}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
if (util.checkIsLogin()) {
this.setData({
userInfo: wx.getStorageSync('user')
}, () => this.Statistics());
}
},
enterHistory(e) {
wx.navigateTo({
url: e.currentTarget.dataset.path
})
},
enterEdit() {
wx.navigateTo({ url: '/pages/edit/edit' })
},
async Statistics() {
let { userInfo } = this.data;
let res = await user.Statistics({
user_id: userInfo.user_id
});
this.setData({
[`thingTypeArr[0].nums`]: res.lose_matter,
[`thingTypeArr[1].nums`]: res.search_matter,
})
},
tagClick(e) {
let {listArr} = this.data;
let { index } = e.currentTarget.dataset;
if (listArr[index].is) {
wx.showModal({
title: '提示',
content: '确定退出账户吗?',
success(res) {
if (res.confirm) {
wx.clearStorageSync();
wx.switchTab({url: '/pages/index/index'})
}
}
})
} else {
switch (index) {
case 0:
wx.showModal({
title: '关于',
content: '校园失物招领管理系统(拾金小程序)的主要功能就是帮助校内同学更快的找到自己的丢失之物。\n小程序系统UI界面简洁清晰、用户操作简易、没有繁杂的信息流、广告弹窗等众多干扰元素、减少使用成本提高使用效率增强用户粘性和归属感为同学们提供最便捷优质的服务。',
showCancel: false
})
break;
case 1:
break;
case 2:
break;
case 3:
break;
}
}
// console.log("index ",e.currentTarget.dataset.index)
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})