| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- 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: <GuangZuan.MyPerformanc>({}),
- /// 联系信息
- 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: GuangZuan.MyPerformanc = JSON.parse(options.id ?? '')
- 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
- })
- }
- this.setData({ order: obj })
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- 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() {
- }
- })
|