|
@@ -7,38 +7,81 @@ use Dever;
|
|
|
class Children
|
|
|
{
|
|
|
public function text(){
|
|
|
- echo "<font style='color: yellow'>12312323</font>";
|
|
|
+ $cur = Dever::input('mid');
|
|
|
+
|
|
|
+ $invite = Dever::load('invite/api')->getChild($cur);
|
|
|
+
|
|
|
+ $result = array();
|
|
|
+ $data = array();
|
|
|
+ $index = array();
|
|
|
+ $count = count($invite) - 1;
|
|
|
+ $i=0;
|
|
|
+ foreach($invite as $k => $v) {
|
|
|
+
|
|
|
+ }
|
|
|
+ print_R($result);die;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
- public function home($mid){
|
|
|
- $invite = Dever::load('invite/api')->getParentAll($mid);
|
|
|
+ public function home(){
|
|
|
+ $cur = Dever::input('mid');
|
|
|
+ $invite = Dever::load('invite/api')->getParentAll($cur, 5);
|
|
|
+
|
|
|
+ $result = array();
|
|
|
+ $data = array();
|
|
|
if($invite){
|
|
|
- foreach($invite as $k => $v){
|
|
|
- if($v['level'] == 5){
|
|
|
- $info = $this->index($v['uid']);
|
|
|
- }else{
|
|
|
- if($v['level'] == 4){
|
|
|
- $info = $this->index($v['uid']);
|
|
|
- }else{
|
|
|
- if($v['level'] == 3){
|
|
|
- $info = $this->index($v['uid']);
|
|
|
- }else{
|
|
|
- if($v['level'] == 2){
|
|
|
- $info = $this->index($v['uid']);
|
|
|
- }else{
|
|
|
- if($v['level'] == 1){
|
|
|
- $info = $this->index($v['uid']);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ $index = array();
|
|
|
+ $count = count($invite) - 1;
|
|
|
+ foreach($invite as $k => $v) {
|
|
|
+
|
|
|
+ $uid = $v['uid'];
|
|
|
+ $v = $this->button($v['uid'], $v['uid']);
|
|
|
+ if ($count == $k) {
|
|
|
+
|
|
|
+ }
|
|
|
+ if ($k == 0) {
|
|
|
+ $result = $v;
|
|
|
+ list($result['children'], $index[$k]) = $this->child($uid, $invite[$k+1]['uid']);
|
|
|
+ }
|
|
|
+ if ($k == 1) {
|
|
|
+ list($result['children'][$index[$k-1]]['children'], $index[$k]) = $this->child($uid, $invite[$k+1]['uid']);
|
|
|
+ }
|
|
|
+ if ($k == 2) {
|
|
|
+ list($result['children'][$index[$k-2]]['children'][$index[$k-1]]['children'], $index[$k]) = $this->child($uid, $invite[$k+1]['uid']);
|
|
|
+ }
|
|
|
+ if ($k == 3) {
|
|
|
+ list($result['children'][$index[$k-3]]['children'][$index[$k-2]]['children'][$index[$k-1]]['children'], $index[$k]) = $this->child($uid, $invite[$k+1]['uid']);
|
|
|
+ }
|
|
|
+ if ($k == 4) {
|
|
|
+ list($result['children'][$index[$k-4]]['children'][$index[$k-3]]['children'][$index[$k-2]]['children'][$index[$k-1]]['children'], $index[$k]) = $this->child($uid, $cur);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
- }else{
|
|
|
- $info = $this->index($mid);
|
|
|
+
|
|
|
}
|
|
|
- exit(Dever::json_encode($info));
|
|
|
+ exit(Dever::json_encode($result));
|
|
|
+ }
|
|
|
+ public function child($parent, $cur = false) {
|
|
|
+ $result = array();
|
|
|
+ $index = 0;
|
|
|
+ $child = Dever::load('invite/api')->getChild($parent, 1, false);
|
|
|
+
|
|
|
+ $num = count($child) / 2;
|
|
|
+ foreach ($child as $k => $v) {
|
|
|
+ $result[] = $this->button($v['to_uid'], $cur);
|
|
|
+ if ($v['to_uid'] == $cur) {
|
|
|
+ $index = $k;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($cur) {
|
|
|
+ $old = $result;
|
|
|
+ $result[$index] = $result[$num];
|
|
|
+ $result[$num] = $old[$index];
|
|
|
+ $index = $num;
|
|
|
+ }
|
|
|
+
|
|
|
+ return array($result, $index);
|
|
|
}
|
|
|
|
|
|
public function index($mid){
|
|
@@ -46,17 +89,18 @@ class Children
|
|
|
|
|
|
|
|
|
$invite = $this->invite($mid);
|
|
|
+
|
|
|
if($invite){
|
|
|
foreach($invite as $k =>$v){
|
|
|
$member = $this->button($mid);
|
|
|
- if($mid == $uid){
|
|
|
- $info['name'] = $member['value'];
|
|
|
- $info['itemStyle']['color'] = 'blue';
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- }else{
|
|
|
- $info['name'] = $member['value'];
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
$m1 = $this->button($v['to_uid']);
|
|
|
if($v['to_uid']==$uid){
|
|
@@ -129,7 +173,7 @@ class Children
|
|
|
$info['children'][$k]['children'][$k1]['children'][$k2]['children'][$k3]['children'][$k4]['children'][$k5]['children'][$k6]['name'] = $m7['value'];
|
|
|
$info['children'][$k]['children'][$k1]['children'][$k2]['children'][$k3]['children'][$k4]['children'][$k5]['children'][$k6]['itemStyle']['color'] = 'blue';
|
|
|
}else{
|
|
|
-
|
|
|
+ $info['children'][$k]['children'][$k1]['children'][$k2]['children'][$k3]['children'][$k4]['children'][$k5]['children'][$k6]['name'] = $m7['value'];
|
|
|
}
|
|
|
|
|
|
|
|
@@ -188,31 +232,44 @@ class Children
|
|
|
|
|
|
|
|
|
exit(Dever::json_encode($info));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
public function invite($mid){
|
|
|
- $invite = Dever::load('invite/api')->getChild($mid,$level_id = 1);
|
|
|
+ $invite = Dever::load('invite/api')->getChild($mid,$level_id = 1, false);
|
|
|
|
|
|
return $invite;
|
|
|
}
|
|
|
|
|
|
- public function button($mid){
|
|
|
+ public function button($mid, $cur = false, $color = 2){
|
|
|
$child = Dever::db('agent/member')->find($mid);
|
|
|
$role = Dever::db('setting/role')->find($child['role']);
|
|
|
- $child['value'] = $child['name']."\r\n".$child['mobile']."\r\n".$role['name'];
|
|
|
+ $result = array();
|
|
|
+ $result['mid'] = $mid;
|
|
|
+ $result['name'] = $child['name'];
|
|
|
+ $result['value'] = $child['name']."\r\n".$child['mobile']."\r\n".$role['name'];
|
|
|
if (isset($child['level_id']) && $child['level_id'] && $child['level_id'] > 0) {
|
|
|
$level = Dever::db('setting/level')->find($child['level_id']);
|
|
|
- $child['value'].= '('.$level['name'].')';
|
|
|
+ $result['value'].= '('.$level['name'].')';
|
|
|
}
|
|
|
if(isset($child['source_id']) && $child['source_id'] && $child['source_id']>0){
|
|
|
$source=Dever::db('setting/source')->one(array('id'=>$child['source_id'],'state'=>1));
|
|
|
if($source){
|
|
|
- $child['value'] .= "\r\n".$source['name'];
|
|
|
+ $result['value'] .= "\r\n".$source['name'];
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if ($cur && $mid == $cur) {
|
|
|
+ if ($color == 1) {
|
|
|
+ $result['itemStyle']['color'] = 'green';
|
|
|
+ } else {
|
|
|
+ $result['itemStyle']['color'] = 'blue';
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- return $child;
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
}
|