lan 1 anno fa
parent
commit
1a5cee1e55

+ 222 - 36
assets/prefab/public/DeviceCodeUI.prefab

@@ -24,23 +24,20 @@
         "__id__": 5
       },
       {
-        "__id__": 8
-      },
-      {
-        "__id__": 11
+        "__id__": 16
       },
       {
-        "__id__": 14
+        "__id__": 19
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 24
+        "__id__": 29
       }
     ],
     "_prefab": {
-      "__id__": 25
+      "__id__": 30
     },
     "_opacity": 255,
     "_color": {
@@ -198,20 +195,90 @@
   },
   {
     "__type__": "cc.Node",
-    "_name": "codeBg",
+    "_name": "codeNode",
     "_objFlags": 0,
     "_parent": {
       "__id__": 1
     },
+    "_children": [
+      {
+        "__id__": 6
+      },
+      {
+        "__id__": 9
+      },
+      {
+        "__id__": 12
+      }
+    ],
+    "_active": false,
+    "_components": [],
+    "_prefab": {
+      "__id__": 15
+    },
+    "_opacity": 255,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 0,
+      "height": 0
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_trs": {
+      "__type__": "TypedArray",
+      "ctor": "Float64Array",
+      "array": [
+        0,
+        0,
+        0,
+        0,
+        0,
+        0,
+        1,
+        1,
+        1,
+        1
+      ]
+    },
+    "_eulerAngles": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_skewX": 0,
+    "_skewY": 0,
+    "_is3DNode": false,
+    "_groupIndex": 0,
+    "groupIndex": 0,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "codeBg",
+    "_objFlags": 0,
+    "_parent": {
+      "__id__": 5
+    },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 6
+        "__id__": 7
       }
     ],
     "_prefab": {
-      "__id__": 7
+      "__id__": 8
     },
     "_opacity": 255,
     "_color": {
@@ -265,7 +332,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 5
+      "__id__": 6
     },
     "_enabled": true,
     "_materials": [
@@ -300,7 +367,7 @@
     "asset": {
       "__id__": 0
     },
-    "fileId": "eczYtAoSlI1a08Xj0htXxq",
+    "fileId": "48Xc9MMvZNira88aISvoI0",
     "sync": false
   },
   {
@@ -308,17 +375,17 @@
     "_name": "code",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 1
+      "__id__": 5
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 9
+        "__id__": 10
       }
     ],
     "_prefab": {
-      "__id__": 10
+      "__id__": 11
     },
     "_opacity": 255,
     "_color": {
@@ -372,7 +439,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 8
+      "__id__": 9
     },
     "_enabled": true,
     "_materials": [
@@ -408,7 +475,7 @@
     "asset": {
       "__id__": 0
     },
-    "fileId": "daOXq2AEhF86OM83hyULDh",
+    "fileId": "5cj75WP4ZH7KFmWD+0QQaM",
     "sync": false
   },
   {
@@ -416,17 +483,17 @@
     "_name": "lb",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 1
+      "__id__": 5
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 12
+        "__id__": 13
       }
     ],
     "_prefab": {
-      "__id__": 13
+      "__id__": 14
     },
     "_opacity": 255,
     "_color": {
@@ -480,7 +547,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 11
+      "__id__": 12
     },
     "_enabled": true,
     "_materials": [
@@ -516,7 +583,126 @@
     "asset": {
       "__id__": 0
     },
-    "fileId": "a60un75mFCyLQNcIpJ5uoQ",
+    "fileId": "0eys67wPxMHZO45F/yg5r6",
+    "sync": false
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "c6Qhf/GLJN1q2uurqMPuUu",
+    "sync": false
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "tipLb",
+    "_objFlags": 0,
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 17
+      }
+    ],
+    "_prefab": {
+      "__id__": 18
+    },
+    "_opacity": 255,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 0,
+      "height": 50.4
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_trs": {
+      "__type__": "TypedArray",
+      "ctor": "Float64Array",
+      "array": [
+        0,
+        0,
+        0,
+        0,
+        0,
+        0,
+        1,
+        1,
+        1,
+        1
+      ]
+    },
+    "_eulerAngles": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_skewX": 0,
+    "_skewY": 0,
+    "_is3DNode": false,
+    "_groupIndex": 0,
+    "groupIndex": 0,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.Label",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 16
+    },
+    "_enabled": true,
+    "_materials": [
+      {
+        "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
+      }
+    ],
+    "_srcBlendFactor": 770,
+    "_dstBlendFactor": 771,
+    "_string": "",
+    "_N$string": "",
+    "_fontSize": 32,
+    "_lineHeight": 40,
+    "_enableWrapText": true,
+    "_N$file": null,
+    "_isSystemFontUsed": true,
+    "_spacingX": 0,
+    "_batchAsBitmap": false,
+    "_styleFlags": 0,
+    "_underlineHeight": 0,
+    "_N$horizontalAlign": 1,
+    "_N$verticalAlign": 1,
+    "_N$fontFamily": "Arial",
+    "_N$overflow": 0,
+    "_N$cacheMode": 0,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "21Rg33qGlA2pugdAQ0QuPR",
     "sync": false
   },
   {
@@ -528,20 +714,20 @@
     },
     "_children": [
       {
-        "__id__": 15
+        "__id__": 20
       },
       {
-        "__id__": 18
+        "__id__": 23
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 21
+        "__id__": 26
       }
     ],
     "_prefab": {
-      "__id__": 23
+      "__id__": 28
     },
     "_opacity": 255,
     "_color": {
@@ -595,17 +781,17 @@
     "_name": "default_btn_normal",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 14
+      "__id__": 19
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 16
+        "__id__": 21
       }
     ],
     "_prefab": {
-      "__id__": 17
+      "__id__": 22
     },
     "_opacity": 255,
     "_color": {
@@ -659,7 +845,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 15
+      "__id__": 20
     },
     "_enabled": true,
     "_materials": [
@@ -702,17 +888,17 @@
     "_name": "Label",
     "_objFlags": 0,
     "_parent": {
-      "__id__": 14
+      "__id__": 19
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 19
+        "__id__": 24
       }
     ],
     "_prefab": {
-      "__id__": 20
+      "__id__": 25
     },
     "_opacity": 255,
     "_color": {
@@ -766,7 +952,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 18
+      "__id__": 23
     },
     "_enabled": true,
     "_materials": [
@@ -810,7 +996,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 14
+      "__id__": 19
     },
     "_enabled": true,
     "_normalMaterial": null,
