| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 |
- 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: <GuangZuan.PermancePlanTmp[]>[],
- /// 选中履约模板
- tmp: <GuangZuan.PermancePlanTmp>({}),
- /// 是否显示
- 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 = (<string> e.target.id).split(' ')
- let id = (<string> e.target.id).split(' ')[0]
- const index = <number> <unknown>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() {
- }
- })
|