|
@@ -1,30 +1,38 @@
|
|
|
-import { _decorator, Component, instantiate, Label, Node, Prefab } from 'cc';
|
|
|
+import { _decorator, Component, instantiate, Label, Node, Prefab, utils } from 'cc';
|
|
|
import { http } from '../http';
|
|
|
import { config } from '../config';
|
|
|
-import { level_list_item_data } from '../../data/data';
|
|
|
+import { level_list_item_data, long_story_list_item_data } from '../../data/data';
|
|
|
import { level_list_item } from './level_list_item';
|
|
|
import { tools } from '../tools';
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@ccclass('level_list')
|
|
|
export class level_list extends Component {
|
|
|
- @property(Node) version:Node = null;
|
|
|
+ @property(Node) btn_back:Node = null;
|
|
|
+ @property(Node) lab_title:Node = null;
|
|
|
@property(Node) content:Node = null;
|
|
|
@property(Prefab) item:Prefab = null;
|
|
|
@property(Node) page_number:Node = null;
|
|
|
@property(Node) btn_previous_page:Node = null;
|
|
|
@property(Node) lab_current_page:Node = null;
|
|
|
@property(Node) btn_next_page:Node = null;
|
|
|
-
|
|
|
+
|
|
|
+ private m_long_story_list_data: long_story_list_item_data = null
|
|
|
+
|
|
|
+ private m_back_call_back = null;
|
|
|
private m_click_callback = null;
|
|
|
|
|
|
private m_cur_page:number = 1;
|
|
|
private m_every_page_count:number = 18;
|
|
|
private m_total_page_count:number = 0;
|
|
|
- private m_prefab_node_list:Node[] = [];
|
|
|
|
|
|
protected start(): void {
|
|
|
- this.version.getComponent(Label).string = config.version
|
|
|
+ this.btn_back.on(Node.EventType.TOUCH_END,()=>{
|
|
|
+ if(this.m_back_call_back) {
|
|
|
+ this.m_back_call_back()
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
this.page_number.active = false
|
|
|
let self = this
|
|
|
this.btn_previous_page.on(Node.EventType.TOUCH_END, ()=> {
|
|
@@ -45,52 +53,47 @@ export class level_list extends Component {
|
|
|
},this)
|
|
|
}
|
|
|
|
|
|
- public init(call_back){
|
|
|
+ public init(long_story_list_data: long_story_list_item_data, back_call_back, call_back){
|
|
|
+ this.m_long_story_list_data = long_story_list_data
|
|
|
+ if(this.m_long_story_list_data) {
|
|
|
+ this.lab_title.getComponent(Label).string = this.m_long_story_list_data.name
|
|
|
+ }
|
|
|
+ this.m_back_call_back = back_call_back;
|
|
|
this.m_click_callback = call_back;
|
|
|
this.requestData()
|
|
|
}
|
|
|
|
|
|
initView(list:level_list_item_data[]){
|
|
|
- if(this.m_prefab_node_list.length == 0) {
|
|
|
- this.content.removeAllChildren()
|
|
|
- for (let index = 0; index < list.length; index++) {
|
|
|
- const element = list[index];
|
|
|
- let node = instantiate(this.item)
|
|
|
- node.parent = this.content;
|
|
|
- this.m_prefab_node_list.push(node)
|
|
|
- node.getComponent(level_list_item).initView(element,this.m_click_callback)
|
|
|
- }
|
|
|
- } else {
|
|
|
- for(let index = 0; index < this.m_prefab_node_list.length; index++) {
|
|
|
- let node = this.m_prefab_node_list[index]
|
|
|
- if(index < list.length) {
|
|
|
- node.active = true
|
|
|
- const element = list[index]
|
|
|
- node.getComponent(level_list_item).initView(element,this.m_click_callback)
|
|
|
- } else {
|
|
|
- node.active = false
|
|
|
- }
|
|
|
- }
|
|
|
+ for (let index = 0; index < list.length; index++) {
|
|
|
+ const element = list[index];
|
|
|
+ let node = instantiate(this.item)
|
|
|
+ node.parent = this.content;
|
|
|
+ node.getComponent(level_list_item).initView(element,this.m_click_callback)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
requestData() {
|
|
|
- let request_data = {"page":this.m_cur_page,"limit":this.m_every_page_count}
|
|
|
- http.post("/tool/mysnote/levels",request_data,(err,data)=>{
|
|
|
- if(!err){
|
|
|
- // console.log(data)
|
|
|
- let _data = JSON.parse(data);
|
|
|
- let __data = _data.content
|
|
|
- if(this.m_cur_page == 1) {
|
|
|
- this.page_number.active = true
|
|
|
- this.m_total_page_count = Math.ceil(__data.tool_number/this.m_every_page_count)
|
|
|
+ this.content.removeAllChildren()
|
|
|
+ if(this.m_long_story_list_data==null) {
|
|
|
+ let request_data = {"page":this.m_cur_page,"limit":this.m_every_page_count}
|
|
|
+ http.post("/tool/mysnote/levels",request_data,(err,data)=>{
|
|
|
+ if(!err){
|
|
|
+ // console.log(data)
|
|
|
+ let _data = JSON.parse(data);
|
|
|
+ let __data = _data.content
|
|
|
+ if(this.m_cur_page == 1) {
|
|
|
+ this.page_number.active = true
|
|
|
+ this.m_total_page_count = Math.ceil(__data.tool_number/this.m_every_page_count)
|
|
|
+ }
|
|
|
+ this.setupLabNumber()
|
|
|
+ config.last_id = parseInt(_data.content.zujian_id)
|
|
|
+ console.log("level_list",config.last_id )
|
|
|
+ this.initView(__data.list)
|
|
|
}
|
|
|
- this.setupLabNumber()
|
|
|
- config.last_id = parseInt(_data.content.zujian_id)
|
|
|
- console.log("level_list",config.last_id )
|
|
|
- this.initView(__data.list)
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
setupLabNumber() {
|