import { queryMyPerformanc } from "../../../../services/api/orders/index" import { getPerformancestatus, getSteptype, userid } from "../../../../services/utils" import { hideLoading, showLoading } from "../../../../utils/message/index" import { isnullstr } from "../../../../utils/util" Page({ /** * 页面的初始数据 */ data: { /// tab激活索引 active: 0, /// tabs tabs: [{id: 0, name: '买履约'}, {id: 1, name: '卖履约'}], /// 是否空数据 isEmpty: false, /// 当前页签 page: 1, /// 列头 titles: [['价格 | 已付金额 | 剩余冻结金额', '当前步骤 | 剩余天数'], ['形状 | 颜色 | 重量 | 对手方', '状态']], /// 查询数据 datas: [], /// 显示的值 values: <{}[]>[], /// 左滑宽度 width: 50 }, /// 查询我的履约 queryMyPerformanc(buyOrSell: number) { /// loding..... showLoading(()=>{ /// 发送请求 queryMyPerformanc({ data: { userid: userid(), buyorsell: buyOrSell, ishis: true, page: this.data.page }, success: (res) => { if (res.code != 200) { hideLoading(()=>{}, '请求失败,原因:'+res.msg) return } hideLoading(()=>{ /// 查询成功 this.setData({ datas: res.data, isEmpty: res.data.length === 0, /// 显示的值 values: res.data.map(obj => { return {up: [obj.zscurrencytypedisplayunit+obj.price.toString()+' | '+ (this.data.active == 0 ? obj.buypaidamount : obj.sellreceivedamount).toFixed(2)+' | '+ (this.data.active == 0 ? obj.buyerfreezeamount : obj.sellerfreezeamount).toFixed(2), getSteptype(obj.steptypeid)+' | '+ obj.remaindays.toString()+'天'], dwn: [isnullstr(obj.zsshapetypedisplay)+' | '+ isnullstr(obj.zscolortype1display)+' | '+ (obj.weight === 0 ? '--' : obj.weight.toFixed(2))+' | '+ isnullstr(obj.accountname), getPerformancestatus(obj.performancestatus)]} }) }) }) }, fail: (emsg) => { /// showToast hideLoading(()=>{}, emsg) }, complete: ()=>{ /// 停止下拉刷新 wx.stopPullDownRefresh() } }) }) }, /** * tabbar点击事件 */ onTabChange(e: any) { /// 设置激活项 this.setData({ active: e.detail.index }) /// 查询履约数据 this.queryMyPerformanc(this.data.active) }, /** * 返回上层视图 */ backToParent() { /// 返回上层视图 wx.navigateBack() }, /** * 按钮点击响应事件 */ onButtonPressed(e: any) { /// 获取对应的id const ids = ( e.target.id).split(' ') let id = ( e.target.id).split(' ')[0] const index = ids[1] switch (id) { case "detail": /// 详情 wx.navigateTo({ url: '/mMine/pages/myperformance/detail/index?id='+JSON.stringify(this.data.datas[index]) }) break; default: break; } }, /** * 生命周期函数--监听页面加载 */ onLoad() { /// 查询我的买履约 this.queryMyPerformanc(0) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() {}, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { /// 设置页签 this.setData({ page: 1 }) /// 查询我的买卖履约 this.queryMyPerformanc(this.data.active) }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { /// 设置页签 this.setData({ page: this.data.page+1 }) /// 查询我的买卖履约 this.queryMyPerformanc(this.data.active) }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })