|
@@ -9,6 +9,7 @@ const {
|
|
|
import lexin_util from '../../../utils/lexin/util.js';
|
|
|
import routePath from '../../../utils/routePath.js';
|
|
|
import routeUtil from '../../../utils/routeUtil.js';
|
|
|
+import { autoAuth, unbind, EnumPlatformId } from '../../../utils/auth/auth_util.js';
|
|
|
|
|
|
Page({
|
|
|
data: {
|
|
@@ -24,21 +25,21 @@ Page({
|
|
|
alarm_id_1: {}, // 唤醒
|
|
|
timeindex: 1,
|
|
|
timeArray: [{
|
|
|
- id: 600,
|
|
|
- name: '10分钟'
|
|
|
- },
|
|
|
- {
|
|
|
- id: 1800,
|
|
|
- name: '30分钟'
|
|
|
- },
|
|
|
- {
|
|
|
- id: 3600,
|
|
|
- name: '60分钟'
|
|
|
- },
|
|
|
- {
|
|
|
- id: 5400,
|
|
|
- name: '90分钟'
|
|
|
- }
|
|
|
+ id: 600,
|
|
|
+ name: '10分钟'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 1800,
|
|
|
+ name: '30分钟'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 3600,
|
|
|
+ name: '60分钟'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 5400,
|
|
|
+ name: '90分钟'
|
|
|
+ }
|
|
|
],
|
|
|
clientType: "",
|
|
|
time0: '00:00:00',
|
|
@@ -58,13 +59,16 @@ Page({
|
|
|
twoButText: "好的",
|
|
|
footTop: 10,
|
|
|
},
|
|
|
- twoButCallback: () => {},
|
|
|
+ twoButCallback: () => { },
|
|
|
toast_visible: false,
|
|
|
// 后续新加需求
|
|
|
deviceOther: null,
|
|
|
updataDeviceInfo: false,
|
|
|
repeatIndex: 0,
|
|
|
deviceId: "",
|
|
|
+ isQQAuth: false,
|
|
|
+ isAuthXmly: false,
|
|
|
+ qqAuthInfo: {},
|
|
|
},
|
|
|
|
|
|
onLoad(options) {
|
|
@@ -93,6 +97,11 @@ Page({
|
|
|
DstDeviceName: deviceMac
|
|
|
});
|
|
|
|
|
|
+ app.PubMsg({
|
|
|
+ type: "start_dm_auth",
|
|
|
+ DstDeviceName: deviceMac
|
|
|
+ });
|
|
|
+
|
|
|
// 赋值按钮回调
|
|
|
that.setData({
|
|
|
twoButCallback: () => {
|
|
@@ -105,11 +114,11 @@ Page({
|
|
|
|
|
|
onShow(options) {
|
|
|
var that = this;
|
|
|
- var deviceMac = that.data.deviceMac;
|
|
|
- app.PubMsg({
|
|
|
- type: "get_dev_info",
|
|
|
- DstDeviceName: deviceMac,
|
|
|
- });
|
|
|
+ // var deviceMac = that.data.deviceMac;
|
|
|
+ // app.PubMsg({
|
|
|
+ // type: "get_dev_info",
|
|
|
+ // DstDeviceName: deviceMac,
|
|
|
+ // });
|
|
|
},
|
|
|
|
|
|
mqttCallback(type, option) {
|
|
@@ -136,6 +145,7 @@ Page({
|
|
|
case "message":
|
|
|
// 设备信息
|
|
|
if (payloads.type === "get_dev_info") {
|
|
|
+ console.log("设备信息get_dev_info:", payloads);
|
|
|
that.setData({
|
|
|
deviceOther: payloads.other,
|
|
|
updataDeviceInfo: true,
|
|
@@ -223,8 +233,19 @@ Page({
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
+ } else if (payloads.type === "start_dm_auth") {
|
|
|
+ // {
|
|
|
+ // "dsn": "431589788221452",
|
|
|
+ // "authReqInfo": {
|
|
|
+ // "codeChallenge": "YzJkMmU5NGU2Y2NlZjM1ODAwMDIzNjJjYmZmY2Y5OTJhY2Q0MmU1N2FiYzBkYWYyMzVmMDJlYzMxMTZiMjc1Mw==",
|
|
|
+ // "sessionId": "1646821421"
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ console.log("设备信息start_dm_auth:", payloads);
|
|
|
+ that.data.qqAuthInfo = payloads.other;
|
|
|
+
|
|
|
}
|
|
|
- default:
|
|
|
+ default:
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -473,6 +494,92 @@ Page({
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
+ goQQAuth() {
|
|
|
+ var that = this;
|
|
|
+ if (that.data.isQQAuth) {
|
|
|
+ wx.showModal({
|
|
|
+ title: '解除授权',
|
|
|
+ content: '确定要解除QQ音乐授权吗?',
|
|
|
+ success(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ that.setData({
|
|
|
+ isQQAuth: false
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+
|
|
|
+ autoAuth(EnumPlatformId.QQ, that.getDeivce()).then((res) => {
|
|
|
+ console.log("isQQAuth", res);
|
|
|
+ if (res) {
|
|
|
+ that.setData({
|
|
|
+ isAuthXmly: true
|
|
|
+ });
|
|
|
+ } else if (res === false) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '授权失败,请稍后再试',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // null的不处理
|
|
|
+ }
|
|
|
+ }).catch((error) => {
|
|
|
+ console.error('Error during authorization:', error);
|
|
|
+ wx.showToast({
|
|
|
+ title: '授权失败,请稍后再试',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ goXmlyAuth() {
|
|
|
+ var that = this;
|
|
|
+ console.log("goXmlyAuth", that.data.isAuthXmly)
|
|
|
+ if (that.data.isAuthXmly) {
|
|
|
+ wx.showModal({
|
|
|
+ title: '解除授权',
|
|
|
+ content: '确定要解除喜马拉雅授权吗?',
|
|
|
+ success(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ unbind(EnumPlatformId.XMLY, that.getDeivce()).then((res) => {
|
|
|
+ that.setData({
|
|
|
+ isAuthXmly: res
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // routeUtil.jump(routePath.xmlyAuth);
|
|
|
+ autoAuth(EnumPlatformId.XMLY, that.getDeivce()).then((res) => {
|
|
|
+ console.log("isAuthXmly", res);
|
|
|
+
|
|
|
+ if (res) {
|
|
|
+ that.setData({
|
|
|
+ isAuthXmly: true
|
|
|
+ });
|
|
|
+ } else if (res === false) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '授权失败,请稍后再试',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // null的不处理
|
|
|
+ }
|
|
|
+ }).catch((error) => {
|
|
|
+ console.error('Error during authorization:', error);
|
|
|
+ wx.showToast({
|
|
|
+ title: '授权失败,请稍后再试',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getDeivce() {
|
|
|
+ var that = this;
|
|
|
+ return { "clientType": that.data.clientType, "deviceMac": that.data.deviceMac, "deviceId": that.data.deviceId, "dsn": that.data.qqAuthInfo.dsn };
|
|
|
+ },
|
|
|
|
|
|
/**
|
|
|
* 时间戳转化为年 月 日 时 分 秒
|