From 474c68f0fea10cc62977c67d186732b3346cdd53 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 17 一月 2023 18:04:45 +0800
Subject: [PATCH] 2023-01-17

---
 src/tabviews/custom/components/carousel/prop-card/index.jsx |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/src/tabviews/custom/components/carousel/prop-card/index.jsx b/src/tabviews/custom/components/carousel/prop-card/index.jsx
index 9b7b8d8..0b5782b 100644
--- a/src/tabviews/custom/components/carousel/prop-card/index.jsx
+++ b/src/tabviews/custom/components/carousel/prop-card/index.jsx
@@ -31,6 +31,8 @@
     visible: false
   }
 
+  loaded = false
+
   UNSAFE_componentWillMount () {
     const { data, initdata } = this.props
     let _config = fromJS(this.props.config).toJS()
@@ -51,7 +53,7 @@
       BID = BData.$BID || ''
     }
     
-    if (_config.setting && _config.wrap.datatype === 'dynamic') {
+    if (_config.wrap.datatype === 'dynamic') {
       _sync = _config.setting.sync === 'true'
 
       if (_sync && data) {
@@ -60,13 +62,17 @@
           _data = _data[0] || {$$empty: true}
         }
         _sync = false
+        this.loaded = true
       } else if (_sync && initdata) {
         _data = initdata
         if (Array.isArray(_data)) {
           _data = _data[0] || {$$empty: true}
         }
         _sync = false
+        this.loaded = true
       }
+    } else if (_config.wrap.datatype === 'static') {
+      this.loaded = true
     }
 
     _data.$$uuid = _data[_config.setting.primaryKey] || ''
@@ -130,6 +136,17 @@
         this.loadData('timer')
       })
     }
+
+    if (config.$cache && !this.loaded) {
+      Api.getLCacheConfig(config.uuid).then(res => {
+        if (!res || this.loaded) return
+
+        let _data = res[0]
+        _data.$$uuid = _data[config.setting.primaryKey] || ''
+
+        this.setState({data: _data})
+      })
+    }
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -166,6 +183,8 @@
       _data.$$uuid = _data[config.setting.primaryKey] || ''
       _data.$$BID = BID || ''
       _data.$$BData = BData || ''
+
+      this.loaded = true
 
       this.setState({sync: false, data: _data}, () => {
         if (config.wrap.display === 'modal') {
@@ -271,6 +290,8 @@
       this.setState({
         data: {$$BID: BID || '', $$BData: BData, $$empty: true}
       })
+
+      this.loaded = true
       return
     }
 
@@ -294,6 +315,11 @@
     if (result.status) {
       let _data = {}
 
+      this.loaded = true
+      if (config.$cache) {
+        Api.writeCacheConfig(config.uuid, result.data || '')
+      }
+
       if (!result.data || !result.data[0]) {
         _data.$$empty = true
       } else {

--
Gitblit v1.8.0