Browse Source

[用户授权nick][修复]:用户登录后获取couponList,couponChannel等

tags/2.2.4
Stormeye.Wu 6 years ago
parent
commit
9ede485a9a
4 changed files with 102 additions and 87 deletions
  1. +6
    -0
      app.js
  2. +11
    -12
      pages/getuserinfo/index.js
  3. +24
    -18
      pages/index/coupons/index.js
  4. +61
    -57
      pages/index/rushToBuy/index.js

+ 6
- 0
app.js View File

@@ -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: {}


+ 11
- 12
pages/getuserinfo/index.js View File

@@ -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"
})
})
},
})

+ 24
- 18
pages/index/coupons/index.js View File

@@ -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
})
})
})
}
}
})
})

+ 61
- 57
pages/index/rushToBuy/index.js View File

@@ -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
})
})
}
})

Loading…
Cancel
Save