| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- cc.Class({
- extends: cc.Component,
- properties: {
- listItemAddress: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- otherUserItem: {
- default: null,
- serializable: false,
- visible: false
- },
- bLoadUserInfo: false
- },
- setInfo(context) {
- let { item } = context;
- this.otherUserItem = item;
- this.listItemAddress.string = item.address;
- },
- /**
- * 进入其他用户的农场偷菜
- */
- onEnterOtherFarm() {
- GlobalD.OtherUserInfo = this.otherUserItem;
- if (GlobalD.OtherUserInfo.length <= 0) {
- console.log('没有用户', GlobalD.OtherUserInfo);
- }
- if (this.bLoadUserInfo) return;
- this.bLoadUserInfo = true;
- GlobalD.GameData.getOtherUserLandList(GlobalD.OtherUserInfo.userId, () => {
- this.bLoadUserInfo = false;
- });
- let _dogContainerScript = cc.find("Canvas/DogContainer").getComponent("DogContainer")
- _dogContainerScript.onGetOtherUserList();
- //不同用户,切换背景
- if (GlobalD.dapp && GlobalD.OtherUserInfo.address) {
- GlobalD.dapp.userLevel(GlobalD.OtherUserInfo.address).then((data) => {
- console.log("场景身份信息:" + JSON.stringify(data));
- const { err, res } = data;
- if (err === null) {
- //成功设置状态,并且更新
- GlobalD.GameData.onSwitchAddressBg(res);
- } else {
- console.log(err) // 申请失败
- GlobalD.GameData.showToast(this.ToastParent, err, 3);
- }
- })
- }
- }
- });
|