张延森 3 年之前
父節點
當前提交
f2517637ff

+ 2
- 1
src/components/List/index.jsx 查看文件

@@ -2,6 +2,7 @@ import React, { useEffect, useRef, useState, useImperativeHandle, useMemo } from
2 2
 import Spin3 from '@/components/Spin/Spin3';
3 3
 import { ScrollView } from '@tarojs/components';
4 4
 import Taro from '@tarojs/taro';
5
+import { random } from '@/utils';
5 6
 
6 7
 export default React.forwardRef((props, ref) => {
7 8
   const {
@@ -23,7 +24,7 @@ export default React.forwardRef((props, ref) => {
23 24
   const pageRef = useRef({ current: 1 })
24 25
   const [hasMore, setHasMore] = useState(false)
25 26
 
26
-  const uqCls = useMemo(() => `f-${Math.random().toString(36).substring(2)}`, [])
27
+  const uqCls = useMemo(() => random('f'), [])
27 28
 
28 29
   // 滚动
29 30
   const handleScrollToLower = (e) => {

+ 0
- 1
src/components/MasonryLayout/Item.jsx 查看文件

@@ -8,7 +8,6 @@ import './style.less'
8 8
 export default (props) => {
9 9
   const { className, item, top, render, onRenderFinish } = props
10 10
 
11
-  // const uqClass = useMemo(() => `f-${Math.random().toString(36).substring(2)}`, [])
12 11
   const vid = item.__vid;
13 12
   
14 13
   const handleCallback = () => {

+ 2
- 1
src/components/MasonryLayout/Waterfall.jsx 查看文件

@@ -1,12 +1,13 @@
1 1
 import React, { useEffect, useMemo, useState } from 'react'
2 2
 import Taro from '@tarojs/taro';
3 3
 import { View } from '@tarojs/components'
4
+import { random } from '@/utils';
4 5
 import { classNames, getRect } from './utils';
5 6
 import './style.less'
6 7
 
7 8
 export default (props) => {
8 9
   const { className, itemClassName, style, gutter = 0, list, render, ...leftProps } = props
9
-  const uqClass = useMemo(() => `f-${Math.random().toString(36).substring(2)}`, [])
10
+  const uqClass = useMemo(() => random('f'), [])
10 11
 
11 12
   const [styles, setStyles] = useState([])
12 13
 

+ 2
- 1
src/components/MasonryLayout/hooks.js 查看文件

@@ -1,4 +1,5 @@
1 1
 import { useRef, useState } from "react";
2
+import { random } from '@/utils';
2 3
 
3 4
 export function useList() {
4 5
   const [lst, setList] = useState([])
@@ -34,7 +35,7 @@ export function useRenderFunc(renderList, leftHeight, rightHeight, appendLeft, a
34 35
 
35 36
     // 每次把数组最上面的一个拿出来
36 37
     const item = renderList.current.shift()
37
-    item.__vid = `f-${Math.random().toString(36).substring(2)}`
38
+    item.__vid = random('f')
38 39
 
39 40
     // 优先放入低高度的栏里面
40 41
     if (leftHeight.current <= rightHeight.current) {

+ 2
- 1
src/components/SlideView/index.jsx 查看文件

@@ -2,6 +2,7 @@
2 2
 import React, { useEffect, useMemo, useRef, useState } from 'react'
3 3
 import Taro from '@tarojs/taro';
4 4
 import { ScrollView, View, Image, Text } from '@tarojs/components';
5
+import { random } from '@/utils';
5 6
 import deleteIcon from '@/assets/icons/landlord/delete.png';
6 7
 import './style.less'
7 8
 
@@ -12,7 +13,7 @@ export default (props) => {
12 13
   const contentHeightRef = useRef(0)
13 14
   const [actStyle, setActStyle]= useState()
14 15
 
15
-  const uqClass = useMemo(() => `f-${Math.random().toString(36).substring(2)}`, [])
16
+  const uqClass = useMemo(() => random('f'), [])
16 17
   const classes = [className, 'slideview-wrapper', uqClass].filter(Boolean).join(' ');
17 18
 
18 19
   const handleScrollLeft = () => {

+ 27
- 0
src/components/Spin/style.less 查看文件

@@ -163,3 +163,30 @@
163 163
     }
164 164
   }
165 165
 }
166
+
167
+
168
+.wx_loading_view{
169
+  display: flex;
170
+  justify-content: center;
171
+  align-items: center;
172
+  overflow: hidden;
173
+
174
+  &__hide {
175
+    height: 0 !important;
176
+    display: none;
177
+  }
178
+
179
+  &__animated&__hide {
180
+    display: flex;
181
+  }
182
+}
183
+
184
+.loading {
185
+    color:rgba(255, 255, 255, 0.9);
186
+    font-size:17px;
187
+    text-align:center;
188
+}
189
+
190
+.loading_view_translation {
191
+  transition: height .2s .3s ease;
192
+}

+ 2
- 4
src/pages/index/components/Card/index.jsx 查看文件

@@ -2,7 +2,7 @@
2 2
 import { useMemo } from 'react'
3 3
 import Taro from '@tarojs/taro'
4 4
 import useSave from "@/utils/hooks/useSave"
5
-import { compressImage } from '@/utils'
5
+import { compressImage, random } from '@/utils'
6 6
 import msTip from '@/assets/icons/housemantj/foodtip.png'
7 7
 import mjTip from '@/assets/icons/housemantj/mjtip.png'
8 8
 import location from '@/assets/icons/housemantj/location.png'
@@ -14,9 +14,7 @@ export default (props) => {
14 14
 
15 15
   const { className, item, style, onImageLoad } = props
16 16
   
17
-  const uqClass = useMemo(() => {
18
-    return `f-${Math.random().toString(36).substring(2)}`
19
-  }, [])
17
+  const uqClass = useMemo(() => random('f'), [])
20 18
 
21 19
   const cls = useMemo(() => [className, 'contentCard', uqClass].filter(Boolean).join(' '), [className, uqClass])
22 20
 

+ 1
- 0
src/pages/index/index.config.js 查看文件

@@ -3,6 +3,7 @@ export default {
3 3
   navigationStyle: 'custom',
4 4
   styleIsolation: 'shared',
5 5
   enableShareAppMessage: true,
6
+  disableScroll: false,
6 7
   usingComponents: {
7 8
     "mp-tabbar": "weui-miniprogram/tabbar/tabbar",
8 9
     "mp-tabs": "../../../components/tabs/index",

+ 4
- 5
src/pages/index/tabs/Recommend.jsx 查看文件

@@ -1,5 +1,5 @@
1 1
 import Taro, { useDidShow } from '@tarojs/taro'
2
-import { React, useState, useEffect, useRef } from 'react'
2
+import { React, useState, useEffect, useRef, useMemo } from 'react'
3 3
 import iconsearch from '@/assets/icons/housemantj/search.png'
4 4
 import locationimg from '@/assets/icons/housemantj/location.png'
5 5
 import Tip from '@/components/tip'
@@ -8,6 +8,7 @@ import NoData from '@/components/NoData'
8 8
 import MasonryLayout from '@/components/MasonryLayout';
9 9
 import Waterfall from '@/components/MasonryLayout/Waterfall';
10 10
 import { getIndexType, getResourceList } from '@/services/home'
11
+import { random } from '@/utils'
11 12
 import Card from '../components/Card'
12 13
 import './less/Recommend.less'
13 14
 
@@ -16,6 +17,7 @@ const listStyle = { height: '100%' }
16 17
 export default (props) => {
17 18
   const { router, person, location } = props
18 19
 
20
+  const listClass = useMemo(() => random('f'), [])
19 21
   const [activeTab, setActiveTab] = useState(0)
20 22
   const [typeList, setTypeList] = useState([])
21 23
   const listRef = useRef()
@@ -50,7 +52,6 @@ export default (props) => {
50 52
       if (listRef.current?.context) {
51 53
         Taro.nextTick(() => {
52 54
           const t = setTimeout(() => {
53
-            console.log('------------>', listRef.current.context.scrollTo)
54 55
             listRef.current.context.scrollTo({ top: 0 })
55 56
             clearTimeout(t)
56 57
           }, 500)
@@ -61,8 +62,6 @@ export default (props) => {
61 62
     setListData({ list: value, rfTimes: rfTimes.current })
62 63
   }
63 64
 
64
-
65
-
66 65
   useEffect(() => {
67 66
     //查询分类标签表
68 67
     getIndexType({ pageSize: 20 }).then((res) => {
@@ -106,7 +105,7 @@ export default (props) => {
106 105
           </mp-tabs>
107 106
         </scroll-view>
108 107
       </view>
109
-      <view style={{ flex:'auto' }}>
108
+      <view className={listClass} style={{ flex:'auto', height: '100%', overflow: 'hidden' }}>
110 109
         <List
111 110
           ref={listRef}
112 111
           style={listStyle}

+ 3
- 3
src/utils/hooks/useRouter.js 查看文件

@@ -1,5 +1,5 @@
1 1
 import Taro, { useRouter } from '@tarojs/taro'
2
-import { parseQueryString } from '@/utils'
2
+import { parseQueryString, random } from '@/utils'
3 3
 import { useModel } from '@/store'
4 4
 import { useEffect, useRef, useState } from 'react'
5 5
 import { getQrcode } from '@/services/miniapp'
@@ -32,7 +32,7 @@ export default () => {
32 32
           ...qrParams,
33 33
           parseQRFinished: true,
34 34
         }
35
-        setToggleRefresh(Math.random().toString())
35
+        setToggleRefresh(random())
36 36
       } else {
37 37
         getQrcode(scene).then((res) => {
38 38
           const qrParams = parseQueryString(res.scene) || {}
@@ -41,7 +41,7 @@ export default () => {
41 41
             ...qrParams,
42 42
             parseQRFinished: true,
43 43
           }
44
-          setToggleRefresh(Math.random().toString())
44
+          setToggleRefresh(random())
45 45
         })
46 46
       }
47 47
     }

+ 11
- 0
src/utils/index.js 查看文件

@@ -45,6 +45,17 @@ export function getQueryString(params) {
45 45
   return arr.filter(Boolean).join('&')
46 46
 }
47 47
 
48
+/**
49
+ * 随机串
50
+ * @param {*} prefix 
51
+ * @returns 
52
+ */
53
+export function random(prefix) {
54
+  const s = Math.random().toString(36).substring(2)
55
+
56
+  return prefix ? `${prefix}-${s}` : s
57
+}
58
+
48 59
 /**
49 60
  * 压缩图片
50 61
  * @param {*} url