@@ -819,7 +1005,7 @@
     "zoomScale": 1.2,
     "clickEvents": [
       {
-        "__id__": 22
+        "__id__": 27
       }
     ],
     "_N$interactable": true,

+ 3 - 0
assets/script/GameControl.ts

@@ -14,6 +14,7 @@ import {HttpManager} from './mgrs/HttpManager'
 import {LocalMsgManager} from './mgrs/LocalMsgManager'
 import {HomeData} from './data/HomeData'
 import {ChildData} from './data/ChildData'
+import {ActiveManager} from './mgrs/ActiveManager'
 
 export const Data = {
     game: new GameData(), // 游戏数据
@@ -39,12 +40,14 @@ export const Mgr = {
     net: new NetManager(), // Net管理器
     http: new HttpManager(), // HTTP管理器
     localMsg: new LocalMsgManager(), // 局域网数据处理管理器
+    active: new ActiveManager(), // 激活处理管理器
     async init() {
         cc.director.getCollisionManager().enabled = true
         // cc.director.getCollisionManager().enabledDebugDraw = true
 
         let isInit: boolean = true
         Mgr.localMsg.init()
+        Mgr.active.init()
         // 屏蔽暂时不需要的初始化
         // Mgr.platform.init()
         // Mgr.res.init()

+ 3 - 0
assets/script/enums/Enum.ts

@@ -20,6 +20,9 @@ export enum LOCAL {
     chineseWordChooseStr = 'chineseWordChooseStr', // 幼儿园自选汉字
     app_key = 'app_key', // 机构码
     deviceID = 'deviceID', // 设备ID
+    winActiveTime = 'winActiveTime', // 设备激活时间
+    winExpireTime = 'winExpireTime', // 设备过期时间
+    winUpdateTime = 'winUpdateTime', // 设备请求接口时间
 }
 
 export enum EVENT {

+ 205 - 0
assets/script/lib/MD5.ts

@@ -0,0 +1,205 @@
+/** @format */
+
+export function md5(md5str: string) {
+    var createMD5String = function (string: string) {
+        var x = Array()
+        var k, AA, BB, CC, DD, a, b, c, d
+        var S11 = 7,
+            S12 = 12,
+            S13 = 17,
+            S14 = 22
+        var S21 = 5,
+            S22 = 9,
+            S23 = 14,
+            S24 = 20
+        var S31 = 4,
+            S32 = 11,
+            S33 = 16,
+            S34 = 23
+        var S41 = 6,
+            S42 = 10,
+            S43 = 15,
+            S44 = 21
+        string = uTF8Encode(string)
+        x = convertToWordArray(string)
+        a = 0x67452301
+        b = 0xefcdab89
+        c = 0x98badcfe
+        d = 0x10325476
+        for (k = 0; k < x.length; k += 16) {
+            AA = a
+            BB = b
+            CC = c
+            DD = d
+            a = FF(a, b, c, d, x[k + 0], S11, 0xd76aa478)
+            d = FF(d, a, b, c, x[k + 1], S12, 0xe8c7b756)
+            c = FF(c, d, a, b, x[k + 2], S13, 0x242070db)
+            b = FF(b, c, d, a, x[k + 3], S14, 0xc1bdceee)
+            a = FF(a, b, c, d, x[k + 4], S11, 0xf57c0faf)
+            d = FF(d, a, b, c, x[k + 5], S12, 0x4787c62a)
+            c = FF(c, d, a, b, x[k + 6], S13, 0xa8304613)
+            b = FF(b, c, d, a, x[k + 7], S14, 0xfd469501)
+            a = FF(a, b, c, d, x[k + 8], S11, 0x698098d8)
+            d = FF(d, a, b, c, x[k + 9], S12, 0x8b44f7af)
+            c = FF(c, d, a, b, x[k + 10], S13, 0xffff5bb1)
+            b = FF(b, c, d, a, x[k + 11], S14, 0x895cd7be)
+            a = FF(a, b, c, d, x[k + 12], S11, 0x6b901122)
+            d = FF(d, a, b, c, x[k + 13], S12, 0xfd987193)
+            c = FF(c, d, a, b, x[k + 14], S13, 0xa679438e)
+            b = FF(b, c, d, a, x[k + 15], S14, 0x49b40821)
+            a = GG(a, b, c, d, x[k + 1], S21, 0xf61e2562)
+            d = GG(d, a, b, c, x[k + 6], S22, 0xc040b340)
+            c = GG(c, d, a, b, x[k + 11], S23, 0x265e5a51)
+            b = GG(b, c, d, a, x[k + 0], S24, 0xe9b6c7aa)
+            a = GG(a, b, c, d, x[k + 5], S21, 0xd62f105d)
+            d = GG(d, a, b, c, x[k + 10], S22, 0x2441453)
+            c = GG(c, d, a, b, x[k + 15], S23, 0xd8a1e681)
+            b = GG(b, c, d, a, x[k + 4], S24, 0xe7d3fbc8)
+            a = GG(a, b, c, d, x[k + 9], S21, 0x21e1cde6)
+            d = GG(d, a, b, c, x[k + 14], S22, 0xc33707d6)
+            c = GG(c, d, a, b, x[k + 3], S23, 0xf4d50d87)
+            b = GG(b, c, d, a, x[k + 8], S24, 0x455a14ed)
+            a = GG(a, b, c, d, x[k + 13], S21, 0xa9e3e905)
+            d = GG(d, a, b, c, x[k + 2], S22, 0xfcefa3f8)
+            c = GG(c, d, a, b, x[k + 7], S23, 0x676f02d9)
+            b = GG(b, c, d, a, x[k + 12], S24, 0x8d2a4c8a)
+            a = HH(a, b, c, d, x[k + 5], S31, 0xfffa3942)
+            d = HH(d, a, b, c, x[k + 8], S32, 0x8771f681)
+            c = HH(c, d, a, b, x[k + 11], S33, 0x6d9d6122)
+            b = HH(b, c, d, a, x[k + 14], S34, 0xfde5380c)
+            a = HH(a, b, c, d, x[k + 1], S31, 0xa4beea44)
+            d = HH(d, a, b, c, x[k + 4], S32, 0x4bdecfa9)
+            c = HH(c, d, a, b, x[k + 7], S33, 0xf6bb4b60)
+            b = HH(b, c, d, a, x[k + 10], S34, 0xbebfbc70)
+            a = HH(a, b, c, d, x[k + 13], S31, 0x289b7ec6)
+            d = HH(d, a, b, c, x[k + 0], S32, 0xeaa127fa)
+            c = HH(c, d, a, b, x[k + 3], S33, 0xd4ef3085)
+            b = HH(b, c, d, a, x[k + 6], S34, 0x4881d05)
+            a = HH(a, b, c, d, x[k + 9], S31, 0xd9d4d039)
+            d = HH(d, a, b, c, x[k + 12], S32, 0xe6db99e5)
+            c = HH(c, d, a, b, x[k + 15], S33, 0x1fa27cf8)
+            b = HH(b, c, d, a, x[k + 2], S34, 0xc4ac5665)
+            a = II(a, b, c, d, x[k + 0], S41, 0xf4292244)
+            d = II(d, a, b, c, x[k + 7], S42, 0x432aff97)
+            c = II(c, d, a, b, x[k + 14], S43, 0xab9423a7)
+            b = II(b, c, d, a, x[k + 5], S44, 0xfc93a039)
+            a = II(a, b, c, d, x[k + 12], S41, 0x655b59c3)
+            d = II(d, a, b, c, x[k + 3], S42, 0x8f0ccc92)
+            c = II(c, d, a, b, x[k + 10], S43, 0xffeff47d)
+            b = II(b, c, d, a, x[k + 1], S44, 0x85845dd1)
+            a = II(a, b, c, d, x[k + 8], S41, 0x6fa87e4f)
+            d = II(d, a, b, c, x[k + 15], S42, 0xfe2ce6e0)
+            c = II(c, d, a, b, x[k + 6], S43, 0xa3014314)
+            b = II(b, c, d, a, x[k + 13], S44, 0x4e0811a1)
+            a = II(a, b, c, d, x[k + 4], S41, 0xf7537e82)
+            d = II(d, a, b, c, x[k + 11], S42, 0xbd3af235)
+            c = II(c, d, a, b, x[k + 2], S43, 0x2ad7d2bb)
+            b = II(b, c, d, a, x[k + 9], S44, 0xeb86d391)
+            a = addUnsigned(a, AA)
+            b = addUnsigned(b, BB)
+            c = addUnsigned(c, CC)
+            d = addUnsigned(d, DD)
+        }
+        var tempValue = wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d)
+        return tempValue.toLowerCase()
+    }
+    var rotateLeft = function (lValue: number, iShiftBits: number) {
+        return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits))
+    }
+    var addUnsigned = function (lX: number, lY: number) {
+        var lX4, lY4, lX8, lY8, lResult
+        lX8 = lX & 0x80000000
+        lY8 = lY & 0x80000000
+        lX4 = lX & 0x40000000
+        lY4 = lY & 0x40000000
+        lResult = (lX & 0x3fffffff) + (lY & 0x3fffffff)
+        if (lX4 & lY4) return lResult ^ 0x80000000 ^ lX8 ^ lY8
+        if (lX4 | lY4) {
+            if (lResult & 0x40000000) return lResult ^ 0xc0000000 ^ lX8 ^ lY8
+            else return lResult ^ 0x40000000 ^ lX8 ^ lY8
+        } else {
+            return lResult ^ lX8 ^ lY8
+        }
+    }
+    var F = function (x: number, y: number, z: number) {
+        return (x & y) | (~x & z)
+    }
+    var G = function (x: number, y: number, z: number) {
+        return (x & z) | (y & ~z)
+    }
+    var H = function (x: number, y: number, z: number) {
+        return x ^ y ^ z
+    }
+    var I = function (x: number, y: number, z: number) {
+        return y ^ (x | ~z)
+    }
+    var FF = function (a: number, b: number, c: number, d: number, x: number, s: number, ac: number) {
+        a = addUnsigned(a, addUnsigned(addUnsigned(F(b, c, d), x), ac))
+        return addUnsigned(rotateLeft(a, s), b)
+    }
+    var GG = function (a: number, b: number, c: number, d: number, x: number, s: number, ac: number) {
+        a = addUnsigned(a, addUnsigned(addUnsigned(G(b, c, d), x), ac))
+        return addUnsigned(rotateLeft(a, s), b)
+    }
+    var HH = function (a: number, b: number, c: number, d: number, x: number, s: number, ac: number) {
+        a = addUnsigned(a, addUnsigned(addUnsigned(H(b, c, d), x), ac))
+        return addUnsigned(rotateLeft(a, s), b)
+    }
+    var II = function (a: number, b: number, c: number, d: number, x: number, s: number, ac: number) {
+        a = addUnsigned(a, addUnsigned(addUnsigned(I(b, c, d), x), ac))
+        return addUnsigned(rotateLeft(a, s), b)
+    }
+    var convertToWordArray = function (string: string) {
+        var lWordCount
+        var lMessageLength = string.length
+        var lNumberOfWordsTempOne = lMessageLength + 8
+        var lNumberOfWordsTempTwo = (lNumberOfWordsTempOne - (lNumberOfWordsTempOne % 64)) / 64
+        var lNumberOfWords = (lNumberOfWordsTempTwo + 1) * 16
+        var lWordArray = Array(lNumberOfWords - 1)
+        var lBytePosition = 0
+        var lByteCount = 0
+        while (lByteCount < lMessageLength) {
+            lWordCount = (lByteCount - (lByteCount % 4)) / 4
+            lBytePosition = (lByteCount % 4) * 8
+            lWordArray[lWordCount] = lWordArray[lWordCount] | (string.charCodeAt(lByteCount) << lBytePosition)
+            lByteCount++
+        }
+        lWordCount = (lByteCount - (lByteCount % 4)) / 4
+        lBytePosition = (lByteCount % 4) * 8
+        lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition)
+        lWordArray[lNumberOfWords - 2] = lMessageLength << 3
+        lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29
+        return lWordArray
+    }
+    var wordToHex = function (lValue: number) {
+        var WordToHexValue = '',
+            WordToHexValueTemp = '',
+            lByte,
+            lCount
+        for (lCount = 0; lCount <= 3; lCount++) {
+            lByte = (lValue >>> (lCount * 8)) & 255
+            WordToHexValueTemp = '0' + lByte.toString(16)
+            WordToHexValue = WordToHexValue + WordToHexValueTemp.substr(WordToHexValueTemp.length - 2, 2)
+        }
+        return WordToHexValue
+    }
+    var uTF8Encode = function (string: string) {
+        string = string.toString().replace(/\x0d\x0a/g, '\x0a')
+        var output = ''
+        for (var n = 0; n < string.length; n++) {
+            var c = string.charCodeAt(n)
+            if (c < 128) {
+                output += String.fromCharCode(c)
+            } else if (c > 127 && c < 2048) {
+                output += String.fromCharCode((c >> 6) | 192)
+                output += String.fromCharCode((c & 63) | 128)
+            } else {
+                output += String.fromCharCode((c >> 12) | 224)
+                output += String.fromCharCode(((c >> 6) & 63) | 128)
+                output += String.fromCharCode((c & 63) | 128)
+            }
+        }
+        return output
+    }
+    return createMD5String(md5str)
+}

