import { sendMsgToMQ } from "../../../../services/api/common/index" import { FunCode } from "../../../../constants/enum/funcode" import { accountid, getErrorMsg, getPerformancestatus, getStepStatus, getSteptype, isEncrypted, protoHeader, userid } from "../../../../services/utils"; import { queryWrPerformancePlanStep } from "../../../../services/api/orders/index"; import { formatDateString, isnullstr } from "../../../../utils/util"; import { hideLoading, showLoading, showToast } from "../../../../utils/message/index"; import { encryptBody } from "../../../../utils/websocket/crypto"; Page({ /** * 页面的初始数据 */ data: { /// 底部安全区域 safeBottom: getApp().globalData.safeBottom, /// 列头 titles: [['重量 | 形状 | 款式 | 尺寸', ' 编号'], ['颜色 | 净度 | 对称 | 抛光 | 荧光 | 证书', '价格']], /// 显示的值 values: <{}[]>[], /// 履约单据信息 order: ({}), /// 延期备注 remark: '', /// 延期天数 delaydays: '', /// 是否显示延期申请 showDelay: false, /// 是否显示立即执行 showExculate: false, /// 履约步骤信息 steps: [], /// 步骤信息 stepsValues:[{}], /// 状态 status: '', /// 当前执行步骤 step: '', /// 资金账号 accountid: accountid() }, /** * 返回上层视图 */ backToParent() { /// 返回上层视图 wx.navigateBack() }, /** * 延期申请 */ doDelay() { this.setData({ showDelay: false}) /// 合规性校验 if (!this.check(true)) { return } /// loding..... showLoading(()=>{ /// 参数信息 const info = JSON.stringify({ PerformancePlanStepID: this.data.order.curstepid, delaydays: Number(this.data.delaydays), applyremark: this.data.remark, applicant: userid(), Header: protoHeader(FunCode.PerformanceDelayApplyReq) }) /// 发送请求 sendMsgToMQ({ data: { data: encryptBody(info), funCodeReq: FunCode.PerformanceDelayApplyReq, funCodeRsp: FunCode.PerformanceDelayApplyRsp, 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) } }) }, '延期申请请求中.....') }, /** * 立即执行 */ doExculpate() { this.setData({ showDelay: false}) /// 合规性校验 if (!this.check(false)) { return } /// loding..... showLoading(()=>{ /// 参数信息 const info = JSON.stringify({ PerformancePlanStepID: this.data.order.curstepid, PerformanceExecuteSide: this.data.order.buyaccountid === accountid() ? 1 : 2, StepRemark: this.data.remark, Header: protoHeader(FunCode.PerformanceManualConfirmReq) }) /// 发送请求 sendMsgToMQ({ data: { data: encryptBody(info), funCodeReq: FunCode.PerformanceManualConfirmReq, funCodeRsp: FunCode.PerformanceManualConfirmRsp, 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) } }) }, '立即执行请求中.....') }, onClose() { /// 关闭 this.setData({ showDelay: false, showExculate: false }) }, onShowDelay() { /// 关闭 this.setData({ showDelay: true }) }, onShowExculate() { /// 关闭 this.setData({ showExculate: true }) }, check(isDelay: boolean): boolean { if ( (Number(this.data.delaydays) === 0 || this.data.delaydays === ' ') && isDelay) { showToast('请输入延期天数!') return false } if (this.data.remark === '') { showToast('请输入备注!') return false } return true }, /** * 查询履约信息 */ queryWrPerformancePlanStep() { /// loding..... showLoading(()=> { /// 发送请求 queryWrPerformancePlanStep({ data: { planid: this.data.order.performanceplanid }, success: (res) => { /// 请求失败 if (res.code != 200) { /// 加载失败 hideLoading(()=>{}, '请求失败,原因:'+res.msg) return } hideLoading(()=>{ this.setData({ steps: res.data, stepsValues: res.data.map(itm => { return { stepindex: itm.stepindex, steptypename: itm.steptypename, stepstatus: itm.stepstatus, stepstatusdisplay: getStepStatus(itm.stepstatus), starttime: formatDateString(itm.starttime, 'YYYY-MM-DD'), endtime: formatDateString(itm.endtime, 'YYYY-MM-DD'), remaindays: itm.stepstatus === 2 ? `剩余${itm.remaindays}天` : ((itm.stepstatus === 3 || itm.stepstatus === 6) ? `${itm.stepdays}` : ''), stepdays: itm.stepdays, bgcolor: itm.stepstatus === 2 ? '#2794FF' : ((itm.stepstatus === 3 || itm.stepstatus === 6) ? '#89C5FF' : '#DDE3E8') } }) }) }) }, fail: (emsg) => { hideLoading(()=>{}, emsg) } }) }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options: any) { console.log(options) /// 数据处理 var item: GuangZuan.MyPerformanc = JSON.parse(options.item) if (item) { var buyer = '' var seller = '' /// 买方信息 if (item.buyerinfo != '') { const { ContactInfo, ReceiveInfo, ReceiptInfo } = JSON.parse(item.buyerinfo) if ( ContactInfo != '' ) { buyer = buyer+'联络信息:'+ContactInfo+' ' } if ( ReceiveInfo != '' ) { buyer = buyer+'收货地址:'+ReceiveInfo+' ' } if ( ReceiptInfo != '' ) { buyer = buyer+'发票信息:'+ReceiptInfo } } /// 卖方信息 if (item.sellerinfo != '') { const { ContactInfo, ReceiptInfo, ReceiveInfo } = JSON.parse(item.sellerinfo) if ( ContactInfo != '' ) { seller = seller+ContactInfo+' ' } if ( ReceiveInfo != '' ) { seller = seller+'收货地址:'+ReceiveInfo+' ' } if ( ReceiptInfo != '' ) { seller = seller+'发票信息:'+ReceiptInfo } } item.sellerinfo = isnullstr(seller) item.buyerinfo = isnullstr(buyer) this.setData({ order: item, values: [{up: [`${ item.weight === 0.0 ? '--' : isnullstr(item.weight.toFixed(2))} | ${isnullstr(item.zsshapetypedisplay)} | ${isnullstr(item.zsstyletypedisplay)} | ${isnullstr(item.sizedisplay)}`, `${isnullstr(item.goodsno)}`], dwn: [`${isnullstr(item.zscolortype1display)} | ${isnullstr(item.zscuttype1display)}| ${isnullstr(item.zssymmetrytype1display)} | ${isnullstr(item.zspolishtype1display)}| ${isnullstr(item.zsfluorescencetype1display)} | ${isnullstr(item.zscerttypedisplay)}`, item.price.toFixed(2)]}], status: getPerformancestatus(item.performancestatus), step: getSteptype(item.steptypeid) }) } /// 查询履约信息 this.queryWrPerformancePlanStep() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })