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.

130 lines
3.1 KiB

3 years ago
const app = getApp();
Page({
3 years ago
data: {
result: ['1', '2', '3'],
3 years ago
checked: true,
3 years ago
sSeriesName: '',
brand: '',
Id: "",
comfirmShow: false,
},
onLoad() {
wx.setNavigationBarTitle({
3 years ago
title: '危机消息预警设置'
3 years ago
})
let pages = getCurrentPages();
let currentPage = pages[pages.length - 1]
let options = currentPage.options
this.setData({
brand: options.brand
})
},
onShow() {
this.getSwsQyQuartz()
},
getSwsQyQuartz() {
let obj = {
action: "getSwsQyQuartzList",
pid: 'brand',
token: wx.getStorageSync('token') || 't%2BrswgjvzGM='
}
let setBrand = wx.getStorageSync("setBrand");
if (this.data.brand != setBrand) {
wx.setStorageSync("sSeriesArr", '');
}
app.globalData.request(obj).then(res => {
let data = res[0];
let Es = data.Es || {};
let Id = data.Id || "";
let crisis = Es.Crisis ? Es.Crisis.split(",") : [];
let seriesNames = wx.getStorageSync("sSeriesArr") || '';
let checked = data.Statu == 0 ? true : false
this.setData({
Id: Id,
result: this.data.brand == Es.Brands ? crisis : [],
sSeriesName: seriesNames,
checked: this.data.brand == Es.Brands ? checked : false
})
wx.setStorageSync("setBrand", this.data.brand);
})
},
onChange(event) {
wx.setStorageSync('sCrisis', event.detail.toString());
this.setData({
result: event.detail,
});
},
onChange1({
detail
}) {
let Statu = detail ? 0 : 1; //开启0 停止1
this.setData({
checked: detail
});
let data = {
action: 'addOrUpdSwsQyQuartzList',
data: JSON.stringify({
Id: this.data.Id,
Statu: Statu
}),
token: wx.getStorageSync('token') || 't%2BrswgjvzGM='
}
app.globalData.request(data).then(res => {
if (res = [])
wx.showModal({
title: '提示',
content: '修改成功',
3 years ago
});
3 years ago
}).catch(err => {
wx.showModal({
title: '提示',
content: err.Msg,
})
});
},
handlerModel() {
app.globalData.request({
action: 'getUserMainBrand',
token: wx.getStorageSync('token') || 't%2BrswgjvzGM='
}).then(res => {
wx.navigateTo({
url: '/pages/brandCrisis/chooseModel/index?brand=' + res
})
})
},
saveComfirm() {
if (this.data.checked == true) {
if (this.data.sSeriesName == "") {
3 years ago
this.setData({
3 years ago
comfirmShow: true
3 years ago
})
3 years ago
} else {
this.save();
}
} else {
this.save();
}
},
save() {
let data = {
action: "addOrUpdSwsQyQuartzList",
token: wx.getStorageSync('token') || 't%2BrswgjvzGM=',
data: JSON.stringify({
Id: this.data.Id,
WeiXinID: wx.getStorageSync('openid'),
Es: {
Brands: this.data.brand,
Crisis: this.data.result.toString(),
SeriesNames: this.data.sSeriesName,
3 years ago
}
3 years ago
})
}
app.globalData.request(data).then(() => {
wx.setStorageSync("setBrand", this.data.brand);
wx.showModal({
title: '提示',
content: '设置成功!'
})
})
},
3 years ago
})