You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

495 lines
9.8 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// pages/noticeDetail/index.js
const app = getApp();
import dateUtil from "../../utils/dateUtil";
Page({
/**
* 页面的初始数据
*/
data: {
roleOf41: false,
roleOf132: false,
managerRoleClassify:false,
articleId: "",
record: {},
html: "",
newContent:'',
isEdit:false,
height:"",
bohui:false,
tongguo:false,
chooseTime:false,
minute3:false,
minute740:false,
status:10,
articleTitle:""
},
setCopy(e){
var that = this;
wx.setClipboardData({
data: e.currentTarget.dataset.content,
success (res) {
wx.getClipboardData({
success (res) {
console.log(res.data) // data
wx.showToast({
title: '内容已复制',
icon: 'none',
duration: 1500
})
}
})
}
})
},
close() {
this.setData({
bohui: false,
chooseTime:false,
tongguo:false,
chexiao:false
});
},
onlyClose(){
this.setData({
minute3:false,
minute740:false
});
},
only3Close(){
// /cms/notice/publish/{noticeId}?type=1
var that = this;
wx.request({
url: app.globalData.ip + "/cms/notice/publish/"+ that.data.articleId+"?type=1",
header: app.globalData.header,
method: "GET",
success: function (res) {
wx.showToast({
title: '发布成功',
icon: 'success',
duration: 1000
})
setTimeout(() => {
// wx.redirectTo({
// url: '../announce/index',
// })
wx.navigateBack({
delta: 1,
})
},1000)
},
});
this.setData({
minute3:false,
chooseTime:false
});
},
only740Close(){
// /cms/notice/publish/{noticeId}?type=1
var that = this;
wx.request({
url: app.globalData.ip + "/cms/notice/publish/"+ that.data.articleId+"?type=2",
header: app.globalData.header,
method: "GET",
success: function (res) {
wx.showToast({
title: '发布成功',
icon: 'success',
duration: 1000
})
setTimeout(() => {
wx.navigateBack({
delta: 1,
})
},1000)
},
});
this.setData({
minute740:false,
chooseTime:false
});
},
bohuiTap() {
this.setData({
bohui: true,
});
},
tongguoTap(){
this.setData({
tongguo: true,
});
},
chooseTimeTap(){
this.setData({
chooseTime: true,
});
},
minute3Tap(){
this.setData({
minute3: true,
});
},
minute740Tap(){
this.setData({
minute740: true,
});
},
reset(){
wx.setNavigationBarTitle({
title: this.data.articleTitle,
})
},
cancelForm(){
wx.setNavigationBarTitle({
title: this.data.articleTitle,
})
this.setData({
isEdit: false,
});
},
chexiaoTap(){
this.setData({
chexiao: true,
isEdit: false,
});
},
tongguoClose(){
var that = this;
this.setData({
tongguo: false
});
let currData = {};
currData["id"] = that.data.articleId;
currData["noticeState"] = 30;
wx.request({
url: app.globalData.ip + "/cms/notice/updateNoticeState",
header: app.globalData.header,
method: "GET",
data: currData,
success: function (res) {
wx.showToast({
title: '通过成功',
icon: 'success',
duration: 1000
})
setTimeout(() => {
wx.navigateBack({
delta: 1,
})
},1000)
},
});
},
bohuiClose(){
var that = this;
this.setData({
bohui: false
});
let currData = {};
currData["id"] = that.data.articleId;
currData["noticeState"] = 20;
wx.request({
url: app.globalData.ip + "/cms/notice/updateNoticeState",
header: app.globalData.header,
method: "GET",
data: currData,
success: function (res) {
wx.showToast({
title: '驳回成功',
icon: 'success',
duration: 1000
})
setTimeout(() => {
wx.navigateBack({
delta: 1,
})
// if(that.data.status != 15){
// wx.redirectTo({
// url: '../announce/index?status='+that.data.status,
// })
// }else{
// wx.redirectTo({
// url: '../announceReview/index',
// })
// }
},1000)
},
});
},
chexiaoClose(){
var that = this;
this.setData({
chexiao: false
});
let currData = {};
currData["id"] = that.data.articleId;
currData["noticeState"] = 20;
wx.request({
url: app.globalData.ip + "/cms/notice/updateNoticeState",
header: app.globalData.header,
method: "GET",
data: currData,
success: function (res) {
wx.showToast({
title: '修改成功',
icon: 'success',
duration: 1000
})
setTimeout(() => {
wx.navigateBack({
delta: 1,
})
// if(that.data.status != 15){
// wx.redirectTo({
// url: '../announce/index?status='+that.data.status,
// })
// }else{
// wx.redirectTo({
// url: '../announceReview/index',
// })
// }
},1000)
},
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log(options.status);
console.log(options.workOrderId);
// let pages = getCurrentPages();
// let currPage = pages[pages.length - 1];
// console.log(pages);
// console.log(currPage.route)
// pages.forEach((item,index)=>{
// })
// 15 this.data.status 审核中
this.setData({
articleId: options.workOrderId,
status:options.status,
roleOf41: app.globalData.roleOf41,
roleOf132: app.globalData.roleOf132,
managerRoleClassify:app.globalData.managerRoleClassify
});
},
showForm(){
var that = this;
that.setData({
isEdit: !that.data.isEdit
})
wx.setNavigationBarTitle({
title: "通告内容",
})
// const query = wx.createSelectorQuery()
// query.select('#textareawrap').boundingClientRect()
// query.selectViewport().scrollOffset()
// query.exec(function(res){
// that.setData({
// height: res[0].height*2 + "px"
// });
// })
},
textareaFocus(e){
console.log(e.detail)
var that = this;
that.setData({
height: e.detail.heightRpx + 400
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.getDetail();
},
getDetail() {
var that = this;
wx.request({
url: app.globalData.ip + "/cms/notice/detail/" + that.data.articleId,
header: app.globalData.header,
method: "GET",
success: function (res) {
console.log(res.data);
// console.log(that.convertHtmlToText(res.data.data.articleContent));
wx.setNavigationBarTitle({
title: res.data.data.title,
})
that.setData({
record: res.data.data,
newContent: res.data.data.content,
articleTitle:res.data.data.title
});
wx.request({
url: app.globalData.ip + "/msg/read/cms/" + that.data.articleId,
header: app.globalData.header,
method: "GET",
success: function (res) {
console.log(res);
console.log(res.data.data);
},
});
// let id = "#textareawrap";
},
fail: function (res) {
console.log(res);
},
});
},
formSubmit(e) {
var that = this;
wx.showLoading({
title: '提交中...',
})
console.log(e.detail);
if(app.isEmptyCheck(e.detail.value.textarea)){
wx.showToast({
title: '内容不能为空',
icon: 'error',
duration: 1000
})
wx.hideLoading();
return
}
if(app.isEmptyCheck(e.detail.value.title)){
wx.showToast({
title: '标题不能为空',
icon: 'error',
duration: 1000
})
wx.hideLoading();
return
}
console.log('form发生了submit事件携带数据为', e.detail.value)
console.log(e.detail.value.textarea.replace(/↵/g,"/\n/"))
// debugger;
let currData = {};
currData["id"] = that.data.articleId;
currData["content"] = e.detail.value.textarea;
currData["title"] = e.detail.value.title;
wx.setNavigationBarTitle({
title: e.detail.value.title,
})
wx.request({
url: app.globalData.ip + "/cms/notice/updateNotice",
header: app.globalData.header,
method: "POST",
data: currData,
success: function (res) {
wx.showToast({
title: '修改成功',
icon: 'success',
duration: 1000
})
wx.hideLoading();
that.setData({
newContent:e.detail.value.textarea,
isEdit:false
})
},
fail:function(res){
console.log(app.globalData.ip);
console.log(res);
wx.showToast({
title: '修改失败',
icon: 'success',
duration: 1000
})
wx.hideLoading();
}
});
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {},
});