import { FunCode } from "../../../constants/enum/funcode"; import { sendMsgToMQ } from "../../../services/api/common/index"; import { queryMyWRPosition } from "../../../services/api/orders/index"; import { accountid, clientType, isEncrypted, marketid, protoHeader, timetample, userid } from "../../../services/utils"; import { hideLoading, showLoading, showModel } from "../../../utils/message/index"; import { isnullstr } from "../../../utils/util"; Page({ /** * 页面的初始数据 */ data: { /// 单据信息 order: ({}), /// 我的库存 objs: [], /// 选中的仓单 wrPositon: ({}), /// 备注信息 remark: '', /// 申请价格 applyPrice: 0.0, /// 列头 titles: [['重量', '形状', '尺寸', '编号'], ['颜色 | 净度 | 切工 | 对称 | 抛光 | 荧光 | 证书', '价格']], // 显示的值 values: [{ up: [''], dwn: [''], isChecked: false }], /// 数据是否为空 isEmpty: false, /// 单据显示 orderValue: { up: [''], dwn: ['']}, }, /** * 返回上层视图 */ 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] }) }, /// 摘买 doDelistingBuy() { /// showModel showModel(() => { /// showLoading showLoading(() => { /// 参数信息 const params = { Header: protoHeader(FunCode.ZSSellOrderDestingApplyReq), UserID: userid(), AccountID: accountid(), BuyWRTradeOrderID: '', WRStandardID: '', WRFactorTypeID: 0, ApplyQty: 0, ApplyPrice: this.data.applyPrice, LadingBillID: '', SubNum: 0, ApplyRemark: this.data.remark, ClientType: clientType(), ClientSerialNo: timetample(), MarketID: marketid() } /// 发送请求 sendMsgToMQ({ data: { data: JSON.stringify(params), funCodeRsp: FunCode.ZSSellOrderDestingApplyRsp, funCodeReq: FunCode.ZSSellOrderDestingApplyReq, isEncrypted: isEncrypted() }, success: (res) => { /// 请求失败 if (res.code != 0) { hideLoading(()=>{}, '摘牌请失败,原因:'+res.msg, 'error') return } /// 求购发布请求成功 hideLoading(() => { wx.navigateBack() }, '摘牌请成功', 'success') }, fail: (emsg) => { hideLoading(()=>{}, '摘牌请求失败,原因:'+emsg, 'error') } }) }, '摘牌请求中.....') }, '提示', '确认要摘牌吗?') }, /// 查询我的库存 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.size1), isnullstr(obj.goodsno)], dwn: [isnullstr(obj.zsczcolor1typedisplay)+' | '+ isnullstr(obj.zsclaritytype1display)+' | '+ isnullstr(obj.zscuttype1display)+' | '+ isnullstr(obj.zssymmetrytype1display)+' | '+ isnullstr(obj.zspolishtype1display)+' | '+ isnullstr(obj.zsfluorescencetype1display)+' | '+ isnullstr(obj.zscerttypedisplay), obj.zscurrencytypedisplayunit+obj.price.toFixed(2)], isChecked: false} }) }) }) }, fail: (emsg) => { hideLoading(() => {}, '库存请求失败,原因:'+emsg, 'error') } }) }) }, /** * 生命周期函数--监听页面加载 */ 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)+' | '+ isnullstr(item.zscerttypedisplay)] } }) } /// 查询我的库存 this.queryMyWRPosition() } catch (error) { console.log(error) } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })