stanley-king 8 tahun lalu
induk
melakukan
42afe8734d

+ 2 - 2
data/model/bonus_ranklist.model.php

@@ -13,7 +13,7 @@ class bonus_ranklistModel extends Model
     public function __construct() {
         parent::__construct('bonus_ranklist');
     }
-    public function getToplist($cond,$field = '*',$order = '') {
+    public function getRanklist($cond,$field = '*',$order = '') {
         return $this->field($field)->where($cond)->order($order)->limit(false)->select();
     }
 
@@ -25,4 +25,4 @@ class bonus_ranklistModel extends Model
     {
         return $this->where($cond)->update($data);
     }
-}
+}

TEMPAT SAMPAH
data/resource/mobile/bonus/imgaes/concern.png


TEMPAT SAMPAH
data/resource/mobile/bonus/imgaes/noconcern.png


+ 14 - 26
helper/model/ranklist.php

@@ -50,8 +50,8 @@ class ranklist
             }
         }
         elseif($num == 2) {
-            $this->member_id = func_get_arg(0);
-            $this->list_date = func_get_arg(1);
+            $this->member_id = intval(func_get_arg(0));
+            $this->list_date = intval(func_get_arg(1));
             $this->list_sn = ranklist_helper::make_sn($this->member_id,$this->list_date);
 
             $param = $this->mod_toplist->getByListSn($this->list_sn);
@@ -69,7 +69,7 @@ class ranklist
             if($this->update) {
                 $data = array();
                 $data['list_value'] = $this->list_value;
-                $data['supports'] = serialize($this->supports);
+                $data['supports'] = $this->supports;
                 $data['friends'] = serialize($this->friends);
                 $data['top_id'] = $this->top_id;
                 $data['top_money'] = $this->top_money;
@@ -82,7 +82,7 @@ class ranklist
                 $data['list_sn'] = $this->list_sn;
                 $data['member_id'] = $this->member_id;
                 $data['list_date'] = $this->list_date;
-                $data['supports'] = serialize($this->supports);
+                $data['supports'] = $this->supports;
                 $data['friends'] = serialize($this->friends);
                 $data['top_id'] = $this->top_id;
                 $data['top_money'] = $this->top_money;
@@ -158,33 +158,21 @@ class ranklist
     {
         return $this->supports();
     }
-    public function supports_count()
+
+    public function support()
     {
-        return count($this->supports);
+        $this->supports += 1;
+        $this->dirty = true;
     }
-    public function support($other_id)
-    {
-        if(algorithm_helper::bsearch($other_id,$this->supports) == -1) {
-            array_push($this->supports,$other_id);
-            sort($this->supports);
-            $this->dirty = true;
 
-            return true;
-        } else {
-            return false;
-        }
-    }
-    public function unsupport($other_id)
+    public function unsupport()
     {
-        $pos = algorithm_helper::bsearch($other_id,$this->supports);
-        if($pos == -1) {
-            return false;
-        } else {
-            array_splice($this->supports,$pos,1);
+        if($this->supports >= 1) {
+            $this->supports -= 1;
             $this->dirty = true;
-            return true;
         }
     }
+
     private function init($param)
     {
         if(!empty($param)) {
@@ -195,7 +183,7 @@ class ranklist
             $this->list_rank = intval($param['list_rank']);
             $this->top_id = intval($param['top_id']);
             $this->top_money = $param['top_money'];
-            $this->supports = empty($param['supports']) ? array() : unserialize(($param['supports']));
+            $this->supports = intval($param['supports']);
             $this->friends = empty($param['$friends']) ? array() : unserialize(($param['$friends']));
 
             $this->update = true;
@@ -204,7 +192,7 @@ class ranklist
             $this->list_rank = 0;
             $this->top_id = 0;
             $this->top_money = 0.00;
-            $this->supports = array();
+            $this->supports = 0;
             $this->friends = array();
 
             $this->update = false;

+ 22 - 3
helper/ranklist_helper.php

@@ -110,6 +110,25 @@ class ranklist_helper
         }
     }
 
+    public static function gen_ranklist($list_sn,&$err)
+    {
+        $rank = ranklist::create_by_sn($list_sn);
+        if($rank == false) {
+            $err = array(errcode::ErrParamter,'该排行榜不存在或者已经过期~');
+            return false;
+        }
+        $friends = $rank->get_friends();
+        $mod_rank = Model('bonus_ranklist');
+        $cond = array('list_date' => $rank->list_date(),'member_id' => array('in',$friends));
+        $items = $mod_rank->getRanklist($cond,'*','order by list_value desc');
+        if(!empty($items)) {
+            $top = ranklist::create_by_store($items[0]);
+            $rank->set_top($top->member_id(),$top->money());
+        }
+
+        return $items;
+    }
+
     public static function calc_top(ranklist &$top)
     {
         $member_id = $top->member_id();
@@ -134,7 +153,7 @@ class ranklist_helper
         }
 
         $mod_top = Model('bonus_ranklist');
-        $items = $mod_top->getToplist(array('member_id' => array('in',$friends),'list_date' => $list_date),'*','order by list_value desc');
+        $items = $mod_top->getRanklist(array('member_id' => array('in',$friends),'list_date' => $list_date),'*','order by list_value desc');
 
         if(empty($items)) {
             $top->set_top($member_id,$top->money());
@@ -166,7 +185,7 @@ class ranklist_helper
         }
     }
 
-    public static function top_list($member_id,$times)
+    public static function ranklists($member_id, $times)
     {
         $ret_list = array();
         foreach ($times as $val) {
@@ -174,7 +193,7 @@ class ranklist_helper
         }
 
         $mod_top = Model('bonus_ranklist');
-        $items = $mod_top->getToplist(array('member_id' => $member_id,'list_date' => array('in',$times)),'*','order by list_date desc');
+        $items = $mod_top->getRanklist(array('member_id' => $member_id,'list_date' => array('in',$times)),'*','order by list_date desc');
         foreach ($items as $item)
         {
             $top = ranklist::create_by_store($item);

+ 2 - 1
mobile/control/member_bonus.php

@@ -306,9 +306,10 @@ class member_bonusControl extends mbMemberControl
         array_push($mids,intval($_SESSION['member_id']));
 
         $top_infos = array();
-        $tops = ranklist_helper::top_list($_SESSION['member_id'],$times);
+        $tops = ranklist_helper::ranklists($_SESSION['member_id'],$times);
         foreach ($tops as $key => $top) {
             $item = array();
+            $item['list_sn'] = $top->list_sn();
             $item['list_rank']  = $top->get_rank() + 1;
             $item['list_value'] = $top->money();
             $item['list_date']  = $top->list_date();

+ 128 - 0
mobile/control/rank_list.php

@@ -0,0 +1,128 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 16/7/26
+ * Time: 上午11:00
+ */
+
+class rank_listControl extends mobileControl
+{
+    public function __construct() {
+        parent::__construct();
+    }
+
+    public function indexOp()
+    {
+        $list_sn = $_GET['list_sn'];
+        if(!isset($list_sn) || empty($list_sn)) {
+            return self::outerr(errcode::ErrParamter,'请输入排行榜序列号.');
+        }
+
+        $items = ranklist_helper::gen_ranklist($list_sn,$err);
+        if($items == false) {
+            return self::outerr($err['code'],$err['msg']);
+        }
+
+        $mids = array();
+        $list_infos = array();
+        $rank_num = 1;
+        $mine = null;
+        foreach ($items as $item) {
+            $rank = ranklist::create_by_store($item);
+
+            $item = array();
+            $item['supported'] = $this->supported($rank->list_sn());
+            $item['list_sn'] = $rank->list_sn();
+            $item['supports'] = $rank->supports();
+            $item['list_value'] = $rank->money();
+            $item['member_id'] = $rank->member_id();
+            $item['rank'] = $rank_num;
+            array_push($list_infos,$item);
+            array_push($mids,$rank->member_id());
+            if($_SESSION['member_id'] == $rank->member_id()) {
+                $mine = $item;
+            }
+            ++$rank_num;
+        }
+
+        $mem_desc = array();
+        $members = Model('member')->getMemberList(array('member_id' => array('in',$mids)));
+        foreach ($members as $val) {
+            $info = new member_info($val);
+            array_push($mem_desc,$info->filter());
+        }
+
+        return self::outsuccess(array('mine' => $mine,'list_infos' => $list_infos,'mem_desc' => $mem_desc),"bonus/ranklist");
+    }
+
+    public function supportOp()
+    {
+        $list_sn = $_GET['list_sn'];
+        if(!isset($list_sn) || empty($list_sn)) {
+            return self::outerr(errcode::ErrParamter,'请输入排行榜序列号.');
+        }
+
+        $rank = ranklist::create_by_sn($list_sn);
+        if($rank == false) {
+            return self::outerr(errcode::ErrParamter,'该排行榜不存在或者已经过期~');
+        }
+
+        if($this->supported($list_sn)) {
+            $rank->unsupport();
+            $_SESSION['rank_list'][$list_sn]['supported'] = false;
+        } else {
+            $rank->support();
+            $_SESSION['rank_list'][$list_sn]['supported'] = true;
+        }
+
+        return self::outsuccess(array('supports' => $rank->supports(),'list_sn' => $rank->list_sn()));
+    }
+
+    private function supported($list_sn)
+    {
+        if(!isset($_SESSION['rank_list'])) {
+            $_SESSION['rank_list'] = array();
+        }
+
+        if(array_key_exists($list_sn,$_SESSION['rank_list'])) {
+            $_SESSION['rank_list'][$list_sn] = array();
+            $_SESSION['rank_list'][$list_sn]['supported'] = false;
+        }
+
+        return boolval($_SESSION['rank_list'][$list_sn]['supported']);
+    }
+}
+
+function bonus_output_meminfo($mid,$mdescs)
+{
+    foreach ($mdescs as $info) {
+        if($info['member_id'] == $mid) {
+            return $info;
+        }
+    }
+
+    return false;
+}
+
+function bonus_output_rankitem($item,$mdescs)
+{
+    $mid = $item['member_id'];
+    $minfo = bonus_output_meminfo($mid,$mdescs);
+
+    echo '<div class="list_li overflow">';
+    echo    '<div class="index float_l w-8">' .$item['rank']. '</div>';
+    echo    '<div class="icon_header float_l w-12 margin-r-1">';
+    echo        '<img src="' . $minfo['avatar'] .'" alt=""/>';
+    echo    '</div>';
+    echo    '<div class="msg float_l w-80 relative_li">';
+    echo        '<div class="name text_l w-45 float_l overflow">' . $minfo['nickname'] . '</div>';
+    echo        '<div class="number text_r w-35 float_l">' . $item['list_value'] .'元</div>';
+    echo        '<div class="float_l w-20 concern_box">';
+    echo            '<div class="concern">' . $item['supports'] .'</div>';
+    echo            '<input type="hidden" class="list_sn" value="' . $item['list_sn'] .'"/>';
+    echo         '</div>';
+    echo     '</div>';
+    echo '</div>';
+}

+ 173 - 0
mobile/templates/default/bonus/ranklist.php

@@ -0,0 +1,173 @@
+<!doctype html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
+    <title>红包风云榜</title>
+    <style type="text/css">
+        html,
+        body,
+        span,
+        img {
+            margin: 0;
+            padding: 0;
+        }
+        html {
+            background: #fff;
+            font-size: 12px;
+            color: #454545;
+            font-family: "Roboto" ,sans-serif;
+        }
+        img {
+            width: 2.9rem;
+            border: none;
+            vertical-align: middle;
+        }
+        .maincontent {
+            width: 100%;
+            height: 100%;
+        }
+        .relative_li {
+            position: relative;
+        }
+        .relative_li:after {
+            content: '';
+            display: block;
+            position: absolute;
+            width: 93%;
+            left: 0;
+            bottom: 0;
+            height: 1px;
+            background-color: #EBEBEB;
+            -webkit-transform: scaleY(0.5);
+            transform: scaleY(0.5);
+        }
+        .first {
+            color: #FF4E4E;
+        }
+        .list_ul {
+            font-size: 1.17rem;
+        }
+        .list_ul .list_li,.msg {
+            line-height: 58px;
+        }
+        .float_l {
+            float: left;
+        }
+        .float_r {
+            float: right;
+        }
+        .text_c {
+            text-align: center;
+        }
+        .text_l {
+            text-align: left;
+        }
+        .text_r {
+            text-align: right;
+        }
+        .overflow {
+            overflow: hidden;
+        }
+        .w-8 {
+            width: 8%;
+        }
+        .w-12 {
+            width: 12%;
+        }
+        .w-80 {
+            width: 79%;
+        }
+        .w-45 {
+            width: 45%;
+            height: 58px;
+        }
+        .w-35 {
+            width: 35%;
+        }
+        .w-20 {
+            width: 20%;
+        }
+        .concern_box {
+            background: url("<?php echo RESOURCE_SITE_URL; ?>/mobile/bonus/images/noconcern.png") no-repeat center 85%;
+            background-size: 0.96rem 0.81rem;
+            font-size: 1rem;
+            height: 58px;
+            position: relative;
+            bottom: 8px;
+        }
+        .concern_box_active {
+            background: url("<?php echo RESOURCE_SITE_URL; ?>/mobile/bonus/images/concern.png") no-repeat center 85%;
+            background-size: 0.96rem 0.81rem;
+        }
+        .margin-r-1 {
+            margin-right: 1%;
+        }
+        .br {
+            height: 10px;
+            background: #EBEBEB;
+        }
+    </style>
+</head>
+<body>
+<div class="maincontent">
+    <div class="content">
+        <div class="list_ul text_c">
+            <?php bonus_output_rankitem($output['mine'],$output['mem_desc']); ?>
+        </div>
+
+        <div class="br"></div>
+        <div class="list_ul text_c">
+            <?php
+                $mem_desc = $output['mem_desc'];
+                $list_infos = $output['list_infos'];
+                foreach ($list_infos as $info) {
+                    bonus_output_rankitem($info,$mem_desc);
+                }
+            ?>
+        </div>
+    </div>
+</div>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/bonus/js/zepto.min.js"></script>
+<script type="text/javascript">
+    $(function(){
+        var concern={
+            number:function(id){
+                var that=this;
+                $(id).on('touchstart',function(){
+                    var number=parseInt($(this).text()),
+                        datas=$(this).find('.list_sn').val();
+                    if($(this).hasClass('concern_box_active')){
+                        $(this).removeClass('concern_box_active');
+                        var num=number-1;
+                        $(this).text(num);
+                        that.ajax(datas);
+                    }
+                    else {
+                        $(this).addClass('concern_box_active');
+                        var num=number+1;
+                        $(this).text(num);
+                        that.ajax(datas);
+                    }
+                })
+            },
+            ajax:function(data){
+                var that=this;
+                $.ajax({
+                    url:'http://a.lrlz.com/mobile/index.php?act=rank_list&op=support&client_type=wap',
+                    dataType:'jsonp',
+                    jsonp:'callback',
+                    data:{
+                        list_sn:data
+                    },
+                    success:function(){
+                        return false;
+                    }
+                })
+            }
+        };
+        concern.number('.concern_box');
+    })
+</script>
+</body>
+</html>