Browse Source

Improve notification configuration

vbea 2 năm trước cách đây
mục cha
commit
ef07fc5b47

+ 7 - 3
Strides-APP/app.json

@@ -12,7 +12,6 @@
     "apply_phv": false,
     "membership": true,
     "nationally": false,
-    "notifications": true,
     "topup_payment_type": false,
     "support": {
       "phone": "+6564775355",
@@ -31,8 +30,7 @@
     "drawer": true,
     "summary": true,
     "anzPayment": false,
-    "paymentMethod": false,
-    "showCampaigns": false
+    "paymentMethod": false
   },
   "vehicle": {
     "newVersionPage": false,
@@ -41,5 +39,11 @@
     "requireConnectorType": true,
     "requireImageUpload": true,
     "vehicleInRegisterPage": false
+  },
+  "notifications": {
+    "enable": true,
+    "showArticle": true,
+    "showCampaigns": false,
+    "description": "如果showCampaigns为true,需确保showArticle也为true,如果showArticle为false,则只显示Alert"
   }
 }

+ 28 - 2
Strides-APP/app/pages/alert/ListAlerts.js

@@ -11,6 +11,7 @@ import { MyRefreshProps } from '../../components/ThemesConfig';
 import { PageList } from '../Router';
 import AlertUtil from './AlertUtil';
 import ItemView from './ItemAlert';
+import TextView from '../../components/TextView';
 
 export default class ListAlerts extends Component {
   constructor(props) {
@@ -18,7 +19,8 @@ export default class ListAlerts extends Component {
     this.state = {
       dataList: [],
       refreshing: false,
-      showReadAll: false
+      showReadAll: false,
+      unreadTotal: 0
     };
   }
 
@@ -80,6 +82,7 @@ export default class ListAlerts extends Component {
       if (res.data) {
         this.setState({
           dataList: res.data,
+          unreadTotal: AlertUtil.getUnreadAlert(),
           showReadAll: res.data?.length > 0 && AlertUtil.getUnreadAlert() > 0
         })
       }
@@ -142,7 +145,19 @@ export default class ListAlerts extends Component {
   }
 
   topView = (props) => {
-    if (this.state.showReadAll) {
+    if (this.props.showUnread && this.state.unreadTotal > 0) {
+      return (
+        <View style={styles.topView2}>
+          <TextView style={styles.unreadText}>Unread: {this.state.unreadTotal}</TextView>
+          <Button
+            style={styles.topButton}
+            viewStyle={styles.topButtonView}
+            textStyle={styles.topButtonText}
+            text={$t("notification.btnReadAll")}
+            onClick={() => this.onClickReadAll()}/>
+        </View>
+      )
+    } else if (this.state.showReadAll) {
       return (
         <View style={styles.topView}>
           <Button
@@ -200,7 +215,18 @@ const styles = StyleSheet.create({
     flexDirection: 'row',
     justifyContent: 'flex-end'
   },
+  topView2: {
+    padding: 8,
+    flexDirection: 'row',
+    justifyContent: 'space-between'
+  },
+  unreadText: {
+    color: textSecondary,
+    fontSize: 14,
+    paddingLeft: 6
+  },
   topButton: {
+    marginRight: 4,
     flexDirection: 'row',
     backgroundColor: 'white',
     borderColor: textCancel,

+ 23 - 11
Strides-APP/app/pages/alert/Notification.js

@@ -15,7 +15,6 @@ import apiNotification from '../../api/apiNotification';
 import TextView from '../../components/TextView';
 import AlertUtil from './AlertUtil';
 
-
 export default class Notification extends Component {
   constructor(props) {
     super(props);
@@ -58,13 +57,26 @@ export default class Notification extends Component {
   }
 
   componentDidMount() {
-    this.setState({
-      pageAdapter: app.v3.showCampaigns ? this.pageAdapterAll : this.pageAdapter
-    }, () => {
-      setTimeout(() => {
-        this.init();
-      }, 300);
-    });
+    if (app.notifications.showCampaigns && app.notifications.showArticle) {
+      this.setState({
+        pageAdapter: this.pageAdapterAll
+      }, () => {
+        setTimeout(() => {
+          this.init();
+        }, 300);
+      });
+    } else if (app.notifications.showArticle) {
+      this.setState({
+        pageAdapter: this.pageAdapter
+      }, () => {
+        setTimeout(() => {
+          this.init();
+        }, 300);
+      });
+    } else {
+      this.init();
+    }
+    
     this.props.navigation.addListener('focus', () => {
       if (this.isHide) {
         this.isHide = false;
@@ -120,14 +132,14 @@ export default class Notification extends Component {
     let count = 0;
     switch (index) {
       case 0:
-        if (app.v3.showCampaigns) {
+        if (app.notifications.showCampaigns) {
           count = this.state.countInfo?.campaignUnreadCount;
         } else {
           count = this.state.countInfo?.alertUnreadCount;
         }
         break;
       case 1:
-        if (app.v3.showCampaigns) {
+        if (app.notifications.showCampaigns) {
           count = this.state.countInfo?.alertUnreadCount;
         } else {
           count = this.state.countInfo?.newsUnreadCount;
@@ -171,7 +183,7 @@ export default class Notification extends Component {
         </Tab.Navigator>
       );
     } else {
-      return <View></View>
+      return <ListAlerts {...this.props} showUnread={true}/>
     }
   }
 }

+ 1 - 1
Strides-APP/app/pages/home/Drawer.js

@@ -147,7 +147,7 @@ export default DrawerView = ({isLogin=false, userInfo, onLogout, notificationCou
       }
 
       {/*附加功能-开始*/}
-      { (app.modules.notifications && isLogin) &&
+      { (app.notifications.enable && isLogin) &&
         <Button
           style={styles.itemButton}
           viewStyle={styles.itemView}

+ 1 - 1
Strides-APP/app/pages/home/DrawerV2.js

@@ -173,7 +173,7 @@ export default DrawerV2 = ({isLogin=false, userInfo, onLogout, sideCountInfo={},
         </Button></>
       }
 
-      { (app.modules.notifications && isLogin) &&
+      { (app.notifications.enable && isLogin) &&
         <Button
           style={styles.itemButton}
           viewStyle={styles.itemView}

+ 2 - 2
Strides-APP/app/pages/home/Index.js

@@ -42,7 +42,7 @@ export default class Home extends Component {
           userInfo: info
         });
       }, true);
-      if (app.modules.notifications && this.state.isLogin) {
+      if (app.notifications.enable && this.state.isLogin) {
         this.getNotificationTotal();
       }
     });
@@ -72,7 +72,7 @@ export default class Home extends Component {
             }
           }
         }, true);
-        if (app.modules.notifications) {
+        if (app.notifications.enable && status) {
           this.getNotificationTotal();
         }
       });