-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.js
35 lines (33 loc) · 999 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import Vue from 'vue'
import App from './App'
Vue.config.productionTip = false
import { useAdapter, initCloud } from './util/cloud.js'
import { adapters } from './util/adapters.js'
useAdapter({ adapters, platform: 'uin-app' })
const wxcloud = initCloud()
const wxcloudConfig = {
appid:'wxxxxxxxxxxxxx', // 公众号appid
scope:'snsapi_base', // 登录授权类型
resourceAppid: 'wxxxxxxxxxxxxx', // 云托管环境ID所属资源方账号appid,资源复用或者自己
resourceEnv: 'prod-xxxx' // 云托管环境ID
}
wxcloud.checkLogin({
provider: 'OfficialAccount',
appid: wxcloudConfig.appid,
}).then(async res=>{
console.log('登录状态',res)
if(res.loggedIn==false){
wxcloud.startLogin({
provider: 'OfficialAccount',
appid: wxcloudConfig.appid,
scope: wxcloudConfig.scope,
redirectUri: window.location.href,
})
} else {
App.mpType = 'app'
const app = new Vue({ ...App })
app.cloud = wxcloud.Cloud(wxcloudConfig)
await app.cloud.init()
app.$mount()
}
})