Commit 8b6803fd authored by mengcuiguang's avatar mengcuiguang

添加微信登录

parent f2b83d8e
......@@ -84,7 +84,7 @@
},
onShow() {
// if (app.globalData.resetLogin && !this.isFirstLoad) {
// // this.wxLogin()
// this.wxLogin()
// }
// this.isFirstLoad = false
......@@ -109,9 +109,6 @@
tabChange(index) {
if (this.currentPage == index) return
// if (app.globalData.token == '' || app.globalData.token == null) {
// this.wxLogin()
// }
this.currentPage = index;
this.loadComponentData();
},
......@@ -130,36 +127,6 @@
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) {
this.showEditBar = b
this.isFullChoice = false
......
......@@ -164,70 +164,6 @@
},
methods: {
show() {
console.log('123123123');
if (app.globalData.userInfo != 'undefined' && app.globalData.userInfo == null) {
this.visitorlogin();
} else {
this.loadPost();
}
},
visitorlogin() {
let that = this
var obj = wx.getEnterOptionsSync()
var tempInviteUId = this.shareId;
var channel = '' // 渠道
var clueToken = '' // 归因参数
var adId = '' // 计划id
var advertiserId = '' // 账号id
var reqId = '' // 请求id
var creativeId = '' // 创意id
if (obj.query.clueToken ?? '' != '') {
channel = 'tt'
clueToken = obj.query.clueToken ?? ''
adId = obj.query.adId ?? ''
advertiserId = obj.query.advertiserId ?? ''
reqId = obj.query.reqId ?? ''
creativeId = obj.query.creativeId ?? ''
}
if (obj.query.ksChannel ?? '' != '') {
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',
......@@ -249,19 +185,18 @@
}
});
// 最近观看剧
// this.post({
// url: '/vedio/newest',
// showLoading: false,
// success: ({
// data
// }) => {
// if (data.list != null && data.list.length > 0) {
// this.newRecordBean = data.list[0];
// }
// }
// });
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) {
// 推荐列表
this.post({
......
......@@ -46,13 +46,13 @@
},
onLaunch(options) {},
onShow(options) {
this.visitorlogin();
this.wxlogin();
setTimeout(() => {
redirectTo('home');
}, 2300);
},
methods: {
visitorlogin() {
wxlogin() {
let that = this
var obj = wx.getEnterOptionsSync()
var tempInviteUId = this.shareId;
......@@ -80,8 +80,12 @@
creativeId = obj.query.ksCreativeId ?? ''
}
this.post({
url: '/user/visitorlogin',
uni.login({
provider: 'weixin',
success: function(loginRes) {
that.post({
url: '/app/wxLogin',
data: {
channel: channel,
clueToken: clueToken,
......@@ -89,6 +93,7 @@
advertiserId: advertiserId,
reqId: reqId,
creativeId: creativeId,
code: loginRes.code,
inviteUId: tempInviteUId
},
showLoading: false,
......@@ -98,11 +103,9 @@
app.globalData.token = data.token;
app.globalData.userId = data.pk_id;
app.globalData.userInfo = data;
},
fail: (e) => {
setTimeout(() => {
redirectTo('home');
}, 1300);
}
});
}
});
}
......
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