|
@@ -4,7 +4,7 @@ import store from '@/store'
|
|
|
// #endif
|
|
// #endif
|
|
|
// import { share } from '@/mixins'
|
|
// import { share } from '@/mixins'
|
|
|
import CONSTANT from '@/constant'
|
|
import CONSTANT from '@/constant'
|
|
|
-import UTIL from '@/utils/util'
|
|
|
|
|
|
|
+// import util from '@/utils/util'
|
|
|
|
|
|
|
|
import {
|
|
import {
|
|
|
getStaffApi,
|
|
getStaffApi,
|
|
@@ -21,7 +21,7 @@ import util from './util'
|
|
|
*/
|
|
*/
|
|
|
export async function getShopUser(update) {
|
|
export async function getShopUser(update) {
|
|
|
let userInfo = store.getters.getShopUser
|
|
let userInfo = store.getters.getShopUser
|
|
|
- if (!UTIL.isEmpty(userInfo) && !update) {
|
|
|
|
|
|
|
+ if (!util.isEmpty(userInfo) && !update) {
|
|
|
return userInfo
|
|
return userInfo
|
|
|
}
|
|
}
|
|
|
await getShopUserApi().then((res) => {
|
|
await getShopUserApi().then((res) => {
|
|
@@ -40,7 +40,7 @@ export async function getShopUser(update) {
|
|
|
*/
|
|
*/
|
|
|
export async function getUser(update) {
|
|
export async function getUser(update) {
|
|
|
let userInfo = store.getters.getUser
|
|
let userInfo = store.getters.getUser
|
|
|
- if (!UTIL.isEmpty(userInfo) && !update) {
|
|
|
|
|
|
|
+ if (!util.isEmpty(userInfo) && !update) {
|
|
|
return userInfo
|
|
return userInfo
|
|
|
}
|
|
}
|
|
|
await getUserApi().then((res) => {
|
|
await getUserApi().then((res) => {
|
|
@@ -82,27 +82,23 @@ export async function wxLoginFn(update) {
|
|
|
if (!util.isEmpty(loginInfo) && !update) {
|
|
if (!util.isEmpty(loginInfo) && !update) {
|
|
|
return loginInfo
|
|
return loginInfo
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- let getObj = await new Promise(resolve => {
|
|
|
|
|
|
|
+ return new Promise(resolve => {
|
|
|
uni.login({
|
|
uni.login({
|
|
|
provider: 'weixin',
|
|
provider: 'weixin',
|
|
|
success: res => {
|
|
success: res => {
|
|
|
uni.setStorageSync('code', res.code)
|
|
uni.setStorageSync('code', res.code)
|
|
|
- resolve(res)
|
|
|
|
|
|
|
+ postWxCode({ code: res.code }).then(subRes => {
|
|
|
|
|
+ if (util.isEmpty(subRes)){
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+ resolve(subRes)
|
|
|
|
|
+ uni.setStorageSync('token', subRes.data.token)
|
|
|
|
|
+ uni.setStorageSync('shopId', subRes.data.shopId)
|
|
|
|
|
+ store.commit('setLoginInfo', subRes.data.user)
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
-
|
|
|
|
|
- await postWxCode({ code: getObj.code }).then(subRes => {
|
|
|
|
|
- if (UTIL.isEmpty(subRes)){
|
|
|
|
|
- return false
|
|
|
|
|
- }
|
|
|
|
|
- uni.setStorageSync('token', subRes.data.token)
|
|
|
|
|
- uni.setStorageSync('shopId', subRes.data.shopId)
|
|
|
|
|
- store.commit('setLoginInfo', subRes.data.user)
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- return dataInfo
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// export default {
|
|
// export default {
|