第58讲 动态数据渲染订单查询实现

动态数据渲染订单查询实现

bash 复制代码
/**
     * 订单查询 type值 0 全部订单  1 待付款  2 待收货 3 退款/退货
     * @param type
     * @return
     */
    @RequestMapping("/list")
    public R list(Integer type){
        System.out.println("type="+type);

        List<Order> orderList=null;
        Map<String,Object> resultMap=new HashMap<>();

        if(type==0){ // 全部订单查询
            orderList=orderService.list(new QueryWrapper<Order>().orderByDesc("id"));
        }else{
            orderList=orderService.list(new QueryWrapper<Order>().eq("status",type).orderByDesc("id"));
        }

        resultMap.put("orderList",orderList);
        return R.ok(resultMap);
    }
  • 订单查询 type值 0 全部订单 1待付款 2 待收货 3 退款/退货
  • @param type
  • @return
bash 复制代码
// 导入request请求工具类
import {
  getBaseUrl,
  requestUtil
} from '../../utils/requestUtil.js';
import regeneratorRuntime from '../../lib/runtime/runtime';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orders:[],
    tabs:[
      {
        id:0,
        value:"全部订单",
        isActive:true
      },
      {
        id:1,
        value:"待付款",
        isActive:false
      },
      {
        id:2,
        value:"待收货",
        isActive:false
      },
      {
        id:3,
        value:"退款/退货",
        isActive:false
      },
    ]
  },

  // 接口参数
  QueryParams:{
    type:0
  },

  /**
   * tab点击事件处理
   * @param {} e 
   */
  handleItemTap(e){
    const {index}=e.currentTarget.dataset;
    console.log(index)
    // 切换标题
    let {tabs}=this.data;
    tabs.forEach((v,i)=>i==index?v.isActive=true:v.isActive=false);

    // 获取订单列表
    this.QueryParams.type=index;
    this.getOrders();

    this.setData({
      tabs
    })
  },

  /**
   * 获取订单
   */
  async getOrders(){
    const res=await requestUtil({url:'/my/order/list',data:this.QueryParams});
    console.log(res)
    this.setData({
      orders:res.orderList
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})

请求后端:

bash 复制代码
<view class="tabs">
  <view class="tabs_title">
    <view
      bindtap="handleItemTap"
      data-index="{{index}}"
      wx:for="{{tabs}}"
      wx:key="id"
      class="title_item {{item.isActive?'active':''}}">
      {{item.value}}
    </view>
   
  </view>
  <view class="tabs_content">
    <view class="order_main">
      <view 
        wx:for="{{orders}}"
        wx:key="id"
      class="order_item">
        <view class="order_no_row">
          <view class="order_no_text">订单编号</view>
          <view class="order_no_value">{{item.orderNo}}</view>
        </view>
        <view class="order_price_row">
          <view class="order_price_text">订单价格</view>
          <view class="order_price_value">¥{{item.totalPrice}}</view>
        </view>
        <view class="order_time_row">
          <view class="order_time_text">订单日期</view>
          <view class="order_time_value">{{item.createDate}}</view>
        </view>
      </view>
    </view>
  </view>
</view>
bash 复制代码
.tabs{
  .tabs_title{
    display: flex;
    .title_item{
      display: flex;
      justify-content: center;
      align-items: center;
      flex:1;
      padding: 15rpx 0;
    }
    .active{
      color: var(--themeColor);
      border-bottom: 5rpx solid currentColor;
    }
  }
  .tabs_content{
    .order_main{
      .order_item{
        padding: 20rpx;
        border-bottom: 1rpx solid #ccc;
        color: #666;
        .order_no_row{
          display: flex;
          justify-content: space-between;
          padding: 10rpx 0;
          .order_no_text{

          }
          .order_no_value{

          }
        }
        .order_price_row{
          display: flex;
          justify-content: space-between;
          padding: 10rpx 0;
          .order_price_text{

          }
          .order_price_value{
            color: var(--themeColor);
            font-size: 32rpx;
          }
        }
        .order_time_row{
          display: flex;
          justify-content: space-between;
          padding: 10rpx 0;
          .order_time_text{

          }
          .order_time_value{

          }
        }
      }
    }
  }
}
相关推荐
m0_462803889 小时前
名单制签到怎么落地:拆解“仅名单内人员签到“的配置链路与匹配逻辑
微信小程序
卓怡学长17 小时前
w192基于springboot“考研情报站”微信小程序设计与实现
java·spring boot·spring·微信小程序·intellij-idea
Q26433650233 天前
【有源码】基于uni-app的旅游行程规划小程序-基于微信小程序的智慧文旅综合服务平台
java·微信小程序·小程序·uni-app·毕业设计·springboot·源代码
网硕互联的小客服3 天前
微信小程序多种跳转页面方式教学
微信小程序·小程序·notepad++
m0_462803884 天前
会议签到里,手写签名怎样从“额外动作“变成流程环节
微信小程序
醒目804 天前
从图像到拼豆图纸:像素化生成与色板匹配技术实践
微信小程序
愚公搬代码5 天前
【愚公系列】《微信小程序项目实战(AI编程+视频图解)》002-一张新地图:AI创业的核心分析框架
人工智能·微信小程序·ai编程
ZeroNews内网穿透5 天前
企业内网穿透别再用随机域名!自有域名实现 OA/ERP 公网安全访问
微信小程序·内网穿透·erp·zeronews·运维实战·企业oa·自有域名
现任明教教主~6 天前
运营级多门店洗车贴膜汽车在线核销保养服务系统洗车预约洗车系统消费分佣扫码核销系统
微信小程序·小程序·汽车
陪我去看海6 天前
被要求猛出小程序,做了这个多平台多环境的部署替我承受压力
前端·微信小程序·抖音小程序