Your Name hace 4 años
padre
commit
f802bcf48b
Se han modificado 3 ficheros con 46 adiciones y 5 borrados
  1. 16
    0
      src/compents/Loading/index.jsx
  2. 17
    0
      src/compents/Loading/style.scss
  3. 13
    5
      src/pages/share/index.jsx

+ 16
- 0
src/compents/Loading/index.jsx Ver fichero

@@ -0,0 +1,16 @@
1
+import React from 'react'
2
+import { View } from '@tarojs/components'
3
+import './style.scss'
4
+
5
+export default props => {
6
+
7
+  const loadingStyle = {
8
+    width: props.size || '64px',
9
+    height: props.size || '64px',
10
+    borderTopColor: props.color || '#fed12f'
11
+  }
12
+
13
+  return (
14
+    <View className="cust-loading" style={loadingStyle}></View>
15
+  )
16
+}

+ 17
- 0
src/compents/Loading/style.scss Ver fichero

@@ -0,0 +1,17 @@
1
+
2
+.cust-loading {
3
+  display: inline-block;
4
+  border: 3px solid #f3f3f3;
5
+  border-top: 3px solid #fed12f;
6
+  border-radius: 50%;
7
+  animation: loading-360 1s infinite linear;
8
+}
9
+
10
+@keyframes loading-360 {
11
+  0% {
12
+      transform: rotate(0deg); /*动画起始的时候旋转了0度*/
13
+  }
14
+  100% {
15
+      transform: rotate(360deg); /*动画结束的时候旋转了360度*/
16
+  }
17
+}

+ 13
- 5
src/pages/share/index.jsx Ver fichero

@@ -3,6 +3,7 @@ import Taro, { useShareAppMessage, useRouter } from "@tarojs/taro";
3 3
 import { useSelector, } from 'react-redux'
4 4
 import { View, Input, Text, Image, Picker, Button } from '@tarojs/components'
5 5
 import { AtModal, AtModalHeader, AtModalContent, AtModalAction } from "taro-ui"
6
+import Loading from '@/compents/Loading'
6 7
 import Layout from '../../layout/index'
7 8
 import Tab from '../../compents/tab/index'
8 9
 import Container from '../../compents/container/index'
@@ -35,6 +36,7 @@ const index = (props) => {
35 36
     const [endTime, setEndTime] = useState('')
36 37
     const [shareObj, setShareObj] = useState()
37 38
     const [showShareModal, setShowShareModal] = useState(false)
39
+    const [showShareLoading, setShowShareLoading] = useState(false)
38 40
     
39 41
     const onTimeChange = (e) => {
40 42
         setStartTime(e.detail.value)
@@ -49,9 +51,7 @@ const index = (props) => {
49 51
             endDate: endTime
50 52
         }
51 53
         
52
-        Taro.showLoading({
53
-            title: '正在生成分享内容,请稍后...'
54
-        })
54
+        setShowShareLoading(true)
55 55
 
56 56
         return request({ url: '/taHouseSetting', method: 'post', data }).then(res => {
57 57
             const { data } = res.data
@@ -67,11 +67,11 @@ const index = (props) => {
67 67
                     }
68 68
 
69 69
                     setShareObj(share)
70
-                    Taro.hideLoading()
70
+                    setShowShareLoading(false)
71 71
                     setShowShareModal(true)
72 72
                 })
73 73
             } else {
74
-                Taro.hideLoading()
74
+                setShowShareLoading(false)
75 75
                 Taro.showModal({
76 76
                     title: '输入信息有误',
77 77
                     content: '请重新输入',
@@ -127,6 +127,14 @@ const index = (props) => {
127 127
             </View>
128 128
         </Layout>
129 129
         <Tab className='addhousetab' color='#ffffff' pageState='3' onClick={handleShareReady} value={['分享到微信']} ></Tab>
130
+        <AtModal isOpened={showShareLoading} closeOnClickOverlay={false}>
131
+            <AtModalContent>
132
+                <View style={{textAlign: 'center'}}>
133
+                    <Loading size="48px" />
134
+                </View>
135
+                <View style={{marginTop: '2em', textAlign: 'center'}}>正在生成分享内容, 请稍后...</View>
136
+            </AtModalContent>
137
+        </AtModal>
130 138
         <AtModal isOpened={showShareModal}>
131 139
             <AtModalHeader>分享到微信</AtModalHeader>
132 140
             <AtModalAction>