+ 10 - 0
assets/script/lib/MD5.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "d956f4c6-6c0c-4744-af0b-556e45203333",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 33 - 0
assets/script/mgrs/ActiveManager.ts

@@ -0,0 +1,33 @@
+/** @format */
+import {Data, Mgr} from '../GameControl'
+import {LOCAL} from '../enums/Enum'
+import {UI} from '../enums/UI'
+export class ActiveManager {
+    recodeTimeIntervalId: any
+    init() {
+        this.clearRecodeTimeInterval()
+    }
+    recodeTime() {
+        let winExpireTime = Mgr.storage.getNumber(LOCAL.winExpireTime)
+        let winUpdateTime = Mgr.storage.getNumber(LOCAL.winUpdateTime)
+        if (Date.now() < winUpdateTime) {
+            this.clearRecodeTimeInterval()
+            Mgr.ui.closeAll()
+            Mgr.ui.show(UI.DeviceCodeUI, '当前设备时间异常,请联网恢复正常时间')
+        } else {
+            Mgr.storage.set(LOCAL.winUpdateTime, Date.now())
+            if (Date.now() > winExpireTime) {
+                this.clearRecodeTimeInterval()
+                Mgr.ui.closeAll()
+                Mgr.ui.show(UI.DeviceCodeUI, '当前设备激活已过期,请联系管理员激活')
+            }
+        }
+    }
+    startRecodeTime() {
+        this.recodeTimeIntervalId = setInterval(this.recodeTime.bind(this), 5 * 1000)
+    }
+    clearRecodeTimeInterval() {
+        if (this.recodeTimeIntervalId) clearInterval(this.recodeTimeIntervalId)
+        this.recodeTimeIntervalId = null
+    }
+}

