import { FunCode } from "../../../constants/enum/funcode"; import { sendMsgToMQ } from "../../../services/api/common/index"; import { queryMyWRPosition, queryPermancePlanTmp } from "../../../services/api/orders/index"; import { accountid, clientType, getErrorMsg, isEncrypted, loginQuery, marketid, protoHeader, timetample, userid } from "../../../services/utils"; import { hideLoading, showLoading, showModel, showToast } from "../../../utils/message/index"; import { isnullstr } from "../../../utils/util"; import { encryptBody } from "../../../utils/websocket/crypto"; Page({ /** * 页面的初始数据 */ data: { /// 底部安全区域 safeBottom: getApp().globalData.safeBottom, /// 单据信息 order: ({}), /// 我的库存 objs: [], /// 选中的仓单 wrPositon: ({}), /// 备注信息 remark: '', /// 申请价格 applyPrice: 0.0, /// 汇率 rate: loginQuery().exchangeRateConfigs[0].exchangerate, /// 列头 titles: [['重量', '形状', '尺寸', '编号'], ['颜色 | 净度 | 切工 | 抛光 | 对称 | 荧光 | 证书', '价格']], // 显示的值 values: [{ up: [''], dwn: [''], isChecked: false }], /// 选中履约模板 tmp: ({}), /// 数据是否为空 isEmpty: false, /// 单据显示 orderValue: { up: [''], dwn: ['']}, /// 颜色 colors: ['rebeccapurple', 'green', 'hotpink', 'orange', 'darkgoldenrod'] }, /** * 返回上层视图 */ backToParent() { /// 返回上层视图 wx.navigateBack() }, /** * 每行选中触发事件 */ onSelectItem(e: any) { var objs = this.data.values objs.forEach(obj => { obj.isChecked = false }) objs[e.currentTarget.id].isChecked = true /// 数据赋值 this.setData({ values: objs, wrPositon: this.data.objs[e.currentTarget.id] }) }, /// 获取履约模板信息 queryPermancePlanTmp() { /// showLoading showLoading(() => { queryPermancePlanTmp({ data: { marketid: marketid() }, success: (res) => { /// 获取数据 this.setData({ tmps: res.data, tmp: res.data[0], actions: res.data.map(obj => { return obj.templatename }) }) }, complete: () => { /// hideLoading hideLoading() } }) }) }, /// 摘买 doDelistingBuy() { if (!this.check()) { return } /// showModel showModel(() => { /// showLoading showLoading(() => { /// 参数信息 const info = JSON.stringify({ Header: protoHeader(FunCode.ZSSellOrderDestingApplyReq), UserID: userid(), AccountID: accountid(), BuyWRTradeOrderID: this.data.order.wrtradeorderid, WRStandardID: this.data.wrPositon.wrstandardid, WRFactorTypeID: 0, ApplyQty: this.data.wrPositon.ftotalqty, ApplyPrice: this.data.applyPrice, LadingBillID: this.data.wrPositon.ladingbillid, SubNum: this.data.wrPositon.subnum, ApplyRemark: this.data.remark, ClientType: clientType(), ClientSerialNo: timetample().toString(), MarketID: marketid() }) /// 发送请求 sendMsgToMQ({ data: { data: encryptBody(info), funCodeRsp: FunCode.ZSSellOrderDestingApplyRsp, funCodeReq: FunCode.ZSSellOrderDestingApplyReq, 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.wrPositon.ladingbillid === "" ) { showToast('请选择仓单数据!') return false } /// 请输入价格 if (this.data.applyPrice === 0) { showToast('请输入价格!') return false } return true }, /// 查询我的库存 queryMyWRPosition() { /// showLoading showLoading(() => { /// 发送查询请求 queryMyWRPosition({ data: { wruserid: userid(), zscategorys: this.data.order.zscategory.toString(), marketflag: 1 }, success: (res) => { /// hideLoading hideLoading(() => { this.setData({ objs: res.data, isEmpty: res.data.length === 0, /// 显示的值 values: res.data.map(obj => { return {up: [obj.weight+'ct', isnullstr(obj.zsshapetypedisplay), isnullstr(obj.sizedisplay), isnullstr(obj.goodsno)], dwn: [isnullstr(obj.zsczcolor1typedisplay)+' | '+ isnullstr(obj.zsclaritytype1display)+' | '+ isnullstr(obj.zscuttype1display)+' | '+ isnullstr(obj.zspolishtype1display)+' | '+ isnullstr(obj.zssymmetrytype1display)+' | '+ isnullstr(obj.zsfluorescencetype1display)+' | '+ isnullstr(obj.zscerttypedisplay), obj.zscurrencytypedisplayunit+obj.price.toFixed(2)], isChecked: false} }) }) }) }, fail: (emsg) => { hideLoading(() => {}, emsg) } }) }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options: any) { /// 数据显示 try { const item = JSON.parse(options.item) if (item) { this.setData({ order: item, orderValue: { up: [isnullstr(item.zsshapetypedisplay), isnullstr(item.zssize), isnullstr(item.zscategorydisplay)], dwn: [isnullstr(item.zscolortypedisplay)+' | '+ isnullstr(item.zsclaritytypedisplay)+' | '+ isnullstr(item.zscuttypedisplay)+' | '+ isnullstr(item.zssymmetrytypedisplay)+' | '+ isnullstr(item.zspolishtypedisplay)+' | '+ isnullstr(item.zsfluorescencetypedisplay)] } }) } /// 查询我的库存 this.queryMyWRPosition() /// 查询履约模板信息 this.queryPermancePlanTmp() } catch (error) { console.log(error) } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })