|
- // pages/index/sw/index.js
- let config = require('../../../config/config.js')
- let Http = require('../../../utils/HttpBasics')
- const app = getApp()
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
-
- },
-
- /**
- * 组件的初始数据
- */
- data: {
- tabs: [{
- key: 1,
- name: "全部"
- },
- {
- key: 2,
- name: "餐饮"
- },
- {
- key: 3,
- name: "娱乐"
- }, {
- key: 4,
- name: "服饰"
- }, {
- key: 5,
- name: "超市"
- },
- {
- key: 6,
- name: "亲子"
- }, {
- key: 7,
- name: "其他"
- },
- ],
- list: [],
- current: '1',
- current_scroll: '1',
- },
-
- /**
- * 组件的方法列表
- */
- methods: {
- handleChange({
- detail
- }) {
- this.setData({
- current: detail.key
- });
- },
-
- handleChangeScroll({
- detail
- }) {
- this.setData({
- current_scroll: detail.key
- });
- },
- },
- ready() {
- // TODO business获取
- if (app.globalData.token && app.globalData.token != null) {
- Http.get({
- url: config.api.couponList,
- data: {
- pageNum: 1,
- pageSize: 10
- }
- }).then(res => {
- console.log(res);
- this.setData({
- list: res.data.list
- })
- })
- } else {
- app.couponListCallback = token => {
- Http.get({
- url: config.api.couponList,
- data: {
- pageNum: 1,
- pageSize: 10
- }
- }).then(res => {
- console.log(res);
- this.setData({
- list: res.data.list
- })
- })
- }
- }
- }
- })
|