|
- // pages/index/sw/index.js
- let config = require("../../../config/config.js");
- let Http = require("../../../utils/HttpBasics");
- let app = getApp();
- // 请求数据
- Component({
- /**
- * 组件的属性列表
- */
- properties: {},
-
- /**
- * 组件的初始数据
- */
- data: {
- tabs: [],
- list: [],
- current: "0",
- current_scroll: "0",
- pageNum: 1, // 设置加载的第几次,默认是第一次
- pageSize: 10, //返回数据的个数
- searchLoading: false, //"上拉加载"的变量,默认false,隐藏
- searchLoadingComplete: false //“没有数据”的变量,默认false,隐藏
- },
- /**
- * 组件的方法列表
- */
- methods: {
- handleChange({ detail }) {
- this.setData({
- current: detail.key
- });
- },
- handleChangeScroll({ detail }) {
- this.setData({
- current_scroll: detail.key
- });
- },
- //滚动到底部触发事件
- searchScrollLower() {
- // let that = this;
- console.log("00000000");
- // if(that.data.searchLoading && !that.data.searchLoadingComplete){
- // that.setData({
- // searchPageNum: that.data.searchPageNum+1,
- // isFromSearch: false
- // });
- // that.fetchSearchList();
- // }
- }
- },
-
- ready() {
- var that = this;
- app.couponListCallback = token => {
- Http.setToken(token);
- // business获取
- Http.get({
- url: config.api.businessList,
- data: {
- pageNum: 1,
- pageSize: 10,
- type: 1
- }
- }).then(res => {
- console.log(res);
- that.setData({
- tabs: res.data.list
- });
- });
-
- // 券list获取
- Http.get({
- url: config.api.couponList,
- data: {
- pageNum: 1,
- pageSize: 20
- }
- }).then(res => {
- console.log(res);
- that.setData({
- list: res.data.list
- });
- });
- };
- if (app.globalData.token && app.globalData.token != null) {
- app.couponListCallback(app.globalData.token);
- }
- }
- });
|