+ 10 - 0
assets/script/mgrs/ActiveManager.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "f618db75-2550-49ff-8517-4482d162b5d5",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 60 - 24
assets/script/ui/MainScene.ts

@@ -10,6 +10,7 @@ import {SemePartCfg} from '../config/SemePartCfg'
 import {HttpUrl} from '../config/HttpUrl'
 import {ccUtils} from '../utils/ccUtils'
 import {HomeWorkGames} from '../config/GlobalConfig'
+import {md5} from '../lib/MD5'
 
 /** @format */
 
@@ -113,36 +114,73 @@ export default class MainScene extends BaseUI {
                         Mgr.storage.set(LOCAL.homeCurUser, Data.home.curUser)
                         this.startGameHome()
                     },
-                    fail(): void {},
                 })
-            } else if (theRequest.windows) {
+            } else if (theRequest.windows || Mgr.platform.isWindows()) {
                 Data.global.curAppType = APP_TYPE.windows
                 let data: any = {}
-                Data.child.deviceID = theRequest.deviceID
-                data.deviceId = theRequest.deviceID
+                if (theRequest.windows) Data.child.deviceID = theRequest.deviceID
+                if (Mgr.platform.isWindows()) {
+                    // @ts-ignore
+                    Data.child.deviceID = md5(cc.jsbbridge.GetCPUNumber())
+                }
+                //Data.child.deviceID = '8dceab9afeb65e8ec9698175603ebc85'
+                data.deviceId = Data.child.deviceID
                 data.productId = 10001
                 if (data.deviceId) {
-                    Mgr.http.request({
-                        url: HttpUrl.deviceActivate,
-                        method: 'POST',
-                        data,
-                        success: (res: any) => {
-                            let activate = res.data ? res.data[0] : null
-                            if (activate && activate.status == 1 && Date.now() > new Date(activate.issued).getTime()) {
-                                Mgr.ui.show(UI.MainLaunchUI)
+                    let winActiveTime = Mgr.storage.getNumber(LOCAL.winActiveTime)
+                    let winExpireTime = Mgr.storage.getNumber(LOCAL.winExpireTime)
+                    let winUpdateTime = Mgr.storage.getNumber(LOCAL.winUpdateTime)
+                    if (Mgr.platform.isWindows() && winActiveTime) {
+                        if (Date.now() < winUpdateTime) {
+                            Mgr.ui.show(UI.DeviceCodeUI, '当前设备时间异常,请联网恢复正常时间')
+                        } else {
+                            Mgr.storage.set(LOCAL.winUpdateTime, Date.now())
+                            if (Date.now() > winExpireTime) {
+                                Mgr.ui.show(UI.DeviceCodeUI, '当前设备激活已过期,请联系管理员激活')
+                            } else if (Date.now() < winActiveTime) {
+                                Mgr.ui.show(
+                                    UI.DeviceCodeUI,
+                                    `当前设备激活时间未到,请${Date.Format('yyyy-MM-dd   hh:mm', winActiveTime)}后进入`,
+                                )
                             } else {
-                                Mgr.ui.show(UI.DeviceCodeUI)
-                                Mgr.ui.tip('当前设备未激活不可用')
+                                Mgr.ui.show(UI.MainLaunchUI)
+                                Mgr.active.startRecodeTime()
                             }
-                        },
-                        fail(): void {},
-                    })
-                } else {
-                    Mgr.ui.show(UI.DeviceCodeUI)
+                        }
+                    } else {
+                        Mgr.http.request({
+                            url: HttpUrl.deviceActivate,
+                            method: 'POST',
+                            data,
+                            success: (res: any) => {
+                                let activate = res.data ? res.data[0] : null
+                                if (activate) {
+                                    if (Mgr.platform.isWindows()) {
+                                        Mgr.storage.set(LOCAL.winUpdateTime, Date.now())
+                                        Mgr.storage.set(LOCAL.winActiveTime, new Date(activate.issued).getTime())
+                                        Mgr.storage.set(LOCAL.winExpireTime, new Date(activate.expire).getTime())
+                                    }
+                                    if (
+                                        activate.status == 1 &&
+                                        Date.now() > new Date(activate.issued).getTime() &&
+                                        Date.now() < new Date(activate.expire).getTime()
+                                    ) {
+                                        Mgr.ui.show(UI.MainLaunchUI)
+                                        if (Mgr.platform.isWindows()) Mgr.active.startRecodeTime()
+                                    } else {
+                                        Mgr.ui.show(UI.DeviceCodeUI, '当前设备未激活不可用')
+                                    }
+                                } else {
+                                    Mgr.ui.show(UI.DeviceCodeUI)
+                                    Mgr.ui.tip('请绑定设备')
+                                }
+                            },
+                            fail: () => {
+                                Mgr.ui.show(UI.DeviceCodeUI, '当前设备链接网络失败,请检查网络')
+                            },
+                        })
+                    }
                 }
-            } else if (Mgr.platform.isWindows()) {
-                Data.global.curAppType = APP_TYPE.windows
-                Mgr.ui.show(UI.MainLaunchUI)
             } else {
                 this.startGameHome()
             }
@@ -208,7 +246,6 @@ export default class MainScene extends BaseUI {
                                         Mgr.storage.set(LOCAL.loginAndUsersVersion, serverVersion.version)
                                         finish(versionKey)
                                     },
-                                    fail(): void {},
                                 })
                             } else if (versionKey == 'getActivates' && (lowVer || !Data.home.productInfo)) {
                                 Mgr.http.request({
@@ -298,7 +335,6 @@ export default class MainScene extends BaseUI {
 
                                         finish(versionKey)
                                     },
-                                    fail(): void {},
                                 })
                             }
                         }

