| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- import { FunCode } from "../../../../constants/enum/funcode"
- import { protoHeader, userid, isEncrypted, timetample } from "../../../../services/utils"
- import { sendMsgToMQ } from "../../../../services/api/common/index"
- import { hideLoading, showLoading, showToast } from "../../../../utils/message/index"
- 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 userInfo = { 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: JSON.stringify(userInfo),
- funCodeReq: FunCode.UserReceiptInfoReq,
- funCodeRsp: FunCode.UserReceiptInfoReq,
- isEncrypted: isEncrypted()
- },
- success: (res) => {
- /// 操作失败
- if (res.code != 0) {
- hideLoading(()=>{}, '请求失败,原因:'+res.msg, 'error')
- return
- }
- /// 操作成功
- hideLoading(()=>{
- /// 返回上层视图
- wx.navigateBack()
- }, '操作成功', 'success')
- },
- fail: (emsg) => {
- /// 操作失败
- hideLoading(()=>{}, '请求失败,原因:'+emsg, 'error')
- },
- })
- }, '操作请求中......')
- },
- /**
- * 删除发票信息
- */
- deleteUserReceiptInfoReqReq() {
- /// loding.....
- showLoading(()=>{
- /// 参数信息
- const userInfo = {
- ReceiptInfoId: this.data.autoid,
- Header: protoHeader(FunCode.DelUserReceiptInfoReq)
- }
- /// 发送请求
- sendMsgToMQ({
- data: {
- data: JSON.stringify(userInfo),
- funCodeReq: FunCode.DelUserReceiptInfoReq,
- funCodeRsp: FunCode.DelUserReceiptInfoRsp,
- isEncrypted: isEncrypted()
- },
- success: (res) => {
- /// 操作失败
- if (res.code != 0) {
- /// 操作失败
- hideLoading(()=>{}, '删除操作请求失败,原因:'+res.msg, 'error')
- return
- }
- /// 操作成功
- hideLoading(()=>{
- /// 返回上层视图
- wx.navigateBack()
- }, '操作成功', 'success')
- },
- fail: (emsg) => {
- /// 操作失败
- hideLoading(()=>{}, '删除操作请求失败,原因:'+emsg, 'error')
- }
- })
- }, '删除操作请求中......')
- },
- /**
- * 按钮点击响应事件
- */
- 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() {
- }
- })
|