Commit 8b6803fd authored by mengcuiguang's avatar mengcuiguang

添加微信登录

parent f2b83d8e
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
}, },
onShow() { onShow() {
// if (app.globalData.resetLogin && !this.isFirstLoad) { // if (app.globalData.resetLogin && !this.isFirstLoad) {
// // this.wxLogin() // this.wxLogin()
// } // }
// this.isFirstLoad = false // this.isFirstLoad = false
...@@ -109,9 +109,6 @@ ...@@ -109,9 +109,6 @@
tabChange(index) { tabChange(index) {
if (this.currentPage == index) return if (this.currentPage == index) return
// if (app.globalData.token == '' || app.globalData.token == null) {
// this.wxLogin()
// }
this.currentPage = index; this.currentPage = index;
this.loadComponentData(); this.loadComponentData();
}, },
...@@ -130,36 +127,6 @@ ...@@ -130,36 +127,6 @@
this.$refs.recommend.hide(); this.$refs.recommend.hide();
} }
}, },
wxLogin() {
let that = this
uni.login({
provider: 'weixin',
success: function(loginRes) {
that.post({
url: '/app/wxLogin',
data: {
code: loginRes.code,
inviteUId: '',
},
showLoading: false,
success: ({
data
}) => {
app.globalData.resetLogin = false
uni.setStorage({
key: 'token',
data: data.session
});
app.globalData.token = data.session;
app.globalData.userId = data.userId;
app.globalData.userInfo = data;
}
});
}
});
},
showEditBarH(b) { showEditBarH(b) {
this.showEditBar = b this.showEditBar = b
this.isFullChoice = false this.isFullChoice = false
......
...@@ -164,104 +164,39 @@ ...@@ -164,104 +164,39 @@
}, },
methods: { methods: {
show() { show() {
console.log('123123123'); // 轮播图
this.post({
if (app.globalData.userInfo != 'undefined' && app.globalData.userInfo == null) { url: '/vedio/topTabs',
this.visitorlogin(); showLoading: false,
} else { success: ({
this.loadPost(); data
} }) => {
}, this.bannerList = data.list;
visitorlogin() { }
let that = this });
var obj = wx.getEnterOptionsSync() // 排行榜
var tempInviteUId = this.shareId; this.post({
url: '/vedio/orders',
var channel = '' // 渠道 showLoading: false,
var clueToken = '' // 归因参数 success: ({
var adId = '' // 计划id data
var advertiserId = '' // 账号id }) => {
var reqId = '' // 请求id this.topList = data.list;
var creativeId = '' // 创意id }
});
if (obj.query.clueToken ?? '' != '') { // 最近观看剧
channel = 'tt' this.post({
clueToken = obj.query.clueToken ?? '' url: '/vedio/newest',
adId = obj.query.adId ?? '' showLoading: false,
advertiserId = obj.query.advertiserId ?? '' success: ({
reqId = obj.query.reqId ?? '' data
creativeId = obj.query.creativeId ?? '' }) => {
} if (data.list != null && data.list.length > 0) {
if (obj.query.ksChannel ?? '' != '') { this.newRecordBean = data.list[0];
channel = 'kuaishou' }
clueToken = obj.query.callback ?? '' }
adId = obj.query.ksCampaignId ?? ''
reqId = obj.query.ksUnitId ?? ''
creativeId = obj.query.ksCreativeId ?? ''
}
this.post({
url: '/user/visitorlogin',
data: {
channel: channel,
clueToken: clueToken,
adId: adId,
advertiserId: advertiserId,
reqId: reqId,
creativeId: creativeId,
inviteUId: tempInviteUId
},
showLoading: false,
success: ({
data
}) => {
app.globalData.token = data.token;
app.globalData.userId = data.pk_id;
app.globalData.userInfo = data;
that.loadPost();
},
fail: (e) => {
// 测试使用
that.loadPost();
}
}); });
}, },
loadPost() {
// 轮播图
this.post({
url: '/vedio/topTabs',
showLoading: false,
success: ({
data
}) => {
this.bannerList = data.list;
}
});
// 排行榜
this.post({
url: '/vedio/orders',
showLoading: false,
success: ({
data
}) => {
this.topList = data.list;
}
});
// 最近观看剧
// this.post({
// url: '/vedio/newest',
// showLoading: false,
// success: ({
// data
// }) => {
// if (data.list != null && data.list.length > 0) {
// this.newRecordBean = data.list[0];
// }
// }
// });
},
queryList(page, size) { queryList(page, size) {
// 推荐列表 // 推荐列表
this.post({ this.post({
......
...@@ -46,13 +46,13 @@ ...@@ -46,13 +46,13 @@
}, },
onLaunch(options) {}, onLaunch(options) {},
onShow(options) { onShow(options) {
this.visitorlogin(); this.wxlogin();
setTimeout(() => { setTimeout(() => {
redirectTo('home'); redirectTo('home');
}, 2300); }, 2300);
}, },
methods: { methods: {
visitorlogin() { wxlogin() {
let that = this let that = this
var obj = wx.getEnterOptionsSync() var obj = wx.getEnterOptionsSync()
var tempInviteUId = this.shareId; var tempInviteUId = this.shareId;
...@@ -80,29 +80,32 @@ ...@@ -80,29 +80,32 @@
creativeId = obj.query.ksCreativeId ?? '' creativeId = obj.query.ksCreativeId ?? ''
} }
this.post({ uni.login({
url: '/user/visitorlogin', provider: 'weixin',
data: { success: function(loginRes) {
channel: channel,
clueToken: clueToken, that.post({
adId: adId, url: '/app/wxLogin',
advertiserId: advertiserId, data: {
reqId: reqId, channel: channel,
creativeId: creativeId, clueToken: clueToken,
inviteUId: tempInviteUId adId: adId,
}, advertiserId: advertiserId,
showLoading: false, reqId: reqId,
success: ({ creativeId: creativeId,
data code: loginRes.code,
}) => { inviteUId: tempInviteUId
app.globalData.token = data.token; },
app.globalData.userId = data.pk_id; showLoading: false,
app.globalData.userInfo = data; success: ({
}, data
fail: (e) => { }) => {
setTimeout(() => { app.globalData.token = data.token;
redirectTo('home'); app.globalData.userId = data.pk_id;
}, 1300); app.globalData.userInfo = data;
}
});
} }
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment