123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- const app = getApp();
- import { getRollList } from '../../api/order.js';
- import { getIndexData, getCoupons } from '../../api/api.js';
- import Util from '../../utils/util.js';
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- loading:false,//是否加载中
- loadend:false,//是否加载完毕
- loadTitle:'加载更多',//提示语
- imgUrls: [],
- bastBanner: [],
- bastInfo: '',
- bastList: [],
- fastInfo: '',
- firstInfo: '',
- salesInfo: '',
- indicatorDots: false,
- circular: true,
- autoplay: true,
- interval: 3000,
- duration: 500,
- orderStatus:1,//订单状态
- orderList:[],//订单数组
- page:1,
- limit:5,
- loading:false,//是否加载中
- loadend:false,//是否加载完毕
- parameter:{
- 'navbar': '1',
- 'return': '0',
- 'title': '首页',
- 'color': true,
- 'class': '5'
- },
- window: false,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- if (options.spid) app.globalData.spid = options.spid;
- if (options.scene) app.globalData.code = decodeURIComponent(options.scene);
- // this.getOrderList();
- console.log(wx.getStorageSync('token'));
- },
- /**
- * 事件回调
- *
- */
- onChangeFun:function(e){
- let opt = e.detail;
- let action = opt.action || null;
- let value = opt.value != undefined ? opt.value : null;
- (action && this[action]) && this[action](value);
- },
- getIndexConfig:function(){
- var that = this;
- getIndexData().then(res=>{
- that.setData({
- imgUrls: res.data.banner,
- bastBanner: res.data.info.bastBanner,
- bastInfo: res.data.info.bastInfo,
- bastList: res.data.info.bastList,
- fastInfo: res.data.info.fastInfo,
- firstInfo: res.data.info.firstInfo,
- salesInfo: res.data.info.salesInfo,
- logoUrl: res.data.logoUrl,
- couponList: res.data.couponList,
- });
- wx.getSetting({
- success(res) {
- if (!res.authSetting['scope.userInfo']) {
- that.setData({ window: that.data.couponList.length ? true : false });
- } else {
- that.setData({ window: false });
- }
- }
- });
- })
- },
- /**
- * 获取开团列表
- */
- getOrderList:function(){
- var that=this;
- if(that.data.loadend) return;
- if(that.data.loading) return;
- that.setData({ loading: true, loadTitle:""});
- getRollList({
- status: that.data.orderStatus
- }).then(res=>{
- var list = res.data, loadend = list.length < that.data.limit;
- that.data.orderList = app.SplitArray(list, that.data.orderList);
- that.setData({
- orderList: that.data.orderList,
- loadend: loadend,
- loading: false,
- loadTitle: loadend ? "我也是有底线的" : '加载更多',
- page: that.data.page + 1,
- });
- }).catch(err=>{
- that.setData({ loading: false, loadTitle: "加载更多" });
- })
- },
- /**
- * 切换类型
- */
- statusClick:function(e){
- var status = e.currentTarget.dataset.status;
- if (status == this.data.orderStatus) return;
- this.setData({ orderStatus: status, loadend: false, page: 1, orderList:[]});
- this.getOrderList();
- },
- catchTouchMove: function (res) {
- return false
- },
- onColse:function(){
- this.setData({ window: false});
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.getIndexConfig();
- this.getOrderList();
- if(app.globalData.isLog && app.globalData.token) this.get_issue_coupon_list();
- if (app.globalData.isLog && this.data.isClose){
- this.setData({ loadend: false, page: 1, orderList:[]});
-
- }
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- this.setData({ window:false});
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- this.getIndexConfig();
- this.getOrderList();
- if (app.globalData.isLog && app.globalData.token) this.get_issue_coupon_list();
- wx.stopPullDownRefresh();
- },
- setGoodsSearch:function(){
- wx.navigateTo({
- url: '/pages/goods_search/index',
- })
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- // onReachBottom: function () {
- // this.getOrderList();
- // },
- })
|