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.

131 lines
2.7 KiB

3 years ago
// pages/varComm/pages/addEvent/index.js
const app = getApp()
Page({
3 years ago
/**
* 页面的初始数据
*/
data: {
active: 0,
result: [],
themeList: [],
themeData: [],
issList: [],
titleList: [{
title: '我的主题',
index: 0,
active: true
}, {
title: '往期主题',
index: 1,
active: false
}]
},
3 years ago
3 years ago
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getData()
if (options.switchTheme) {
let switchTheme = JSON.parse(options.switchTheme)
this.setData({
switchTheme
})
}
},
onUnload() {
if (this.data.switchTheme) {
this.back('switch')
}
},
changeTitle(e) {
let index = e.currentTarget.dataset.index
let arr = this.data.titleList
for (let [index1, i] of arr.entries()) {
if (index1 == index) {
i.active = true
} else {
i.active = false
}
}
this.setData({
titleList: arr,
active: index
})
this.getData()
},
onChange(event) {
const {
detail
} = event
let themeData = []
for (let i of detail) {
themeData.push(JSON.parse(i))
}
themeData.len = 6
this.setData({
result: detail,
themeData,
})
wx.setStorageSync('themeData', themeData)
this.setData({
hasAdd: true
})
this.back('add')
},
back(type) {
if (type == 'add') {
wx.navigateBack({
delta: 1,
})
} else if (type == "switch" && !this.data.hasAdd) {
let {
themeData
} = this.data
themeData.push(this.data.switchTheme)
wx.setStorageSync('themeData', themeData)
}
},
getData() {
let themeData = wx.getStorageSync('themeData')
let result = []
themeData.forEach(ele => {
if (ele) result.push(JSON.stringify(ele)), this.data.themeData.push(ele)
})
this.setData({
result
})
app.globalData.request({
action: 'getSchemeDataToTheme',
3 years ago
token: app.globalData.getStorage('token'),
3 years ago
pageSize: 100,
sType: this.data.active == 0 ? 'now' : 'former'
}).then(res => {
for (let i of themeData) {
if (i) {
for (let j = 0; j < res.length; j++) {
if (i.Id == res[j].Id) {
res.splice(j, 1)
3 years ago
}
3 years ago
}
3 years ago
}
3 years ago
}
this.setData({
themeList: res
})
})
3 years ago
3 years ago
// app.globalData.request({
// action: 'getSchemeDataToTheme',
3 years ago
// token: app.globalData.getStorage('token'),
3 years ago
// sType: 'former',
// pageSize:100,
// }).then(res => {
// this.setData({
// issList: res
// })
// })
}
3 years ago
})