+ 1 - 2
assets/script/ui/home/HomeLoginUI.ts

@@ -70,7 +70,7 @@ export class HomeLoginUI extends BaseUI {
                 this.unschedule(this.codeCountdown)
                 this.schedule(this.codeCountdown, 1, 60)
             },
-            fail(): void {
+            fail: () => {
                 Mgr.ui.tip('验证码获取失败,请重试')
             },
         })
@@ -98,7 +98,6 @@ export class HomeLoginUI extends BaseUI {
                 this.hide()
                 cc.director.loadScene('Main')
             },
-            fail(): void {},
         })
     }
 }

+ 1 - 1
assets/script/ui/home/HomeSemeTestCheckUI.ts

@@ -105,7 +105,7 @@ export class HomeSemeTestCheckUI extends BaseUI {
         semeBg.forEach((value, index1) => {
             value.active = index1 == Math.floor(Data.global.semeType.indexOf(data.semeID.toString()) / 2)
         })
-        ccUtils.setLabel(Date.Format('yyyy-MM-dd   hh:mm', data.time / 1000), node, 'time')
+        ccUtils.setLabel(Date.Format('yyyy-MM-dd   hh:mm', data.time), node, 'time')
         node['data'] = data
     }
     initClassItem(node, index) {

+ 1 - 1
assets/script/ui/home/HomeSemeTestHistoryUI.ts

@@ -45,7 +45,7 @@ export class HomeSemeTestHistoryUI extends BaseUI {
         semeBg.forEach((value, index1) => {
             value.active = index1 == Math.floor(Data.global.semeType.indexOf(data.semeID.toString()) / 2)
         })
-        ccUtils.setLabel(Date.Format('yyyy-MM-dd   hh:mm', data.time / 1000), node, 'time')
+        ccUtils.setLabel(Date.Format('yyyy-MM-dd   hh:mm', data.time), node, 'time')
         node['data'] = data
     }
     onItemClick(event) {

+ 2 - 2
assets/script/ui/mathApp/game/ClockGameUI.ts

@@ -48,7 +48,7 @@ export default class ClockGameUI extends TeachingGameUI {
         let date = new Date()
         date.setHours(this.answerHour)
         date.setMinutes(this.answerMinute)
-        ccUtils.setLabel(Date.Format('hh    mm', date.getTime() / 1000), this.node, 'answerTime')
+        ccUtils.setLabel(Date.Format('hh    mm', date.getTime()), this.node, 'answerTime')
     }
     protected onEnable() {
         this.touchNode.on(cc.Node.EventType.TOUCH_START, this.handTouchStart, this)
@@ -136,6 +136,6 @@ export default class ClockGameUI extends TeachingGameUI {
         let date = new Date()
         date.setHours(hour != undefined ? hour : this.curHour)
         date.setMinutes(this.curMinute)
-        ccUtils.setLabel(Date.Format('hh:mm', date.getTime() / 1000), this.node, 'time')
+        ccUtils.setLabel(Date.Format('hh:mm', date.getTime()), this.node, 'time')
     }
 }

+ 32 - 12
assets/script/ui/public/DeviceCodeUI.ts

@@ -12,16 +12,15 @@ const {ccclass, property} = cc._decorator
 @ccclass
 export class MainLaunchUI extends BaseUI {
     onShow(args, fromUI: number) {
-        let node = cc.find('code', this.node)
+        this.tip(args ? args : '')
+        let codeGraph = cc.find('codeNode/code', this.node)
         let qrcode = new QRCode(-1, QRErrorCorrectLevel.H)
         qrcode.addData(Data.child.deviceID)
         qrcode.make()
-
-        let ctx = node.getComponent(cc.Graphics)!
+        let ctx = codeGraph.getComponent(cc.Graphics)!
         ctx.fillColor = cc.Color.BLACK
-        let tileW = node.width / qrcode.getModuleCount()
-        let tileH = node.height / qrcode.getModuleCount()
-
+        let tileW = codeGraph.width / qrcode.getModuleCount()
+        let tileH = codeGraph.height / qrcode.getModuleCount()
         // draw in the Graphics
         for (let row = 0; row < qrcode.getModuleCount(); row++) {
             for (let col = 0; col < qrcode.getModuleCount(); col++) {
@@ -46,15 +45,36 @@ export class MainLaunchUI extends BaseUI {
             method: 'POST',
             data,
             success: (res: any) => {
-                let activate = res.data![0]
-                if (activate && activate.status == 1 && Date.now() > new Date(activate.issued).getTime()) {
-                    this.hide()
-                    Mgr.ui.show(UI.MainLaunchUI)
+                let activate = res.data ? res.data[0] : null
+                if (activate) {
+                    if (Mgr.platform.isWindows()) {
+                        Mgr.storage.set(LOCAL.winUpdateTime, Date.now())
+                        Mgr.storage.set(LOCAL.winActiveTime, new Date(activate.issued).getTime())
+                        Mgr.storage.set(LOCAL.winExpireTime, new Date(activate.expire).getTime())
+                    }
+                    if (
+                        activate.status == 1 &&
+                        Date.now() > new Date(activate.issued).getTime() &&
+                        Date.now() < new Date(activate.expire).getTime()
+                    ) {
+                        Mgr.ui.show(UI.MainLaunchUI)
+                        if (Mgr.platform.isWindows()) Mgr.active.startRecodeTime()
+                    } else {
+                        this.tip('当前设备未激活不可用')
+                    }
                 } else {
-                    Mgr.ui.tip('当前设备未激活不可用')
+                    this.tip('')
+                    Mgr.ui.tip('请绑定设备')
                 }
             },
-            fail(): void {},
+            fail: () => {
+                this.tip('当前设备链接网络失败,请检查网络')
+            },
         })
     }
+    tip(tip: string) {
+        cc.find('codeNode', this.node).active = tip == ''
+        cc.find('tipLb', this.node).active = tip != ''
+        ccUtils.setLabel(tip, this.node, 'tipLb')
+    }
 }

+ 0 - 2
assets/script/ui/public/TopBtnUI.ts

@@ -123,7 +123,6 @@ export default class TopBtnUI extends BaseUI {
                                     }
                                     Mgr.storage.set(LOCAL.childAllStudents, JSON.stringify(Data.child.allStudents))
                                 },
-                                fail(): void {},
                             })
                         } else {
                             finish(versionKey)
@@ -137,7 +136,6 @@ export default class TopBtnUI extends BaseUI {
                     }
                     requestFuc()
                 },
