| | |
| | | }, |
| | | _initMethod: function () { |
| | | $that = vc.component; |
| | | $that._injectStyles(); |
| | | $that._initDate(); |
| | | // 进入页面时立即调用接口 |
| | | $that._loadPublicIncomeData(DEFAULT_PAGE, DEFAULT_ROWS); |
| | | // 根据当前标签页加载数据 |
| | | if ($that.moreInfo.currentTab !== 'publicIncome') { |
| | | $that._listData(DEFAULT_PAGE, DEFAULT_ROWS); |
| | | } |
| | | }, |
| | | _initEvent: function () { |
| | | }, |
| | |
| | | changeTab: function (_tab) { |
| | | $that.moreInfo.currentTab = _tab; |
| | | // 根据标签页加载不同数据 |
| | | if (_tab === 'publicIncome') { |
| | | // 公共收益金标签,调用特殊接口 |
| | | $that._loadPublicIncomeData(DEFAULT_PAGE, $that.moreInfo.paginationInfo.rows); |
| | | } else { |
| | | $that._listData(DEFAULT_PAGE, $that.moreInfo.paginationInfo.rows); |
| | | } |
| | | }, |
| | | _loadPublicIncomeData: function (_page, _rows) { |
| | | // 获取URL参数中的costDetailId |
| | | var costDetailId = vc.getParam('costDetailId'); |
| | | if (!costDetailId) { |
| | | // 尝试从hash中获取 |
| | | var hash = location.hash; |
| | | if (hash && hash.indexOf('?') !== -1) { |
| | | var hashParams = hash.substring(hash.indexOf('?') + 1); |
| | | var params = hashParams.split('&'); |
| | | for (var i = 0; i < params.length; i++) { |
| | | var param = params[i].split('='); |
| | | if (param[0] === 'costDetailId') { |
| | | costDetailId = decodeURIComponent(param[1] || ''); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!costDetailId) { |
| | | vc.toast('缺少costDetailId参数'); |
| | | return; |
| | | } |
| | | |
| | | var param = { |
| | | params: { |
| | | mpId: costDetailId, |
| | | page: _page, |
| | | row: _rows |
| | | } |
| | | }; |
| | | |
| | | // 调用公共收益金接口 |
| | | vc.http.apiGet('/announcementTimeRange/queryAnnouncementTimeRangeInfo', |
| | | param, |
| | | function (json, res) { |
| | | try { |
| | | var _json = JSON.parse(json); |
| | | if (_json.code === "0000") { |
| | | var total = _json.total || 0; |
| | | var rows = _rows || DEFAULT_ROWS; |
| | | // 计算总页数 |
| | | var totalPages = Math.ceil(total / rows); |
| | | if (totalPages === 0) { |
| | | totalPages = 1; |
| | | } |
| | | |
| | | $that.moreInfo.paginationInfo.dataCount = total; |
| | | $that.moreInfo.paginationInfo.total = totalPages; |
| | | |
| | | // 映射数据字段 |
| | | var dataList = []; |
| | | if (_json.data && Array.isArray(_json.data)) { |
| | | dataList = _json.data.map(function(item) { |
| | | return { |
| | | id: item.id, |
| | | mpId: item.mpId, |
| | | proposedStartDate: item.plannedAnnouncementStart || '-', |
| | | proposedEndDate: item.plannedAnnouncementEnd || '-', |
| | | publishedStartDate: item.publishedAnnouncementStart || '-', |
| | | publishedEndDate: item.publishedAnnouncementEnd || '-', |
| | | createTime: item.createTime || '', |
| | | updateTime: item.updateTime || '', |
| | | _originalData: item |
| | | }; |
| | | }); |
| | | } |
| | | |
| | | $that.moreInfo.dataList = dataList; |
| | | $that.moreInfo.paginationInfo.currentPage = _page; |
| | | $that._freshPageList(); |
| | | } else { |
| | | vc.toast(_json.msg || '查询失败'); |
| | | $that.moreInfo.dataList = []; |
| | | $that.moreInfo.paginationInfo.dataCount = 0; |
| | | $that.moreInfo.paginationInfo.total = 1; |
| | | $that.moreInfo.paginationInfo.currentPage = _page; |
| | | $that._freshPageList(); |
| | | } |
| | | } catch (e) { |
| | | console.error('数据解析失败:', e); |
| | | vc.toast('数据解析失败'); |
| | | $that.moreInfo.dataList = []; |
| | | $that.moreInfo.paginationInfo.dataCount = 0; |
| | | $that.moreInfo.paginationInfo.total = 1; |
| | | $that.moreInfo.paginationInfo.currentPage = _page; |
| | | $that._freshPageList(); |
| | | } |
| | | }, |
| | | function (errInfo, error) { |
| | | console.error('请求失败:', errInfo, error); |
| | | vc.toast(errInfo || '请求失败,请检查网络连接'); |
| | | $that.moreInfo.dataList = []; |
| | | $that.moreInfo.paginationInfo.dataCount = 0; |
| | | $that.moreInfo.paginationInfo.total = 1; |
| | | $that.moreInfo.paginationInfo.currentPage = _page; |
| | | $that._freshPageList(); |
| | | } |
| | | ); |
| | | }, |
| | | _listData: function (_page, _rows) { |
| | | $that.moreInfo.conditions.page = _page; |
| | |
| | | $that.moreInfo.paginationInfo.pageList = pageList; |
| | | }, |
| | | _changePageSize: function () { |
| | | if ($that.moreInfo.currentTab === 'publicIncome') { |
| | | $that._loadPublicIncomeData(DEFAULT_PAGE, $that.moreInfo.paginationInfo.rows); |
| | | } else { |
| | | $that._listData(DEFAULT_PAGE, $that.moreInfo.paginationInfo.rows); |
| | | } |
| | | }, |
| | | _goToPage: function (_page) { |
| | | if (!_page || _page < 1 || _page > $that.moreInfo.paginationInfo.total) { |
| | | return; |
| | | } |
| | | if ($that.moreInfo.currentTab === 'publicIncome') { |
| | | $that._loadPublicIncomeData(_page, $that.moreInfo.paginationInfo.rows); |
| | | } else { |
| | | $that._listData(_page, $that.moreInfo.paginationInfo.rows); |
| | | } |
| | | }, |
| | | _jumpToPage: function () { |
| | | var page = parseInt($that.moreInfo.jumpPage); |
| | |
| | | if (page > $that.moreInfo.paginationInfo.total) { |
| | | page = $that.moreInfo.paginationInfo.total; |
| | | } |
| | | if ($that.moreInfo.currentTab === 'publicIncome') { |
| | | $that._loadPublicIncomeData(page, $that.moreInfo.paginationInfo.rows); |
| | | } else { |
| | | $that._listData(page, $that.moreInfo.paginationInfo.rows); |
| | | } |
| | | }, |
| | | _add: function () { |
| | | // 添加功能 |