|
@@ -1,6 +1,6 @@
|
|
|
const app = getApp();
|
|
|
const {
|
|
|
- getBanner,
|
|
|
+ login,
|
|
|
listByDevice
|
|
|
} = require('../../utils/api.js');
|
|
|
|
|
@@ -77,6 +77,7 @@ Page({
|
|
|
|
|
|
onLoad(options) {
|
|
|
var that = this;
|
|
|
+ that.onLoginLoad();
|
|
|
that.onDeviceLoad();
|
|
|
that.onUserInfoLoad();
|
|
|
that.onBannerLoad();
|
|
@@ -87,6 +88,51 @@ Page({
|
|
|
that.onBannerShow();
|
|
|
},
|
|
|
|
|
|
+ onLoginLoad() {
|
|
|
+ var that = this;
|
|
|
+ var userInfo = wx.getStorageSync("userInfo") || "";
|
|
|
+ if (!strings.isEmpty(userInfo)) {
|
|
|
+ var phone = userInfo.phone;
|
|
|
+ if (!strings.isEmpty(phone)) {
|
|
|
+ that.loginReset(phone, null, null, null);
|
|
|
+ };
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ ///重新登录
|
|
|
+ loginReset(phone, succeedCall1, succeedCall2, failCall) {
|
|
|
+ // {"openid":"oZHPJ5JcNem2och3ToaocggmUENw","userId":933625,"deviceUid":1,"accessToken":"PUK8WVnLbIFsWYjSteitmg3OhllpbUMvIPKUtfJgwhRtpl1jx4Fm1NkHQIiZYhHz","phone":"15915390284","headUrl":"https://music-play.oss-cn-shenzhen.aliyuncs.com/user/headurl/20220316194115703366576.png","nickname":"儿子的爸爸叫啥"}
|
|
|
+ var that = this;
|
|
|
+ wx.login({
|
|
|
+ success: res0 => {
|
|
|
+ // {"openid":"oZHPJ5JcNem2och3ToaocggmUENw","unionid":null,"userId":933625,"deviceUid":1,"accessToken":"kaKdNAb9eO0iUGKsaLP18UE0wRwrvoCr4opjNC3AieaigH4Fu1IspQKi2zTPgLNG","phone":"15915390284","headUrl":"https://music-play.oss-cn-shenzhen.aliyuncs.com/user/headurl/20220316194115703366576.png","nickname":"儿子的爸爸叫啥","isNewUser":false}
|
|
|
+ login({
|
|
|
+ code: res0.code,
|
|
|
+ phone: phone,
|
|
|
+ }).then((res1) => {
|
|
|
+ app.globalData.userInfo = res1;
|
|
|
+ store.setStore("userInfo", res1);
|
|
|
+ store.setStore("token", JSON.stringify({
|
|
|
+ id: res1.userId,
|
|
|
+ token: res1.accessToken,
|
|
|
+ }));
|
|
|
+ that.onUserInfoLoad();
|
|
|
+ if (succeedCall1 != null) {
|
|
|
+ succeedCall1();
|
|
|
+ }
|
|
|
+ if (succeedCall2 != null) {
|
|
|
+ succeedCall2();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ fail(fail4) {
|
|
|
+ if (failCall != null) {
|
|
|
+ failCall();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
onDeviceLoad() {
|
|
|
var that = this;
|
|
|
var deviceList = store.getStore("deviceList");
|