张善主

feat(人民号频道):增加推荐接口

@@ -35,6 +35,10 @@ export class HttpUrlUtils { @@ -35,6 +35,10 @@ export class HttpUrlUtils {
35 */ 35 */
36 static readonly COMP_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/compInfo"; 36 static readonly COMP_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/compInfo";
37 /** 37 /**
  38 + * 展现comp接口(推荐)
  39 + */
  40 + static readonly COMP_REC_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/compInfo";
  41 + /**
38 * 详情页面详情接口 42 * 详情页面详情接口
39 */ 43 */
40 static readonly DETAIL_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail"; 44 static readonly DETAIL_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail";
@@ -159,7 +159,7 @@ export struct PageComponent { @@ -159,7 +159,7 @@ export struct PageComponent {
159 // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 159 // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代
160 for (const group of pageInfo.groups) { 160 for (const group of pageInfo.groups) {
161 this.pageDto = await PageViewModel.getPageData(this.pageModel.pageId, `${group.id}`, this.pageModel.channelId 161 this.pageDto = await PageViewModel.getPageData(this.pageModel.pageId, `${group.id}`, this.pageModel.channelId
162 - , this.pageModel.currentPage, this.pageModel.pageSize, getContext(this)) 162 + , this.pageModel.currentPage, this.pageModel.pageSize,group.groupStrategy, getContext(this))
163 this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() 163 this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString()
164 if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { 164 if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) {
165 this.pageDto.compList.forEach((comp) => { 165 this.pageDto.compList.forEach((comp) => {
@@ -45,8 +45,15 @@ export class PageRepository { @@ -45,8 +45,15 @@ export class PageRepository {
45 return url; 45 return url;
46 } 46 }
47 47
48 - static getCompInfoUrl(pageId: string, groupId: string, channelId: string, currentPage: number, pageSize: number) {  
49 - let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMP_PATH; 48 + static getCompInfoUrl(pageId: string, groupId: string, channelId: string, groupStrategy: number, currentPage: number, pageSize: number) {
  49 + let url = HttpUrlUtils.getHost();
  50 + if(1 == groupStrategy){
  51 + //推荐
  52 + url = url + HttpUrlUtils.COMP_REC_PATH;
  53 + }else{
  54 + //非推荐
  55 + url = url + HttpUrlUtils.COMP_PATH;
  56 + }
50 // TODO 暂定只请求第一页,后续对接分页加载,参数再调整 first_load? 57 // TODO 暂定只请求第一页,后续对接分页加载,参数再调整 first_load?
51 url = url + "?channelStrategy=2&loadStrategy=first_load" 58 url = url + "?channelStrategy=2&loadStrategy=first_load"
52 + "&districtCode=" + HttpUrlUtils.getDistrictCode() 59 + "&districtCode=" + HttpUrlUtils.getDistrictCode()
@@ -180,8 +187,8 @@ export class PageRepository { @@ -180,8 +187,8 @@ export class PageRepository {
180 return WDHttp.get<ResponseDTO<PageInfoBean>>(url, headers) 187 return WDHttp.get<ResponseDTO<PageInfoBean>>(url, headers)
181 }; 188 };
182 189
183 - static fetchPageData(pageId: string, groupId: string, channelId: string, currentPage: number, pageSize: number) {  
184 - let url = PageRepository.getCompInfoUrl(pageId, groupId, channelId, currentPage, pageSize) 190 + static fetchPageData(pageId: string, groupId: string, channelId: string,groupStrategy:number, currentPage: number, pageSize: number) {
  191 + let url = PageRepository.getCompInfoUrl(pageId, groupId, channelId,groupStrategy, currentPage, pageSize)
185 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); 192 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
186 return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) 193 return WDHttp.get<ResponseDTO<PageDTO>>(url, headers)
187 }; 194 };
@@ -72,7 +72,7 @@ export function touchUpPullRefresh(pageModel: PageModel) { @@ -72,7 +72,7 @@ export function touchUpPullRefresh(pageModel: PageModel) {
72 setTimeout(() => { 72 setTimeout(() => {
73 let self: PageModel = pageModel; 73 let self: PageModel = pageModel;
74 74
75 - PageViewModel.getPageData(self.pageId, self.groupId, self.channelId, self.currentPage, self.pageSize, getContext()) 75 + PageViewModel.getPageData(self.pageId, self.groupId, self.channelId, self.currentPage, self.pageSize,self.groupStrategy, getContext())
76 .then((data: PageDTO) => { 76 .then((data: PageDTO) => {
77 self.timestamp = DateTimeUtils.getTimeStamp().toString() 77 self.timestamp = DateTimeUtils.getTimeStamp().toString()
78 if (data == null || data.compList == null || data.compList.length == 0) { 78 if (data == null || data.compList == null || data.compList.length == 0) {
@@ -28,7 +28,7 @@ export function touchUpLoadMore(model: PageModel) { @@ -28,7 +28,7 @@ export function touchUpLoadMore(model: PageModel) {
28 self.isLoading = true; 28 self.isLoading = true;
29 setTimeout(() => { 29 setTimeout(() => {
30 closeLoadMore(model); 30 closeLoadMore(model);
31 - PageViewModel.getPageData(self.pageId, self.groupId, self.channelId, self.currentPage, self.pageSize, getContext()) 31 + PageViewModel.getPageData(self.pageId, self.groupId, self.channelId, self.currentPage, self.pageSize,self.groupStrategy, getContext())
32 .then((data: PageDTO) => { 32 .then((data: PageDTO) => {
33 self.timestamp = DateTimeUtils.getTimeStamp().toString() 33 self.timestamp = DateTimeUtils.getTimeStamp().toString()
34 if (data == null || data.compList == null || data.compList.length == 0) { 34 if (data == null || data.compList == null || data.compList.length == 0) {
@@ -141,13 +141,13 @@ export class PageViewModel extends BaseViewModel { @@ -141,13 +141,13 @@ export class PageViewModel extends BaseViewModel {
141 } 141 }
142 142
143 async getPageData(pageId: string, groupId: string, channelId: string, currentPage: number 143 async getPageData(pageId: string, groupId: string, channelId: string, currentPage: number
144 - , pageSize: number, context: Context): Promise<PageDTO> { 144 + , pageSize: number,groupStrategy:number, context: Context): Promise<PageDTO> {
145 Logger.debug(TAG, 'getPageData pageId: ' + pageId); 145 Logger.debug(TAG, 'getPageData pageId: ' + pageId);
146 if (mock_switch) { 146 if (mock_switch) {
147 return this.getPageData1(currentPage, context); 147 return this.getPageData1(currentPage, context);
148 } 148 }
149 return new Promise<PageDTO>((success, error) => { 149 return new Promise<PageDTO>((success, error) => {
150 - PageRepository.fetchPageData(pageId, groupId, channelId, currentPage, pageSize) 150 + PageRepository.fetchPageData(pageId, groupId, channelId,groupStrategy, currentPage, pageSize)
151 .then((resDTO: ResponseDTO<PageDTO>) => { 151 .then((resDTO: ResponseDTO<PageDTO>) => {
152 if (!resDTO || !resDTO.data) { 152 if (!resDTO || !resDTO.data) {
153 Logger.error(TAG, 'getNavData then resDTO is empty'); 153 Logger.error(TAG, 'getNavData then resDTO is empty');