123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- let app = getApp();
- let host = app.globalData.servsers; // 请求的url
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- state:2, // 请求状态]
- orderList:[], // 订单列表
- host: host,
- rows:1, //默认第一页
- requestState:true, //请求状态,默认是true
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- state: options.state
- })
-
-
-
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.getOrderList(this, this.data.state, this.data.rows)
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- console.log("上拉")
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- if(this.data.requestState){
- this.setData({
- rows: this.data.rows + 1
- })
- this.getOrderList(this,this.data.state,this.data.rows)
- }
- console.log('到底了')
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- getOrderList(that, state, rows){
- let orderList = that.data.orderList;
- wx.showLoading({
- title: '加载中...',
- })
- wx.request({
- url: host + '/queryOrderCustomerByUserId',
- method:'get',
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- data:{
- userId:app.globalData.user_id,
- orderStatus: state, //订单状态 0未支付\\1: 待定制\\2: 待发货\\3: 已发货\\4: 已完成\\5: 取消'
- limit:10,
- offset: rows,
- },
- success(res){
- console.log(res,"orderList")
- let data = res.data;
- data.forEach(el=>{
- el['imgArray'] = el.orderCustomGoodsList[0].customGoodsImg ? el.orderCustomGoodsList[0].customGoodsImg.split(',') : [];
- })
- orderList.push(...data)
- if(res.data.length < 10 && rows !==1){
- that.setData({
- requestState:false
- })
- }
- that.setData({
- orderList: orderList
- })
- console.log(that.data.orderList,"orderList")
- },
- complete(){
- wx.hideLoading()
- }
- })
- }
- })
|