|
@@ -11,15 +11,49 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
type: 'spinner-cycle',
|
|
|
- title: '加载中...'
|
|
|
+ title: '加载中...',
|
|
|
+ isSuccess: false,
|
|
|
}
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ window.addEventListener('popstate', this.handleBack);
|
|
|
+ },
|
|
|
+ beforeDestroy() {
|
|
|
+ window.removeEventListener('popstate', this.handleBack);
|
|
|
+ },
|
|
|
+ handleBack() {
|
|
|
+
|
|
|
+ const name = 'authXmlyWeb'
|
|
|
+ const code = this.isSuccess ? "1" : "0"
|
|
|
+ const postMessage = `?name=${name}&code=${code}`
|
|
|
+ if (window.wx && window.wx.miniProgram) {
|
|
|
+ uni.showToast({
|
|
|
+ title: "微信小程序环境2",
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ window.wx.miniProgram.postMessage(postMessage);
|
|
|
+ } else if (window.webChannel) {
|
|
|
+ uni.showToast({
|
|
|
+ title: "app环境2",
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ webChannel.postMessage(postMessage)
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: "其他环境2",
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });}
|
|
|
+ },
|
|
|
onLoad(e) {
|
|
|
const deviceid = window.location.hash.split('=')[1]
|
|
|
getCallBack({ ...e, deviceid: deviceid }).then(res => {
|
|
|
if (res.code === 0) {
|
|
|
this.type = 'checkbox-filled'
|
|
|
this.title = '授权成功!'
|
|
|
+ this.isSuccess = true
|
|
|
} else {
|
|
|
this.type = 'clear'
|
|
|
this.title = '授权失败!'
|
|
@@ -29,10 +63,25 @@ export default {
|
|
|
const code = res.code === 0 ? "1" : "0"
|
|
|
const postMessage = `?name=${name}&code=${code}`
|
|
|
if (window.wx && window.wx.miniProgram) {
|
|
|
- window.wx && window.wx.miniProgram.postMessage(postMessage);
|
|
|
+ uni.showToast({
|
|
|
+ title: "微信小程序环境",
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ window.wx.miniProgram.postMessage(postMessage);
|
|
|
} else if (window.webChannel) {
|
|
|
+ uni.showToast({
|
|
|
+ title: "app环境",
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
webChannel.postMessage(postMessage)
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: "其他环境",
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });}
|
|
|
})
|
|
|
}, getEnvType() {
|
|
|
if (window.wx && window.wx.miniProgram) {
|