From 9ede485a9a73bb3543fdcdb38880fd3045c66a2a Mon Sep 17 00:00:00 2001 From: "Stormeye.Wu" Date: Thu, 23 Aug 2018 11:27:45 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=94=A8=E6=88=B7=E6=8E=88=E6=9D=83nick][?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D]=EF=BC=9A=E7=94=A8=E6=88=B7=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=90=8E=E8=8E=B7=E5=8F=96couponList=EF=BC=8CcouponCh?= =?UTF-8?q?annel=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 6 ++ pages/getuserinfo/index.js | 23 +++---- pages/index/coupons/index.js | 42 +++++++----- pages/index/rushToBuy/index.js | 118 +++++++++++++++++---------------- 4 files changed, 102 insertions(+), 87 deletions(-) diff --git a/app.js b/app.js index 404103d..59a4671 100644 --- a/app.js +++ b/app.js @@ -23,6 +23,12 @@ App({ // console.log("req",res); this.globalData.token = res.data.token; Http.setToken(res.data.token) + if (that.couponChannelListCallback) { + that.couponChannelListCallback(res.data.token); + } + if (that.couponListCallback) { + that.couponListCallback(res.data.token); + } return Http.post({ url: config.api.checkUserStatus, data: {} diff --git a/pages/getuserinfo/index.js b/pages/getuserinfo/index.js index 37822c9..f671631 100755 --- a/pages/getuserinfo/index.js +++ b/pages/getuserinfo/index.js @@ -23,17 +23,16 @@ Page({ } }) .then(function(res) { - console.log(res); - //返回主页 - wx.redirectTo({ - url: '../index/index', - }) - }, function(error) { - wx.showToast({ - title: '请授权个人信息', - icon: "none" - }) - } - ) + console.log(res); + //返回主页 + wx.switchTab({ + url: '/pages/index/index', + }) + }, function(error) { + wx.showToast({ + title: '请授权个人信息', + icon: "none" + }) + }) }, }) \ No newline at end of file diff --git a/pages/index/coupons/index.js b/pages/index/coupons/index.js index c40fe3e..07cea2a 100644 --- a/pages/index/coupons/index.js +++ b/pages/index/coupons/index.js @@ -1,5 +1,7 @@ // pages/index/sw/index.js +let config = require('../../../config/config.js') let Http = require('../../../utils/HttpBasics') +const app = getApp() Component({ /** * 组件的属性列表 @@ -12,8 +14,7 @@ Component({ * 组件的初始数据 */ data: { - tabs: [ - { + tabs: [{ key: 1, name: "全部" }, @@ -39,9 +40,7 @@ Component({ name: "其他" }, ], - list: [ - - ], + list: [], current: '1', current_scroll: '1', }, @@ -50,29 +49,36 @@ Component({ * 组件的方法列表 */ methods: { - handleChange({ detail }) { + handleChange({ + detail + }) { this.setData({ current: detail.key }); }, - handleChangeScroll({ detail }) { + handleChangeScroll({ + detail + }) { this.setData({ current_scroll: detail.key }); }, }, ready() { - Http.get({ - url: Http.config.api.couponList, - data: { - pageNum: 1, - pageSize: 10 - } - }).then(res => { - this.setData({ - list: res.list + app.couponListCallback = token => { + Http.get({ + url: Http.config.api.couponList, + data: { + pageNum: 1, + pageSize: 10 + } + }).then(res => { + console.log(res); + this.setData({ + list: res.data.list + }) }) - }) + } } -}) +}) \ No newline at end of file diff --git a/pages/index/rushToBuy/index.js b/pages/index/rushToBuy/index.js index c232313..64c387e 100644 --- a/pages/index/rushToBuy/index.js +++ b/pages/index/rushToBuy/index.js @@ -1,67 +1,71 @@ // pages/index/sw/index.js let config = require('../../../config/config.js') let Http = require('../../../utils/HttpBasics') +const app = getApp() Component({ - /** - * 组件的属性列表 - */ - properties: { + /** + * 组件的属性列表 + */ + properties: { - }, + }, - /** - * 组件的初始数据 - */ - data: { - list: [ - // { - // img: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg", - // name: "海鲜焗饭", - // time: "2天12小时25分钟", - // oPrice: "59.00", - // pPrice: "1.00", - // }, - // { - // img: "http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg", - // name: "海鲜焗饭", - // time: "2天12小时25分钟", - // oPrice: "59.00", - // pPrice: "1.00", - // }, - // { - // img: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg", - // name: "海鲜焗饭", - // time: "2天12小时25分钟", - // oPrice: "59.00", - // pPrice: "1.00", - // }, - // { - // img: "http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg", - // name: "海鲜焗饭", - // time: "2天12小时25分钟", - // oPrice: "59.00", - // pPrice: "1.00", - // }, - ] - }, + /** + * 组件的初始数据 + */ + data: { + list: [ + // { + // img: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg", + // name: "海鲜焗饭", + // time: "2天12小时25分钟", + // oPrice: "59.00", + // pPrice: "1.00", + // }, + // { + // img: "http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg", + // name: "海鲜焗饭", + // time: "2天12小时25分钟", + // oPrice: "59.00", + // pPrice: "1.00", + // }, + // { + // img: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg", + // name: "海鲜焗饭", + // time: "2天12小时25分钟", + // oPrice: "59.00", + // pPrice: "1.00", + // }, + // { + // img: "http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg", + // name: "海鲜焗饭", + // time: "2天12小时25分钟", + // oPrice: "59.00", + // pPrice: "1.00", + // }, + ] + }, - /** - * 组件的方法列表 - */ - methods: { + /** + * 组件的方法列表 + */ + methods: { - }, - ready() { - Http.get({ - url: config.api.couponChannelList, - data: { - pageNum: 1, - pageSize: 10 + }, + ready() { + app.couponChannelListCallback = token => { + Http.setToken(token); + Http.get({ + url: config.api.couponChannelList, + data: { + pageNum: 1, + pageSize: 10 + } + }).then(res => { + this.setData({ + list: res.data.list + }) + }) + } } - }).then(res => { - this.setData({ - list: res.list - }) - }) - } }) \ No newline at end of file