| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 | 
							- /**
 
-  * 绑定邀请码信息
 
-  */
 
- import gameToast from "../Network/gameToast"
 
- cc.Class({
 
-     extends: cc.Component,
 
-     properties: {
 
-         neighborValue: {
 
-             default: null,
 
-             type: cc.Label
 
-         },
 
-         neighborConsumValue: {
 
-             default: null,
 
-             type: cc.Label
 
-         },
 
-         neighborDirectValue: {
 
-             default: null,
 
-             type: cc.Label
 
-         },
 
-         farmerValue: {
 
-             default: null,
 
-             type: cc.Label
 
-         },
 
-         farmerConsumValue: {
 
-             default: null,
 
-             type: cc.Label
 
-         },
 
-         myInviteValue: {
 
-             default: null,
 
-             type: cc.Label
 
-         },
 
-         parentInviteValue: {
 
-             default: null,
 
-             type: cc.Label
 
-         },
 
-         inputInviteValue: {
 
-             default: '',
 
-             visible: false
 
-         },
 
-         ToastParent: {
 
-             default: null,
 
-             type: cc.Node,
 
-             serializable: true
 
-         },
 
-         //输入节点
 
-         inputContainer:{
 
-             default:null,
 
-             type:cc.Node,
 
-             serializable:true
 
-         }
 
-     },
 
-     // LIFE-CYCLE CALLBACKS:
 
-     // onLoad () {},
 
-     start() {
 
-     },
 
-     onOpenInviteInfo() {
 
-         if (!GlobalD.dapp) {
 
-             console.error("InviteInfo start,dapp未初始化!");
 
-             return;
 
-         }
 
-         this.node.active = true;
 
-         this.myInviteValue.string = GlobalD.Dapp.UserInfo.invite_code;
 
-         if (GlobalD.Dapp.UserInfo.parent) {
 
-             this.parentInviteValue.string = GlobalD.Dapp.UserInfo.parent.invite_code;
 
-             //如果存在父节点,隐藏输入框
 
-             this.inputContainer.active = false;
 
-         }
 
-         // {
 
-         //     "children_count": 1, // 直推下级数量
 
-         //     "team_count": 1, // 伞下成员数量(包含直推数量)
 
-         //     "children_village_chief_count": 1, // 直推村长数量(镇长身份才需要展示)
 
-         //     "children_cnt_amount": 0, // 直推下级租赁土地消费CNT业绩数量
 
-         //     "team_cnt_amount": 0 // 伞下团队租赁土地消费CNT数量(含直推数量)
 
-         // }
 
-         // 获取镇长/村长团队信息(村长或镇长身份才需要)
 
-         // if (0 === GlobalD.Dapp.UserInfo.agent_level) {
 
-         //     console.log("村民不需要获取团队信息");
 
-         //     return;
 
-         // }
 
-         GlobalD.dapp.teamData().then((data) => {
 
-             // console.log("teamData:" + JSON.stringify(data));
 
-             if (data.err === null) {
 
-                 // 返回成功,见下面消息体
 
-                 this.neighborValue.string = data.res.children_count;
 
-                 this.neighborConsumValue.string = data.res.children_cnt_amount;
 
-                 this.neighborDirectValue.string = data.res.children_village_chief_count;
 
-                 this.farmerValue.string = data.res.team_count;
 
-                 this.farmerConsumValue.string = data.res.team_cnt_amount;
 
-             } else {
 
-                 //TODO 服务错误
 
-                 console.log(data.err)
 
-                 GlobalD.GameData.showToast(this.ToastParent, data.err, 3);
 
-             }
 
-         })
 
-     },
 
-     inputInvite(value, e) {
 
-         console.log(value);
 
-         this.inputInviteValue = value;
 
-     },
 
-     onBindInviteInfo() {
 
-         console.log('绑定的inputInviteValue:' + this.inputInviteValue);
 
-         if (!GlobalD.dapp) {
 
-             console.error("onBindInviteInfo warn,dapp未初始化!");
 
-             return;
 
-         }
 
-         let _self = this;
 
-         GlobalD.dapp.bindParent(_self.inputInviteValue).then((data) => {
 
-             if (data.err === null) {
 
-                 // 返回成功,见下面消息体
 
-                 console.log(data.res)
 
-                 //绑定成功时候,隐藏输入框,设置父节点
 
-                 GlobalD.Dapp.UserInfo.parent = data.res;
 
-                 _self.parentInviteValue.string = GlobalD.Dapp.UserInfo.parent.invite_code;
 
-                 //如果存在父节点,隐藏输入框
 
-                 _self.inputContainer.active = false;
 
-                 GlobalD.GameData.showToast(_self.ToastParent, "绑定成功!", 2);
 
-             } else {
 
-                 //TODO 服务错误
 
-                 console.log(data.err)
 
-                 GlobalD.GameData.showToast(_self.ToastParent, "绑定失败!", 2);
 
-             }
 
-         })
 
-     },
 
-     onClose() {
 
-         this.node.active = false;
 
-     },
 
-     webCopyString() {
 
-         console.log('复制');
 
-         var input = GlobalD.Dapp.UserInfo.invite_code + '';
 
-         const el = document.createElement('textarea');
 
-         el.value = input;
 
-         el.setAttribute('readonly', '');
 
-         el.style.contain = 'strict';
 
-         el.style.position = 'absolute';
 
-         el.style.left = '-9999px';
 
-         el.style.fontSize = '12pt'; // Prevent zooming on iOS
 
-         const selection = getSelection();
 
-         var originalRange = false;
 
-         if (selection.rangeCount > 0) {
 
-             originalRange = selection.getRangeAt(0);
 
-         }
 
-         document.body.appendChild(el);
 
-         el.select();
 
-         el.selectionStart = 0;
 
-         el.selectionEnd = input.length;
 
-         var success = false;
 
-         try {
 
-             success = document.execCommand('copy');
 
-         } catch (err) { }
 
-         document.body.removeChild(el);
 
-         if (originalRange) {
 
-             selection.removeAllRanges();
 
-             selection.addRange(originalRange);
 
-         }
 
-         return success;
 
-     },
 
-     // update (dt) {},
 
- });
 
 
  |