import { FunCode } from "../../../../constants/enum/funcode" import { protoHeader, userid, isEncrypted, timetample, getErrorMsg } from "../../../../services/utils" import { sendMsgToMQ } from "../../../../services/api/common/index" import { hideLoading, showLoading, showToast } from "../../../../utils/message/index" import { encryptBody } from "../../../../utils/websocket/crypto" Page({ /** * 页面的初始数据 */ data: { /// 1个人 2企业 type: 1, /// 发票抬头 inname: '', /// 税号 inno: '', /// 开户银行 bankname: '', /// 银行账号 bankno: '', /// 企业地址 inaddress: '', /// 企业电话 inmobile: '', /// 自增id autoid: 0, /// 发票类型 intypes: ["个人", "企业"], /// 是否发票类型 show: false }, /** * 返回上层视图 */ backToParent() { /// 返回上层视图 wx.navigateBack() }, /// 关闭地址选择组件 onCancel(event: any) { const { index } = event.detail /// 关闭 this.setData({ show: false, type: index+1 }) }, /// 合规性校验 check(): boolean { /// 请输入发票抬头 if (this.data.inname.length == 0) { showToast('请输入发票抬头!') return false } /// 请输入纳税人识别号 if (this.data.inno.length == 0 && this.data.type != 1) { showToast('请输入纳税人识别号!') return false } return true }, /** * 业务操作 */ userReceiptInfoReq() { /// 合规性校验 if (!this.check()) { return } /// loding..... showLoading(()=>{ /// 参数信息 const info = JSON.stringify({ ClientSerialID: timetample(), UserID: userid(), UserName: this.data.inname, ReceiptType: this.data.type, TaxpayerID: this.data.inno, Address: this.data.inaddress, ReceiptBank: this.data.bankname, ReceiptAccount: this.data.bankno, ReceiptInfoId: this.data.autoid, ContactInfo: this.data.inmobile, Header: protoHeader(FunCode.UserReceiptInfoReq) }) /// 发送请求 sendMsgToMQ({ data: { data: encryptBody(info), funCodeReq: FunCode.UserReceiptInfoReq, funCodeRsp: FunCode.UserReceiptInfoRsp, isEncrypted: isEncrypted() }, success: (res) => { /// 请求失败 if (res.code ! = 0) { hideLoading(() => {}, res.msg) return } /// 解析对象 const data = JSON.parse(res.data.data) if (data.RetCode != 0) { hideLoading(() => {}, getErrorMsg(data.RetCode)) return } /// 操作成功 hideLoading(()=>{ /// 返回上层视图 wx.navigateBack() }, '操作成功', 'success') }, fail: (emsg) => { /// 操作失败 hideLoading(()=>{}, emsg) }, }) }, '操作请求中......') }, /** * 删除发票信息 */ deleteUserReceiptInfoReqReq() { /// loding..... showLoading(()=>{ /// 参数信息 const info = JSON.stringify({ ReceiptInfoId: this.data.autoid, Header: protoHeader(FunCode.DelUserReceiptInfoReq) }) /// 发送请求 sendMsgToMQ({ data: { data: encryptBody(info), funCodeReq: FunCode.DelUserReceiptInfoReq, funCodeRsp: FunCode.DelUserReceiptInfoRsp, isEncrypted: isEncrypted() }, success: (res) => { /// 请求失败 if (res.code ! = 0) { hideLoading(() => {}, res.msg) return } /// 解析对象 const data = JSON.parse(res.data.data) if (data.RetCode != 0) { hideLoading(() => {}, getErrorMsg(data.RetCode)) return } /// 操作成功 hideLoading(()=>{ /// 返回上层视图 wx.navigateBack() }, '操作成功', 'success') }, fail: (emsg) => { /// 操作失败 hideLoading(()=>{}, emsg) } }) }, '删除操作请求中......') }, /** * 按钮点击响应事件 */ onButtonPressed(e: any) { switch (e.target.id) { case "type-selsct": /// 类型选择 /// 显示 this.setData({ show: true }) break; case 'delete': /// 删除 this.deleteUserReceiptInfoReqReq() break; default: /// 发送业务操作 this.userReceiptInfoReq() break; } }, /** * 生命周期函数--监听页面加载 */ onLoad(options: any) { /// 传参信息 const d: GuangZuan.WrUserReceiptInfo = JSON.parse(options.id ?? '') this.setData({ inname: d.username, inmobile: d.contactinfo, inno: d.taxpayerid, autoid: d.autoid, inaddress: d.address, bankno: d.receiptaccount, bankname: d.receiptbank, type: d.receipttype }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })