123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- const Api = require('../net/Api');
- var FriendApi = require('../net/FriendSystemApi');
- var DWTool = require('../utils/DWTool');
- cc.Class({
- extends: cc.Component,
- properties: {
- bgSprite: cc.Sprite,
- headSprite: cc.Sprite,
- nickLabel: cc.Label,
- starCountLabel: cc.Label,
- genderIcon: cc.Sprite,
- commonFriend1: cc.Node,
- commonFriend2: cc.Node,
- commonFriend3: cc.Node,
- commonFriendLabel: cc.Label,
- addFriendButton: cc.Button,
- addFriendLabel: cc.Label,
- _friendList: null,
- _itemId: 0,
- femaleFrame: cc.SpriteFrame,
- maleFrame: cc.SpriteFrame,
- },
-
- onLoad() {
- },
- setFriendList(friendList) {
- this._friendList = friendList;
- },
- setListViewAdapter(listViewAdapter) {
- this._listViewAdapter = listViewAdapter;
- },
-
- updateItem(userInfo, itemId) {
- this._itemId = itemId;
- this.user = userInfo;
- this.genderIcon.spriteFrame = userInfo.gender == 1 ? this.maleFrame : this.femaleFrame;
- this.nickLabel.string = userInfo.nick;
- this.starCountLabel.string = userInfo.stars;
- Api.createImageFromUrl(userInfo.head, (spriteFrame) => {
- this.headSprite.spriteFrame = spriteFrame;
- }, (err) => {
- this.headSprite.spriteFrame = null;
- });
-
-
-
-
- if (userInfo.commons != undefined && userInfo.commons != null && userInfo.commons.length > 0) {
- this.commonFriendLabel.string = '...' + userInfo.commons.length + '个共同好友';
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- },
- start() {
- },
- deleteItem() {
- FriendApi.processApply(this.user.uid, -1);
- this._listViewAdapter.removeItem(this);
- },
- friendApply() {
- if (this.user.sendedApply === undefined) {
- this.user.sendedApply = true;
- FriendApi.friendApply(this.user.uid, () => {
- this.addFriendButton.interactable = false;
- this.addFriendLabel.string = '已发送';
- });
- }
- },
-
- });
|