|
|
|
@ -12,7 +12,7 @@ import { gotoBack, validates } from "@/libs/utils"; |
|
|
|
import config from "@/libs/utils/config"; |
|
|
|
import { encryptData } from "@/libs/utils/crypto"; |
|
|
|
|
|
|
|
const appData = getApp().globalData; |
|
|
|
// const appData = getApp().globalData; |
|
|
|
/** |
|
|
|
* 判断小程序的API,回调,参数,组件等是否在当前版本可用 |
|
|
|
*/ |
|
|
|
@ -105,8 +105,11 @@ function wxLogin() { |
|
|
|
async success(res) { |
|
|
|
const res2 = await xcxWxLoginApi({ code: res.code }); |
|
|
|
if (res2.code === "0") { |
|
|
|
openid.value = res2.openid; |
|
|
|
openid.value = res2.data.openid; |
|
|
|
uni.setStorageSync("openid", openid.value); |
|
|
|
// FIXME: 这里的session_key 是无效的,询问一下 |
|
|
|
// uni.setStorageSync("session", res2.data.session_key); |
|
|
|
|
|
|
|
getUserByXcxAPPOpenId({ openid: openid.value }); |
|
|
|
} |
|
|
|
else { |
|
|
|
@ -121,21 +124,24 @@ function wxLogin() { |
|
|
|
* 根据用户openid获取session |
|
|
|
*/ |
|
|
|
async function getUserByXcxAPPOpenId(data) { |
|
|
|
appData.header = { |
|
|
|
"content-type": "", |
|
|
|
"header": "", |
|
|
|
"version": "2.0", |
|
|
|
}; |
|
|
|
// appData.header = { |
|
|
|
// "content-type": "", |
|
|
|
// "header": "", |
|
|
|
// "version": "2.0", |
|
|
|
// }; |
|
|
|
uni.showLoading({ title: "登录中..." }); |
|
|
|
const res = await getUserByXcxAPPOpenIdApi(data); |
|
|
|
uni.hideLoading(); |
|
|
|
|
|
|
|
if (res.code === "0") { |
|
|
|
appData.header.session = res.header.session; |
|
|
|
appData.header["X-Header-Token"] = res.header.session; |
|
|
|
uni.setStorageSync("session", res.header.session); |
|
|
|
uni.hideLoading(); |
|
|
|
// uni.setStorageSync("X-Header-Token", res.header.session); |
|
|
|
// appData.header.session = res.header.session; |
|
|
|
// appData.header["X-Header-Token"] = res.header.session; |
|
|
|
// uni.setStorageSync("session", res.header.session); |
|
|
|
getmyarea(); |
|
|
|
} |
|
|
|
else { |
|
|
|
uni.hideLoading(); |
|
|
|
updateUserInfo(res); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -143,9 +149,9 @@ async function getUserByXcxAPPOpenId(data) { |
|
|
|
async function getmyarea() { |
|
|
|
const res = await getmyareaApi({ warehouseid: "", isEnabled: 1 }); |
|
|
|
if (res.code === "0") { |
|
|
|
const list = res.data.list.sort((pre, cur) => Number(cur) - Number(pre)); |
|
|
|
// const list = res.data.list.sort((pre, cur) => Number(cur) - Number(pre)); |
|
|
|
// each 就是找到有isLastDefaultAddr,没有就那第一个值 |
|
|
|
const each = list.find(each => each.isLastDefaultAddr) || list[0]; |
|
|
|
const each = res.data.list.find(each => each.isLastDefaultAddr) || res.data.list[0]; |
|
|
|
uni.setStorageSync("warehousId", each.warehousId); |
|
|
|
uni.setStorageSync("addressId", each.addrId); |
|
|
|
// selectAddress.value = list[0]; |
|
|
|
@ -249,11 +255,14 @@ onLoad(() => { |
|
|
|
if (uni.getUserProfile) { |
|
|
|
canIUseGetUserProfile.value = true; |
|
|
|
} |
|
|
|
uni.getSystemInfo({ |
|
|
|
success(res) { |
|
|
|
isIos.value = res.platform === "ios"; |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
isIos.value = uni.getAppBaseInfo().uniPlatform === "ios"; |
|
|
|
|
|
|
|
// uni.getSystemInfo({ |
|
|
|
// success(res) { |
|
|
|
// isIos.value = res.platform === "ios"; |
|
|
|
// }, |
|
|
|
// }); |
|
|
|
}); |
|
|
|
</script> |
|
|
|
|
|
|
|
|