import Magix from 'magix' import * as View from '../../../view' Magix.applyStyle('@./channel-sync-tips.less') export default View.extend({ tmpl: '@channel-sync-tips.html', init (options) { this.options = options }, async render () { this.updater.digest({ loading: true }) const { syncAccounts, errorMsg } = await this.getChannelSyncDetail() if (errorMsg) { return this.updater.digest({ loading: false, errorMsg }) } const { app, crowdId, crowdName } = this.options.data const successSynced = syncAccounts.filter(account => account.status == 1) const failSynced = syncAccounts.filter(account => account.status == -1) this.updater.digest({ loading: false, successSynced, failSynced, app, crowdName, crowdId, syncAccounts }) }, async getChannelSyncDetail () { try { const { app, crowdId } = this.options.data const params = { crowdId, deliverAppId: app.appId } const models = [{ name: 'api_deliverapp_xMemberDetail_get', params }] const [model] = await this.fetch(models) const syncAccounts = model.get('data.list', []) return { syncAccounts } } catch (error) { return { errorMsg: error.msg || error.message || error || '请求失败' } } }, 'showDetail' (e) { const { successSynced, failSynced, app, crowdName, crowdId, syncAccounts } = this.updater.get() const viewPath = '@./channel-sync-detail' const viewOptions = { successSynced, failSynced, app, crowdName, crowdId, syncAccounts } const dialogOptions = { top: 100, width: 780 } this.mxDialog(viewPath, viewOptions, dialogOptions) } })