| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434 |
- import { queryBuyOrder, queryDiamond } from "../../services/api/orders/index"
- import { clientType, isEncrypted, marketid, protoHeader, userid, timetample } from "../../services/utils";
- import { FunCode } from "../../constants/enum/funcode";
- import { sendMsgToMQ } from "../../services/api/common/index";
- import { isnullstr } from "../../utils/util";
- import { hideLoading, showLoading, showToast } from "../../utils/message/index";
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- /// 底部安全区域
- safeBottom: getApp().globalData.safeBottom,
- /// tabs
- tabs: [{id: 1, name: '出售大厅'}, {id: 2, name: '求购大厅'}],
- /// tab索引
- active: 0,
- /// 出售大厅列头
- asktitles: [['形状', '尺寸', '分类'],
- ['颜色 | 净度 | 切工 | 对称 | 抛光 | 荧光 | 证书', '']],
- /// 求购大厅列头
- selltitles: [['重量', '形状', '尺寸', '分类'],
- ['颜色 | 净度 | 切工 | 对称 | 抛光 | 荧光', '价格']],
- /// 钻石分类
- categorys: [{ text: '单颗裸钻', value: 2 },
- { text: '单颗彩钻', value: 5 }],
- category: 2,
- /// 钻石形状
- shapes: [{ text: '圆明亮形', value: '1' },
- { text: '公主方形', value: '2' },
- { text: '心形', value: '3' },
- { text: '马眼形', value: '4' },
- { text: '三角形', value: '5' },
- { text: '垫形', value: '6' },
- { text: '祖母绿形', value: '7' },
- { text: '梨形', value: '8' },
- { text: '椭圆形', value: '9' },
- { text: '长方形', value: '10' },
- { text: '雷迪恩形', value: '11' },
- { text: '阿斯切形', value: '12' },
- { text: '其他', value: '13' }],
- shape: ['1'],
- /// 净度
- claritys: [{ text: 'FL', value: 1 },
- { text: 'IF', value: 2 },
- { text: 'VVS1', value: 3 },
- { text: 'VVS2', value: 4 },
- { text: 'VS1', value: 5 },
- { text: 'VS2', value: 6 },
- { text: 'SI1', value: 7 },
- { text: 'SI2', value: 8 },
- { text: 'SI3', value: 9 },
- { text: 'I1', value: 10 },
- { text: 'I2', value: 11 },
- { text: 'I3', value: 12 }],
- clarity: 1,
- /// 切工
- cuts: [{ text: 'EX', value: 1 },
- { text: 'VG', value: 2 },
- { text: 'G', value: 3 },
- { text: 'F', value: 4 },
- { text: 'P', value: 5 }],
- cut: 1,
- /// 荧光
- fluorescences: [{ text: '无', value: 1 },
- { text: '微弱', value: 2 },
- { text: '中等', value: 3 },
- { text: '强', value: 4 },
- { text: '极强', value: 5 }],
- fluorescence: 1,
- /// 卖大厅数据
- sellOrders: <GuangZuan.SellOrder[]>[],
- /// 买大厅数据
- askOrders: <GuangZuan.BuyOrder[]>[],
- /// 显示的值
- values: [{ up: [''], dwn: [''] }],
- /// 左滑宽度
- width: 100,
- /// 数据是否为空
- isEmpty: true,
- /// 商品(查询字段-模糊查询)
- zsallproperties: '',
- /// 数据缓存
- storge: {}
- },
- /**
- * tab触发事件
- */
- onTabChange(e: any) {
- this.setData({ active: e.detail.index })
- /// 查询数据
- e.detail.index == 0 ? this.queryDiamond() : this.queryBuyOrder()
- /// 清空搜索条件
- const info = wx.getStorageSync('TradeParams')
- if (info) { wx.removeStorageSync('TradeParams') }
- },
- /// 搜索按钮点击
- onClick() {
- /// 查询求购数据
- this.queryBuyOrder()
- },
- /**
- * 下拉菜单触发时间
- */
- onDropdownChange(e: any) {
- switch (e.target.id) {
- case "categorys": /// 钻石分类
- this.setData({
- category: e.detail
- })
- break;
- case "shapes": /// 形状
- this.setData({
- shape: [e.detail.toString()]
- })
- break;
- case "claritys": /// 钻石净度
- this.setData({
- clarity: e.detail
- })
- break;
- case "cuts": /// 切工
- this.setData({ cut: e.detail })
- break;
- default: /// 荧光
- this.setData({ fluorescence: e.detail })
- break;
- }
- /// 数据查询
- 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 'goods-info': /// 商品详情
- wx.navigateTo({ url: '/mHome/pages/goodsdetail/index?goodsno='+ this.data.sellOrders[index].goodsno})
- break;
- case 'search':
- wx.navigateTo({ url: '/mHome/pages/search/index' })
- break;
- case 'delisting': /// 摘牌
- wx.navigateTo({
- url: '/mTrade/pages/delistingbuy/index?item='+JSON.stringify(this.data.sellOrders[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 'buy-inquiry': /// 我要询价
- wx.navigateTo({ url: '/mTrade/pages/buyinquiry/index' })
- break;
- case 'order-detail': /// 挂牌详情
- wx.navigateTo({ url: '/mTrade/pages/orderdetail/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 = {
- UserID: userid(),
- OperateType: 1,
- ClientType: clientType(),
- MarketID: marketid(),
- ClientSerialNo: timetample().toString(),
- WRTradeOrderID: wrtradeorderid,
- Header: protoHeader(FunCode.GoodsFavoriteOperateReq)
- }
- /// 发送请求
- sendMsgToMQ({
- data: {
- data: JSON.stringify(info),
- funCodeReq: FunCode.GoodsFavoriteOperateReq,
- funCodeRsp: FunCode.GoodsFavoriteOperateRsp,
- isEncrypted: isEncrypted()
- },
- success: (res) => {
- /// 操作失败
- if (res.code != 0) {
- hideLoading(()=>{}, '请求失败,原因:'+res.msg, 'error')
- return
- }
- /// 操作成功
- hideLoading(()=>{}, '请求成功'+res.msg, 'success')
- },
- fail: (emsg) => {
- /// 操作失败
- hideLoading(()=>{}, '请求失败,原因:'+emsg, 'error')
- }
- })
- })
- },
- /// 查询出售大厅委托单
- queryDiamond() {
- /// 数据存储
- var data = {
- /// 钻石分类
- zscategory: this.data.category,
- /// 形状
- zsshapetype: this.data.shape,
- /// 净度
- 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()] : [null],
- /// 证书类型
- zscerttype: info ? [info.zscerttype.toString()] : [null],
- /// 抛光
- zspolishtype: info ? [info.zspolishtype] : [null],
- /// 对称
- zssymmetrytype: info ? [info.zssymmetrytype] : [null],
- /// 总重量(克拉重量)-从
- weight1: info ? info.weight1 : null,
- /// 总重量(克拉重量)-至
- weight2: info ? info.weight2 : null
- },
- /// 加载成功
- success: (res) => {
- if (res.code != 200) {
- /// 加载失败
- showToast('请求失败,原因:'+res.msg)
- return
- }
- /// 数据赋值
- this.setData({
- sellOrders: res.data,
- isEmpty: res.data.length === 0,
- /// 显示的值
- values: res.data.map(obj => {
- return {up: [obj.kpweight.toString()+'ct',
- isnullstr(obj.zsshapetypedisplay),
- isnullstr(obj.sizedisplay),
- isnullstr(obj.zscategorydisplay)],
- dwn: [isnullstr(obj.zscolortype1display)+' | '+
- isnullstr(obj.zsclaritytype1display)+' | '+
- isnullstr(obj.zscuttype1display)+' | '+
- isnullstr(obj.zssymmetrytype1display)+' | '+isnullstr(obj.zspolishtype1display)+' | '+
- isnullstr(obj.zsfluorescencetype1display),
- obj.zscurrencytypedisplayunit+obj.price]}
- })
- })
- },
- fail: (emsg) => {
- /// 加载失败
- showToast('请求失败,原因:'+emsg)
- },
- complete: () => {
- /// 停止下拉刷新
- wx.stopPullDownRefresh()
- }
- })
- },
- /// 查询求购大厅委托单
- queryBuyOrder() {
- /// loding.....
- showLoading(()=>{
- /// loding....
- queryBuyOrder({
- data: {
- /// 模糊搜索
- zsallproperties: this.data.zsallproperties
- },
- /// 加载成功
- success: (res) => {
- if (res.code != 200) {
- /// 加载失败
- hideLoading(()=>{}, '请求失败,原因:'+res.msg, 'error')
- return
- }
- hideLoading(()=>{
- /// 数据赋值
- this.setData({
- buyOrders: res.data,
- isEmpty: res.data.length === 0,
- /// 显示的值
- values: res.data.map(obj => {
- return {up: [isnullstr(obj.zsshapetypedisplay),
- obj.zssize,
- isnullstr(obj.zscategorydisplay)],
- dwn: [isnullstr(obj.zscolortypedisplay)+' | '+
- isnullstr(obj.zsclaritytypedisplay)+' | '+
- isnullstr(obj.zscuttypedisplay)+' | '+
- isnullstr(obj.zssymmetrytypedisplay)+' | '+
- isnullstr(obj.zspolishtypedisplay)+' | '+
- isnullstr(obj.zsfluorescencetypedisplay), '']}
- })
- })
- })
- },
- fail: (emsg) => {
- /// 加载失败
- hideLoading(()=>{}, '请求失败,原因:'+emsg, 'error')
- },
- complete: () => {
- /// 停止下拉刷新
- wx.stopPullDownRefresh()
- }
- })
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad() {},
- onShow() {
- /// 获取参数
- const storge = JSON.parse(wx.getStorageSync('TradeParams'))
- if (storge) {
- /// 数据缓存
- this.setData({
- storge: storge,
- category: storge.category,
- cut: storge.zscuttype,
- shape: storge.zsshapetype,
- clarity: storge.zsclaritytype,
- fluorescence: storge.zsfluorescencetype
- })
- }
- /// 查询出售大厅委托单
- this.data.active == 0 ? this.queryDiamond() : this.queryBuyOrder()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
-
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
-
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- /// 查询数据
- this.data.active == 0 ? this.queryDiamond() : this.queryBuyOrder()
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|