import { EOrderSrc, EValidType } from "../../../constants/enum/index"; import { FunCode } from "../../../constants/enum/funcode"; import { sendMsgToMQ } from "../../../services/api/common/index"; import { accountid, clientType, getErrorMsg, isEncrypted, marketID, protoHeader, saveTradeActive, timetample, userid } from "../../../services/utils"; import { hideLoading, showLoading, showModel } from "../../../utils/message/index"; import { isnullstr } from "../../../utils/util"; import { queryMyWRPosition, queryPermancePlanTmp } from "../../../services/api/orders/index"; import { encryptBody } from "../../../utils/websocket/crypto"; Page({ /** * 页面的初始数据 */ data: { /// 底部安全区域 safeBottom: getApp().globalData.safeBottom, /// tabs tabs: [{id: 2, name: '单颗裸钻'}, {id: 5, name: '单颗彩钻'}], /// tab索引 active: 0, /// 出售挂牌 dataList: [], /// 选中的单据 postion: ({}), /// 列头 titles: [['重量', '形状', '尺寸', '编号'], ['颜色 | 净度 | 切工 | 抛光 | 对称 | 荧光 | 证书', '价格']], /// 显示的值 values: [{ up: [''], dwn: [''], isChecked: false }], /// 是否空数据 isEmpty: false, /// 当前页 page: 1, /// 履约模板信息 tmps: [], /// 选中履约模板 tmp: ({}), /// 是否显示 show: false, /// 显示信息 actions: [''], /// 颜色 colors: ['rebeccapurple', 'green', 'hotpink', 'orange', 'darkgoldenrod', 'firebrick', 'forestgreen', 'darksalmon', 'goldenrod', 'khaki', 'rosybrown', 'sandybrown'] }, /** * 返回上层视图 */ backToParent() { /// 返回上层视图 wx.navigateBack() }, /// 显示履约模板 showPlanTmps() { this.setData({ show: true }) }, /// 关闭 onClose() { this.setData({ show: false }) }, onSelect(e: any) { /// 默认显示项 const { index } = e.detail; this.setData({ tmp: this.data.tmps[index], show: false }) }, /** * 每行选中触发事件 */ onSelectItem(e: any) { var objs = this.data.values objs.forEach(obj => { obj.isChecked = false }) objs[e.currentTarget.id].isChecked = true /// 数据赋值 this.setData({ values: objs, sellorder: this.data.dataList[e.currentTarget.id] }) }, /** * tab触发事件 */ onTabChange(e: any) { /// 设置激活项 this.setData({ active: e.detail.index, /// 设置列头 titles: this.data.tabs[e.detail.index].id === 2 ? [['重量', '形状', '尺寸', '编号'], ['颜色 | 净度 | 切工 | 抛光 | 对称 | 荧光 | 证书', '价格']] : [['重量', '形状', '尺寸', '编号'], ['颜色 | 净度 | 抛光 | 对称 | 荧光 | 证书', '价格']], }) /// 查询单据信息 this.queryMyWRPosition() }, /// 获取履约模板信息 queryPermancePlanTmp() { /// showLoading showLoading(() => { queryPermancePlanTmp({ success: (res) => { /// 获取数据 this.setData({ tmps: res.data, tmp: res.data[0], actions: res.data.map(obj => { return obj.templatename }) }) }, complete: () => { /// hideLoading hideLoading() /// 停止下拉刷新 wx.stopPullDownRefresh() } }) }) }, /// 查询我的库存 queryMyWRPosition() { /// loding showLoading(()=>{ /// 数据查询请求 queryMyWRPosition({ data: { wruserid: userid(), zscategorys: this.data.tabs[this.data.active].id.toString(), }, success: (res) => { /// 请求失败 if (res.code != 200) { /// 加载失败 hideLoading(()=>{}, '请求失败,原因:'+res.msg) return } hideLoading(()=>{ /// 设置数据 this.setData({ /// 设置列头 dataList: res.data.filter(e => { return e.marketflag != 1 }), isEmpty: res.data.length === 0, active: 0, /// 显示的值 values: res.data.filter(e => { return e.marketflag != 1 }).map(obj => { return this.data.tabs[this.data.active].id === 2 ? { up: [obj.ftotalqty+'ct', isnullstr(obj.zsshapetypedisplay), isnullstr(obj.sizedisplay), obj.goodsno], dwn: [isnullstr(obj.zscolortype1display)+' | '+ 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 } : { up: [obj.ftotalqty+'ct', isnullstr(obj.zsshapetypedisplay), isnullstr(obj.sizedisplay), obj.goodsno], dwn: [isnullstr(obj.zsczcolor3typedisplay)+' | '+ isnullstr(obj.zsclaritytype1display)+' | '+ isnullstr(obj.zspolishtype1display)+' | '+ isnullstr(obj.zssymmetrytype1display)+' | '+ isnullstr(obj.zsfluorescencetype1display)+' | '+ isnullstr(obj.zscerttypedisplay), obj.zscurrencytypedisplayunit+obj.price.toFixed(2)], isChecked: false } }) }) }) }, fail: (emsg) => { /// 加载失败 hideLoading(()=>{}, emsg) }, complete: () => { /// 停止下拉刷新 wx.stopPullDownRefresh() } }) }) }, /// 摘卖 doListingSell() { /// showModel showModel(() => { /// showLoading showLoading(() => { const { wrstandardid, ftotalqty, ladingbillid, subnum } = this.data.postion const { autoid } = this.data.tmp /// 请求参数 const info = JSON.stringify({ Header: protoHeader(FunCode.ZSSellOrderListingReq, marketID(67)), UserID: userid(), AccountID: accountid(), WRStandardID: wrstandardid, // WRFactorTypeID: wrfactortypeid, LadingBillID: ladingbillid, SubNum: subnum, OrderQty: ftotalqty, PerformanceTemplateID: autoid, TimevalidType: EValidType.VALIDTYPE_YZ, OrderSrc: EOrderSrc.ORDERSRC_CLIENT, ClientSerialNo: timetample().toString(), ClientType: clientType(), MarketID: marketID(67), }) /// 发送请求 sendMsgToMQ({ data: { data: encryptBody(info), funCodeReq: FunCode.ZSSellOrderListingReq, funCodeRsp: FunCode.ZSSellOrderListingRsp, isEncrypted: isEncrypted() }, success: (res) => { /// 解析对象 const data = JSON.parse(res.data.data) if (data.RetCode != 0) { hideLoading(() => {}, getErrorMsg(data.RetCode)) return } /// 求购发布请求成功 hideLoading(() => { saveTradeActive(0) wx.navigateBack() }, '出售发布请求成功', 'success') }, fail: (emsg) => { hideLoading(()=>{}, emsg) } }) }, '出售请求中....') }, '提示', '确认要发布出售吗?') }, /** * 生命周期函数--监听页面加载 */ onLoad() { /// 查询我的出售 this.queryMyWRPosition() /// 获取履约模板信息 this.queryPermancePlanTmp() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { /// 查询我的出售 this.queryMyWRPosition() /// 获取履约模板信息 this.queryPermancePlanTmp() }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })