import { EOrderSrc } from "../../../constants/enum/index"; import { FunCode } from "../../../constants/enum/funcode"; import { sendMsgToMQ } from "../../../services/api/common/index"; import { accountid, clientType, getEnumList, getErrorMsg, isEncrypted, marketid, protoHeader, timetample, userid } from "../../../services/utils"; import { hideLoading, showLoading, showModel, showToast } from "../../../utils/message/index"; import { queryPermancePlanTmp } from "../../../services/api/orders/index"; import { encryptBody } from "../../../utils/websocket/crypto"; Page({ /** * 页面的初始数据 */ data: { /// 底部安全区域 safeBottom: getApp().globalData.safeBottom, /// 颜色 tcolors: ['rebeccapurple', 'green', 'hotpink', 'orange', 'darkgoldenrod', 'firebrick', 'forestgreen', 'darksalmon', 'goldenrod', 'khaki', 'rosybrown', 'sandybrown'], /// tabs tabs: [{ id: 2, name: '单颗裸钻' }, { id: 5, name: '单颗彩钻' }], /// tab索引 active: 0, /// 币种信息 currencys: [{ value: 1, text: '人民币' }], /// 币种类型 currency: 1, /// 形状 shapes: [{ id: 1, name: '圆形', isCheck: true }], /// 选中形状 shape: 1, /// 颜色 colors: [{ value: 1, text: 'D' }], /// 选中颜色1 color1: 1, /// 选中颜色2 color2: 1, /// 切工 qiegongs: [{ value: 1, text: 'EX' }], /// 选中切工1 qiegong1: 1, /// 选中切工2 qiegong2: 1, /// 对称 duichengs: [{ value: 1, text: 'EX' }], /// 选中对称1 duicheng1: 1, /// 选中对称2 duicheng2: 2, /// 抛光 paoguangs: [{ value: 1, text: 'EX' }], /// 选中抛光1 paoguang1: 1, /// 选中抛光2 paoguang2: 2, /// 莹光 yingguangs: [{ value: 1, text: 'N' }], /// 选中莹光1 yingguang1: 1, /// 选中莹光2 yingguang2: 2, /// 净度 neatness: [{ value: 1, text: 'FL/IF' }], /// 选中净度1 neatnes1: 1, /// 选中净度2 neatnes2: 1, /// 履约模板信息 tmps: [], /// 选中履约模板 tmp: ({}), /// 是否显示 show: false, /// 显示信息 actions: [''], /// 最小尺寸 minSize: 0.0, /// 最大尺寸 maxSize: 0.0 }, /** * tab触发事件 */ onTabChange(e: any) { /// 激活项 this.setData({ active: e.detail.index }) }, /// 单选框 onChange(e: any) { switch (e.target.id) { default: break; } }, /** * 返回上层视图 */ backToParent() { /// 返回上层视图 wx.navigateBack() }, /// 形状按钮点击事件 onButtonPressed(e: any) { const ids = ( e.target.id).split(' ') let id = ( e.target.id).split(' ')[0] const index = ids[1] switch (id) { case 'shape': /// 形状 this.setData({ shapes: this.data.shapes.map(item => { if (item.id == index) { if (item.isCheck) { item.isCheck = false } else { item.isCheck = true } } return item }) }) break; default: break; } }, /// 显示履约模板 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 }) }, onRadioChange(e: any) { }, /// 重量范围值更改 syncNumRange(e: any) { this.setData({ minSize: e.detail.value[0], maxSize: e.detail.value[1], }) }, /// 获取履约模板信息 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() } }) }) }, /// 发布求购 doListingBuy() { /// showModel showModel(() => { /// showLoading showLoading(() => { /// 钻石属性 const exinfo = { UserID: userid(), AccountID: accountid(), ZSCategory: this.data.tabs[this.data.active].id, ZSCurrencyType: [this.data.currency], ZSShapeType: [this.data.shape], ZSColorType: [this.data.color1, this.data.color2], ZSClarityType: [this.data.neatnes1, this.data.neatnes2], ZSCutType: [this.data.qiegong1, this.data.qiegong2], ZSSymmetryType: [this.data.duicheng1, this.data.duicheng2], ZSPolishType: [this.data.paoguang1, this.data.paoguang2], ZSFluorescenceType: [this.data.yingguang1, this.data.yingguang2], Size: [this.data.minSize, this.data.maxSize], ZSCZColor1Type: [this.data.color1, this.data.color2], } /// 请求参数 const info = JSON.stringify({ Header: protoHeader(FunCode.ZSBuyOrderListingReq), UserID: userid(), AccountID: accountid(), GZ_BuyOrderDetailExInfo: exinfo, PerformanceTemplateID: this.data.tmp.autoid, MarketID: marketid(), OrderSrc: EOrderSrc.ORDERSRC_CLIENT, ClientType: clientType(), ClientSerialNo: timetample().toString() }) /// 发送请求 sendMsgToMQ({ data: { data: encryptBody(info), funCodeReq: FunCode.ZSBuyOrderListingReq, funCodeRsp: FunCode.ZSBuyOrderListingRsp, 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.shape === 0) { showToast('请选择形状') return false } return true }, /** * 生命周期函数--监听页面加载 */ onLoad() { this.setData({ /// 形状 shapes: getEnumList('ZSShapeType').map(obj => { return { id: obj.enumitemname, name: obj.enumdicname, isCheck: obj.enumitemname === this.data.shape } }), shape: getEnumList('ZSShapeType')[0].enumitemname, /// 颜色 colors: getEnumList('ZSColorType').map(obj => { return { value: obj.enumitemname, text: obj.enumdicname } }), color1: getEnumList('ZSColorType')[0].enumitemname, color2: getEnumList('ZSColorType')[0].enumitemname, /// 净度 neatness: getEnumList('ZSClarityType').map(obj => { return { value: obj.enumitemname, text: obj.enumdicname } }), neatnes1: getEnumList('ZSClarityType')[0].enumitemname, neatnes2: getEnumList('ZSClarityType')[0].enumitemname, /// 切工 qiegongs: getEnumList('ZSCutType').map(obj => { return { value: obj.enumitemname, text: obj.enumdicname } }), qiegong1: getEnumList('ZSCutType')[0].enumitemname, qiegong2: getEnumList('ZSCutType')[0].enumitemname, /// 对称 duichengs: getEnumList('ZSSymmetryType').map(obj => { return { value: obj.enumitemname, text: obj.enumdicname } }), duicheng1: getEnumList('ZSSymmetryType')[0].enumitemname, duicheng2: getEnumList('ZSSymmetryType')[0].enumitemname, /// 抛光 paoguangs: getEnumList('ZSPolishType').map(obj => { return { value: obj.enumitemname, text: obj.enumdicname } }), paoguang1: getEnumList('ZSPolishType')[0].enumitemname, paoguang2: getEnumList('ZSPolishType')[0].enumitemname, /// 荧光 yingguangs: getEnumList('ZSFluorescenceType').map(obj => { return { value: obj.enumitemname, text: obj.enumdicname } }), yingguang1: getEnumList('ZSFluorescenceType')[0].enumitemname, yingguang2: getEnumList('ZSFluorescenceType')[0].enumitemname, /// 币种信息 currencys: getEnumList('ZSCurrencyType').map(obj => { return { value: obj.enumitemname, text: obj.enumdicname } }), currency: getEnumList('ZSCurrencyType')[0].enumitemname, }) /// 获取履约模板信息 this.queryPermancePlanTmp() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })