|
@@ -1,10 +1,12 @@
|
|
|
-import { YTAvoid, yTRouter } from "basic"
|
|
|
|
|
|
|
+import { YTAvoid } from "basic"
|
|
|
|
|
+import { HistoryApis } from "../Apis/HistoryApis"
|
|
|
|
|
+import { MilitaryNewsItem, NesResponse, Query } from "../model/Index"
|
|
|
|
|
|
|
|
@ObservedV2
|
|
@ObservedV2
|
|
|
export class MainViewModel{
|
|
export class MainViewModel{
|
|
|
@Trace safeTop: number = 0
|
|
@Trace safeTop: number = 0
|
|
|
|
|
|
|
|
- @Trace dataSource: Array<string> = new Array(10).fill('')
|
|
|
|
|
|
|
+ @Trace dataSource: Array<MilitaryNewsItem> = []
|
|
|
|
|
|
|
|
@Trace selectIndex: number = -1
|
|
@Trace selectIndex: number = -1
|
|
|
@Trace areaList: Array<Area> = new Array(3)
|
|
@Trace areaList: Array<Area> = new Array(3)
|
|
@@ -12,17 +14,31 @@ export class MainViewModel{
|
|
|
@Trace lineX: number = 32
|
|
@Trace lineX: number = 32
|
|
|
@Trace lineY: number = 102
|
|
@Trace lineY: number = 102
|
|
|
|
|
|
|
|
|
|
+ query: Query = {
|
|
|
|
|
+ page: 1,
|
|
|
|
|
+ limit: 6,
|
|
|
|
|
+ // 类型 0全部.1国内 2国际
|
|
|
|
|
+ type: 0
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
constructor() {
|
|
constructor() {
|
|
|
this.safeTop = AppStorage.get(YTAvoid.SAFE_TOP_KEY) as number
|
|
this.safeTop = AppStorage.get(YTAvoid.SAFE_TOP_KEY) as number
|
|
|
|
|
+
|
|
|
|
|
+ this.getMilitaryNews()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 更改选中的下标
|
|
// 更改选中的下标
|
|
|
changeSelectIndex(i: number) {
|
|
changeSelectIndex(i: number) {
|
|
|
|
|
+ if(this.selectIndex == i) return
|
|
|
|
|
+
|
|
|
animateToImmediately({ duration: 200 }, () => {
|
|
animateToImmediately({ duration: 200 }, () => {
|
|
|
this.selectIndex = i
|
|
this.selectIndex = i
|
|
|
|
|
|
|
|
this.lineX = this.areaList[i].globalPosition.x as number - 15
|
|
this.lineX = this.areaList[i].globalPosition.x as number - 15
|
|
|
this.lineY = this.areaList[i].globalPosition.y as number - 17
|
|
this.lineY = this.areaList[i].globalPosition.y as number - 17
|
|
|
|
|
+
|
|
|
|
|
+ this.query.type = i
|
|
|
|
|
+ this.getMilitaryNews(true)
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -35,4 +51,24 @@ export class MainViewModel{
|
|
|
this.lineWidth = this.areaList[i].width as number - 30
|
|
this.lineWidth = this.areaList[i].width as number - 30
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 获取军事咨询
|
|
|
|
|
+ async getMilitaryNews(isReload: boolean = true) {
|
|
|
|
|
+ if (isReload) {
|
|
|
|
|
+ this.query.page = 1
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if(this.dataSource.length >= this.query.total!) return
|
|
|
|
|
+ this.query.page!++
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let ans: NesResponse = await HistoryApis.getMilitaryNews(this.query)
|
|
|
|
|
+
|
|
|
|
|
+ if(isReload){
|
|
|
|
|
+ this.dataSource = ans?.newList
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.dataSource.push(...ans?.newList)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.query.total = Number.parseInt(ans?.total ?? "0")
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|