chengkun
2025-05-26 8f3df543230cd4403368b39b9bbe5726d11a0284
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
 
class friendhelp_controller extends common{
    
    
    function share_action(){
        
        
        $helpM        =    $this -> MODEL('friendhelp');
        $return        =    $helpM -> getTokenInfo($_GET['id'],$_GET['token']);
        
        if($return['error']  == '1'){
 
            if($return['helpinfo']['etime']<time()){
                
                $this->ACT_msg_wap(Url('wap'), '本次助力已结束!',1 ,5);
            
            }else{
                //权益套餐
                $package        =    $helpM -> packageList($return['helpinfo']);
                $_GET['token']    =    urlencode($_GET['token']);
                
                $this->yunset("shareurl",Url('wap').'index.php?c=friendhelp&a=show&id='.$return['helpinfo']['id'].'&token='.$_GET['token']);
                
                $this->yunset("package",$package);
                $this->yunset("row",$return['helpinfo']);
                
                $this->seo('friendhelp');
                
                $this->yunset("headertitle","分享助力");
            }
            
        }else{
            $this->ACT_msg_wap(Url('wap'), '参数错误!',1 ,5);
        }
 
        $this->yuntpl(array('wap/helpshare'));
 
    }
    function show_action(){
        
            $helpM        =    $this  -> MODEL('friendhelp');
        //微信读取放在头部 只有在取得微信ID后才会继续执行 防止产生跳转开销
        if(is_weixin()){
            
            session_start();
            if(!$_SESSION['wxuser']){
                
                    //拉取微信OPENID
                $packM         = $this->MODEL('pack');
                $wxUser = $packM->getWxOpenid(Url('wap').'index.php?c=friendhelp&a=show&id='.$_GET['id'].'&token='.rawurlencode($_GET['token']),1);
                $_SESSION['wxuser']    =    $wxUser;
            }
        
            
            
 
            $this->yunset('isweixin','1');
            
            //检测是否已助力
            $logInfo    =    $helpM -> getSharelogInfo(array('pid'=>$_GET['id'],'wxid'=>$_SESSION['wxuser']['openid']));
            
            $this->yunset("loginfo",$logInfo);
            
        }
        
    
        $return        =    $helpM -> getTokenInfo($_GET['id'],$_GET['token']);
    
        //验证token 是否有效
        if($return['error']  == '1'){
            if($return['helpinfo']['etime']<time()){
                
                $this->ACT_msg_wap(Url('wap'), '本次助力已结束!',1 ,5);
            
            }else{
                
 
                //查询相关企业、招聘职位信息
                $CompanyM    =   $this -> MODEL('company');
                $comInfo    =    $CompanyM -> getInfo($return['helpinfo']['comid'], array('logo' => '1'));
            
                $JobM    =   $this -> MODEL('job');
 
                $joblist   =   $JobM -> getList(array('uid' => $return['helpinfo']['comid'], 'status' => '0', 'state' => '1', 'orderby' => 'lastupdate,desc', 'limit'=>'5'),array('isurl'=>'yes','field'=>'`id`,`uid`,`name`,`edu`,`exp`,`minsalary`,`maxsalary`'));
            
                //
                $loglist    =    $helpM -> getLogList(array('pid' => $return['helpinfo']['id']));
                
                $this->yunset("loglist",$loglist);
 
                $_GET['token']    =    urlencode($_GET['token']);
                $this->yunset("shareurl",Url('wap').'index.php?c=friendhelp&a=show&id='.$return['helpinfo']['id'].'&token='.$_GET['token']);
 
                $this->yunset("row",$return['helpinfo']);
 
                $this->yunset("cominfo",$comInfo);
 
                $this->yunset("joblist",$joblist['list']);
            }
            
        }else{
            $this->ACT_msg_wap(Url('wap'), '本次助力已结束!',1 ,5);
        }
        
        $this->seo('friendhelp');
        $this->yuntpl(array('wap/helpshow'));
    }
 
    //添加助力
    function addlog_action(){
        
        if($_POST['id'] && $_POST['token']){
            session_start();
            
            if($_SESSION['wxuser']){
            
                //进入页面就视为已助力
                $helpM            =    $this  -> MODEL('friendhelp');
                $return            =    $helpM -> getTokenInfo($_POST['id'],urldecode($_POST['token']));
                    
                if($return['error']  == '1'){
                
                    if($return['helpinfo']['etime']>=time()){
                        
                        $returnShare    =    $helpM -> checkHelp($return['helpinfo'],$_SESSION['wxuser']);
                        if($returnShare['error']=='1'){
                            
                                echo json_encode(array('error'=>'1'));
                        }else{
                            
                                echo json_encode(array('error'=>'0','msg'=>$returnShare['msg']));
                        }
                    
                    }else{
                
                        echo json_encode(array('error'=>'0','msg'=>'本次助力已结束!'));
                    }
                }
            }else{
                echo json_encode(array('error'=>'0','msg'=>'请使用微信为好友助力'));
            
            }
        }else{
        
            echo json_encode(array('error'=>'0','msg'=>'助力失败'));
        }
    }
}
?>