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.

430 lines
10 KiB

import moment from "moment"
const app = getApp();
Page({
data: {
steps: [{
text: '名称设置',
inactiveIcon: 'more-o',
activeIcon: 'more',
},
{
text: '分析词设置',
inactiveIcon: 'more-o',
activeIcon: 'more',
},
{
text: '定向监测',
inactiveIcon: 'more-o',
activeIcon: 'more',
}
],
//表单
Name: '',
StartTime: new Date().setMonth((new Date().getMonth() - 1)),
EndTime: new Date().getTime(),
DetailsData: [],
AnalyzeWord: '', // 和 或 的主体词
HuoWord: '', // 和 或 的可选词
PaiChu: '', // 排除词
highAnalizeWord: '', // 高级模式分析词
Source: '', // 定向监测媒体
UserAuthor: '', // 定向监测作者
//
active: 0,
activeNames: [],
show1: false,
show2: false,
dt: '',
dt2: '',
// 总体模式
totalMode: 0, // 0便捷 1高级
/* 分析词设置 */
currWordType: '必选词和的关系',
wtShow: false,
wtColumns: ['必选词和的关系', '主题词或的关系'],
// 是否推送信息
Statu: 1,
// 预警选项
affList: [],
qgList: [{
key: 1,
value: "正面",
isSelect: false
},
{
key: 2,
value: "负面",
isSelect: false
},
{
key: 3,
value: "中性",
isSelect: false
}
],
wjList: [{
key: 1,
value: '低级危机',
isSelect: false
},
{
key: 2,
value: '中级危机',
isSelect: false
},
{
key: 3,
value: '高级危机',
isSelect: false
}
],
checkedshow: false
},
onShow() {
this.getApi();
},
getApi() {
app.globalData.request({
action: 'getQuDao', //获取所有渠道
token: wx.getStorageSync('token') || 't%2BrswgjvzGM=',
}).then(res => {
res.forEach(ele => {
ele.isSelect = false;
})
this.setData({
affList: res
})
});
},
changeSource(event) {
let that = this;
let val = event.currentTarget.dataset.value;
if (val.key == -1 && val.isSelect == false) {
that.data.affList.forEach(ele => {
ele.isSelect = true;
})
} else if (val.key == -1 && val.isSelect == true) {
that.data.affList.forEach(ele => {
ele.isSelect = false;
})
} else {
that.data.affList[0].isSelect = false;
}
if (val.key == -1) {
this.setData({
affList: that.data.affList
});
} else {
that.data.affList[val.key].isSelect = !that.data.affList[val.key].isSelect;
this.setData({
affList: that.data.affList
});
};
},
changeQingGan(event) {
let that = this;
let val = event.currentTarget.dataset.value;
that.data.qgList[val.key - 1].isSelect = !that.data.qgList[val.key - 1].isSelect;
this.setData({
qgList: that.data.qgList
});
},
changeWeiJi(event) {
let that = this;
let val = event.currentTarget.dataset.value;
that.data.wjList[val.key - 1].isSelect = !that.data.wjList[val.key - 1].isSelect;
this.setData({
wjList: that.data.wjList
});
},
//表单
themeNameInput(event) {
this.setData({
Name: event.detail.value
})
},
//
changeTips(value) {
this.setData({
activeNames: value.detail,
});
},
onConfirm(event) {
var time = event.detail
this.setData({
show1: false,
StartTime: time,
start: moment(time).format('YYYY-MM-DD HH:mm:ss') //显示
});
},
onConfirm2(event) {
var time = event.detail
this.setData({
show2: false,
EndTime: time,
end: moment(time).format('YYYY-MM-DD HH:mm:ss') //显示
});
},
onDisplay() {
this.setData({
show1: true
});
},
onDisplay2() {
this.setData({
show2: true
});
},
onCancel() {
this.setData({
show1: false,
});
},
onCancel2() {
this.setData({
show2: false,
});
},
changeTotalMode(event) {
this.setData({
totalMode: event.detail.index
});
},
wordType() {
this.setData({
wtShow: true
});
},
wtConfirm(event) {
this.setData({
wtShow: false,
currWordType: event.detail.value
});
},
wtCancel() {
this.setData({
wtShow: false
});
},
infoPushChange(event) {
if (event.detail == 0) {
this.setData({
checkedshow: true,
Statu: event.detail
})
} else {
this.setData({
checkedshow: false,
Statu: event.detail
});
}
},
goBeforeStep() {
this.setData({
active: this.data.active - 1
})
},
goNextStep() {
let that = this;
if (this.data.active == 0) {
if (this.data.Name == '' || this.data.StartTime == '' || this.data.EndTime == '') {
wx.showModal({
title: '提示',
content: "主题名称、开始时间、结束时间不能为空",
success: function (res) {
if (res.confirm) {
that.setData({
active: that.data.active
})
}
}
});
} else if (this.data.StartTime > this.data.EndTime) {
wx.showModal({
title: '提示',
content: "开始时间不能大于结束时间",
success: function (res) {
if (res.confirm) {
that.setData({
active: that.data.active
})
}
}
});
} else {
this.setData({
active: this.data.active + 1
})
}
} else if (this.data.active == 1) {
if (this.data.totalMode == 1) {
if (this.data.highAnalizeWord == "") {
wx.showModal({
title: '提示',
content: "分析词不能为空",
success: function (res) {
if (res.confirm) {
that.setData({
active: that.data.active
})
}
}
});
} else {
this.setData({
active: this.data.active + 1
})
}
} else {
if (this.data.AnalyzeWord == "") {
wx.showModal({
title: '提示',
content: "必选词词不能为空",
success: function (res) {
if (res.confirm) {
that.setData({
active: that.data.active
})
}
}
});
} else {
this.setData({
active: this.data.active + 1
})
}
}
}
},
// 分析词设置
bindAnalyzeWord(event) {
this.setData({
AnalyzeWord: event.detail.value
})
},
bindHuoWord(event) {
this.setData({
HuoWord: event.detail.value
})
},
bindPaiChu(event) {
this.setData({
PaiChu: event.detail.value
})
},
bindHighAnalizeWord(event) {
this.setData({
highAnalizeWord: event.detail.value
})
},
// 定向监测
bindSource(event) {
this.setData({
Source: event.detail.value
})
},
bindUserAuthor(event) {
this.setData({
UserAuthor: event.detail.value
})
},
themeSave() {
let qdList = [];
this.data.affList.forEach(ele => {
if (ele.isSelect && ele.key != -1) {
qdList.push(ele.key)
}
});
// let qgList = [];
// this.data.qgList.forEach(ele => {
// if (ele.isSelect && ele.key != -1) {
// qgList.push(ele.key)
// }
// });
let wjList = [];
this.data.wjList.forEach(ele => {
if (ele.isSelect && ele.key != -1) {
wjList.push(ele.key)
}
});
let Statu = this.data.Statu
if (Statu == 0) {
let dtData = {
"AnalyzeWord": this.data.totalMode == 1 ? this.data.highAnalizeWord.replace("+","%2B") : this.data.AnalyzeWord.replace("+","%2B"),
"HuoWord": this.data.HuoWord,
"PaiChu": this.data.PaiChu,
"IsAdvancedQuery": this.data.totalMode == 0 && this.data.currWordType == '必选词和的关系' ? 0 : this.data.totalMode == 1 ? 1 : 2,
"Source": this.data.Source,
"UserAuthor": this.data.UserAuthor
};
let jsonObj = {
"Guids": null,
"Name": this.data.Name,
"Classify": 0,
"StartTime": this.data.start,
"EndTime": this.data.end,
"Types": "theme_v6",
"DetailsData": [dtData],
"Warning": {
"Statu": Statu,
"Es": {
"QuDao": qdList.join(',') || '',
// "QingGan": qgList.join(',') || '',
"QingGan": '2',
"Crisis": wjList.join(',') || '',
}
}
}
var dtJson = JSON.stringify(jsonObj)
}else{
let dtData = {
"AnalyzeWord": this.data.totalMode == 1 ? this.data.highAnalizeWord.replace("+","%2B") : this.data.AnalyzeWord.replace("+","%2B"),
"HuoWord": this.data.HuoWord,
"PaiChu": this.data.PaiChu,
"IsAdvancedQuery": this.data.totalMode == 0 && this.data.currWordType == '必选词和的关系' ? 0 : this.data.totalMode == 1 ? 1 : 2,
"Source": this.data.Source,
"UserAuthor": this.data.UserAuthor
};
let jsonObj = {
"Guids": null,
"Name": this.data.Name,
"Classify": 0,
"StartTime": this.data.start,
"EndTime": this.data.end,
"Types": "theme_v6",
"DetailsData": [dtData],
}
var dtJson = JSON.stringify(jsonObj)
}
app.globalData.request({
action: 'setSchemeData', //数据列表
token: wx.getStorageSync('token') || 't%2BrswgjvzGM=',
DataJson: dtJson,
}).then(res => {
if (res != [])
wx.showModal({
title: '提示',
content: '添加成功',
success(res) {
if (res.confirm) {
wx.navigateBack({
delta: 1,
})
}
}
});
}).catch(err => {
wx.showModal({
title: '提示',
content: err.Msg,
})
});
}
})