|
|
@@ -1,5 +1,4 @@
|
|
|
import HttpRequest from '@/common/httpRequest'
|
|
|
-import queue from '@/common/queue'
|
|
|
|
|
|
/**
|
|
|
* 处理微信登录
|
|
|
@@ -11,8 +10,8 @@ export function wxLogin(callback) {
|
|
|
uni.login({
|
|
|
provider: 'weixin',
|
|
|
success: (wxRes) => {
|
|
|
- queue.setData('openId', wxRes.authResult.openid)
|
|
|
- queue.setData('unionId', wxRes.authResult.unionId)
|
|
|
+ setData('openId', wxRes.authResult.openid)
|
|
|
+ setData('unionId', wxRes.authResult.unionId)
|
|
|
let data = {
|
|
|
wxOpenId: loginRes.authResult.openid,
|
|
|
token: loginRes.authResult.access_token
|
|
|
@@ -65,17 +64,17 @@ export function phoneLogin(params) {
|
|
|
*/
|
|
|
export function login(res) {
|
|
|
if (res.code == 0) {
|
|
|
- queue.setData("userId", res.user.userId)
|
|
|
- queue.setData("token", res.token)
|
|
|
- queue.setData("phone", res.user.phone)
|
|
|
- queue.setData("userName", res.user.userName)
|
|
|
- queue.setData("avatar", res.user.avatar)
|
|
|
- queue.setData("invitationCode", res.user.invitationCode)
|
|
|
- queue.setData("inviterCode", res.user.inviterCode)
|
|
|
+ setData("userId", res.user.userId)
|
|
|
+ setData("token", res.token)
|
|
|
+ setData("phone", res.user.phone)
|
|
|
+ setData("userName", res.user.userName)
|
|
|
+ setData("avatar", res.user.avatar)
|
|
|
+ setData("invitationCode", res.user.invitationCode)
|
|
|
+ setData("inviterCode", res.user.inviterCode)
|
|
|
getIsVip()
|
|
|
uni.hideLoading()
|
|
|
if (res.user.userType) {
|
|
|
- queue.setData("userType", res.user.userType)
|
|
|
+ setData("userType", res.user.userType)
|
|
|
uni.reLaunch({
|
|
|
url: '/pages/my/index',
|
|
|
})
|
|
|
@@ -95,7 +94,7 @@ export function login(res) {
|
|
|
function getIsVip() {
|
|
|
HttpRequest.get("/app/UserVip/isUserVip").then((res) => {
|
|
|
if (res.code == 0) {
|
|
|
- queue.setData("isVip", res.data);
|
|
|
+ setData("isVip", res.data);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -113,3 +112,53 @@ export function membershipExpirationReminder(data) {
|
|
|
}, 1000)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取极光推送相关登录信息
|
|
|
+ */
|
|
|
+export function getJPLoginParams() {
|
|
|
+ // 极光推送SDK初始化注册ID
|
|
|
+ let registrationId = getData('registerID') || ''
|
|
|
+ // 设备类型:0 安卓、1 iOS、2 鸿蒙
|
|
|
+ let deviceType = 0
|
|
|
+ if (uni.getSystemInfoSync().platform == "ios") {
|
|
|
+ deviceType = 1
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ registrationId,
|
|
|
+ deviceType
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 退出登录,断开极光推送连接
|
|
|
+ */
|
|
|
+export function logoutJP() {
|
|
|
+ // 退出登录,断开极光推送连接
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ HttpRequest
|
|
|
+ .getT('/app/Login/out')
|
|
|
+ .then(res => {
|
|
|
+ console.log('退出登录成功', res)
|
|
|
+ })
|
|
|
+ // #endif
|
|
|
+}
|
|
|
+
|
|
|
+function setData(key, value) {
|
|
|
+ try {
|
|
|
+ uni.setStorageSync(key, value);
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function getData(key) {
|
|
|
+ try {
|
|
|
+ const value = uni.getStorageSync(key);
|
|
|
+ if (value) {
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e)
|
|
|
+ }
|
|
|
+}
|