| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397 |
- import { queryBuyOrder, queryDiamond } from "../../services/api/orders/index"
- import { clientType, isEncrypted, marketid, protoHeader, userid, timetample, getEnumList, getErrorMsg } from "../../services/utils";
- import { FunCode } from "../../constants/enum/funcode";
- import { sendMsgToMQ } from "../../services/api/common/index";
- import { hideLoading, showLoading, showToast } from "../../utils/message/index";
- import { encryptBody } from "../../utils/websocket/crypto";
- import { appConfig } from "../../config/index";
- import { isnullstr } from "../../utils/util";
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- /// 状态栏高度
- statusBarHeight: getApp().globalData.statusBarHeight,
- /// 导航栏高度
- navHeight: getApp().globalData.navHeight,
- /// 底部安全区域
- safeBottom: getApp().globalData.safeBottom,
- /// 窗口高度
- windowHeight: getApp().globalData.windowHeight,
- /// tabs
- tabs: [{id: 1, name: '出售大厅'}, {id: 2, name: '求购大厅'}],
- /// 功能菜单
- menus: [{id: "listing-buy", icon: appConfig.imgUrl+'trade-listingbuy', title: '求购', path: '/mTrade/pages/listingbuy/index'},
- {id: "listing-sell", icon: appConfig.imgUrl+'trade-listingsell', title: '出售', path: '/mTrade/pages/listingsell/index'},
- {id: "search", icon: appConfig.imgUrl+'trade-search', title: '筛选', path: '/mHome/pages/search/index'}],
- /// tab索引
- active: 0,
- /// 钻石分类
- categorys: [{ text: '单颗裸钻', value: 2 },
- { text: '单颗彩钻', value: 5 }],
- category: 2,
- /// 钻石形状
- shapes: [{ value: 0, text: '形状' }],
- shape: 0,
- /// 净度
- claritys: [{ text: '净度', value: 0 }],
- clarity: 0,
- /// 切工
- cuts: [{ text: '切工', value: 0 }],
- cut: 0,
- /// 荧光
- fluorescences: [{ text: '荧光', value: 0 }],
- fluorescence: 0,
- ///出售大厅数据
- sellOrders: <GuangZuan.SellOrder[]>[],
- /// 求购大厅数据
- askOrders: <GuangZuan.BuyOrder[]>[],
- /// 数据是否为空
- isEmpty: true,
- /// 商品(查询字段-模糊查询)
- zsallproperties: '',
- /// 数据缓存
- storge: {}
- },
- /**
- * tab触发事件
- */
- onTabChange(e: any) {
- this.setData({ active: e.detail.index })
- /// 查询数据
- e.detail.index == 0 ? this.queryDiamond() : this.queryBuyOrder()
- },
- /// 搜索按钮点击
- onClick() {
- /// 查询求购数据
- this.queryBuyOrder()
- },
- /**
- * 下拉菜单触发时间
- */
- onDropdownChange() {
- /// 数据查询
- this.data.active == 0 ? this.queryDiamond() : this.queryBuyOrder()
- },
- /**
- * 按钮点击响应事件
- */
- onButtonPressed(e: any){
- /// 获取对应的id
- const ids = (<string> e.target.id).split(' ')
- let id = (<string> e.target.id).split(' ')[0]
- const index = <number><unknown>ids[1]
- switch (id) {
- case 'favorite': /// 添加收藏
- this.onAddFavorite(index)
- break
- case 'detail': /// 商品详情
- wx.navigateTo({
- url: this.data.active === 0 ? '/mHome/pages/goodsdetail/index?goodsno='+this.data.sellOrders[index].goodsno+'&ordertime='+this.data.sellOrders[index].ordertime : ('/mTrade/pages/orderdetail/index?item='+JSON.stringify(this.data.askOrders[index]))
- })
- break;
- case 'delisting': /// 摘牌
- wx.navigateTo({ url: '/mTrade/pages/delistingsell/index?item='+JSON.stringify(this.data.askOrders[index])})
- break;
- case 'listing-buy': /// 我要求购
- wx.navigateTo({ url: '/mTrade/pages/listingbuy/index' })
- break;
- case 'listing-sell': /// 我要出售
- wx.navigateTo({ url: '/mTrade/pages/listingsell/index' })
- break;
- case 'ask-buy': /// 求购信息
- wx.navigateTo({ url: '/mTrade/pages/orderdetail/index' })
- break;
- default:
- break;
- }
- },
- onIconClick(e: any) {
- switch (e.currentTarget.id) {
- case 'listing-buy': /// 挂买
- wx.navigateTo({ url: '/mTrade/pages/listingbuy/index' })
- break;
- case 'listing-sell': /// 挂卖
- wx.navigateTo({ url: '/mTrade/pages/listingsell/index' })
- break;
- case 'search': /// 搜索
- wx.navigateTo({ url: '/mHome/pages/search/index' })
- break;
- default: break;
- }
- },
- /**
- * 添加收藏
- */
- onAddFavorite(index: number) {
- /// loding.....
- showLoading(()=>{
- /// 委托单号
- const wrtradeorderid = this.data.sellOrders[index].wrtradeorderid
- /// 参数信息
- const info = JSON.stringify({
- UserID: userid(),
- OperateType: 1,
- ClientType: clientType(),
- MarketID: marketid(),
- ClientSerialNo: timetample().toString(),
- WRTradeOrderID: wrtradeorderid,
- Header: protoHeader(FunCode.GoodsFavoriteOperateReq)
- })
- /// 发送请求
- sendMsgToMQ({
- data: {
- data: encryptBody(info),
- funCodeReq: FunCode.GoodsFavoriteOperateReq,
- funCodeRsp: FunCode.GoodsFavoriteOperateRsp,
- isEncrypted: isEncrypted()
- },
- success: (res) => {
- /// 解析对象
- const data = JSON.parse(res.data.data)
- if (data.RetCode != 0) {
- hideLoading(() => {}, getErrorMsg(data.RetCode))
- return
- }
- /// 操作成功
- hideLoading(()=>{}, '请求成功'+res.msg, 'success')
- },
- fail: (emsg) => {
- /// 操作失败
- hideLoading(()=>{}, emsg)
- },
- complete: () => {
- wx.stopPullDownRefresh()
- }
- })
- })
- },
- /// 查询出售大厅委托单
- queryDiamond() {
- /// 数据存储
- var data = {
- /// 钻石分类
- zscategory: this.data.category,
- /// 形状
- zsshapetype: [this.data.shape.toString()],
- /// 净度
- zsclaritytype: [this.data.clarity],
- /// 切工
- zscuttype: [this.data.cut],
- /// 荧光
- zsfluorescencetype: [this.data.fluorescence],
- }
- // /// 获取参数
- // const info = JSON.parse(wx.getStorageSync('TradeParams'))
- /// 钻石查询
- queryDiamond({
- data: {
- ...data,
- // /// 颜色
- // zscolortype: info ? info.zscolortype : [null],
- // /// 货币类型
- // zscurrencytype: info ? [info.zscurrencytype.toString()] : [''],
- // /// 证书类型
- // zscerttype: info ? [info.zscerttype.toString()] : [''],
- // /// 抛光
- // zspolishtype: info ? [info.zspolishtype] : [],
- // /// 对称
- // zssymmetrytype: info ? [info.zssymmetrytype] : [],
- // /// 总重量(克拉重量)-从
- // weight1: info ? info.weight1 : 0.0,
- // /// 总重量(克拉重量)-至
- // weight2: info ? info.weight2 : 0
- },
- /// 加载成功
- success: (res) => {
- if (res.code != 200) {
- /// 加载失败
- showToast('请求失败,原因:'+res.msg)
- return
- }
- /// 数据赋值
- this.setData({ sellOrders: res.data.map(itm => {
- var obj = itm
- obj.zscuttype1display = isnullstr(itm.zscuttype1display)
- obj.zspolishtype1display = isnullstr(itm.zspolishtype1display)
- obj.zsfluorescencetype1display = isnullstr(itm.zsfluorescencetype1display)
- obj.zssymmetrytype1display = isnullstr(itm.zssymmetrytype1display)
- return obj
- }) })
- },
- fail: (emsg) => {
- /// 加载失败
- showToast(emsg)
- },
- complete: () => {
- /// 数据赋值
- this.setData({ isEmpty: this.data.sellOrders.length === 0 })
- /// 停止下拉刷新
- wx.stopPullDownRefresh()
- }
- })
- },
- /// 查询求购大厅委托单
- queryBuyOrder() {
- /// loding.....
- showLoading(()=>{
- /// loding....
- queryBuyOrder({
- data: {
- /// 模糊搜索
- zsallproperties: this.data.zsallproperties
- },
- /// 加载成功
- success: (res) => {
- if (res.code != 200) {
- /// 加载失败
- hideLoading(()=>{}, '请求失败,原因:'+res.msg)
- return
- }
- hideLoading(()=>{
- /// 数据赋值
- this.setData({
- isEmpty: res.data.length === 0,
- askOrders: res.data.map(itm => {
- var obj = itm
- obj.zscuttypedisplay = isnullstr(itm.zscuttypedisplay)
- obj.zssize = itm.zssize.replace(',', '-')
- obj.zsfluorescencetypedisplay = isnullstr(itm.zsfluorescencetypedisplay)
- obj.zssymmetrytypedisplay = isnullstr(itm.zssymmetrytypedisplay)
- obj.zsclaritytypedisplay = isnullstr(itm.zsclaritytypedisplay)
- obj.zscuttypedisplay = isnullstr(itm.zscuttypedisplay)
- obj.zscolortypedisplay = isnullstr(itm.zscolortypedisplay)
- obj.zspolishtypedisplay = isnullstr(itm.zspolishtypedisplay)
- obj.zssize = isnullstr(itm.zssize)
- return obj
- })
- })
- })
- },
- fail: (emsg) => {
- /// 加载失败
- hideLoading(()=>{}, emsg)
- },
- complete: () => {
- /// 停止下拉刷新
- wx.stopPullDownRefresh()
- }
- })
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad() {
- /// 显示默认数据
- this.setData({
- /// 形状
- shapes: [{ value: 0, text: '形状' }].concat(getEnumList('ZSShapeType').map(obj => {
- return {
- value: obj.enumitemname,
- text: obj.enumdicname
- }
- })),
- /// 净度
- claritys: [{ value: 0, text: '净度' }].concat(getEnumList('ZSClarityType').map(obj => {
- return {
- value: obj.enumitemname,
- text: obj.enumdicname
- }
- })),
- /// 切工
- cuts: [{ value: 0, text: '切工' }].concat(getEnumList('ZSCutType').map(obj => {
- return {
- value: obj.enumitemname,
- text: obj.enumdicname
- }
- })),
- /// 荧光
- fluorescences: [{ value: 0, text: '荧光' }].concat(getEnumList('ZSFluorescenceType').map(obj => {
- return {
- value: obj.enumitemname,
- text: obj.enumdicname
- }
- })),
- })
- },
- onShow() {
- // /// 获取参数
- // const storge = wx.getStorageSync('TradeParams')
- // if (storge) {
- // try {
- // const info = JSON.parse(storge)
- // if (storge) {
- // /// 数据缓存
- // this.setData({
- // storge: info,
- // category: info.category,
- // cut: info.zscuttype,
- // shape: info.zsshapetype,
- // clarity: info.zsclaritytype,
- // fluorescence: info.zsfluorescencetype
- // })
- // }
- // } catch (error) {}
- // }
- /// 查询出售大厅委托单
- this.data.active == 0 ? this.queryDiamond() : this.queryBuyOrder()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
-
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
-
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- /// 查询数据
- this.data.active == 0 ? this.queryDiamond() : this.queryBuyOrder()
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|