|
|
// pages/mine/pages/PushSettings/index.js
|
|
|
const app = getApp();
|
|
|
Page({
|
|
|
data: {
|
|
|
result: ['1', '2', '3'],
|
|
|
weekList: ['1', '2', '3', '4', '5', '6', '7'],
|
|
|
checked: false,
|
|
|
sSeriesName: '',
|
|
|
brand: '',
|
|
|
Id: "",
|
|
|
comfirmShow: false,
|
|
|
EmailStart:'',
|
|
|
EmailEnd:'',
|
|
|
date: '',
|
|
|
date2: '',
|
|
|
end: '18:02',
|
|
|
start:'10:00'
|
|
|
},
|
|
|
onLoad() {
|
|
|
wx.setNavigationBarTitle({
|
|
|
title: '推送设置'
|
|
|
})
|
|
|
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: '修改成功',
|
|
|
});
|
|
|
}).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 == "") {
|
|
|
this.setData({
|
|
|
comfirmShow: true
|
|
|
})
|
|
|
} 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,
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
app.globalData.request(data).then(() => {
|
|
|
wx.setStorageSync("setBrand", this.data.brand);
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '设置成功!'
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
//星期
|
|
|
bindTimeChange: function(e) {
|
|
|
console.log('picker发送选择改变,携带值为', e.detail.value)
|
|
|
this.setData({
|
|
|
time: e.detail.value
|
|
|
})
|
|
|
},
|
|
|
onChange2(event) {
|
|
|
wx.setStorageSync('WxWeek', event.detail.toString());
|
|
|
this.setData({
|
|
|
weekList: event.detail,
|
|
|
});
|
|
|
},
|
|
|
// 点击日期组件确定事件
|
|
|
bindDateChange: function (e) {
|
|
|
let isBefore = moment(this.data.date2).isBefore(e.detail.value)
|
|
|
if (!isBefore) {
|
|
|
iPageIndex = 1
|
|
|
iPageSize = 20
|
|
|
this.setData({
|
|
|
date: e.detail.value,
|
|
|
ranking: [],
|
|
|
})
|
|
|
this.getData()
|
|
|
} else {
|
|
|
this.setData({
|
|
|
showDialog: isBefore,
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
bindDateChange2: function (e) {
|
|
|
this.setData({
|
|
|
time2: e.detail.value
|
|
|
})
|
|
|
},
|
|
|
Emailpush() {
|
|
|
let data = {
|
|
|
action: "saveSwsQyWarningConf",
|
|
|
token: wx.getStorageSync('token') || 't%2BrswgjvzGM=',
|
|
|
data: JSON.stringify({
|
|
|
WxWeek: this.data.weekList.toString(),
|
|
|
EmailWeek: this.data.weekList.toString(),
|
|
|
EmailStart:this.data.EmailStart,
|
|
|
EmailEnd:this.data.EmailEnd,
|
|
|
WxStart:this.data.date,
|
|
|
WxEnd:this.data.date2
|
|
|
})
|
|
|
}
|
|
|
app.globalData.request(data).then(() => {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '设置成功!'
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
|
|
|
}) |