-                fail(): void {},
             })
         }
     }

+ 1 - 1
assets/script/utils/DateUtils.ts

@@ -25,7 +25,7 @@ Date.Format = (fmt: string, value?: number): string => {
     if (!value) {
         tempDate = new Date()
     } else {
-        tempDate = new Date(value * 1000)
+        tempDate = new Date(value)
     }
     const o = {
         'M+': tempDate.getMonth() + 1, // 月份

+ 3 - 1
build-templates/jsb-link/main.js

@@ -150,7 +150,9 @@ if (window.jsb) {
         }
         require('jsb-adapter/jsb-engine.js');
     }
-
+    if (cc.sys.isNative && cc.sys.os === cc.sys.OS_WINDOWS) {
+        cc.jsbbridge = jsbbridge.JSBBridge.getInstance()
+    }
     cc.macro.CLEANUP_IMAGE_CACHE = true;
     window.boot();
 }

+ 56 - 48
build/jsb-link/frameworks/runtime-src/Classes/jsb_module_register.cpp

@@ -41,6 +41,10 @@
 #include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.hpp"
 #include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.hpp"
 
+#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
+#include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_jsbbridge_auto.hpp"
+#endif
+
 #if USE_GFX_RENDERER
 #include "cocos/scripting/js-bindings/auto/jsb_gfx_auto.hpp"
 #include "cocos/scripting/js-bindings/auto/jsb_renderer_auto.hpp"
