|
@@ -293,9 +293,11 @@ export default {
|
|
|
subjectList: [],
|
|
|
subIndex: 0,
|
|
|
courSubjectId: '',
|
|
|
+ optObj: {},
|
|
|
};
|
|
|
},
|
|
|
async onLoad(option) {
|
|
|
+ console.log('onLoadonLoad');
|
|
|
this.isLogin = this.$method.isLogin()
|
|
|
this.dictObj
|
|
|
this.getAdvertising();
|
|
@@ -327,6 +329,29 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
async onShow() {
|
|
|
+ // #ifdef H5
|
|
|
+ if (location.search) {
|
|
|
+ let arrs = location.search.slice(1).split("&")
|
|
|
+ for (let i = 0; i < arrs.length; i++) {
|
|
|
+ this.optObj[arrs[i].split('=')[0]] = arrs[i].split('=')[1]
|
|
|
+ }
|
|
|
+ console.log('optObj:', this.optObj);
|
|
|
+ uni.setStorageSync('h5_code', this.optObj.code)
|
|
|
+ this.OfficialLogin()
|
|
|
+ } else {
|
|
|
+ // 没有code,就重定向到地址https://www.xyyxt.net?ask_type=h.xyyxt.net 去获取code,授权后就会把code带上然后访问域名,这时候你就拿到code了
|
|
|
+ if (!uni.getStorageSync('h5_code')) {
|
|
|
+ console.log('跳转');
|
|
|
+ location.replace(
|
|
|
+ "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx6f48f721d18244eb" +
|
|
|
+ "&redirect_uri=" +
|
|
|
+ encodeURIComponent('https://www.xyyxt.net/?ask_type=h.xyyxt.net') +
|
|
|
+ "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"
|
|
|
+ )
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // #endif
|
|
|
this.getInfo() // 判断有没有关注公众号
|
|
|
this.isClickOff() //关注公众号,每天最多显示1次;当天学员关闭弹窗后,无需再显示
|
|
|
uni.removeStorageSync('goPath')
|
|
@@ -415,6 +440,18 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
...mapActions(['getUserInfo','appCommonConfig']),
|
|
|
+ // 公众号登录
|
|
|
+ OfficialLogin() {
|
|
|
+ this.$http({
|
|
|
+ url: '/gzh_login',
|
|
|
+ method: 'post',
|
|
|
+ data: {
|
|
|
+ code: this.optObj.code
|
|
|
+ },
|
|
|
+ }).then((res) => {
|
|
|
+ if (res.data.code == 200) {}
|
|
|
+ })
|
|
|
+ },
|
|
|
tobuy(item) {
|
|
|
if (item.goodsType == 2) {
|
|
|
uni.navigateTo({
|