VipItem CurrItem; // 当前选中商品项 protected override void Initialize() { Screen = GetControl <Dropdown>(this, "Screen"); Search = GetControl <InputField>(this, "Search"); List = Get(this, "List"); Item = NewElement <VipItem>(this, Get(List, "VipItem")); }
/// <summary> /// 会员项点击事件 /// </summary> /// <param name="item"></param> private void ClickFunc(VipItem item) { if (CurrItem != null) { CurrItem.SelectState(false); // 重复点击 if (CurrItem.data.Id == item.data.Id) { CurrItem = null; return; } } item.SelectState(true); CurrItem = item; // Log.Format("当前项:{0}", CurrItem.data.Name); }
/// <summary> /// 添加会员响应 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void AddData(Obj sender, Events.Vip.Add e) { if (!e.Result) { FireEvent(new Events.UI.OpenUI("CommonTips", e.Reason)); return; } VipItem new_item = Item.Clone <VipItem>(); new_item.RefreshData(e.NewVip); new_item.ClickFunc = ClickFunc; for (int i = 0; i < VipList.Count; i++) { if (i + 1 < VipList.Count && string.CompareOrdinal(VipList[i].data.Id, e.NewVip.Id) > 0) { new_item.transform.SetSiblingIndex(i + 1); VipList.Insert(i, new_item); break; } } }