|
|
|
// pages/varComm/pages/addEvent/index.js
|
|
|
|
const app = getApp()
|
|
|
|
Page({
|
|
|
|
data: {
|
|
|
|
searchValue: '',
|
|
|
|
eventList: [],
|
|
|
|
result: [],
|
|
|
|
eventData: [],
|
|
|
|
sBrand: '',
|
|
|
|
option1: [{
|
|
|
|
text: '品牌选择',
|
|
|
|
value: ""
|
|
|
|
}, ],
|
|
|
|
option2: [{
|
|
|
|
text: '车型选择',
|
|
|
|
value: ''
|
|
|
|
}, ],
|
|
|
|
option3: [{
|
|
|
|
text: '事件类型',
|
|
|
|
value: ''
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: '自燃',
|
|
|
|
value: '自燃'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: '领导人',
|
|
|
|
value: '领导人'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: '维权',
|
|
|
|
value: '维权'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: '车展',
|
|
|
|
value: '车展'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: '裁员',
|
|
|
|
value: '裁员'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: '产品代言',
|
|
|
|
value: '产品代言'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: '新车上市',
|
|
|
|
value: '新车上市'
|
|
|
|
},
|
|
|
|
],
|
|
|
|
sSeriesName: '',
|
|
|
|
sQuDao: '',
|
|
|
|
},
|
|
|
|
getData() {
|
|
|
|
let eventData = wx.getStorageSync('eventData')
|
|
|
|
let result = []
|
|
|
|
eventData.forEach(ele => {
|
|
|
|
if (ele) result.push(JSON.stringify(ele)), this.data.eventData.push(ele)
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
result
|
|
|
|
})
|
|
|
|
|
|
|
|
app.globalData.request({
|
|
|
|
action: 'getEventList',
|
|
|
|
token: wx.getStorageSync('token'),
|
|
|
|
sType: 'HotLibraryC',
|
|
|
|
// ...param,
|
|
|
|
sTimeType: 20
|
|
|
|
}).then(res => {
|
|
|
|
for (let i of eventData) {
|
|
|
|
if (i) {
|
|
|
|
for (let j = 0; j < res.length; j++) {
|
|
|
|
if (i.Id == res[j].Id) {
|
|
|
|
res.splice(j, 1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
eventList: res
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
checkChange(event) {
|
|
|
|
const {
|
|
|
|
detail
|
|
|
|
} = event
|
|
|
|
let eventData = []
|
|
|
|
for (let i of detail) {
|
|
|
|
eventData.push(JSON.parse(i))
|
|
|
|
}
|
|
|
|
eventData.lenght = 2
|
|
|
|
this.setData({
|
|
|
|
result: detail,
|
|
|
|
eventData,
|
|
|
|
})
|
|
|
|
// console.log('cz',arr)
|
|
|
|
wx.setStorageSync('eventData', eventData)
|
|
|
|
this.setData({
|
|
|
|
hasAdd: true
|
|
|
|
})
|
|
|
|
this.back('add')
|
|
|
|
},
|
|
|
|
back(type) {
|
|
|
|
if (type == 'add') {
|
|
|
|
wx.navigateBack({
|
|
|
|
delta: 1,
|
|
|
|
})
|
|
|
|
} else if (type == "switch" && !this.data.hasAdd) {
|
|
|
|
console.log("执行切换");
|
|
|
|
let {
|
|
|
|
eventData
|
|
|
|
} = this.data
|
|
|
|
eventData.push(this.data.switchEvent)
|
|
|
|
wx.setStorageSync('eventData', eventData)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
brandChange(e) {
|
|
|
|
let {
|
|
|
|
detail
|
|
|
|
} = e
|
|
|
|
app.globalData.request({
|
|
|
|
action: 'getUserSeriesName',
|
|
|
|
token: wx.getStorageSync('token'),
|
|
|
|
sBrandName: detail
|
|
|
|
}).then(res => {
|
|
|
|
let arr = [{
|
|
|
|
text: '车型选择',
|
|
|
|
value: ''
|
|
|
|
}]
|
|
|
|
for (let i of res) {
|
|
|
|
let obj = {
|
|
|
|
text: i.name,
|
|
|
|
value: i.name
|
|
|
|
}
|
|
|
|
arr.push(obj)
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
option2: arr,
|
|
|
|
sSeriesName: ''
|
|
|
|
})
|
|
|
|
this.getData({
|
|
|
|
sBrand: detail,
|
|
|
|
sSeriesName: this.data.sSeriesName,
|
|
|
|
sQuDao: this.data.sQuDao,
|
|
|
|
sTitle: this.data.searchValue
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
sQuDaoChange(e) {
|
|
|
|
let {
|
|
|
|
detail
|
|
|
|
} = e
|
|
|
|
this.setData({
|
|
|
|
sQuDao: detail
|
|
|
|
})
|
|
|
|
this.getData({
|
|
|
|
sBrand: this.data.sBrand,
|
|
|
|
sSeriesName: this.data.sSeriesName,
|
|
|
|
sQuDao: detail,
|
|
|
|
sTitle: this.data.searchValue
|
|
|
|
})
|
|
|
|
},
|
|
|
|
seriesNameChange(e) {
|
|
|
|
let {
|
|
|
|
detail
|
|
|
|
} = e
|
|
|
|
this.setData({
|
|
|
|
sSeriesName: detail
|
|
|
|
})
|
|
|
|
this.getData({
|
|
|
|
sBrand: this.data.sBrand,
|
|
|
|
sSeriesName: detail,
|
|
|
|
sQuDao: this.data.sQuDao,
|
|
|
|
sTitle: this.data.searchValue
|
|
|
|
})
|
|
|
|
},
|
|
|
|
onChange(e) {
|
|
|
|
let {
|
|
|
|
detail
|
|
|
|
} = e
|
|
|
|
this.setData({
|
|
|
|
searchValue: detail
|
|
|
|
})
|
|
|
|
},
|
|
|
|
onSearch(e) {
|
|
|
|
this.getData({
|
|
|
|
sBrand: this.data.sBrand,
|
|
|
|
sSeriesName: this.data.sSeriesName,
|
|
|
|
sQuDao: this.data.sQuDao,
|
|
|
|
sTitle: e.detail
|
|
|
|
})
|
|
|
|
},
|
|
|
|
onClick() {
|
|
|
|
this.getData({
|
|
|
|
sBrand: this.data.sBrand,
|
|
|
|
sSeriesName: this.data.sSeriesName,
|
|
|
|
sQuDao: this.data.sQuDao,
|
|
|
|
sTitle: this.data.searchValue
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad(options) {
|
|
|
|
this.getData()
|
|
|
|
app.globalData.request({
|
|
|
|
action: 'getUserBrand',
|
|
|
|
token: wx.getStorageSync('token'),
|
|
|
|
}).then(res => {
|
|
|
|
let arr = [{
|
|
|
|
text: '品牌选择',
|
|
|
|
value: ""
|
|
|
|
}, ]
|
|
|
|
for (let i of res) {
|
|
|
|
if (i.firstword == '热门') continue
|
|
|
|
let obj = {
|
|
|
|
text: i.brandname,
|
|
|
|
value: i.brandname
|
|
|
|
}
|
|
|
|
arr.push(obj)
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
option1: arr
|
|
|
|
})
|
|
|
|
})
|
|
|
|
if (options.switchEvent) {
|
|
|
|
let switchEvent = JSON.parse(options.switchEvent)
|
|
|
|
this.setData({
|
|
|
|
switchEvent
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onUnload() {
|
|
|
|
// if(this.data.switchEvent && !this.data.hasAdd){
|
|
|
|
// let boxArr = wx.getStorageSync('eventData')
|
|
|
|
// boxArr.push(this.data.switchEvent)
|
|
|
|
// wx.setStorageSync('eventData', boxArr)
|
|
|
|
// }
|
|
|
|
if (this.data.switchEvent) {
|
|
|
|
this.back('switch')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|