1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- var jobData = require('../data/job');
- cc.Class({
- extends: cc.Component,
- properties: {
- pageview: cc.PageView,
- jobItem: cc.Node,
- summaryLabel: cc.Label,
- artistIconSprite: cc.Sprite,
- artistLabel: cc.Label,
- jobIconFrames: [cc.SpriteFrame],
- },
- bind(currentJobId, gender) {
- this.gender = gender;
- this.pageview.removeAllPages();
- this.jobList = [];
- if (currentJobId) {
- for (var i = 0; i < jobData.length; i++) {
- if (jobData[i].id == currentJobId) {
- } else {
- this.jobList.push(jobData[i]);
- }
- }
- } else {
- this.jobList = jobData;
- }
- for (var i = 0; i < this.jobList.length; i++) {
- let item = cc.instantiate(this.jobItem);
- item.active = true;
- item.position = new cc.p(0, 0);
- item.getComponent('JobItem').bind(this.jobList[i]);
- this.pageview.addPage(item);
- }
-
- this.pageview.sizeMode = cc.PageView.SizeMode.Free;
- this.pageview._updatePageView();
- },
- bindJobList(jobList) {
- this.pageview.removeAllPages();
- this.jobList = jobList;
- for (var i = 0; i < this.jobList.length; i++) {
- let item = cc.instantiate(this.jobItem);
- item.active = true;
- item.position = new cc.p(0, 0);
- item.getComponent('JobItem').bind(this.jobList[i], this.gender);
- this.pageview.addPage(item);
- }
-
- this.pageview.sizeMode = cc.PageView.SizeMode.Free;
- this.pageview._updatePageView();
- },
- bindSelectedJobText() {
- let jobInfo = this.jobList[this.pageview.getCurrentPageIndex()];
- this.artistIconSprite.spriteFrame = this.jobIconFrames[jobInfo.id - 1];
- this.artistLabel.string = jobInfo.name;
- this.summaryLabel.string = jobInfo.msg;
- },
- getSelectedJob() {
- return this.jobList[this.pageview.getCurrentPageIndex()];
- },
-
- });
|