Browse Source

uas手机版
申请订阅
退订

RaoMeng 5 years ago
parent
commit
c856a73c35

+ 23 - 7
uas-office-web/uas-mobile/src/components/private/subscribe/SubAlreadyItem.jsx

@@ -35,15 +35,24 @@ export default class SubAlreadyItem extends Component {
         <div className='comp-sub-already-item-title'>{subObj.title}</div>
         {
           subObj.itemType === SUBSCRIBE_ITEM_NOT ? (
-            <div className='comp-sub-already-item-func'
-                 onClick={this.onSubSelect}>+订阅</div>
+            <div className={
+              subObj.status === 3
+                ? 'comp-sub-already-item-func'
+                : 'comp-sub-already-item-func-disable'}
+                 onClick={this.onSubSelect}>{subObj.status === 1
+              ? '已订阅'
+              : subObj.status === 2 ? '已申请' : '+订阅'}</div>
           ) : (
             <div className='com-row-flex'>
               <div className='comp-sub-already-item-func'
                    onClick={this.onAddHome}>+加到首页
               </div>
-              <div className='comp-sub-already-item-func'
-                   onClick={this.onUnSubSelect}>-退订
+              <div className={subObj.isApplied === -1
+                ? 'comp-sub-already-item-func'
+                : 'comp-sub-already-item-func-disable'}
+                   onClick={this.onUnSubSelect}>{subObj.isApplied === -1
+                ? '-退订'
+                : '不可退订'}
               </div>
             </div>
           )
@@ -53,17 +62,24 @@ export default class SubAlreadyItem extends Component {
   }
 
   onSubSelect = (e) => {
+    const { subObj, onSubSelect } = this.props
     e.stopPropagation()
-    this.props.onSubSelect && this.props.onSubSelect(this.props.subObj)
+    if (subObj.status === 3) {
+      onSubSelect && onSubSelect(subObj)
+    }
   }
 
   onAddHome = (e) => {
+    const { subObj, onAddHome } = this.props
     e.stopPropagation()
-    this.props.onAddHome && this.props.onAddHome(this.props.subObj)
+    onAddHome && onAddHome(subObj)
   }
 
   onUnSubSelect = (e) => {
+    const { subObj, onUnSubSelect, subIndex } = this.props
     e.stopPropagation()
-    this.props.onUnSubSelect && this.props.onUnSubSelect(this.props.subObj)
+    if (subObj.isApplied === -1) {
+      onUnSubSelect && onUnSubSelect(subObj, subIndex)
+    }
   }
 }

+ 5 - 0
uas-office-web/uas-mobile/src/components/private/subscribe/comp-subscrive.less

@@ -135,6 +135,11 @@
     color: dodgerblue;
     padding: 10px 8px;
   }
+
+  .comp-sub-already-item-func-disable {
+    .comp-sub-already-item-func;
+    color: darkgray;
+  }
 }
 
 .comp-sub-left-menu {

+ 6 - 0
uas-office-web/uas-mobile/src/configs/api.config.js

@@ -43,4 +43,10 @@ export const API = {
   //获取订阅推送列表
   SUBSCRIBE_SUBSCRIBETOPUSH: _baseURL +
     '/mobile/appweb/subscribe/subscribeToPush.action',
+  //申请订阅
+  SUBSCRIBE_APPLYSUBSCRIBE: _baseURL +
+    '/mobile/appweb/subscribe/applySubscribe.action',
+  //退订
+  SUBSCRIBE_CANCELSUBSCRIBE: _baseURL +
+    '/mobile/appweb/subscribe/cancelSubscribe.action',
 }

+ 36 - 2
uas-office-web/uas-mobile/src/pages/private/subscribe/SubscribeAlready.jsx

@@ -11,8 +11,12 @@ import { requestMySubscribe } from '../../../utils/private/subscribe.util'
 import { isObjEmpty } from '../../../utils/common/common.util'
 import RefreshLayout
   from '../../../components/common/refreshLayout/RefreshLayout'
-import { _host } from '../../../configs/api.config'
+import { _host, API } from '../../../configs/api.config'
 import { SUBSCRIBE_ITEM_ALREADY } from '../../../configs/constans.config'
+import { Toast } from 'antd-mobile'
+import { fetchPostObj } from '../../../utils/common/fetchRequest'
+import { message } from 'antd'
+import { saveListState } from '../../../redux/actions/listState'
 
 class SubscribeAlready extends Component {
 
@@ -44,7 +48,11 @@ class SubscribeAlready extends Component {
             type: SUBSCRIBE_ITEM_ALREADY,
           }}
           onSubItemClick={this.onSubItemClick.bind(this)}
-          key={'subAlready' + index}/>)
+          key={'subAlready' + index}
+          subIndex={index}
+          onAddHome={this.onAddHome.bind(this)}
+          onUnSubSelect={this.onUnSubSelect.bind(this)}
+        />)
       })
     }
 
