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.
277 lines
6.5 KiB
277 lines
6.5 KiB
// subpages/heart/pages/myApply/myApply.js
|
|
const api = require("../../../../utils/api")
|
|
const understand_api = require("../../../../utils/understandJs")
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
showPicker: false, //是否显示底部时间选择器插件
|
|
dataForm: {
|
|
content: '',
|
|
anonymousFlag: '1', //0-不匿名 1-匿名
|
|
reportUser: '',
|
|
reportUserMobile: '',
|
|
images: [] //当前未要求
|
|
},
|
|
dialogVisible: false, //提示框
|
|
dialogTitle: '提交成功', //提交提示,成功还是失败
|
|
errMsg: [], //提交失败msg
|
|
lock: false, //锁定提交状态,防止连击,
|
|
violationsCount: 0, //内容审核计数
|
|
isConReview: false, //内容审核标志
|
|
isAgree: false, //是否 勾选已阅读
|
|
agreement: {}, //须知内容
|
|
agreementVisible: false, //是否显示 诉求须知 内容
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
let params = {
|
|
pageIndex: 1,
|
|
pageSize: 10,
|
|
noticeCategory: 'notice_jsqf_wyjb'
|
|
}
|
|
understand_api.noticelist(params).then(res => {
|
|
console.log(res.data[0])
|
|
this.data.agreement = { ...res.data[0] }
|
|
this.setData({
|
|
agreement: this.data.agreement
|
|
})
|
|
}).catch(err => { })
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
// onShareAppMessage: function () {
|
|
|
|
// }
|
|
|
|
//是否匿名
|
|
onChangeRadio (e) {
|
|
this.setData({
|
|
'dataForm.anonymousFlag': e.currentTarget.dataset.flag
|
|
})
|
|
},
|
|
|
|
onInputContent (e) {
|
|
this.setData({
|
|
'dataForm.content': e.detail.value.trim(' ')
|
|
})
|
|
},
|
|
onInputUser (e) {
|
|
this.setData({
|
|
'dataForm.reportUser': e.detail.value.trim(' ')
|
|
})
|
|
},
|
|
onInputMobile (e) {
|
|
this.setData({
|
|
'dataForm.reportUserMobile': e.detail.value.trim(' ')
|
|
})
|
|
},
|
|
|
|
//去除 输入内容 首尾空格
|
|
contentTrim () {
|
|
this.setData({
|
|
'dataForm.content': this.data.dataForm.content.trim(' '),
|
|
'dataForm.reportUser': this.data.dataForm.reportUser.trim(' '),
|
|
'dataForm.reportUserMobile': this.data.dataForm.reportUserMobile.trim(' ')
|
|
})
|
|
},
|
|
//提交申请
|
|
submitIssue () {
|
|
if (!this.data.isAgree) {
|
|
this.showToast("请先勾选我已阅读并同意诉求须知")
|
|
return false
|
|
}
|
|
if (this.data.lock) {
|
|
this.showToast("正在提交,请耐心等待...")
|
|
return false
|
|
}
|
|
this.contentTrim()
|
|
if (!this.data.dataForm.content) {
|
|
this.showToast("请填写诉求内容")
|
|
return false
|
|
}
|
|
if ( this.data.dataForm.anonymousFlag == '0') {
|
|
if (!this.data.dataForm.reportUser) {
|
|
this.showToast("请填写诉求人姓名")
|
|
return false
|
|
}
|
|
if (this.data.dataForm.reportUser.length > 50) {
|
|
this.showToast("姓名超过字符限制(50字以内)")
|
|
return false
|
|
}
|
|
if (!this.data.dataForm.reportUserMobile) {
|
|
this.showToast("请填写诉求人电话")
|
|
return false
|
|
}
|
|
if (this.data.dataForm.reportUserMobile.length > 20) {
|
|
this.showToast("电话号码超过字符限制(20位)")
|
|
return false
|
|
}
|
|
}
|
|
wx.showLoading({
|
|
title: "加载中",
|
|
})
|
|
this.setData({
|
|
lock: true
|
|
})
|
|
const para = { ...this.data.dataForm }
|
|
para.isConReview = this.data.isConReview
|
|
console.log('submit issue', para)
|
|
let that = this
|
|
api.reportIssue(para).then(res => {
|
|
wx.hideLoading()
|
|
this.setData({
|
|
lock: false
|
|
})
|
|
if (res.code == 0 && res.msg == 'success') {
|
|
this.data.errMsg = []
|
|
this.setData({
|
|
'dataForm.content': '',
|
|
dialogTitle: '提交成功',
|
|
errMsg: this.data.errMsg,
|
|
dialogVisible: !this.data.dialogVisible,
|
|
violationsCount: 0,
|
|
isConReview: false
|
|
})
|
|
// wx.navigateBack()
|
|
} else if (res.code == 533) {
|
|
this.data.violationsCount++
|
|
console.log(this.data.violationsCount)
|
|
if (this.data.violationsCount == 1){
|
|
wx.showToast({
|
|
title: res.msg,
|
|
icon: "none",
|
|
duration: 2000
|
|
})
|
|
} else if (this.data.violationsCount == 2) {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '您提交的内容再次被判定为违规,您确定是否要提交?',
|
|
success (res) {
|
|
if (res.confirm) {
|
|
console.log('用户点击确定')
|
|
that.data.isConReview = true
|
|
that.submitIssue()
|
|
} else if (res.cancel) {
|
|
console.log('用户点击取消')
|
|
that.setData({
|
|
violationsCount: 0,
|
|
isConReview: false
|
|
})
|
|
}
|
|
}
|
|
})
|
|
}
|
|
} else {
|
|
this.data.errMsg[0] = res.msg
|
|
this.setData({
|
|
dialogTitle: '提交失败',
|
|
errMsg: this.data.errMsg,
|
|
dialogVisible: !this.data.dialogVisible
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
console.log(err)
|
|
wx.hideLoading()
|
|
this.setData({
|
|
lock: false
|
|
})
|
|
})
|
|
},
|
|
|
|
//简化提示
|
|
showToast (title) {
|
|
wx.showToast({
|
|
title: title,
|
|
icon: "none",
|
|
duration: 2000
|
|
})
|
|
},
|
|
//跳转到我的列表
|
|
toIssueList () {
|
|
wx.navigateTo({
|
|
url: "/subpages/oneKeyService/pages/reportIssueList/reportIssueList"
|
|
})
|
|
},
|
|
|
|
//关闭弹框
|
|
// closeDialog () {
|
|
// wx.navigateBack()
|
|
// },
|
|
//弹框确定按钮
|
|
confirmDialog () {
|
|
if (this.data.errMsg.length == 0) {
|
|
wx.navigateBack()
|
|
}
|
|
},
|
|
|
|
checkboxChange (e) {
|
|
let value = e.detail.value
|
|
this.setData({
|
|
isAgree: value.length > 0 ? true : false
|
|
})
|
|
},
|
|
|
|
//是否显示 诉求须知 对话框
|
|
showAgreement () {
|
|
this.setData({
|
|
agreementVisible: true
|
|
})
|
|
},
|
|
// 关闭 诉求须知 回调函数
|
|
confirmAgreement () {
|
|
this.setData({
|
|
agreementVisible: false
|
|
})
|
|
}
|
|
})
|