Baozhangchao 3 anni fa
parent
commit
a0d93fb6f2

+ 90
- 4
package-lock.json Vedi File

@@ -4,6 +4,15 @@
4 4
   "lockfileVersion": 1,
5 5
   "requires": true,
6 6
   "dependencies": {
7
+    "@ahooksjs/use-request": {
8
+      "version": "2.8.13",
9
+      "resolved": "https://registry.npmmirror.com/@ahooksjs/use-request/download/@ahooksjs/use-request-2.8.13.tgz?cache=0&sync_timestamp=1635254759234&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2F%40ahooksjs%2Fuse-request%2Fdownload%2F%40ahooksjs%2Fuse-request-2.8.13.tgz",
10
+      "integrity": "sha1-Ws5ThZ/ra0/p68vy5ymCu5t9s4M=",
11
+      "requires": {
12
+        "lodash.debounce": "^4.0.8",
13
+        "lodash.throttle": "^4.1.1"
14
+      }
15
+    },
7 16
     "@antmjs/iconfont": {
8 17
       "version": "1.9.4",
9 18
       "resolved": "https://registry.npmmirror.com/@antmjs/iconfont/download/@antmjs/iconfont-1.9.4.tgz",
@@ -11,6 +20,8 @@
11 20
     },
12 21
     "@antmjs/vantui": {
13 22
       "version": "1.2.5",
23
+      "resolved": "https://registry.npmmirror.com/@antmjs/vantui/download/@antmjs/vantui-1.2.5.tgz",
24
+      "integrity": "sha512-DHO8dIKe17L7jOUhooc1Gp8uCfxBCFjP/ArexXXQOzjiDSu4NcwbycDr/99Olj3921Ia7s06NGgxAHKZFz0Qyw==",
14 25
       "requires": {
15 26
         "@antmjs/iconfont": "1.9.4",
16 27
         "@babel/runtime-corejs3": "^7.14.7",
@@ -1760,6 +1771,8 @@
1760 1771
     },
1761 1772
     "@tarojs/mini-runner": {
1762 1773
       "version": "3.2.13",
1774
+      "resolved": "https://registry.npmmirror.com/@tarojs/mini-runner/download/@tarojs/mini-runner-3.2.13.tgz",
1775
+      "integrity": "sha1-qRfXuJXbhs+mSc9/KyZp8pIx7A4=",
1763 1776
       "dev": true,
1764 1777
       "requires": {
1765 1778
         "@babel/core": "^7.11.1",
@@ -2521,6 +2534,8 @@
2521 2534
     },
2522 2535
     "@tarojs/react": {
2523 2536
       "version": "3.2.13",
2537
+      "resolved": "https://registry.npmmirror.com/@tarojs/react/download/@tarojs/react-3.2.13.tgz",
2538
+      "integrity": "sha1-3hFS4QruBgDRBLuCk2DaU7ZspZc=",
2524 2539
       "requires": {
2525 2540
         "@tarojs/runtime": "3.2.13",
2526 2541
         "@tarojs/shared": "3.2.13",
@@ -2683,6 +2698,8 @@
2683 2698
     },
2684 2699
     "@tarojs/webpack-runner": {
2685 2700
       "version": "3.2.13",
2701
+      "resolved": "https://registry.npmmirror.com/@tarojs/webpack-runner/download/@tarojs/webpack-runner-3.2.13.tgz",
2702
+      "integrity": "sha1-/1F2aTQnJ9xEJp/A4O+nyDoZcxY=",
2686 2703
       "dev": true,
2687 2704
       "requires": {
2688 2705
         "@babel/core": "^7.11.1",
@@ -2882,6 +2899,11 @@
2882 2899
         "@types/node": "*"
2883 2900
       }
2884 2901
     },
2902
+    "@types/js-cookie": {
2903
+      "version": "2.2.7",
2904
+      "resolved": "https://registry.npmmirror.com/@types/js-cookie/download/@types/js-cookie-2.2.7.tgz",
2905
+      "integrity": "sha1-ImqeMWgINaYYjoh/OYjmDATT9qM="
2906
+    },
2885 2907
     "@types/json-schema": {
2886 2908
       "version": "7.0.9",
2887 2909
       "resolved": "https://registry.npmmirror.com/@types/json-schema/download/@types/json-schema-7.0.9.tgz?cache=0&sync_timestamp=1637266272940&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2F%40types%2Fjson-schema%2Fdownload%2F%40types%2Fjson-schema-7.0.9.tgz",
@@ -2945,6 +2967,8 @@
2945 2967
     },
2946 2968
     "@types/react": {
2947 2969
       "version": "17.0.37",
2970
+      "resolved": "https://registry.npmmirror.com/@types/react/download/@types/react-17.0.37.tgz",
2971
+      "integrity": "sha512-2FS1oTqBGcH/s0E+CjrCCR9+JMpsu9b69RTFO+40ua43ZqP5MmQ4iUde/dMjWR909KxZwmOQIFq6AV6NjEG5xg==",
2948 2972
       "dev": true,
2949 2973
       "requires": {
2950 2974
         "@types/prop-types": "*",
@@ -2969,6 +2993,8 @@
2969 2993
     },
2970 2994
     "@types/webpack-env": {
2971 2995
       "version": "1.16.3",
2996
+      "resolved": "https://registry.npmmirror.com/@types/webpack-env/download/@types/webpack-env-1.16.3.tgz",
2997
+      "integrity": "sha1-t3YyenPlYbceeIHQzW00oUJNuGo=",
2972 2998
       "dev": true
2973 2999
     },
2974 3000
     "@typescript-eslint/parser": {
@@ -3470,6 +3496,23 @@
3470 3496
         }
3471 3497
       }
3472 3498
     },
3499
+    "ahooks": {
3500
+      "version": "2.10.12",
3501
+      "resolved": "https://registry.npmmirror.com/ahooks/download/ahooks-2.10.12.tgz",
3502
+      "integrity": "sha1-6Mq2UwOUNCeeaVaag0LGArNUXas=",
3503
+      "requires": {
3504
+        "@ahooksjs/use-request": "^2.8.13",
3505
+        "@types/js-cookie": "^2.2.6",
3506
+        "dayjs": "^1.9.1",
3507
+        "intersection-observer": "^0.7.0",
3508
+        "js-cookie": "^2.2.1",
3509
+        "lodash.debounce": "^4.0.8",
3510
+        "lodash.isequal": "^4.5.0",
3511
+        "lodash.throttle": "^4.1.1",
3512
+        "resize-observer-polyfill": "^1.5.1",
3513
+        "screenfull": "^5.0.0"
3514
+      }
3515
+    },
3473 3516
     "ajv": {
3474 3517
       "version": "6.12.6",
3475 3518
       "resolved": "https://registry.npmmirror.com/ajv/download/ajv-6.12.6.tgz?cache=0&sync_timestamp=1637523008505&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fajv%2Fdownload%2Fajv-6.12.6.tgz",
@@ -3871,6 +3914,8 @@
3871 3914
     },
3872 3915
     "babel-plugin-import": {
3873 3916
       "version": "1.13.3",
3917
+      "resolved": "https://registry.npm.taobao.org/babel-plugin-import/download/babel-plugin-import-1.13.3.tgz?cache=0&sync_timestamp=1606209853373&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbabel-plugin-import%2Fdownload%2Fbabel-plugin-import-1.13.3.tgz",
3918
+      "integrity": "sha1-nbu6fRrHK9QSkXqDDUReAJQdJtc=",
3874 3919
       "dev": true,
3875 3920
       "requires": {
3876 3921
         "@babel/helper-module-imports": "^7.0.0",
@@ -3951,6 +3996,8 @@
3951 3996
     },
3952 3997
     "babel-preset-taro": {
3953 3998
       "version": "3.2.13",
3999
+      "resolved": "https://registry.npmmirror.com/babel-preset-taro/download/babel-preset-taro-3.2.13.tgz",
4000
+      "integrity": "sha1-/QmeMzY6/+frMtS2NROAwkKvvp8=",
3954 4001
       "dev": true,
3955 4002
       "requires": {
3956 4003
         "@babel/plugin-proposal-class-properties": "7.10.4",
@@ -6269,6 +6316,8 @@
6269 6316
     },
6270 6317
     "eslint": {
6271 6318
       "version": "6.8.0",
6319
+      "resolved": "https://registry.npmmirror.com/eslint/download/eslint-6.8.0.tgz",
6320
+      "integrity": "sha1-YiYtZylzn5J1cjgkMC+yJ8jJP/s=",
6272 6321
       "dev": true,
6273 6322
       "requires": {
6274 6323
         "@babel/code-frame": "^7.0.0",
@@ -6462,6 +6511,8 @@
6462 6511
     },
6463 6512
     "eslint-config-taro": {
6464 6513
       "version": "3.2.13",
6514
+      "resolved": "https://registry.npmmirror.com/eslint-config-taro/download/eslint-config-taro-3.2.13.tgz",
6515
+      "integrity": "sha1-f6ZM0vIxG7bmfEv8iSA9l8H+eVM=",
6465 6516
       "dev": true,
6466 6517
       "requires": {
6467 6518
         "@typescript-eslint/parser": "^4.15.1",
@@ -6522,6 +6573,8 @@
6522 6573
     },
6523 6574
     "eslint-plugin-import": {
6524 6575
       "version": "2.25.3",
6576
+      "resolved": "https://registry.npmmirror.com/eslint-plugin-import/download/eslint-plugin-import-2.25.3.tgz?cache=0&sync_timestamp=1636529283636&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Feslint-plugin-import%2Fdownload%2Feslint-plugin-import-2.25.3.tgz",
6577
+      "integrity": "sha512-RzAVbby+72IB3iOEL8clzPLzL3wpDrlwjsTBAQXgyp5SeTqqY+0bFubwuo+y/HLhNZcXV4XqTBO4LGsfyHIDXg==",
6525 6578
       "dev": true,
6526 6579
       "requires": {
6527 6580
         "array-includes": "^3.1.4",
@@ -6558,6 +6611,8 @@
6558 6611
     },
6559 6612
     "eslint-plugin-react": {
6560 6613
       "version": "7.27.1",
6614
+      "resolved": "https://registry.npmmirror.com/eslint-plugin-react/download/eslint-plugin-react-7.27.1.tgz?cache=0&sync_timestamp=1637309464913&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Feslint-plugin-react%2Fdownload%2Feslint-plugin-react-7.27.1.tgz",
6615
+      "integrity": "sha512-meyunDjMMYeWr/4EBLTV1op3iSG3mjT/pz5gti38UzfM4OPpNc2m0t2xvKCOMU5D6FSdd34BIMFOvQbW+i8GAA==",
6561 6616
       "dev": true,
6562 6617
       "requires": {
6563 6618
         "array-includes": "^3.1.4",
@@ -6596,6 +6651,8 @@
6596 6651
     },
6597 6652
     "eslint-plugin-react-hooks": {
6598 6653
       "version": "4.3.0",
6654
+      "resolved": "https://registry.npmmirror.com/eslint-plugin-react-hooks/download/eslint-plugin-react-hooks-4.3.0.tgz",
6655
+      "integrity": "sha512-XslZy0LnMn+84NEG9jSGR6eGqaZB3133L8xewQo3fQagbQuGt7a63gf+P1NGKZavEYEC3UXaWEAA/AqDkuN6xA==",
6599 6656
       "dev": true
6600 6657
     },
6601 6658
     "eslint-scope": {
@@ -8515,8 +8572,7 @@
8515 8572
     "intersection-observer": {
8516 8573
       "version": "0.7.0",
8517 8574
       "resolved": "https://registry.npm.taobao.org/intersection-observer/download/intersection-observer-0.7.0.tgz?cache=0&sync_timestamp=1607914497037&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fintersection-observer%2Fdownload%2Fintersection-observer-0.7.0.tgz",
8518
-      "integrity": "sha1-7ha+6XjbU1FurS8KgVSwm0ALvck=",
8519
-      "dev": true
8575
+      "integrity": "sha1-7ha+6XjbU1FurS8KgVSwm0ALvck="
8520 8576
     },
8521 8577
     "ip": {
8522 8578
       "version": "1.1.5",
@@ -9019,6 +9075,11 @@
9019 9075
       "integrity": "sha1-9OaGxd4eofhn28rT1G2WlCjfmMQ=",
9020 9076
       "dev": true
9021 9077
     },
9078
+    "js-cookie": {
9079
+      "version": "2.2.1",
9080
+      "resolved": "https://registry.nlark.com/js-cookie/download/js-cookie-2.2.1.tgz",
9081
+      "integrity": "sha1-aeEG3F1YBolFYpAqpbrsN0Tpsrg="
9082
+    },
9022 9083
     "js-tokens": {
9023 9084
       "version": "4.0.0",
9024 9085
       "resolved": "https://registry.nlark.com/js-tokens/download/js-tokens-4.0.0.tgz?cache=0&sync_timestamp=1619345098261&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fjs-tokens%2Fdownload%2Fjs-tokens-4.0.0.tgz",
@@ -9353,14 +9414,18 @@
9353 9414
     "lodash.debounce": {
9354 9415
       "version": "4.0.8",
9355 9416
       "resolved": "https://registry.nlark.com/lodash.debounce/download/lodash.debounce-4.0.8.tgz?cache=0&sync_timestamp=1618847031591&other_urls=https%3A%2F%2Fregistry.nlark.com%2Flodash.debounce%2Fdownload%2Flodash.debounce-4.0.8.tgz",
9356
-      "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=",
9357
-      "dev": true
9417
+      "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168="
9358 9418
     },
9359 9419
     "lodash.flow": {
9360 9420
       "version": "3.5.0",
9361 9421
       "resolved": "https://registry.npm.taobao.org/lodash.flow/download/lodash.flow-3.5.0.tgz",
9362 9422
       "integrity": "sha1-h79AKSuM+D5OjOGjrkIJ4gBxZ1o="
9363 9423
     },
9424
+    "lodash.isequal": {
9425
+      "version": "4.5.0",
9426
+      "resolved": "https://registry.npm.taobao.org/lodash.isequal/download/lodash.isequal-4.5.0.tgz",
9427
+      "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA="
9428
+    },
9364 9429
     "lodash.memoize": {
9365 9430
       "version": "4.1.2",
9366 9431
       "resolved": "https://registry.nlark.com/lodash.memoize/download/lodash.memoize-4.1.2.tgz",
@@ -9372,6 +9437,11 @@
9372 9437
       "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=",
9373 9438
       "dev": true
9374 9439
     },
9440
+    "lodash.throttle": {
9441
+      "version": "4.1.1",
9442
+      "resolved": "https://registry.npm.taobao.org/lodash.throttle/download/lodash.throttle-4.1.1.tgz",
9443
+      "integrity": "sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ="
9444
+    },
9375 9445
     "lodash.uniq": {
9376 9446
       "version": "4.5.0",
9377 9447
       "resolved": "https://registry.nlark.com/lodash.uniq/download/lodash.uniq-4.5.0.tgz",
@@ -12086,6 +12156,8 @@
12086 12156
     },
12087 12157
     "react": {
12088 12158
       "version": "17.0.2",
12159
+      "resolved": "https://registry.npmmirror.com/react/download/react-17.0.2.tgz",
12160
+      "integrity": "sha1-0LXMUW0p6z7uOD91tihkz7aAADc=",
12089 12161
       "requires": {
12090 12162
         "loose-envify": "^1.1.0",
12091 12163
         "object-assign": "^4.1.1"
@@ -12093,6 +12165,8 @@
12093 12165
     },
12094 12166
     "react-dom": {
12095 12167
       "version": "17.0.2",
12168
+      "resolved": "https://registry.npmmirror.com/react-dom/download/react-dom-17.0.2.tgz",
12169
+      "integrity": "sha1-7P+2hF462Nv83EmPDQqTlzZQLCM=",
12096 12170
       "requires": {
12097 12171
         "loose-envify": "^1.1.0",
12098 12172
         "object-assign": "^4.1.1",
@@ -12579,6 +12653,11 @@
12579 12653
       "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=",
12580 12654
       "dev": true
12581 12655
     },
12656
+    "resize-observer-polyfill": {
12657
+      "version": "1.5.1",
12658
+      "resolved": "https://registry.npm.taobao.org/resize-observer-polyfill/download/resize-observer-polyfill-1.5.1.tgz",
12659
+      "integrity": "sha1-DpAg3T0hAkRY1OvSfiPkAmmBBGQ="
12660
+    },
12582 12661
     "resolve": {
12583 12662
       "version": "1.20.0",
12584 12663
       "resolved": "https://registry.nlark.com/resolve/download/resolve-1.20.0.tgz",
@@ -13049,6 +13128,11 @@
13049 13128
         "ajv-keywords": "^3.5.2"
13050 13129
       }
13051 13130
     },
13131
+    "screenfull": {
13132
+      "version": "5.2.0",
13133
+      "resolved": "https://registry.npmmirror.com/screenfull/download/screenfull-5.2.0.tgz?cache=0&sync_timestamp=1635923508328&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fscreenfull%2Fdownload%2Fscreenfull-5.2.0.tgz",
13134
+      "integrity": "sha1-ZTPVJNMGIfwSg7lpIUbz8TqT0bo="
13135
+    },
13052 13136
     "scss-bundle": {
13053 13137
       "version": "3.1.2",
13054 13138
       "resolved": "https://registry.npm.taobao.org/scss-bundle/download/scss-bundle-3.1.2.tgz",
@@ -13991,6 +14075,8 @@
13991 14075
     },
13992 14076
     "stylelint": {
13993 14077
       "version": "9.3.0",
14078
+      "resolved": "https://registry.npmmirror.com/stylelint/download/stylelint-9.3.0.tgz?cache=0&sync_timestamp=1636911087701&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fstylelint%2Fdownload%2Fstylelint-9.3.0.tgz",
14079
+      "integrity": "sha1-/hduTkIawQ6sGmttnyjpCOtYxds=",
13994 14080
       "dev": true,
13995 14081
       "requires": {
13996 14082
         "autoprefixer": "^8.0.0",

+ 1
- 0
package.json Vedi File

@@ -42,6 +42,7 @@
42 42
     "@tarojs/runtime": "3.2.13",
43 43
     "@tarojs/taro": "3.2.13",
44 44
     "@zjxpcyc/react-tiny-store": "^1.0.0",
45
+    "ahooks": "^2.10.12",
45 46
     "react": "^17.0.0",
46 47
     "react-dom": "^17.0.0"
47 48
   },

BIN
src/components/voice/wexMP3.mp3 Vedi File


+ 94
- 32
src/pages/index/index.jsx Vedi File

@@ -1,10 +1,13 @@
1 1
 
2 2
 import { useEffect, useMemo, useRef, useState } from 'react';
3
+import { useThrottle, useThrottleFn } from 'ahooks';
3 4
 import Taro from '@tarojs/taro';
4 5
 import { View } from '@tarojs/components'
5 6
 import Counter from '@/components/Counter'
6 7
 import { Button } from '@antmjs/vantui';
7 8
 import useInterval from '@/hooks/useInterval';
9
+import wexMP3 from '@/components/voice/wexMP3.mp3'
10
+
8 11
 import { score } from '../../services/user';
9 12
 
10 13
 import TopBar from './components/TopBar'
@@ -19,9 +22,8 @@ const IndexPage = (props) => {
19 22
 
20 23
   const [num, setNum] = useState(0)
21 24
   const [btnDisable, setBtnDisable] = useState(false)
22
-  const { getAvatar, sessionKey, person } = useModel('useFoo')
25
+  const { getAvatar, sessionKey, person, tologin } = useModel('useFoo')
23 26
   const [buttonTitle, setbuttonTitle] = useState(true)
24
-  console.log("🚀 ~ file: index.jsx ~ line 23 ~ IndexPage ~ person", person)
25 27
 
26 28
   // 定时器
27 29
   const [add2TickerList] = useInterval(1400)
@@ -30,8 +32,59 @@ const IndexPage = (props) => {
30 32
   const [count, countFn, startCount] = useCountDown();
31 33
   useMemo(() => add2TickerList(countFn), [])
32 34
 
35
+
36
+  const { run } = useThrottleFn(
37
+    () => {
38
+      setTimeout(() => {
39
+        Taro.vibrateLong()
40
+
41
+      }, 30000);
42
+    },
43
+    { wait: 30000 },
44
+  );
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
33 54
   // 摇一摇
34 55
   const [times, startShake, onShakeEnd] = useShake()
56
+  useEffect(() => {
57
+    if (times >= 1) {
58
+      run()
59
+
60
+      //添加音效
61
+      const innerAudioContext = Taro.createInnerAudioContext()
62
+      innerAudioContext.autoplay = true// 是否自动开始播放,默认为 false
63
+      innerAudioContext.loop = false  // 是否循环播放,默认为 false
64
+      Taro.setInnerAudioOption({ // ios在静音状态下能够正常播放音效
65
+        obeyMuteSwitch: false,   // 即使用户打开了静音开关,也能继续发出声音。
66
+        success: function (e) {
67
+          console.log(e)
68
+          console.log('play success')
69
+        },
70
+        fail: function (e) {
71
+          console.log(e)
72
+          console.log('play fail')
73
+        }
74
+      })
75
+      innerAudioContext.src = wexMP3
76
+      innerAudioContext.onPlay(() => {
77
+        console.log('开始播放')
78
+      })
79
+      innerAudioContext.onError((res) => {
80
+        console.log(res.errMsg)
81
+        console.log(res.errCode)
82
+      })
83
+
84
+
85
+    }
86
+
87
+  }, [times])
35 88
 
36 89
   onShakeEnd(() => {
37 90
     // 摇一摇结束
@@ -60,39 +113,46 @@ const IndexPage = (props) => {
60 113
 
61 114
 
62 115
   const handleStart = () => {
63
-
64
-    if (!person?.avatar) {
65
-      Taro.getUserProfile({
66
-        lang: 'zh_CN',
67
-        desc: "获取你的昵称、头像、地区及性别",
68
-        success: (res) => {
69
-          const data = {
70
-            encryptedData: res.encryptedData,
71
-            iv: res.iv,
72
-            rawData: res.rawData,
73
-            sessionKey: sessionKey,
74
-            signature: res.signature
75
-          }
76
-          getAvatar(data)
77
-          Taro.showToast({
78
-            title: '授权头像成功',
79
-            icon: 'success',
80
-            duration: 2000
81
-          })
82
-
83
-
84
-        },
85
-        fail: () => {
86
-          //拒绝授权
87
-          console.error("拒绝了请求");
88
-          return;
89
-        }
116
+    if (tologin == false) {
117
+      Taro.showToast({
118
+        title: '未登陆',
119
+        icon: 'none',
120
+        duration: 2000,
90 121
       })
91 122
     } else {
123
+      if (!person?.avatar) {
124
+        Taro.getUserProfile({
125
+          lang: 'zh_CN',
126
+          desc: "获取你的昵称、头像、地区及性别",
127
+          success: (res) => {
128
+            const data = {
129
+              encryptedData: res.encryptedData,
130
+              iv: res.iv,
131
+              rawData: res.rawData,
132
+              sessionKey: sessionKey,
133
+              signature: res.signature
134
+            }
135
+            getAvatar(data)
136
+            Taro.showToast({
137
+              title: '授权头像成功',
138
+              icon: 'success',
139
+              duration: 2000
140
+            })
141
+
142
+
143
+          },
144
+          fail: () => {
145
+            //拒绝授权
146
+            console.error("拒绝了请求");
147
+            return;
148
+          }
149
+        })
150
+      } else {
92 151
 
93
-      modRef.current = 'countdown'
94
-      startCount(3)
95
-      setBtnDisable(true)
152
+        modRef.current = 'countdown'
153
+        startCount(3)
154
+        setBtnDisable(true)
155
+      }
96 156
     }
97 157
 
98 158
 
@@ -101,6 +161,8 @@ const IndexPage = (props) => {
101 161
 
102 162
 
103 163
 
164
+
165
+
104 166
   }
105 167
 
106 168
   useEffect(() => {

+ 0
- 1
src/pages/topListCopy/index.jsx Vedi File

@@ -88,7 +88,6 @@ export default (props) => {
88 88
               )
89 89
             }
90 90
 
91
-
92 91
           })
93 92
         }
94 93
       </scroll-view>

+ 30
- 1
src/store/models/useFoo.js Vedi File

@@ -10,6 +10,9 @@ export default function useUser() {
10 10
   const [person, setPerson] = useState()
11 11
   const [sessionKey, setSessionKey] = useState()
12 12
 
13
+  // 是否登陆
14
+  const [tologin, setTologin] = useState(false)
15
+
13 16
 
14 17
 
15 18
   const signIn = (params) => {
@@ -17,8 +20,33 @@ export default function useUser() {
17 20
       const { person: taPerson, skey, token } = res;
18 21
       setPerson(taPerson);
19 22
       setSessionKey(skey);
20
-
21 23
       Taro.setStorage({ key: 'token', data: token })
24
+      setTologin(true)
25
+    }).catch(e => {
26
+      setTologin(false)
27
+
28
+      if (tologin === false) {
29
+        Taro.showModal({
30
+          title: '提示',
31
+          content: `系统错误,请退出后重试`,
32
+          success: function (res) {
33
+            setTologin(false)
34
+
35
+            if (res.confirm) {
36
+              Taro.navigateBack({
37
+                delta: 0
38
+              })
39
+            } else if (res.cancel) {
40
+              Taro.navigateBack({
41
+                delta: 0
42
+              })
43
+            }
44
+          }
45
+        })
46
+      }
47
+
48
+
49
+
22 50
     })
23 51
   }
24 52
 
@@ -36,6 +64,7 @@ export default function useUser() {
36 64
     user,
37 65
     person,
38 66
     sessionKey,
67
+    tologin,
39 68
 
40 69
     signIn,
41 70
     signOut,

+ 55
- 1
yarn.lock Vedi File

@@ -2,6 +2,14 @@
2 2
 # yarn lockfile v1
3 3
 
4 4
 
5
+"@ahooksjs/use-request@^2.8.13":
6
+  version "2.8.13"
7
+  resolved "https://registry.npmmirror.com/@ahooksjs/use-request/download/@ahooksjs/use-request-2.8.13.tgz?cache=0&sync_timestamp=1635254759234&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2F%40ahooksjs%2Fuse-request%2Fdownload%2F%40ahooksjs%2Fuse-request-2.8.13.tgz#5ace53859feb6b4fe9ebcbf2e72982bb9b7db383"
8
+  integrity sha1-Ws5ThZ/ra0/p68vy5ymCu5t9s4M=
9
+  dependencies:
10
+    lodash.debounce "^4.0.8"
11
+    lodash.throttle "^4.1.1"
12
+
5 13
 "@antmjs/iconfont@1.9.4":
6 14
   version "1.9.4"
7 15
   resolved "https://registry.yarnpkg.com/@antmjs/iconfont/-/iconfont-1.9.4.tgz#afc0ba1a46ac57dc3fd53a32bd77a3d8fedceaf7"
@@ -1545,6 +1553,11 @@
1545 1553
     "@types/minimatch" "*"
1546 1554
     "@types/node" "*"
1547 1555
 
1556
+"@types/js-cookie@^2.2.6":
1557
+  version "2.2.7"
1558
+  resolved "https://registry.npmmirror.com/@types/js-cookie/download/@types/js-cookie-2.2.7.tgz#226a9e31680835a6188e887f3988e60c04d3f6a3"
1559
+  integrity sha1-ImqeMWgINaYYjoh/OYjmDATT9qM=
1560
+
1548 1561
 "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.8":
1549 1562
   version "7.0.9"
1550 1563
   resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d"
@@ -1917,6 +1930,22 @@ aggregate-error@^3.0.0:
1917 1930
     clean-stack "^2.0.0"
1918 1931
     indent-string "^4.0.0"
1919 1932
 
1933
+ahooks@^2.10.12:
1934
+  version "2.10.12"
1935
+  resolved "https://registry.npmmirror.com/ahooks/download/ahooks-2.10.12.tgz#e8cab653039434279e69569a8342c602b3545dab"
1936
+  integrity sha1-6Mq2UwOUNCeeaVaag0LGArNUXas=
1937
+  dependencies:
1938
+    "@ahooksjs/use-request" "^2.8.13"
1939
+    "@types/js-cookie" "^2.2.6"
1940
+    dayjs "^1.9.1"
1941
+    intersection-observer "^0.7.0"
1942
+    js-cookie "^2.2.1"
1943
+    lodash.debounce "^4.0.8"
1944
+    lodash.isequal "^4.5.0"
1945
+    lodash.throttle "^4.1.1"
1946
+    resize-observer-polyfill "^1.5.1"
1947
+    screenfull "^5.0.0"
1948
+
1920 1949
 ajv-errors@^1.0.0:
1921 1950
   version "1.0.1"
1922 1951
   resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.1.tgz#f35986aceb91afadec4102fbd85014950cefa64d"
@@ -3728,7 +3757,7 @@ data-urls@^1.1.0:
3728 3757
     whatwg-mimetype "^2.2.0"
3729 3758
     whatwg-url "^7.0.0"
3730 3759
 
3731
-dayjs@^1.10.6:
3760
+dayjs@^1.10.6, dayjs@^1.9.1:
3732 3761
   version "1.10.7"
3733 3762
   resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.7.tgz#2cf5f91add28116748440866a0a1d26f3a6ce468"
3734 3763
   integrity sha512-P6twpd70BcPK34K26uJ1KT3wlhpuOAPoMwJzpsIWUxHZ7wpmbdZL/hQqBDfz7hGurYSa5PhzdhDHtt319hL3ig==
@@ -6204,6 +6233,11 @@ js-base64@^2.1.9:
6204 6233
   resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.6.4.tgz#f4e686c5de1ea1f867dbcad3d46d969428df98c4"
6205 6234
   integrity sha512-pZe//GGmwJndub7ZghVHz7vjb2LgC1m8B07Au3eYqeqv9emhESByMXxaEgkUkEqJe87oBbSniGYoQNIBklc7IQ==
6206 6235
 
6236
+js-cookie@^2.2.1:
6237
+  version "2.2.1"
6238
+  resolved "https://registry.nlark.com/js-cookie/download/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8"
6239
+  integrity sha1-aeEG3F1YBolFYpAqpbrsN0Tpsrg=
6240
+
6207 6241
 "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0:
6208 6242
   version "4.0.0"
6209 6243
   resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
@@ -6553,6 +6587,11 @@ lodash.flow@^3.5.0:
6553 6587
   resolved "https://registry.yarnpkg.com/lodash.flow/-/lodash.flow-3.5.0.tgz#87bf40292b8cf83e4e8ce1a3ae4209e20071675a"
6554 6588
   integrity sha1-h79AKSuM+D5OjOGjrkIJ4gBxZ1o=
6555 6589
 
6590
+lodash.isequal@^4.5.0:
6591
+  version "4.5.0"
6592
+  resolved "https://registry.npmmirror.com/lodash.isequal/download/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
6593
+  integrity sha1-QVxEePK8wwEgwizhDtMib30+GOA=
6594
+
6556 6595
 lodash.memoize@^4.1.2:
6557 6596
   version "4.1.2"
6558 6597
   resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
@@ -6563,6 +6602,11 @@ lodash.sortby@^4.7.0:
6563 6602
   resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
6564 6603
   integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
6565 6604
 
6605
+lodash.throttle@^4.1.1:
6606
+  version "4.1.1"
6607
+  resolved "https://registry.nlark.com/lodash.throttle/download/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4"
6608
+  integrity sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ=
6609
+
6566 6610
 lodash.uniq@^4.5.0:
6567 6611
   version "4.5.0"
6568 6612
   resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
@@ -9041,6 +9085,11 @@ requires-port@^1.0.0:
9041 9085
   resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
9042 9086
   integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=
9043 9087
 
9088
+resize-observer-polyfill@^1.5.1:
9089
+  version "1.5.1"
9090
+  resolved "https://registry.nlark.com/resize-observer-polyfill/download/resize-observer-polyfill-1.5.1.tgz?cache=0&sync_timestamp=1618910925988&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fresize-observer-polyfill%2Fdownload%2Fresize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464"
9091
+  integrity sha1-DpAg3T0hAkRY1OvSfiPkAmmBBGQ=
9092
+
9044 9093
 resolve-cwd@^2.0.0:
9045 9094
   version "2.0.0"
9046 9095
   resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a"
@@ -9366,6 +9415,11 @@ schema-utils@^3.0.0:
9366 9415
     ajv "^6.12.5"
9367 9416
     ajv-keywords "^3.5.2"
9368 9417
 
9418
+screenfull@^5.0.0:
9419
+  version "5.2.0"
9420
+  resolved "https://registry.npmmirror.com/screenfull/download/screenfull-5.2.0.tgz?cache=0&sync_timestamp=1635923508328&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fscreenfull%2Fdownload%2Fscreenfull-5.2.0.tgz#6533d524d30621fc1283b9692146f3f13a93d1ba"
9421
+  integrity sha1-ZTPVJNMGIfwSg7lpIUbz8TqT0bo=
9422
+
9369 9423
 scss-bundle@^3.0.2:
9370 9424
   version "3.1.2"
9371 9425
   resolved "https://registry.yarnpkg.com/scss-bundle/-/scss-bundle-3.1.2.tgz#8919dd7603d01a84822e8aab5210e5b0b50c548b"