|
@@ -1,3 +1,6 @@
|
|
|
|
|
+import {
|
|
|
|
|
+ postApi
|
|
|
|
|
+} from "../apis/api"
|
|
|
import cloudApi from "../apis/cloudApi"
|
|
import cloudApi from "../apis/cloudApi"
|
|
|
|
|
|
|
|
function wxSetSessionKey() {
|
|
function wxSetSessionKey() {
|
|
@@ -44,29 +47,22 @@ function getUserProfile() {
|
|
|
|
|
|
|
|
function getOpenId() {
|
|
function getOpenId() {
|
|
|
return new Promise(async (resolve, reject) => {
|
|
return new Promise(async (resolve, reject) => {
|
|
|
- let res1 = await cloudApi('getOpenId')
|
|
|
|
|
- resolve(res1.result.openId)
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-function subMsg() {
|
|
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
|
|
- wx.requestSubscribeMessage({
|
|
|
|
|
- tmplIds: ['q1joCPFWjhAxSJtrZ30QFi_aA9LVva4PQZmBcxZIPhU'],
|
|
|
|
|
- success: res => {
|
|
|
|
|
- console.log(res)
|
|
|
|
|
- },
|
|
|
|
|
- complete: e => {
|
|
|
|
|
- console.log(e)
|
|
|
|
|
|
|
+ wx.login({
|
|
|
|
|
+ success: async e => {
|
|
|
|
|
+ let res1 = await postApi('/wx/getOpenId', {
|
|
|
|
|
+ code: e.code
|
|
|
|
|
+ })
|
|
|
|
|
+ wx.setStorageSync('openId', res1.data.result)
|
|
|
|
|
+ resolve(res1.data.result)
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
module.exports = {
|
|
|
wxSetSessionKey,
|
|
wxSetSessionKey,
|
|
|
getUserProfile,
|
|
getUserProfile,
|
|
|
- getOpenId,
|
|
|
|
|
- subMsg
|
|
|
|
|
|
|
+ getOpenId
|
|
|
}
|
|
}
|