|
|
|
<template>
|
|
|
|
<view>
|
|
|
|
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import {
|
|
|
|
loginBySilence,
|
|
|
|
getH5AccessToken,
|
|
|
|
getH5AccessByOpenId
|
|
|
|
} from '../../Utils/Api.js';
|
|
|
|
let app = getApp();
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onLoad(options) {
|
|
|
|
let that = this;
|
|
|
|
// #ifdef MP
|
|
|
|
app.globalData.accountId = options.accountId;
|
|
|
|
// uni.switchTab({
|
|
|
|
// url: '../tabBar/home/home'
|
|
|
|
// })
|
|
|
|
uni.switchTab({
|
|
|
|
url:'../tabBar/classify/classify'
|
|
|
|
})
|
|
|
|
// #endif
|
|
|
|
// #ifdef H5
|
|
|
|
var arr1 = window.location.href;
|
|
|
|
var arr2 = arr1.split('=');
|
|
|
|
if (arr2[1] != undefined && arr2[2] == '1#/') {
|
|
|
|
app.globalData.h5code = arr2[1];
|
|
|
|
uni.setStorage({
|
|
|
|
key: "h5code",
|
|
|
|
data: arr2[1]
|
|
|
|
})
|
|
|
|
uni.switchTab({
|
|
|
|
url: '../tabBar/home/home'
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
// 获取openid
|
|
|
|
that.jumpcdx();
|
|
|
|
uni.setStorage({
|
|
|
|
key: "accountId",
|
|
|
|
data: arr2[1]
|
|
|
|
})
|
|
|
|
|
|
|
|
uni.setStorage({
|
|
|
|
key: "accountType",
|
|
|
|
data: arr2[1]
|
|
|
|
})
|
|
|
|
if (arr2[2] != undefined && arr2[2]) {
|
|
|
|
let arr3 = arr2[2].split('&');
|
|
|
|
uni.setStorage({
|
|
|
|
key: "gasKey",
|
|
|
|
data: arr3[0]
|
|
|
|
})
|
|
|
|
that.loginBySilence(arr3[0]);
|
|
|
|
}
|
|
|
|
if (arr2[3] != undefined && arr2[3]) {
|
|
|
|
let arr4 = arr2[3].split('#');
|
|
|
|
uni.setStorage({
|
|
|
|
key: "staffCode",
|
|
|
|
data: arr4[0]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (app.globalData.h5code) {
|
|
|
|
that.getH5AccessToken();
|
|
|
|
}
|
|
|
|
// #endif
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
//h5静默登陆
|
|
|
|
loginBySilence(item) {
|
|
|
|
let datas = {
|
|
|
|
phone: item
|
|
|
|
}
|
|
|
|
loginBySilence(datas).then(res => {
|
|
|
|
if (res.return_code == '000000') {
|
|
|
|
app.globalData.userInfo = res.return_data
|
|
|
|
.object
|
|
|
|
.highUser;
|
|
|
|
app.globalData.token = res.return_data.uniqueCode;
|
|
|
|
uni.setStorage({
|
|
|
|
key: "user",
|
|
|
|
data: res.return_data
|
|
|
|
.object
|
|
|
|
.highUser
|
|
|
|
})
|
|
|
|
uni.setStorage({
|
|
|
|
key: "token",
|
|
|
|
data: res.return_data.uniqueCode
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
//H5 获取openId
|
|
|
|
getH5AccessToken() {
|
|
|
|
let params = {
|
|
|
|
code: app.globalData.h5code
|
|
|
|
}
|
|
|
|
getH5AccessToken(params).then(res => {
|
|
|
|
if (res.return_code == '000000' && res.return_data.openid) {
|
|
|
|
app.globalData.openId = res.return_data.openid;
|
|
|
|
uni.setStorage({
|
|
|
|
key: "openId",
|
|
|
|
data: res.return_data.openid
|
|
|
|
})
|
|
|
|
this.getH5AccessByOpenId();
|
|
|
|
} else {
|
|
|
|
this.jumpcdx();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
//判断手机号
|
|
|
|
getH5AccessByOpenId() {
|
|
|
|
let datas = {
|
|
|
|
openId: app.globalData.openId
|
|
|
|
}
|
|
|
|
getH5AccessByOpenId(datas).then(res => {
|
|
|
|
app.globalData.userInfo = res.return_data
|
|
|
|
.object
|
|
|
|
.highUser;
|
|
|
|
app.globalData.token = res.return_data.uniqueCode;
|
|
|
|
uni.setStorage({
|
|
|
|
key: "user",
|
|
|
|
data: res.return_data
|
|
|
|
.object
|
|
|
|
.highUser
|
|
|
|
})
|
|
|
|
uni.setStorage({
|
|
|
|
key: "token",
|
|
|
|
data: res.return_data.uniqueCode
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
jumpcdx() {
|
|
|
|
location.href =
|
|
|
|
'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa075e8509802f826&redirect_uri=https%3A%2F%2Fhsg.dctpay.com%2FhsgH5%2Findex.html%23%2F&response_type=code&scope=snsapi_base&state=1#wechat_redirect';
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
</style>
|