欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

收藏功能

程序员文章站 2022-07-02 16:10:41
...

收藏功能
用户项目关联表
收藏功能
项目表collect字段表示收藏次数
首页mobile/index.html

<!DOCTYPE html>
<html lang="zh-cmn-Hans">
  <head>
    <meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
<link rel="stylesheet" href="/public/static/index/assets/css/zpui.css"/>
<link rel="stylesheet" href="/public/static/index/assets/css/all.css"/>
<script src="/public/static/index/assets/js/page.js"></script>
<script src="/public/layer/layer_mobile/jquery-1.11.3.min.js"></script>
<script  src="/public/layer/layer_mobile/layer.js"></script>

      <title>花儿工匠</title>
      <style>

          /*.fanzhi{*/
              /*background: #02b294 !important;*/
          /*}*/
          .gotolog{
              margin: 10px auto;
              display: block;
              background: #22e484;
              border: 0px;
              padding: 0 10px;
              color: #fff;
              border-radius: 3px;
              position: relative;
              height: 36px;
              line-height: 36px;
              min-width: 60px;
              width: 30%;
              font-size: 12px;
          }
              /* 隐藏顶部浮动栏选项  */
        body { position: static !important; top:0px !important; }
        iframe.goog-te-banner-frame { display: none !important; }
        .goog-logo-link { display:none !important; }
        .goog-te-gadget { color: transparent !important; overflow: hidden;}
        .goog-te-balloon-frame{display: none !important;}

        /*使原始文本弹出窗口隐藏*/
        .goog-tooltip {display: none !important;}
        .goog-tooltip:hover {display: none !important;}
        .goog-text-highlight {background-color: transparent !important; border: none !important; box-shadow: none !important;}

        /* 语言选择框颜色 */
        .goog-te-combo {background-color:#848CB5; border-radius:8px;}
        .imgIndex{
        	padding: 0rem 0.15rem;
        	margin-top:0.15rem;
        }
        .imgIndex img{
			width: 100%;
			height: auto;
			border-radius: 0.15rem;
		}

		 .goods-main {
            display: table;
            width: 100%;
        }

        .goods-item:nth-child(odd) {
            padding-right: 5px;
        }

         .goods-item {
            display: table-cell;
            width: 45%;
            height: auto;
            margin-bottom: 15px;
            margin-left: 10px;
            float: left;
        }

        .goods-item-body {
            border-radius: 10px;
            overflow: hidden;
            background: url(/public/images/item.png);
            background-size: 100% 100%;
        }

        .goods-item ul li.li-title {
            width: 100%;
            margin-bottom: 5px;
            text-align: center;
            font-weight: 900;
            color: #f0ad00;
        }

        .goods-item ul li {
            display: table;
            line-height: 20px;
            font-size: 12px;
        }

        .item-btn {
            width: 100%;
            height: auto;
            padding: 15px 0;
            text-align: center;
        }

         .item-btn button{
         font-size: 15px;
         background: #00A1AF !important;
         color:white;

         }

        li span {
         color:white;
        }

       li strong {
                color:white;
               }

      </style>
  </head>
  <body>
  <div id="wrap" style="z-index: 1000000;
    position: fixed ! important;
    right: 0px;
    top: 10px;">
    <!-- 谷歌语言 -->
    <div id="google_translate_element"></div>
   </div>
    <div class="page index">
      <div class="page-bd">
        <!-- 页面内容 -->
        <div class="top fs34 fw_b" style="color: #fff;text-align: center;background-color:#182121;height:0.5rem;line-height:0.5rem;padding:0.1rem 0.15rem">花儿工匠</div>
        <!--<div class="imgBox"><img src="/public/static/index/assets/images/name.png" alt="" /></div> -->
        <div class="imgIndex"><img src="{$config.banner_img}" alt="" /></div>

        <div class="goods-main">
        {volist name="piglist" id="pig"}
            <div class="goods-item" id="pig_level_{$pig.id}">
                <div class="goods-item-body" >
                     <div class="pigimg">
                         <img id='img' src="{$pig.img}" alt="" style="width: 100%;height: 150px;" />
                     </div>
                     <ul>
                        <li class="li-title" style="font-size: 12px">
                            {$pig.name}
                        </li>
                        <li>
                               <span class="label">价值</span>
                               <strong style="margin-left: 8px;">{$pig.min_price}-{$pig.max_price}</strong>
                        </li>
                        <li>
                            <span class="label">领养时间:</span>
                            <strong style="margin-left: 8px;">{$pig.start_time}-{$pig.end_time}</strong>
                        </li>
                        <li>
                            <span class="label">预约/领养 金币:</span>
                             <strong style="margin-left: 8px;">{$pig.pay_points}/{$pig.qiang_points}</strong>
                         </li>
                         <li>
                             <span class="label">智能合约收益:</span>
                             <strong style="margin-left: 8px;">{$pig.cycle}{$pig.time}/{$pig.contract_revenue}%</strong>
                          </li>
                          <li>
                             <span class="label">是否收藏:</span>

                              <strong style="margin-left: 8px;">
                              {if condition="$pig.is_c eq 1"}
                                 <img src="/public/images/2.jpg" alt="" style="width: 20%;height: 20px;" class="collect" data-img="{$pig.id}">
                                 {else/}
                                 <img src="/public/images/1.jpg" alt="" style="width: 20%;height: 20px;" class="collect" data-img="{$pig.id}">
                              {/if}
                              <span class="label">{$pig.collect}</span>人已收藏

                              </strong>
                                                    </li>
                    </ul>
                    <div class="item-btn">
                    <div  class="item-btn">
                                    {switch name="pig.game_status"}
                                      {case value="0"} <div class="button fs28 fw_b buttoning level_btn fanzhi"><button>繁殖中</button></div>{/case}
                                    {case value="1"} <div class="button fs28 fw_b buttoned" data-id="{$pig.id}"><button>预约</button></div>{/case}
                                    {case value="2"} <div class="button fs28 fw_b buttoning"><button>已预约</button></div>{/case}
                                    {case value="4"} <div class="button fs28 fw_b buttoning level_btn kaijiang" data-id="{$pig.id}"><button>开抢领养</button></div>{/case}
                                    {/switch}
                                  </div>
                    </div>
                    </div>
                </div>
                 {/volist}
            </div>

            <div class="model">
                       <div class="modelBG"></div>
                       <div class="Box succeed" style="text-align: center;">
                           <img src="/public/static/index/assets/images/succeedPig.png" alt="">
                           <span class="fs36 fw_b">恭喜您<br>领养成功!</span>
                           <span class="fs36 fw_b"><a href="/index/User/adopt_log"  class="gotolog">前往领养记录</a></span>
                           <div class="closeBox" style="margin-top: 10%;" onClick="closeBox()"><img src="/public/static/index/assets/images/closeIcon.png" alt=""></div>
                       </div>
                       <div class="Box fail" style="text-align: center;">
                           <img src="/public/static/index/assets/images/failPig.png" alt="" style="text-align: center">
                           <span class="fs36 fw_b">好伤心<br>沒抢到花儿</span>
                           <!--<span class="fs36 fw_b"><a href="/dist/pages/adopt_log.html"  class="gotolog">前往领养记录</a></span>-->
                           <div class="closeBox" style="margin-top: 10%;" onClick="closeBox()"><img src="/public/static/index/assets/images/closeIcon.png" alt=""></div>
                       </div>
                       <div class="Box loading">
                           <div class="loadBox"><div></div><div></div><div></div><div></div><div></div></div>
                           <span class="fs36 fw_b">领养中<br>请不要关闭</span>
                       </div>
                   </div>

		 <div class="model3" id="model">
            <div class="modelBG3"></div>
            <div class="Box3 loading">
                <div class="loadBox3"><div></div><div></div><div></div><div></div><div></div></div>
            </div>
        </div>
      </div>
      <div class="bottom-tabbar-wrapper">
  <div class="bottom-tabbar">
    <a href="index.html" class="bottom-tabbar__item active">
        <span class="icon">
            <img src="/public/static/index/assets/images/bottom_icon01.png"/>
            <img class="lhimg" src="/public/static/index/assets/images/bottom_icon01_lh.png"/>
        </span>
      <p class="label">花儿工匠</p>
    </a>
    <a href="{:url('service/index')}" class="bottom-tabbar__item ">
      <span class="icon">
          <img src="/public/static/index/assets/images/bottom_icon02.png"/>
          <img class="lhimg" src="/public/static/index/assets/images/bottom_icon02_lh.png"/>
      </span>
    <p class="label">服务中心</p>
    </a>
    <a href="{:url('user/index')}" class="bottom-tabbar__item ">
        <span class="icon">
            <img src="/public/static/index/assets/images/bottom_icon03.png"/>
            <img class="lhimg" src="/public/static/index/assets/images/bottom_icon03_lh.png"/>
        </span>
      <p class="label">花儿世界</p>
    </a>
  </div>
</div>
<audio src="/public/static/index/assets/audio/9888.wav" id="error"></audio>
<audio src="/public/static/index/assets/audio/10762.wav" id="success"></audio>
    </div>
    <!-- 游戏模块s -->
    <input name="game_time" type="hidden" value="">
    <input name="game_id" type="hidden" value="">
    <input name="game_openaward" type="hidden" value="1000">
    <input name="game_stage" type="hidden" value="">

    <!-- 游戏模块e -->
<script src="/public/static/index/assets/js/lib/jquery-2.1.4.js"></script>
<script src="/public/static/index/assets/js/jquery-weui.min.js"></script>
<script src="/public/static/index/assets/js/lib/fastclick.js"></script>
<script src="/public/static/index/assets/js/layer.js"></script>
<script src="/public/static/index/assets/js/ajaxplugin.js"></script>
<script>
    $(function() {
        FastClick.attach(document.body);
    });
</script>
    <script>

    {if condition="$list neq null"}
var user=getCookie("number");
if(user == ''){
	document.cookie="number=1";
 
    	 var contents ='{$list.content|htmlspecialchars_decode}';
    layer.open({
    content: contents
    ,btn: '我知道了'
  });
  
}
    {/if}
    function getCookie(cname){
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++) {
        var c = ca[i].trim();
        if (c.indexOf(name)==0) { return c.substring(name.length,c.length); }
    }
    return "";
}
      function checkGame(){
        var success = document.getElementById('success');
        var error = document.getElementById('error');
        local_ajax('/index/Index/checkGame',{},'get',function(data){
            var now = Math.floor(Date.now() / 1000);
            var time = data.data.start_time - now;
           	if( time <= 60 && time>= 0){
           		$('#pig_level_'+ data.data.id +' .btns').html('<div class="button fs28 fw_b buttoning level_btn fanzhi">'+time+'</div>');
           	}

            if(data.data.start_time < now && data.data.end_time > now){
				$.get('/index/Index/yuyueStatus',{id:data.data.id},function (res) {
                    console.log(data.data.id);
                    if (res.code==1) {

                        $.post('/index/Index/checkOpen',{id:data.data.id}).then(function(res){
                            if(res.code == 1){
                              $('#img').attr("src", res.url);
   
                                $('#pig_level_'+ data.data.id +' .btns').html('<div class="button fs28 fw_b buttoning level_btn kaijiang" data-id="'+data.data.id+'" οnclick="clickBuy('+data.data.id+')">开抢领养</div>')
                                clearInterval(timer);
                    
                                //window.reload();
                            }else if(res.code == 2){
                              $('#img').attr("src", res.url);
                  
                                $('#pig_level_'+ data.data.id +' .btns').html('<div class="button fs28 fw_b buttoning level_btn kaijiang" data-id="'+data.data.id+'"οnclick="clickBuy('+data.data.id+')">开抢领养</div>')
                                clearInterval(timer);
                           
                                //window.reload();
                            }else if(res.code == 0){
                              $('#img').attr("src", res.url);
                  
                                $('#pig_level_'+ data.data.id +' .btns').html('<div class="button fs28 fw_b buttoning level_btn fanzhi">繁殖中</div>');
                            }else{
                                 $('.model').hide()
                            }
                        })
                    } else {
                        //$('#pig_level_'+ data.data.id +' .btns').html('<div class="button fs28 fw_b buttoning level_btn kaijiang" data-id="'+data.data.id+'" οnclick="clickBuy('+data.data.id+')">開搶领养</div>')
                    }
                })

				
            }else if(data.data.end_time < now ){
            	
               $.get('/index/Index/yuyueStatus',{id:data.data.id},function (res) {
					if(res.code==0){
            $('#img').attr("src", res.url);
						$('#pig_level_'+ data.data.id +' .btns').html('<div class="button fs28 fw_b buttoning level_btn fanzhi">繁殖中</div>');
					}else{
						$('#pig_level_'+ data.data.id +' .btns').html('<div class="button fs28 fw_b buttoning">已预约</div>')  
						
					}
				}) 
            }
        })
    };
    $(function(){
    
         var __gameTimeController = 0 ;      //游戏定时器
         var __gameTimeAward = 0 ; //开奖过程时间
          window.isyuyue = {};
    
         var url = '/api/nologin/pig_goods';
         var type = 'get';
    
         already_yuyue(); //初始化预约列表
           a_load(url,{},type,function(data){
    
               //console.log(JSON.parse(data));
               var str = html ='';
               var eachcount=0;
    
               $.each(JSON.parse(data), function(i, obj) {
    
                 //如果是开奖了,那么全部变成繁殖中
                if(obj.is_open == 1){
                     obj.game_level = 3;
                 }
                // str += '<div class="box" id="pig_level_'+obj.id+'">';
                // str += '<div class="pigimg">';
                // str += '<img src="/uploads/images/'+obj.images+'" alt="" />';
               //  str += '<span class="fs34 fw_b">'+obj.goods_name+'</span>';
                // str += '</div>';
               //  str += '<div class="info fs22" >';
                // str += '<div>价值:<span>'+obj.small_price+'-'+obj.large_price+'</span></div>';
               //  str += '<div>领养时间:<span>'+obj.start_time+'-'+obj.end_time+'</span></div>';
             // str += '<div>预约/即抢领养花粪:<span>'+obj.reservation+'/'+obj.adoptive_energy+'</span></div>';
                // str += '<div>智能合约收益:<span>'+obj.contract_days+'天/'+obj.income_ratio+'%</span></div>';
              //   str += '<div>可挖DSC:<span>'+obj.pig_currency+'枚</span></div>';
              //   str += '<div>可挖DOGG:<span>'+obj.doge_money+'%</span></div>';
              //   str += '</div>';
               //  str += '<div class="game_btn">'
               //  str +=  btn_style(obj.game_level,obj.id);
               //  str += '</div></div>';
    
               /*  str += '<div class="box" id="pig_level_'+obj.id+'">';
                 str += '<div class="pigimg">';
                 str += '<img src="/uploads/images/'+obj.images+'" alt="" />';
                 str += '<span class="fs34 fw_b">'+obj.goods_name+'</span>';
                 str += '</div>';
                 str += '<div class="info fs22" >';
                 str += '<div>价值:'+obj.small_price+'-'+obj.large_price+'</div>';
                 str += '<div>领养时间:'+obj.start_time+'-'+obj.end_time+'</div>';
                 str += '<div>预约/即抢领养花粪:'+obj.reservation+'/'+obj.adoptive_energy+'</div>';
                 str += '<div>智能合约收益:'+obj.contract_days+'天/'+obj.income_ratio+'%</div>';
                 str += '<div>可挖PIG:'+obj.pig_currency+'枚</div>';
                 str += '<div>可挖DOGG:'+obj.doge_money+'%</div>';
                 str += '</div>';
                 str += '<div class="game_btn">'
                 str +=  btn_style(obj.game_level,obj.id);
                 str += '</div></div>';*/
               });
               $(".piglist").append(str);
               //防止加载不到
               setTimeout("checkGame()",1000);
    
           });
    
    
        //每隔5S校验游戏
   

        //按钮样式
        function btn_style(n,id){
            var html ;
            switch(n){
                case 1:
                case 2:
                    html = stage1(id);
                    break;
                case 3:
                case 4:
                    html = '<div class="button fs28 fw_b buttoning level_btn fanzhi">繁殖中</div>';break;
            }
            return html;
        };

        //第一阶段判断是待领养还是预约
        function stage1(id){

            var html,controller =false;

            for(var i = 0; i < isyuyue.length; i++){
               // console.log(isyuyue[i])
                if(id == isyuyue[i]){
                    controller = true;
                    break;
                }
            }

            if(controller){
                html = '<div class="button fs28 fw_b buttoning level_btn">待领养</div>';
            }else{
                html = '<div class="button fs28 fw_b buttoned level_btn" οnclick="yuyue('+id+')">预约</div>';
            }
            return html;
        };
        //获取所有已经预约的游戏--json格式
         function already_yuyue(){
               var isyuyue = {};
             __oajax('/api/Game/isYuyueData',{},type,function(data){
                // console.log(data.data,1111111);
                 window.isyuyue = data.data;
             });
         };

    //第一阶段判断是待领养还是预约
    function stage1(id){

        var html,controller =false;
        for(var i = 0; i < isyuyue.length; i++){
           // console.log(isyuyue[i])
            if(id == isyuyue[i]){
                controller = true;
                break;
            }
        }

       // console.log(id,controller,'123');
        if(controller){
            html = '<div class="button fs28 fw_b buttoning level_btn">待领养</div>';
        }else{
            html = '<div class="button fs28 fw_b buttoned level_btn" οnclick="yuyue('+id+')">预约</div>';
        }
        return html;
    };
    //获取所有已经预约的游戏--json格式
    function already_yuyue(){
        __oajax('/api/Game/isYuyueData',{},'get',function(data){
            window.isyuyue = data.data;
        });
    };
    
    

    //阶段处理
    //点击抢购
     $(document).on('click','.kaijiang',function(){
         var id =  $(this).data('id');
        $('.model').show();
        //2019-3-12-----------
        $('.succeed').hide();
        $('.fail').hide();
        //2019-3-12-----------
         $.get('/index/Index/flash_buy',{id:id},function(data){
$('.loading').show();
            //已经返回结果一次结果
            var _data = data;
           // console.log(_data);
            if(_data.code == 1){
                //alert('进入成功');
                var _aw_time = $('input[name="game_openaward"]').val();

                window.setTimeout(function(){
                    //查询次数
                    var sel_count =  10000;
                    var _interval = window.setInterval(function(){
                        //console.log(sel_count);
                        if(sel_count > 0){
                            $.post('/index/Index/checkFlushOpen',{id:id},function(data){
                            	
                                if(data.code == 1 || data.code == 2){
                                    window.clearInterval(_interval);
                                    if(data.code == 1){
                                        $('.loading').hide();
                                        $('.succeed').show();
                                        var success = document.getElementById('success');
                                        $('#pig_level_'+ id +' .btns').html('<div class="button fs28 fw_b buttoning level_btn fanzhi">繁殖中</div>')
                                        success.play();//audio.play();// 这个就是播放
                                    }else{
                                        $('.loading').hide();
                                        $('.fail').show();
                                        var error = document.getElementById('error');
                                        error.play();//audio.play();// 这个就是播放
                                    }
                                }else{
                                    sel_count --;
                                }
                            })
                        }else{
                            window.clearInterval(_interval);
                            $('.model').hide();
                            $('.loading').hide();
                            $('.fail').show();
                            var error = document.getElementById('error');
                            error.play();//audio.play();// 这个就是播放
                            layer.open({
                                content: '网络异常'
                                ,time: 2
                                ,skin: 'msg'
                            });

                        }

                    },10000)//抢购动画持续时间毫秒
                },_aw_time);
            }else{
                $('.model').hide();
                $('.loading').hide();
                 $('.fail').show();
                // var error = document.getElementById('error');
                // error.play();//audio.play();// 这个就是播放

                layer.open({
                    content:_data.msg
                    ,skin: 'msg'
                    ,time: 2 //2秒后自动关闭
                });
            }
            //第二次访问查看是否有中奖
        });
    });

    //校验游戏
    var id = $('input[name=game_id]');
    var time =  $('input[name=game_time]');
    var openaward =  $('input[name=game_openaward]');
    var stage =  $('input[name=game_stage]');
    var timer;
    //checkGame();
    

    $(document).on('click','.buttoned',function(){
		 let thisid = $(this).data('id');
		 //console.log($(this).data('id'));
		 layer.open({
			content: '您確定要预约嗎?'
			,btn: ['確定', '取消']
			,yes: function(index){
			   $.post('/index/Index/yuyue',{id:thisid}).then(function(res){
			      // console.log(res);
				  if(res.code == 1){
					$('#pig_level_'+ thisid +' .btns').html('<div class="button fs28 fw_b buttoning">等待领养</div>')   
				  }else{
					 $('#pig_level_'+ thisid +' .btns').html('<div class="button fs28 fw_b buttoning">已预约</div>');
					  clearInterval(timer);
					 timer = setInterval(checkGame,1000);
					layer.open({
					  content:res.msg
					  ,skin: 'msg'
					  ,time: 2 //2秒后自动关闭
					});
				  }
			  })
			 layer.close(index);
			}
		  });
	 
     
    });
  
   timer = setInterval(function(){
		checkGame();
   },1000);

        // function detail(){
        // var success = document.getElementById('success'); 
        // var audio1 = document.getElementById('error'); 
        // success.play(); //这个就是播放  
        // audio1.play(); //这个就是播放  
        // }
    })
    function closeBox(){
        $('.model').hide();
    };
    </script>

 <script >
         $('.collect').click(function(){
             var id=$(this).attr('data-img');
             var that=$(this);
             if (that.hasClass("on")){
                $.post('/index/User/delcollect',{id:id},function(data) {
                 layer.open({
                 content:data.msg,
                 skin:'msg',
                 time:2 //关闭
                 })
                 if(data.msg=='取消收藏成功'){
                    that.attr('src','/public/images/1.jpg');
                     that.next().text(data.data);
                    that.removeClass('on');
                 }
                })
             }else{
                $.post('/index/User/docollect',{id:id},function(data){
                                                layer.open({
                                                   content:data.msg
                                                   ,skin: 'msg'
                                                   ,time: 2 //2秒后自动关闭
                                                 });
                                                if(data.msg=='收藏成功'){
                                                    that.attr('src','/public/images/2.jpg');
                                                     that.next().text(data.data);
                                                     that.addClass('on');
                                                }
                                            })
             }
           });