@@ -103,73 +107,73 @@ using namespace cocos2d;
 
 bool jsb_register_all_modules()
 {
-    se::ScriptEngine* se = se::ScriptEngine::getInstance();
-
-    se->addBeforeInitHook([](){
-        JSBClassType::init();
-    });
-
-    se->addBeforeCleanupHook([se](){
-        se->garbageCollect();
-        PoolManager::getInstance()->getCurrentPool()->clear();
-        se->garbageCollect();
-        PoolManager::getInstance()->getCurrentPool()->clear();
-    });
-
-    se->addRegisterCallback(jsb_register_global_variables);
-    se->addRegisterCallback(JSB_register_opengl);
-    se->addRegisterCallback(register_all_engine);
-    se->addRegisterCallback(register_all_cocos2dx_manual);
-    se->addRegisterCallback(register_platform_bindings);
-    
-    se->addRegisterCallback(register_all_network);
-    se->addRegisterCallback(register_all_cocos2dx_network_manual);
-    se->addRegisterCallback(register_all_xmlhttprequest);
-    // extension depend on network
-    se->addRegisterCallback(register_all_extension);
+	se::ScriptEngine* se = se::ScriptEngine::getInstance();
+
+	se->addBeforeInitHook([]() {
+		JSBClassType::init();
+	});
+
+	se->addBeforeCleanupHook([se]() {
+		se->garbageCollect();
+		PoolManager::getInstance()->getCurrentPool()->clear();
+		se->garbageCollect();
+		PoolManager::getInstance()->getCurrentPool()->clear();
+	});
+
+	se->addRegisterCallback(jsb_register_global_variables);
+	se->addRegisterCallback(JSB_register_opengl);
+	se->addRegisterCallback(register_all_engine);
+	se->addRegisterCallback(register_all_cocos2dx_manual);
+	se->addRegisterCallback(register_platform_bindings);
+
+	se->addRegisterCallback(register_all_network);
+	se->addRegisterCallback(register_all_cocos2dx_network_manual);
+	se->addRegisterCallback(register_all_xmlhttprequest);
+	// extension depend on network
+	se->addRegisterCallback(register_all_extension);
 
 #if USE_GFX_RENDERER
-    se->addRegisterCallback(register_all_gfx);
-    se->addRegisterCallback(jsb_register_gfx_manual);
-    se->addRegisterCallback(register_all_renderer);
-    se->addRegisterCallback(jsb_register_renderer_manual);
+	se->addRegisterCallback(register_all_gfx);
+	se->addRegisterCallback(jsb_register_gfx_manual);
+	se->addRegisterCallback(register_all_renderer);
+	se->addRegisterCallback(jsb_register_renderer_manual);
 #endif
 
 #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
-    se->addRegisterCallback(register_javascript_objc_bridge);
+	se->addRegisterCallback(register_javascript_objc_bridge);
 #endif
 
 #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
-    se->addRegisterCallback(register_javascript_java_bridge);
+	se->addRegisterCallback(register_javascript_java_bridge);
 #endif
 
 #if USE_AUDIO
-    se->addRegisterCallback(register_all_audioengine);
+	se->addRegisterCallback(register_all_audioengine);
 #endif
-    
+
 #if USE_SOCKET
-    se->addRegisterCallback(register_all_websocket);
-    se->addRegisterCallback(register_all_socketio);
+	se->addRegisterCallback(register_all_websocket);
+	se->addRegisterCallback(register_all_socketio);
 #if USE_WEBSOCKET_SERVER
-    se->addRegisterCallback(register_all_websocket_server);
+	se->addRegisterCallback(register_all_websocket_server);
 #endif
 #endif
 
 #if USE_GFX_RENDERER && USE_MIDDLEWARE
-    se->addRegisterCallback(register_all_cocos2dx_editor_support);
+	se->addRegisterCallback(register_all_cocos2dx_editor_support);
 
 #if USE_SPINE
-    se->addRegisterCallback(register_all_cocos2dx_spine);
-    se->addRegisterCallback(register_all_spine_manual);
+	se->addRegisterCallback(register_all_cocos2dx_spine);
+	se->addRegisterCallback(register_all_spine_manual);
 #endif
 
 #if USE_DRAGONBONES
-    se->addRegisterCallback(register_all_cocos2dx_dragonbones);
-    se->addRegisterCallback(register_all_dragonbones_manual);
+	se->addRegisterCallback(register_all_cocos2dx_dragonbones);
+	se->addRegisterCallback(register_all_dragonbones_manual);
 #endif
 
 #if USE_PARTICLE
-    se->addRegisterCallback(register_all_cocos2dx_particle);
+	se->addRegisterCallback(register_all_cocos2dx_particle);
 #endif
 
 #endif // USE_MIDDLEWARE
@@ -177,18 +181,22 @@ bool jsb_register_all_modules()
 #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
 
 #if USE_VIDEO
-    se->addRegisterCallback(register_all_video);
+	se->addRegisterCallback(register_all_video);
 #endif
 
 #if USE_WEB_VIEW
-    se->addRegisterCallback(register_all_webview);
+	se->addRegisterCallback(register_all_webview);
 #endif
 
 #endif // (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
 
-    se->addAfterCleanupHook([](){
-        PoolManager::getInstance()->getCurrentPool()->clear();
-        JSBClassType::destroy();
-    });
-    return true;
+#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
+	se->addRegisterCallback(register_all_cocos2dx_jsbbridge);
+#endif
+
+	se->addAfterCleanupHook([]() {
+		PoolManager::getInstance()->getCurrentPool()->clear();
+		JSBClassType::destroy();
+	});
+	return true;
 }