@@ -78,6 +86,32 @@ class SubscribeAlready extends Component {
   onSubItemClick = (subObj) => {
     window.open(_host + '/common/charts/mobilePreview.action?id=' + subObj.id)
   }
+
+  onAddHome = (subObj) => {
+
+  }
+
+  onUnSubSelect = (subObj, subIndex) => {
+    Toast.loading('正在退订', 0)
+    fetchPostObj(API.SUBSCRIBE_CANCELSUBSCRIBE, {
+      id_: subObj.id,
+    }).then(response => {
+      Toast.hide()
+      message.success('退订成功')
+      const { listState: { listData2 } } = this.props
+      listData2.splice(subIndex, 1)
+      saveListState({
+        listData2,
+      })
+    }).catch(error => {
+      Toast.hide()
+      if (typeof error === 'string') {
+        message.error(error)
+      } else {
+        message.error('退订失败')
+      }
+    })
+  }
 }
 
 let mapStateToProps = (state) => ({

+ 31 - 2
uas-office-web/uas-mobile/src/pages/private/subscribe/SubscribeNot.jsx

@@ -14,7 +14,10 @@ import { isObjEmpty } from '../../../utils/common/common.util'
 import { requestSubscribeConfig } from '../../../utils/private/subscribe.util'
 import RefreshLayout
   from '../../../components/common/refreshLayout/RefreshLayout'
-import { _host } from '../../../configs/api.config'
+import { _host, API } from '../../../configs/api.config'
+import { Toast } from 'antd-mobile'
+import { fetchPostObj } from '../../../utils/common/fetchRequest'
+import { message } from 'antd'
 
 class SubscribeNot extends Component {
 
@@ -61,7 +64,9 @@ class SubscribeNot extends Component {
                 type: SUBSCRIBE_ITEM_NOT,
               }}
               onSubItemClick={this.onSubItemClick.bind(this)}
-              key={'subNot' + index}/>,
+              key={'subNot' + index}
+              onSubSelect={this.onSubSelect.bind(this)}
+            />,
           )
         })
       }
@@ -110,6 +115,30 @@ class SubscribeNot extends Component {
   onSubItemClick = (subObj) => {
     window.open(_host + '/common/charts/mobilePreview.action?id=' + subObj.id)
   }
+
+  onSubSelect = (subObj) => {
+    Toast.loading('申请订阅', 0)
+    fetchPostObj(API.SUBSCRIBE_APPLYSUBSCRIBE, {
+      id_: subObj.id,
+    }).then(response => {
+      Toast.hide()
+      message.success('申请成功')
+      const { listState: { listData } } = this.props
+      if (!isObjEmpty(listData, listData[subObj.groupIndex],
+        listData[subObj.groupIndex].subList,
+        listData[subObj.groupIndex].subList[subObj.childIndex])) {
+        listData[subObj.groupIndex].subList[subObj.childIndex].status = 2
+      }
+      saveListState({ listData })
+    }).catch(error => {
+      Toast.hide()
+      if (typeof error === 'string') {
+        message.error(error)
+      } else {
+        message.error('申请失败')
+      }
+    })
+  }
 }
 
 let mapStateToProps = (state) => ({

+ 2 - 0
uas-office-web/uas-mobile/src/utils/private/subscribe.util.js

@@ -78,6 +78,8 @@ export const analysisSubscribeConfig = (response) => {
             type: childItem.TYPE_,
             status: childItem.STATUS_,
             itemType: SUBSCRIBE_ITEM_NOT,
+            groupIndex: groupIndex,
+            childIndex: childIndex,
           })
         })
       }