</script>



  </body>
</html>

个人中心user/collect.html

<!DOCTYPE html>
<html lang="zh-cmn-Hans">
  <head>
    <meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
<link rel="stylesheet" href="/public/static/index/assets/css/zpui.css"/>
<link rel="stylesheet" href="/public/static/index/assets/css/all.css"/>
<script src="/public/static/index/assets/js/page.js"></script>
<style>
              /* 隐藏顶部浮动栏选项  */
        body { position: static !important; top:0px !important; }
        iframe.goog-te-banner-frame { display: none !important; }
        .goog-logo-link { display:none !important; }
        .goog-te-gadget { color: transparent !important; overflow: hidden;}
        .goog-te-balloon-frame{display: none !important;}

        /*使原始文本弹出窗口隐藏*/
        .goog-tooltip {display: none !important;}
        .goog-tooltip:hover {display: none !important;}
        .goog-text-highlight {background-color: transparent !important; border: none !important; box-shadow: none !important;}

        /* 语言选择框颜色 */
        .goog-te-combo {background-color:#848CB5; border-radius:8px;}
 </style>
    <title>我的收藏</title>
  </head>
  <style type="text/css">
    img{
      border-radius: 50%;
    }
  </style>
  <body>
    <div id="wrap" style="z-index: 1000000;
    position: fixed ! important;
    right: -25px;
    top: 8px;">
    <!-- 谷歌语言 -->
    <div id="google_translate_element"></div>
   </div>
    <div class="page appoint">
      <div class="page-hd">
        <div class="header bor-1px-b">
    <div class="header-left">
        <a href="javascript:history.go(-1)" class="left-arrow"></a>
    </div>
    <div class="header-title">项目收藏</div>
    <div class="header-right">
        <a href="#"></a>
    </div>
</div>
      </div>
      <div class="page-bd">
        <!-- 页面内容 -->
        <div class="weui-cells" style="margin:0.2rem auto auto auto !important">
        {volist name="$task_config" id="task"}
        {volist name="$task" id="user_task"}
       <div class="weui-cell box">
              <div class="weui-cell__hd">
                <img src="{$user_task.img}" alt="">
              </div>
              <div class="weui-cell__bd">
                <div class="fs28 color_3 fw_b">
                    <span>{$user_task.name}</span>
                </div>
              </div>
              <div class="weui-cell__ft">
                <div class="fs30 color_3 fw_b"></div>
                <div class="fs24 color_9">开始时间:{$user_task.start_time}</div>
              </div>
          </div>
          {/volist}
         {/volist}

        </div>
      </div>
    </div>
    <script src="/public/static/index/assets/js/lib/jquery-2.1.4.js"></script>
<script src="/public/static/index/assets/js/jquery-weui.min.js"></script>
<script src="/public/static/index/assets/js/lib/fastclick.js"></script>
<script src="/public/static/index/assets/js/layer.js"></script>
<script src="/public/static/index/assets/js/ajaxplugin.js"></script>
    <script></script>

  </body>
</html>

收藏功能mobile/index后台控制器

 //首页
    public function index()
    {
        $piglist = Db::name('task_config')->order('sort','asc')->select();
        $nowtime = date('H:i');
        $nowday = date('Y-m-d ');
        $time = time();
        $user_id = $this->user_id;
        foreach ($piglist as $key=>$val) {
            if($val['time'] == 'time'){
                $piglist[$key]['time'] = '时';
            }else{
                $piglist[$key]['time'] = '天';
            }
            if($val['is_open'] == true){
            	$pigMap = [];
        		$pigMap['pig_id'] = $val['id'];
        		$pigMap['status'] = 0;
				$buyPiglist = Db::name('pig_order')->where($pigMap)->select();
                if($nowtime < $val['end_time'] && $nowtime > $val['start_time']){
                    $piglist[$key]['img'] = $val['img_tow'];
                    $piglist[$key]['game_status'] = 4;
                }else if($nowtime > $val['end_time'] && $nowtime < '23:59' || !$buyPiglist){
                    $piglist[$key]['img'] = $val['img_three'];
                    $piglist[$key]['game_status'] = 0;
                }else{
                    $piglist[$key]['img'] = $val['img_three'];
                    $piglist[$key]['game_status'] = 0;
                }
            }else{
                if($nowtime > '00:00' && $nowtime < $val['start_time']){
                    if($this->isYuyue($val['id'])){
                        $piglist[$key]['game_status'] =2;
                    }else{
                        $piglist[$key]['game_status'] =1;
                    }
                }else{
                    $piglist[$key]['img'] = $val['img_three'];
                    $piglist[$key]['game_status'] = 0;
                }
            }

            //判断是否收藏->单条查询每查询一条增加自定义是否收藏属性,
            $r= DB::name('user_task_config')->where(['uid'=>$user_id,'tid'=>$val['id']])->find();
           // var_dump($r);
            $piglist[$key]['is_c']=$r?1:0;
        }

        $config=unserialize(Db::name('system')->where('name','site_config')->value('value'));
        $base_config = unserialize(Db::name('system')->where('name','base_config')->value('value'));
        $list = Db::name('news')->where('cate','1')->order('id desc')->find();

        return view('Index/index')->assign('list',$list)->assign(['piglist'=>$piglist,'nowday'=>$nowday,'nowtime'=>$time,'config'=>$config,'base_config'=>$base_config]);
    }

收藏功能user/collect、dolcollect、delcollect

    public function collect()
    {
        $user_id = $this->user_id;
        $user_task_id = Db::name('user_task_config')->where('uid',$user_id)->select();

        $task_config=[];
        foreach ($user_task_id as $key=>$val){
            $task_config[]=Db::name('task_config')->where('id',$val['tid'])->select();
        }
        return view('User/collect')->assign('task_config',$task_config);
    }


    public function docollect(){
        $data = $this->request->param();
      //  var_dump( $data['id']);die;
        $user_id = $this->user_id;
        $array2=[];
        $array2['tid']=$data['id'];
        $array2['uid']=$user_id;

       $tid= Db::name('user_task_config')->where($array2)->select();

        $user_id = $this->user_id;
        $array=[];
        $array['uid']=$user_id;
        $array['tid']=$data['id'];

        $result=Db::name('user_task_config')->where('tid',$data['id'])->insert($array);

        if($result){
            Db::name('task_config')->where('id',$data['id'])->setInc('collect', 1);
           $num= Db::name('task_config')->where('id',$data['id'])->value('collect');
            $this->success('收藏成功','',$num);
        }else{
            $this->error('收藏失败');
        }
    }


    public function delcollect(){
        $data = $this->request->param();
        $user_id = $this->user_id;
        $result1=Db::name('user_task_config')->where(['uid'=>$user_id,'tid'=>$data['id']])->delete();
        $result2=Db::name('task_config')->where('id',$data['id'])->setDec('collect',1);
        if($result1 && $result2){
            $num= Db::name('task_config')->where('id',$data['id'])->value('collect');
            $this->success('取消收藏成功','',$num);
        }else{
            $this->error('取消收藏失败');
        }

    }

相关标签: 功能模块