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.

227 lines
5.2 KiB

3 years ago
// pages/mine/pages/PushSettings/index.js
const app = getApp();
3 years ago
import moment from "moment";
3 years ago
Page({
data: {
weekList: ['1', '2', '3', '4', '5', '6', '7'],
3 years ago
EmailStart: '',
EmailEnd: '',
time: '',
time2: '',
// 是否推送信息
checked2: true,
checked: true,
Uid: '',
start: "00:00",
end: "00:00"
3 years ago
},
onLoad() {
wx.setNavigationBarTitle({
title: '推送设置'
})
},
onShow() {
3 years ago
this.getSwsQyQuartz2()
// this.getSwsQyQuartz()
3 years ago
},
3 years ago
getSwsQyQuartz2() {
3 years ago
let obj = {
3 years ago
action: "getSwsQyWarningConf",
3 years ago
token: wx.getStorageSync('token')
3 years ago
}
app.globalData.request(obj).then(res => {
let data = res[0];
3 years ago
let Uid = data.Uid || "";
let weekList = data.WxWeek ? data.WxWeek.split(",") : [];
let weekList2 = data.EmailWeek ? data.EmailWeek.split(",") : [];
let weekList3 = data.EmailWeek ? data.EmailWeek.split(",") : data.WxWeek.split(",");
if (data.WxWeek == []) {
this.setData({
Uid: Uid,
weekList: weekList2,
time: data.EmailStart,
time2: data.EmailEnd,
checked: false,
checked2: true,
})
} else if (data.EmailWeek == []) {
this.setData({
Uid: Uid,
weekList: weekList,
time: data.WxStart,
time2: data.WxEnd,
checked: true,
checked2: false,
})
} else {
this.setData({
Uid: Uid,
weekList: weekList3,
time: data.WxStart,
time2: data.WxEnd,
time: data.EmailStart,
time2: data.EmailEnd,
checked: true,
checked2: true,
})
}
3 years ago
})
3 years ago
3 years ago
},
onChange1({
detail
}) {
this.setData({
checked: detail
});
},
handlerModel() {
app.globalData.request({
action: 'getUserMainBrand',
3 years ago
token: wx.getStorageSync('token')
3 years ago
}).then(res => {
wx.navigateTo({
url: '/pages/brandCrisis/chooseModel/index?brand=' + res
})
})
},
3 years ago
//星期
bindTimeChange: function (e) {
let isBefore = moment(this.data.time2).isBefore(e.detail.value)
if (!isBefore) {
this.setData({
time: e.detail.value
})
3 years ago
} else {
3 years ago
this.setData({
showDialog: isBefore,
3 years ago
})
}
3 years ago
3 years ago
},
3 years ago
bindDateChange2: function (e) {
let isBefore = moment(this.data.time2).isBefore(e.detail.value)
3 years ago
if (!isBefore) {
this.setData({
3 years ago
time2: e.detail.value
3 years ago
})
} else {
this.setData({
showDialog: isBefore,
})
}
},
3 years ago
onChange2(event) {
wx.setStorageSync('WxWeek', event.detail.toString());
3 years ago
this.setData({
3 years ago
weekList: event.detail,
});
3 years ago
},
3 years ago
// onChange3(event) {
// wx.setStorageSync('EmailWeek', event.detail.toString());
// this.setData({
// result: event.detail,
// });
// },
3 years ago
Emailpush() {
3 years ago
if (this.data.checked == false) {
let data = {
action: "saveSwsQyWarningConf",
3 years ago
token: wx.getStorageSync('token'),
3 years ago
data: JSON.stringify({
WxWeek: "",
EmailWeek: this.data.weekList.toString(),
EmailStart: this.data.time || "",
EmailEnd: this.data.time2 || "",
WxStart: "",
WxEnd: "",
})
}
app.globalData.request(data).then(() => {
wx.showModal({
title: '提示',
content: '设置成功!',
success(res) {
if (res.confirm) {
wx.navigateBack({
delta: 1
});
} else {
}
}
})
3 years ago
})
3 years ago
} else if (this.data.checked2 == false) {
let data = {
action: "saveSwsQyWarningConf",
3 years ago
token: wx.getStorageSync('token'),
3 years ago
data: JSON.stringify({
WxWeek: this.data.weekList.toString(),
EmailWeek: "",
EmailStart: "",
EmailEnd: "",
WxStart: this.data.time || "",
WxEnd: this.data.time2 || "",
})
}
app.globalData.request(data).then(() => {
wx.showModal({
title: '提示',
content: '设置成功!',
success(res) {
if (res.confirm) {
wx.navigateBack({
delta: 1
});
} else {
}
}
})
3 years ago
})
3 years ago
} else {
let data = {
action: "saveSwsQyWarningConf",
3 years ago
token: wx.getStorageSync('token'),
3 years ago
data: JSON.stringify({
WxWeek: this.data.weekList.toString(),
EmailWeek: this.data.weekList.toString(),
EmailStart: this.data.time || "",
EmailEnd: this.data.time2 || "",
WxStart: this.data.time || "",
WxEnd: this.data.time2 || "",
})
}
app.globalData.request(data).then(() => {
wx.showModal({
title: '提示',
content: '设置成功!',
success(res) {
if (res.confirm) {
wx.navigateBack({
delta: 1
});
} else {
}
}
})
})
}
},
Emailalert({
detail
}) {
// 需要手动对 checked 状态进行更新
// if(){
// }
this.setData({
checked2: detail
});
3 years ago
},
})