launch.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. content: cc.Node,
  5. prefab: cc.Prefab,
  6. prefabme: cc.Prefab,
  7. GoldMedal: cc.SpriteFrame,
  8. SilverMedal:cc.SpriteFrame,
  9. BronzeMedal:cc.SpriteFrame,
  10. },
  11. onLoad() {
  12. this.nodes = [];
  13. this.ranklist = cc.find("Canvas/ranklist");
  14. this.info = cc.find("Canvas/info");
  15. // this.Transcend = UtilsPrefabs.getNode("Transcend",cc.find("Canvas"));
  16. // this.animCtrl = this.Transcend.getComponent("cc.Animation");
  17. // console.log("动画组件紫玉到底有没有",this.Transcend);
  18. //
  19. //
  20. //
  21. // if (this.animCtrl!=null) {
  22. // this.animCtrl.on('finished', this.finished,this);
  23. // }
  24. // this.canvasAdopt();
  25. },
  26. finished : function(){
  27. // console.log("动画回调了吗",this.Transcendnode);
  28. if (this.Transcendnode != null) {
  29. this.Transcendnode.active = false;
  30. }
  31. },
  32. canvasAdopt() {
  33. // 适配解决方案
  34. let canvas = cc.director.getScene().getChildByName('Canvas').getComponent(cc.Canvas)
  35. // 设计分辨率比
  36. let rateR = canvas.designResolution.height/canvas.designResolution.width;
  37. // 显示分辨率比
  38. let rateV = cc.view.getVisibleSize().height / cc.view.getVisibleSize().width;
  39. console.log("winSize: rateR: " + rateR + " rateV: " + rateV);
  40. if (rateV > rateR) {
  41. canvas.fitHeight = false;
  42. canvas.fitWidth = true;
  43. console.log("winSize: fitWidth");
  44. } else {
  45. canvas.fitHeight = true;
  46. canvas.fitWidth = false;
  47. console.log("winSize: fitHeight");
  48. }
  49. },
  50. getFriend : function(){
  51. this.removeAll();
  52. if (cc.sys.platform === cc.sys.WECHAT_GAME){
  53. wx.getFriendCloudStorage({
  54. keyList: ['score'],
  55. success: function (res) {
  56. // console.log("朋友数据是",res.data);
  57. // console.log("我的数据是",userData.openId);
  58. // console.log(res.data[0].KVDataList[0].value);
  59. // for (let i = 0; i < res.data.length; i++) {
  60. // let friendInfo = res.data[i];
  61. // if (!friendInfo) {
  62. // _self.createPrefab();
  63. // continue;
  64. // }
  65. // _self.createUserBlock(friendInfo,i);
  66. // }
  67. //添加排行榜为 自己的条目在下面
  68. this.testListView(this.initData(res.data));
  69. this.addMyItem();
  70. }.bind(this),
  71. fail: function (res) {
  72. console.error(res);
  73. }.bind(this)
  74. });
  75. // console.log("自己的");
  76. // this.testListView();
  77. } else{
  78. this.testListView(this.initData(null));
  79. //添加排行榜为 自己的条目在下面
  80. this.addMyItem();
  81. }
  82. },
  83. removeAll : function(){
  84. for (var i = 0; i <this.nodes.length ; i++) {
  85. if (this.nodes[i] != null) {
  86. this.nodes[i].destroy();
  87. }
  88. }
  89. this.nodes = [];
  90. },
  91. //获取到当前名字
  92. getRanking : function(callback){
  93. if (cc.sys.platform === cc.sys.WECHAT_GAME){
  94. wx.getFriendCloudStorage({
  95. keyList: ['score'],
  96. success: function (res) {
  97. // console.log("朋友数据是",res.data);
  98. // console.log("我的数据是",userData.openId);
  99. // console.log(res.data[0].KVDataList[0].value);
  100. // for (let i = 0; i < res.data.length; i++) {
  101. // let friendInfo = res.data[i];
  102. // if (!friendInfo) {
  103. // _self.createPrefab();
  104. // continue;
  105. // }
  106. // _self.createUserBlock(friendInfo,i);
  107. // }
  108. this.initData(res.data,callback);
  109. }.bind(this),
  110. fail: function (res) {
  111. console.error(res);
  112. }.bind(this)
  113. });
  114. // console.log("自己的");
  115. // this.testListView();
  116. } else{
  117. this.initData(null,callback);
  118. }
  119. },
  120. initData : function(data,callback){
  121. var list = [
  122. {
  123. name : "汉堡店",
  124. id : 9527,
  125. Price : 100,
  126. Fluctuate : "15%",
  127. TotalPossession : 3500
  128. },
  129. {
  130. name : "汉堡店1",
  131. id : 9527,
  132. Price : 100,
  133. Fluctuate : "15%",
  134. TotalPossession : 3500
  135. },
  136. {
  137. name : "汉堡店3",
  138. id : 9527,
  139. Price : 100,
  140. Fluctuate : "15%",
  141. TotalPossession : 3500
  142. },
  143. ];
  144. var listdata = [
  145. {
  146. id: 2,
  147. name: "22",
  148. avatarUrl: "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=607947196,2238683854&fm=26&gp=0.jpg",
  149. listData: list,
  150. openId :"oGxOa5bd61v9jI_indIdQtI2T5P8",
  151. // num : 0
  152. },
  153. {
  154. id: 6,
  155. name: "22",
  156. avatarUrl: "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=607947196,2238683854&fm=26&gp=0.jpg",
  157. listData: list,
  158. openId :"oGxOa5bjKLaCSbkPev09yVze0WSA",
  159. // num : 1
  160. },
  161. {
  162. id: 3,
  163. name: "22",
  164. avatarUrl: "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=607947196,2238683854&fm=26&gp=0.jpg",
  165. listData: list,
  166. openId :"oGxOa5bjKLaCSbkPev09yVze0WSA",
  167. // num : 2
  168. },
  169. {
  170. id: 3,
  171. name: "22",
  172. avatarUrl: "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=607947196,2238683854&fm=26&gp=0.jpg",
  173. listData: list,
  174. openId :"oGxOa5bjKLaCSbkPev09yVze0WSA",
  175. // num : 3
  176. },
  177. {
  178. id: 7,
  179. name: "汪汪",
  180. avatarUrl: "https://wx.qlogo.cn/mmopen/vi_32/DYAIOgq83eohXLEIOV99ic2JosrQDgIgL4cU4ZlmmvkWzGpygkNV9aEJ6nCC2mVf4kYBDHogNOHgXo2wZhv85jA/132",
  181. listData: list,
  182. openId :"oGxOa5SQ1ltBWWsVRirUvXUBGRRY",
  183. // num : 4
  184. },
  185. ]
  186. if (data!=null) {
  187. listdata = [];
  188. for (let i = 0; i < data.length; i++) {
  189. let friendInfo = data[i];
  190. // console.log("每条外面的数据",friendInfo);
  191. // this.createUserBlock(friendInfo,i);
  192. let nickName = friendInfo.nickname;
  193. let avatarUrl = friendInfo.avatarUrl +"?aa=a.jpg";
  194. let ScoreValue = friendInfo.KVDataList[0].value;
  195. var d = {
  196. }
  197. d.id = parseInt(ScoreValue);
  198. d.name = nickName;
  199. d.openId = friendInfo.openid;
  200. d.avatarUrl = avatarUrl;
  201. d.listData = list;
  202. // d.num = i;
  203. // console.log("每条",d);
  204. listdata.push(d);
  205. if (friendInfo.openid == userData.openId) {
  206. userData.httpData.data.avatarUrl = avatarUrl + "?aa=a.jpg";
  207. userData.httpData.data.nickName = nickName;
  208. userData.httpData.data.id = d.id;
  209. // userData.httpData.data.num = d.num;
  210. }
  211. }
  212. }
  213. var lists = this.getSortArr(listdata);
  214. // console.log("現在的數據是什麼",lists);
  215. // console.log("家网络数据是什么",userData.httpData.data);
  216. if (callback!=null) {
  217. callback(lists);
  218. }
  219. return lists;
  220. },
  221. getSortArr : function(arr){
  222. return arr.sort(this.sortNumberfunction);
  223. },
  224. addMyItem : function(){
  225. let node = cc.instantiate(this.prefabme);
  226. node.parent = this.node;
  227. this.nodes.push(node);
  228. // // getUserInfo will return the nickName, getFriendCloudStorage will return the nickname.
  229. let nickName = userData.httpData.data.nickName;
  230. let avatarUrl = userData.httpData.data.avatarUrl + "?aa=a.jpg";
  231. let ScoreValue = userData.httpData.data.id;
  232. // // console.log("ScoreValue="+ScoreValue);
  233. let userName = node.getChildByName('userName').getComponent(cc.Label);
  234. let userIcon = node.getChildByName('mask').children[0].getComponent(cc.Sprite);
  235. let Scorelabel = node.getChildByName('Score').getComponent(cc.Label);
  236. // console.log("nickName="+nickName);
  237. userName.string = nickName;
  238. Scorelabel.string = ScoreValue;
  239. //
  240. cc.loader.load({
  241. url: avatarUrl, type: 'png'
  242. }, (err, texture) => {
  243. if (err) console.error(err);
  244. userIcon.spriteFrame = new cc.SpriteFrame(texture);
  245. });
  246. },
  247. sortNumberfunction: function(a,b)
  248. {
  249. return b.id-a.id;
  250. },
  251. callMessage : function(){
  252. },
  253. start () {
  254. // wx.postMessage
  255. // var button = this.node.getComponent(cc.Button);
  256. // this.node.on('click', this.callback, this);
  257. //
  258. // let _self = this;
  259. //
  260. // wx.onMessage( data => {
  261. // console.log(data.message);
  262. // });
  263. // https://developers.weixin.qq.com/minigame/dev/document/open-api/data/wx.getUserInfo.html
  264. // wx.getUserInfo({
  265. // openIdList: ['selfOpenId'],
  266. // lang: 'zh_CN',
  267. // success: (res) => {
  268. // console.log('success', res.data);
  269. // let userInfo = res.data[0];
  270. // _self.createUserBlock(userInfo);
  271. // },
  272. // fail: (res) => {
  273. // reject(res);
  274. // }
  275. // });
  276. // https://developers.weixin.qq.com/minigame/dev/document/open-api/data/wx.getFriendCloudStorage.html
  277. },
  278. testListView : function(listdata){
  279. for (let i = 0; i < listdata.length; i++) {
  280. let friendInfo = listdata[i];
  281. this.createtest(friendInfo,i);
  282. }
  283. this.setOnClickItem(function (index) {
  284. // console.log("条目点击",listdata[index],"点了索引了",index);
  285. UtilsPrefabs
  286. .init(this.node.parent)
  287. .addPrefabs(UtilsPrefabs.PrefabsName[5],null,function (node) {
  288. this.initcreateUserInfo(listdata[index],node);
  289. // UtilsWX.wxgameLogin(function (res) {
  290. // console.log('获取玩家信息 准备跳转到下个页面',res);
  291. // this.showLoadDialog();
  292. //
  293. // }.bind(this))
  294. var PCloseButton = UtilsPrefabs.getNode("PCloseButton",node);
  295. UtilsPrefabs.setOff(PCloseButton);
  296. UtilsPrefabs.setOn(PCloseButton,function () {
  297. UtilsPrefabs.removePrefabs(this.node.parent,node.name);
  298. }.bind(this))
  299. }.bind(this));
  300. }.bind(this));
  301. },
  302. createtest (user,index) {
  303. let node = this.createPrefab(index);
  304. // getUserInfo will return the nickName, getFriendCloudStorage will return the nickname.
  305. let nickName = user.name;
  306. let avatarUrl = user.avatarUrl +"?aa=a.jpg";
  307. let ScoreValue = user.id;
  308. // console.log("ScoreValue="+ScoreValue);
  309. let userName = node.getChildByName('userName').getComponent(cc.Label);
  310. let userIcon = node.getChildByName('mask').children[0].getComponent(cc.Sprite);
  311. let Scorelabel = node.getChildByName('Score').getComponent(cc.Label);
  312. node.__itemID = index;
  313. if (userName != null) {
  314. userName.string = nickName;
  315. }
  316. if (Scorelabel != null) {
  317. Scorelabel.string = ScoreValue;
  318. }
  319. // console.log(nickName + '\'s info has been getten.');
  320. cc.loader.load({
  321. url: avatarUrl, type: 'png'
  322. }, (err, texture) => {
  323. if (err) console.error(err);
  324. userIcon.spriteFrame = new cc.SpriteFrame(texture);
  325. });
  326. //点击效果
  327. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  328. // cc.log("begin spin", event.currentTarget.__itemID);
  329. // if (this.onClickItem != null) {
  330. // this.onClickItem(event.currentTarget.__itemID);
  331. // }
  332. // this.Transcend.active = true;
  333. // this.animCtrl.play('Transcend');
  334. // this.Transcendfun();
  335. // this.getCurrs();
  336. }.bind(this));
  337. },
  338. Transcendfun : function(a,b){
  339. // UtilsPrefabs
  340. // .init(this.node.parent)
  341. // .addPrefabs("prefab/Transcend",null,function (node) {
  342. //
  343. // // var m
  344. // // = cc.moveTo(3,50,50);
  345. // // node.runAction(m)
  346. //
  347. // // var data = [];
  348. // // data["openid"] = userData.openId;
  349. // //
  350. // // httpUtils.Post(httpUtils.getUserData, data, function (resData) {
  351. // // console.log("子域访问网络成功", resData);
  352. // //
  353. // // if (resData.code == 0) {
  354. // // // this.getText.string = data.data.userdata;
  355. // // }
  356. // // }.bind(this), function (resData) {
  357. // // console.log("子域访问网络失败", resData);
  358. // // }.bind(this));
  359. //
  360. //
  361. //
  362. // }.bind(this));
  363. // console.log("超越者a",a,"被超者b",b);
  364. this.Transcendnode = UtilsPrefabs.getNode("Transcend",cc.find("Canvas"));
  365. this.Transcendnode.active = true;
  366. this.animCtrl = this.Transcendnode.getComponent("cc.Animation");
  367. if (a !=null && b!=null) {
  368. this.setItemDataA(a);
  369. this.setItemDataB(b);
  370. }
  371. if (this.animCtrl!=null) {
  372. this.animCtrl.play('Transcend');
  373. this.animCtrl.on('finished', this.finished,this);
  374. }
  375. },
  376. getCurrs : function(x,lists){
  377. // console.log("近来数据全不全",x,lists);
  378. this.ranklist.active = true;
  379. if (x == null && lists == null) {
  380. this.initData(null,function (list) {
  381. var listdata = [];
  382. for (var i = 0; i <list.length ; i++) {
  383. if (list[i].openId ==userData.openId) {
  384. // console.log("我 前面",list[i-1]);
  385. // console.log("我 ",list[i]);
  386. // console.log("我 后面",list[i+1]);
  387. if (list[i-1]!=null) {
  388. list[i-1].num = i;
  389. }
  390. if (list[i]!=null) {
  391. list[i].num = i+1;
  392. }
  393. if (list[i+1]!=null) {
  394. list[i+1].num = i+2;
  395. }
  396. listdata.push(list[i-1]);
  397. listdata.push(list[i]);
  398. listdata.push(list[i+1]);
  399. this.setleftmidrightRankListData(listdata);
  400. }
  401. }
  402. }.bind(this))
  403. }else{
  404. // console.log("我在统计数组4",lists);
  405. var listdata = [];
  406. for (var i = 0; i <lists.length ; i++) {
  407. if (lists[i].openId ==userData.openId) {
  408. // console.log("我 前面",lists[i-1]);
  409. // console.log("我 ",lists[i]);
  410. // console.log("我 后面",lists[i+1]);
  411. if (lists[i-1]!=null) {
  412. lists[i-1].num = i;
  413. }
  414. if (lists[i]!=null) {
  415. lists[i].num = i+1;
  416. }
  417. if (lists[i+1]!=null) {
  418. lists[i+1].num = i+2;
  419. }
  420. listdata.push(lists[i-1]);
  421. listdata.push(lists[i]);
  422. listdata.push(lists[i+1]);
  423. this.setleftmidrightRankListData(listdata);
  424. }
  425. }
  426. }
  427. },
  428. curr : function(data){
  429. this.info.active = true;
  430. let layou = UtilsPrefabs.getNode("layou",this.info);
  431. let ic = layou.children[1];
  432. let name = layou.children[2];
  433. let money = layou.children[3];
  434. name.getComponent(cc.Label).string = data.name;
  435. money.getComponent(cc.Label).string = data.id;
  436. cc.loader.load({
  437. url: data.avatarUrl, type: 'png'
  438. }, (err, texture) => {
  439. if (err) console.error(err);
  440. ic.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
  441. });
  442. setTimeout(function () {
  443. this.info.active = false;
  444. }.bind(this),4000)
  445. },
  446. setleftmidrightRankListData : function(listdata){
  447. // console.log("进来的数据是",listdata);
  448. this.closeRanklist();
  449. // console.log("我在统计数组5",listdata);
  450. this.ranklist.active = true;
  451. for (var i = 0; i <listdata.length ; i++) {
  452. if (listdata[i] !=null) {
  453. var bg = this.ranklist.getChildByName("bg");
  454. bg.children[i].active = true;
  455. let num = UtilsPrefabs.getNode("num",bg.children[i]);
  456. let ic = UtilsPrefabs.getNode("ic",bg.children[i]);
  457. let name = UtilsPrefabs.getNode("name",bg.children[i]);
  458. let money = UtilsPrefabs.getNode("money",bg.children[i]);
  459. num.getComponent(cc.Label).string = listdata[i].num+"名";
  460. name.getComponent(cc.Label).string = listdata[i].name;
  461. money.getComponent(cc.Label).string = listdata[i].id;
  462. cc.loader.load({
  463. url: listdata[i].avatarUrl, type: 'png'
  464. }, (err, texture) => {
  465. if (err) console.error(err);
  466. ic.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
  467. });
  468. }
  469. }
  470. this.ranklist.getChildByName("sub").on(cc.Node.EventType.TOUCH_END, function (event) {
  471. this.closeRanklist();
  472. }.bind(this));
  473. setTimeout(function () {
  474. this.closeRanklist();
  475. }.bind(this),5000)
  476. },
  477. closeRanklist : function(){
  478. for (var i = 0; i <this.ranklist.getChildByName("bg").children.length ; i++) {
  479. this.ranklist.getChildByName("bg").children[i].active = false;
  480. }
  481. this.ranklist.getChildByName("sub").off(cc.Node.EventType.TOUCH_END);
  482. this.ranklist.active = false;
  483. },
  484. setItemDataA : function(a){
  485. let nickName = a.name;
  486. let avatarUrl = a.avatarUrl;
  487. let ScoreValue = a.id;
  488. // console.log("ScoreValue="+ScoreValue);i
  489. this.Transcendnode = UtilsPrefabs.getNode("Transcend",cc.find("Canvas"));
  490. this.Other = UtilsPrefabs.getNode("i",this.Transcendnode);
  491. var block = UtilsPrefabs.getNode("block",this.Other);
  492. let userName = block.getChildByName('userName').getComponent(cc.Label);
  493. let userIcon = block.getChildByName('mask').children[0].getComponent(cc.Sprite);
  494. let Scorelabel = block.getChildByName('Score').getComponent(cc.Label);
  495. userName.string = nickName;
  496. Scorelabel.string = ScoreValue;
  497. // console.log(nickName + '\'s info has been getten.');
  498. cc.loader.load({
  499. url: avatarUrl, type: 'png'
  500. }, (err, texture) => {
  501. if (err) console.error(err);
  502. userIcon.spriteFrame = new cc.SpriteFrame(texture);
  503. });
  504. },
  505. setItemDataB : function(b){
  506. let nickName = b.name;
  507. let avatarUrl = b.avatarUrl;
  508. let ScoreValue = b.id;
  509. // console.log("ScoreValue="+ScoreValue);
  510. this.Transcendnode = UtilsPrefabs.getNode("Transcend",cc.find("Canvas"));
  511. var Other = UtilsPrefabs.getNode("Other",this.Transcendnode);
  512. var block = UtilsPrefabs.getNode("block",Other);
  513. let userName = block.getChildByName('userName').getComponent(cc.Label);
  514. let userIcon = block.getChildByName('mask').children[0].getComponent(cc.Sprite);
  515. let Scorelabel = block.getChildByName('Score').getComponent(cc.Label);
  516. userName.string = nickName;
  517. Scorelabel.string = ScoreValue;
  518. // console.log(nickName + '\'s info has been getten.');
  519. cc.loader.load({
  520. url: avatarUrl, type: 'png'
  521. }, (err, texture) => {
  522. if (err) console.error(err);
  523. userIcon.spriteFrame = new cc.SpriteFrame(texture);
  524. });
  525. },
  526. onClickItem: function () {
  527. },
  528. setOnClickItem: function (onClickItem) {
  529. this.onClickItem = onClickItem;
  530. },
  531. createUserBlock (user,index) {
  532. let node = this.createPrefab(index);
  533. // getUserInfo will return the nickName, getFriendCloudStorage will return the nickname.
  534. let nickName = user.nickName ? user.nickName : user.nickname;
  535. let avatarUrl = user.avatarUrl;
  536. let ScoreValue = (user.KVDataList)[0].value;
  537. // console.log("ScoreValue="+ScoreValue);
  538. let userName = node.getChildByName('userName').getComponent(cc.Label);
  539. let userIcon = node.getChildByName('mask').children[0].getComponent(cc.Sprite);
  540. let Scorelabel = node.getChildByName('Score').getComponent(cc.Label);
  541. userName.string = nickName;
  542. Scorelabel.string = ScoreValue;
  543. // console.log(nickName + '\'s info has been getten.');
  544. cc.loader.load({
  545. url: avatarUrl, type: 'png'
  546. }, (err, texture) => {
  547. if (err) console.error(err);
  548. userIcon.spriteFrame = new cc.SpriteFrame(texture);
  549. });
  550. },
  551. createPrefab (index) {
  552. let node = cc.instantiate(this.prefab);
  553. node.parent = this.content;
  554. this.nodes.push(node);
  555. switch (index) {
  556. case 0:
  557. node.spriteFrame=this.GoldMedal;
  558. break;
  559. case 1:
  560. node.spriteFrame=this.SilverMedal;
  561. break;
  562. case 2:
  563. node.spriteFrame=this.BronzeMedal;
  564. break;
  565. }
  566. return node;
  567. },
  568. initcreateUserInfo : function(listdata,node){
  569. cc.loader.loadRes(UtilsPrefabs.PrefabsName[6], function (err, texture) {
  570. this.itemprefab = cc.instantiate(texture);
  571. for (let i = 0; i < listdata.listData.length; i++) {
  572. let info = listdata.listData[i];
  573. var StockSort = UtilsPrefabs.getNode("StockSort",node);
  574. var ScrollView = UtilsPrefabs.getNode("ScrollView",StockSort);
  575. var view = UtilsPrefabs.getNode("view",ScrollView);
  576. var content = UtilsPrefabs.getNode("content",view);
  577. this.createUserInfo(info,i,content);
  578. }
  579. }.bind(this));
  580. },
  581. createUserInfo (user,index,nodes) {
  582. var itemnode = cc.instantiate(this.itemprefab);
  583. nodes.addChild(itemnode);
  584. var Layout = UtilsPrefabs.getNode("Layout",itemnode);
  585. var Name = UtilsPrefabs.getNode("Name",Layout);
  586. var Code = UtilsPrefabs.getNode("Code",Layout);
  587. var Price = UtilsPrefabs.getNode("Price",Layout);
  588. var Fluctuate = UtilsPrefabs.getNode("Fluctuate",Layout);
  589. var TotalPossession = UtilsPrefabs.getNode("TotalPossession",Layout);
  590. Name.getComponent(cc.Label).string = user.name;
  591. Code.getComponent(cc.Label).string = user.id;
  592. Price.getComponent(cc.Label).string = user.Price;
  593. Fluctuate.getComponent(cc.Label).string = user.Fluctuate;
  594. TotalPossession.getComponent(cc.Label).string = user.TotalPossession;
  595. // console.log("来了吗",user,index,nodes);
  596. },
  597. // callback: function (button) {
  598. // //do whatever you want with button
  599. // //另外,注意这种方式注册的事件,也无法传递 customEventData
  600. // console.log("111111111111111111111111111111111");
  601. // }
  602. // callback: function (event, customEventData) {
  603. // //这里 event 是一个 Touch Event 对象,你可以通过 event.target 取到事件的发送节点
  604. // var node = event.target;
  605. // var button = node.getComponent(cc.Button);
  606. // //这里的 customEventData 参数就等于你之前设置的 "foobar"
  607. // console.log("111111111111111111111111111111111");
  608. // }
  609. });