<?php
/**
* Created by PhpStorm.
* User: hy
* Date: 2018/3/28
* Time: 12:10
*/
namespace app\api\controller;
use think\Controller;
use app\common\logic\Wx as Wxsevice;
use app\common\model\Plays;
use app\common\model\Grade;
use app\common\model\GameInit;
use think\Session;
class Wx extends Controller
{
//登陆跳转,获取openid;
public function login()
{
$auth = model('game_init') -> where('id','9') -> value('init');//是否开启
if ($auth !== '0'){
echo '海选赛截止参赛,请留意官网通知!';exit;
}
$url = 'http://ult.rossopharm.com/api/wx/login';
$openid = model('wx','logic') ->getOpenid($url, 0);
Session::set('openid',$openid);
$data = ['openid' => $openid];
//判断用户参数记录情况
$questions = model('plays') -> where('openid',$openid) -> value('questions');//是否已经生成题库
$score = model('plays') -> where('openid',$openid) -> value('score');//是否已经生成成绩
$name = model('plays') -> where('openid',$openid) -> value('name');//是否已经添加报名信息
$title = model('plays') -> where('openid',$openid) -> value('title');//是否已经选择题库
//判断用户是否有成绩
if(($score !== NULL) && $questions){
$this -> redirect('http://ult.rossopharm.com/wap/result.html',302);//展示成绩页
}elseif($questions && ($score === NULL)) {
$this->redirect('http://ult.rossopharm.com/wap/question.html', 302);//答题页
}elseif($name && !$title){
$this->redirect('http://ult.rossopharm.com/wap/sort.html', 302);//选择题库页
}else{
$this -> redirect('http://ult.rossopharm.com/wap/poster.html',302);//活动首页
}
}
//返回获取JsSdk配置包
public function getJsSdk()
{
$jsurl = input('jsurl');
$res = model('Wx','logic')->getSignPackage($jsurl);
Session::set('openid',$openid);
trace($res,'sdk包数据');
ajaxReturn(0, $res);
}
}
评论0