123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- var wechat = require("../net/WeChat");
- const DWTool = require('../utils/DWTool');
- var shareDialog = require('./ShareDialog')
- const ShareAction = require('../utils/ShareAction');
- const FriendSystemApi = require('../net/FriendSystemApi')
- cc.Class({
- extends: cc.Component,
- properties: {
- content: cc.Node,
- friendNode: cc.Node,
- recommendNode: cc.Node,
- _wechatFriendNode: cc.Node,
- friendButton: cc.Button,
- recommendButton: cc.Button,
- wechatFriendButton: cc.Button,
- friendTabSprites: [cc.SpriteFrame],
- recommendTabSprites: [cc.SpriteFrame],
- wechatFriendTabSprites: [cc.SpriteFrame],
- },
- onLoad() {
- this.node.height = cc.view.getVisibleSize().height;
- this.contentY = this.content.y = (this.content.height - this.node.height) / 2;
- this._defaultY = 496;
- this._selectedY = 480;
- },
- onEnable() {
- },
- onDisable() {
- },
- show(wechatFriendNode) {
- this.setWechatFriendNode(wechatFriendNode);
- this.node.parent = cc.find('Canvas');
- this.node.active = true;
- this.content.y = -cc.view.getVisibleSize().height;
- let s = cc.sequence(cc.moveTo(0.2, 0, this.contentY + 20).easing(cc.easeCubicActionOut()), cc.moveBy(0.05, 0, -20));
- this.content.runAction(s);
- this.scheduleOnce(() => {
- this.setTabState(0);
- }, 0.2);
- },
- close() {
- if (this.node && this.node.parent) {
- this._wechatFriendNode.active = false;
- let finish = cc.callFunc(() => {
- this.closeFriendSystem();
- }, this)
- this.content.runAction(cc.sequence(cc.moveTo(0.2, 0, -cc.view.getVisibleSize().height).easing(cc.easeCubicActionIn()), finish));
- }
- },
- setTabState(currentIndex) {
- if (this.currentIndex === currentIndex) {
- return;
- }
- console.log('currentIndex:' + currentIndex);
- this.currentIndex = currentIndex;
- switch (currentIndex) {
- case 0:
- this.setTabSelected(true, this.friendButton, this.friendTabSprites, this.friendNode);
- this.setTabSelected(false, this.recommendButton, this.recommendTabSprites, this.recommendNode);
- this.setTabSelected(false, this.wechatFriendButton, this.wechatFriendTabSprites, this._wechatFriendNode);
- break;
- case 1:
- this.setTabSelected(false, this.friendButton, this.friendTabSprites, this.friendNode);
- this.setTabSelected(true, this.recommendButton, this.recommendTabSprites, this.recommendNode);
- this.setTabSelected(false, this.wechatFriendButton, this.wechatFriendTabSprites, this._wechatFriendNode);
- break;
- case 2:
- this._wechatFriendNode.zIndex = 2;
- this.setTabSelected(false, this.friendButton, this.friendTabSprites, this.friendNode);
- this.setTabSelected(false, this.recommendButton, this.recommendTabSprites, this.recommendNode);
- this.setTabSelected(true, this.wechatFriendButton, this.wechatFriendTabSprites, this._wechatFriendNode);
- break;
- }
- },
- setWechatFriendNode(wechatFriendNode) {
- this._wechatFriendNode = wechatFriendNode;
- this._wechatFriendNode.height = cc.view.getVisibleSize().height;
- },
- closeFriendSystem: function () {
- this.friendNode.getComponent('FriendList').friendLastRequestTime = -1;
- this.currentIndex = -1;
- this.node.active = false;
- this._wechatFriendNode.active = false;
- },
- showTalent() {
- cc.loader.loadRes('/prefabs/talent_mission', cc.Prefab, (error, prefab) => {
- if (error === null) {
- let mission = cc.instantiate(prefab);
- mission = mission.getComponent('TalentMission');
- mission.init();
- } else {
- console.log(JSON.stringify(error));
- }
- });
- },
- inviteFriend: function () {
- wechat.inviteFriendPromise().then(() => {
- FriendSystemApi.shareSuccessNotice();
- });
-
-
-
-
-
-
-
-
-
- },
- changeToWechatFriendTab() {
- this.setTabState(2);
- },
- changeToRecommendTab() {
- this.setTabState(1);
- },
- changeToFriendTab() {
- this.setTabState(0);
- },
- setTabSelected(selected, button, tabBgs, listViewNode) {
- if (selected && button.node.zIndex === 0 || !selected && button.node.zIndex === 1) {
- button.getComponent(cc.Sprite).spriteFrame = selected ? tabBgs[1] : tabBgs[0];
- listViewNode.active = selected;
- button.node.zIndex = selected ? 1 : 0;
- button.node.y = selected ? this._selectedY : this._defaultY;
-
-
-
-
-
- }
- },
-
- });
|