// subpages/heart/pages/myApply/myApply.js const api = require("../../../../utils/api") Page({ /** * 页面的初始数据 */ data: { showPicker: false, //是否显示底部时间选择器插件 dataForm: { content: '', anonymousFlag: '1', //0-不匿名 1-匿名 reportUser: '', reportUserMobile: '', images: [] //当前未要求 }, dialogVisible: false, //提示框 dialogTitle: '提交成功', //提交提示,成功还是失败 errMsg: [], //提交失败msg }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ 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 }) }, onInputUser (e) { this.setData({ 'dataForm.reportUser': e.detail.value }) }, onInputMobile (e) { this.setData({ 'dataForm.reportUserMobile': e.detail.value }) }, //提交申请 submitIssue () { 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 } } const para = { ...this.data.dataForm } console.log('submit issue', para) api.reportIssue(para).then(res => { if (res.code == 0 && res.msg == 'success') { this.data.errMsg = [] this.setData({ dialogTitle: '提交成功', errMsg: this.data.errMsg, dialogVisible: !this.data.dialogVisible }) // wx.navigateBack() } else { this.data.errMsg[0] = res.msg this.setData({ dialogTitle: '提交失败', errMsg: this.data.errMsg, dialogVisible: !this.data.dialogVisible }) } }) }, //简化提示 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() } } })