|
|
@@ -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) => ({
|