import { sendMsgToMQ } from "../../../../services/api/common/index" import { FunCode } from "../../../../constants/enum/funcode" import { accountid, deleteUserRecevieInfo, deleteWrUserReceiptInfo, getErrorMsg, getUserRecevieInfo, getWrUserReceiptInfo, isEncrypted, protoHeader } from "../../../../services/utils"; import { hideLoading, showLoading, showToast } from "../../../../utils/message/index"; import { encryptBody } from "../../../../utils/websocket/crypto"; Page({ /** * 页面的初始数据 */ data: { /// 单据信息 order: {}, /// 联系信息 contract: '', /// 地址信息 address: '', /// 发票信息 invoice: '' }, /** * 返回上层视图 */ backToParent() { /// 返回上层视图 wx.navigateBack() }, onIconClick(e: any) { switch (e.target.id) { case "address": wx.navigateTo({ url: '/mMine/pages/address/list/index?isMine=false' }) break; default: wx.navigateTo({ url: '/mMine/pages/invoice/list/index?isMine=false' }) break; } }, /** * 修改申请 */ doModify() { // 校验失败 if (!this.check()) { return } /// loding..... showLoading(()=>{ /// json const json = { ContactInfo: `${this.data.contract}`, ReceiveInfo: `${this.data.address}`, ReceiptInfo: `${this.data.invoice}` } /// 参数信息 const info = JSON.stringify({ PerformancePlanID: this.data.order.performanceplanid, AccountID: accountid(), ContactInfo: JSON.stringify(json), Header: protoHeader(FunCode.PerformanceModifyContactReq) }) /// 发送请求 sendMsgToMQ({ data: { data: encryptBody(info), funCodeReq: FunCode.PerformanceModifyContactReq, funCodeRsp: FunCode.PerformanceModifyContactRsp, isEncrypted: isEncrypted() }, success: (res) => { /// 解析对象 const data = JSON.parse(res.data.data) if (data.RetCode != 0) { hideLoading(() => {}, getErrorMsg(data.RetCode)) return } /// 操作成功 hideLoading(()=>{ /// 返回上层视图 wx.navigateBack() }, '修改申请成功', 'success') }, fail: (emsg) => { /// 操作失败 hideLoading(()=>{}, emsg) } }) }, '修改申请请求中.....') }, check(): boolean { if (this.data.contract === '') { showToast('请输入联系信息!') return false } if (this.data.address === '' && this.data.order.buyorsell === 0) { showToast('请选择收货地址信息!') return false } if (this.data.invoice === '' && this.data.order.buyorsell === 0) { showToast('请选择发票信息!') return false } return true }, /** * 生命周期函数--监听页面加载 */ onLoad(options: any) { /// 数据解析 const obj = JSON.parse(options.id ?? '') this.setData({ order: obj }) if (obj) { const infos = JSON.parse(obj.buyorsell === 0 ? obj.buyerinfo : obj.sellerinfo) /// 买方信息 if (infos) { const { ContactInfo, ReceiptInfo, ReceiveInfo } = infos this.setData({ contract: ContactInfo, address: ReceiveInfo, invoice: ReceiptInfo }) } } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { const receipt = getWrUserReceiptInfo() const receive = getUserRecevieInfo() if (receipt) { const {receipttype, username, taxpayerid, receiptbank, receiptaccount, address, contactinfo} = receipt if (receipttype === 1) { this.setData({ invoice: `发票抬头:${ username }` }) } else { this.setData({ invoice: `发票抬头:${ username }\n税号:${ taxpayerid }\n开户银行:${ receiptbank }\n银行账号:${ receiptaccount }\n企业地址:${ address }\n企业电话:${ contactinfo }` }) } deleteWrUserReceiptInfo() } if (receive) { const { receivername, phonenum, provincename, cityname, districtname, address } = receive this.setData({ address: `姓名:${receivername}\n电话:${phonenum}\n地址:${provincename+cityname+districtname+address}` }) deleteUserRecevieInfo() } }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })