|
@@ -15,7 +15,6 @@ require_once(BASE_ROOT_PATH . '/helper/model_helper.php');
|
|
|
require_once(BASE_ROOT_PATH . '/helper/user_session/storage.php');
|
|
|
require_once(BASE_ROOT_PATH . '/helper/ugc_helper.php');
|
|
|
|
|
|
-
|
|
|
class specialControl extends mobileHomeControl
|
|
|
{
|
|
|
public function __construct() {
|
|
@@ -53,40 +52,39 @@ class specialControl extends mobileHomeControl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function voteOp()
|
|
|
+ public function submitOp()
|
|
|
{
|
|
|
$special_id = intval($_GET['special_id']);
|
|
|
+ $spitem = spid_helper::instance()->special($special_id);
|
|
|
|
|
|
- if(!empty($_GET['options'])) {
|
|
|
- $options = explode(',',$_GET['options']);
|
|
|
+ if($special_id < 0 || $spitem == false) {
|
|
|
+ return self::outerr(errcode::ErrParamter,"该文章不存在");
|
|
|
}
|
|
|
-
|
|
|
- if($special_id < 0 || empty($options)) {
|
|
|
- return self::outerr(errcode::ErrParamter,"该文章不存在或者没有选中选项");
|
|
|
+ $content = urldecode($_GET['content']);
|
|
|
+ if(empty($content)) {
|
|
|
+ $options = false;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $options = json_decode($content,true);
|
|
|
+ if($options == null) $options = false;
|
|
|
}
|
|
|
|
|
|
- $spitem = spid_helper::instance()->special($special_id);
|
|
|
- if($spitem->has_vote())
|
|
|
+ $result = ugc_helper::submit($special_id,$options,$err);
|
|
|
+ if($result == false) {
|
|
|
+ return self::outerr($err['code'],$err['msg']);
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- $result = ugc_helper::vote($special_id,$options,$err);
|
|
|
- if($result == false) {
|
|
|
- return self::outerr($err['code'],$err['msg']);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- $vote_result = $result['vote_result'];
|
|
|
- $type_sn = $result['type_sn'];
|
|
|
- if(!empty($type_sn)) {
|
|
|
- $url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=open&type_sn={$type_sn}";
|
|
|
- } else {
|
|
|
- $url = "";
|
|
|
- }
|
|
|
-
|
|
|
- return self::outsuccess(['special_id' => $special_id,'vote_result' => $vote_result,'bonus_url' => $url]);
|
|
|
+ $vote_result = $result['vote_result'];
|
|
|
+ $type_sn = $result['type_sn'];
|
|
|
+ if(!empty($type_sn)) {
|
|
|
+ $url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=open&type_sn={$type_sn}";
|
|
|
+ } else {
|
|
|
+ $url = "";
|
|
|
}
|
|
|
- }
|
|
|
- else {
|
|
|
- return self::outerr(errcode::ErrSpecial,"本文不支持投票");
|
|
|
+ $answer_diff = $result['answer_diff'];
|
|
|
+
|
|
|
+ return self::outsuccess(['special_id' => $special_id,'vote_result' => $vote_result,'answer_diff' => $answer_diff,'bonus_url' => $url]);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -152,10 +150,17 @@ class tpl_ugc
|
|
|
private $special_list;
|
|
|
private $summary;
|
|
|
private $mem_info;
|
|
|
- private $special_info;
|
|
|
+ private $special;
|
|
|
|
|
|
+ private $mQuestionIndex;
|
|
|
+
|
|
|
+ public function special_id()
|
|
|
+ {
|
|
|
+ return $this->special->special_id();
|
|
|
+ }
|
|
|
public function __construct($output)
|
|
|
{
|
|
|
+ $this->mQuestionIndex = 0;
|
|
|
$this->spitem = $output['spitem'];
|
|
|
$this->special_list = $output['special_list'];
|
|
|
$this->summary = $output['summary'];
|
|
@@ -165,9 +170,9 @@ class tpl_ugc
|
|
|
$this->mem_info = null;
|
|
|
}
|
|
|
if(!empty($output['special_info'])) {
|
|
|
- $this->special_info = new special_info($output['special_info']);
|
|
|
+ $this->special = new ugc\special($output['special_info']);
|
|
|
} else {
|
|
|
- $this->special_info = null;
|
|
|
+ $this->special = null;
|
|
|
}
|
|
|
}
|
|
|
public function title() {
|
|
@@ -202,6 +207,7 @@ class tpl_ugc
|
|
|
|
|
|
public function show_blocks()
|
|
|
{
|
|
|
+ $this->mQuestionIndex = 0;
|
|
|
foreach ($this->special_list as $block)
|
|
|
{
|
|
|
$item_type = $block['item_type'];
|
|
@@ -213,7 +219,6 @@ class tpl_ugc
|
|
|
}
|
|
|
private function show_items($items)
|
|
|
{
|
|
|
- $qindex = 0;
|
|
|
foreach ($items as $item)
|
|
|
{
|
|
|
$show_type = $item['show_type'];
|
|
@@ -227,8 +232,11 @@ class tpl_ugc
|
|
|
$this->show_vote($item);
|
|
|
}
|
|
|
elseif($show_type == 'question') {
|
|
|
- $this->show_question($item,$qindex);
|
|
|
- $qindex++;
|
|
|
+ $this->show_question($item);
|
|
|
+ $this->mQuestionIndex++;
|
|
|
+ }
|
|
|
+ elseif($show_type == 'goods') {
|
|
|
+
|
|
|
}
|
|
|
else {
|
|
|
|
|
@@ -236,9 +244,67 @@ class tpl_ugc
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private function show_question($item,$qindex)
|
|
|
+ private function show_question($item)
|
|
|
{
|
|
|
+ if(empty($item['data'])) return false;
|
|
|
+ $options = json_decode($item['data'],true);
|
|
|
|
|
|
+ $title = $item['title'];
|
|
|
+ $qindex = $this->mQuestionIndex;
|
|
|
+ $i = $qindex + 1;
|
|
|
+ $show_title = "第{$i}题、{$title}";
|
|
|
+
|
|
|
+ $reserved = $item['reserved'];
|
|
|
+ $kv = preg_split('/=/',$reserved);
|
|
|
+ if(!empty($kv))
|
|
|
+ {
|
|
|
+ $k = trim($kv[0]);
|
|
|
+ $v = trim($kv[1]);
|
|
|
+ if(!empty($k) && $k == 'answer_type') {
|
|
|
+ $answer_type = $v;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $answer_type = intval($answer_type);
|
|
|
+ if($answer_type == 0) {
|
|
|
+ $sanswer_type = '单选';
|
|
|
+ $box = "radio";
|
|
|
+ }
|
|
|
+ elseif ($answer_type == 1) {
|
|
|
+ $sanswer_type = '最多选两项';
|
|
|
+ $box = "checkbox";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $sanswer_type = '多选';
|
|
|
+ $box = "checkbox";
|
|
|
+ }
|
|
|
+
|
|
|
+ $header = "<div class=\"question_list\">
|
|
|
+ <div class=\"question\">
|
|
|
+ <div class=\"question_pro\">
|
|
|
+ <div class=\"question_title\">{$show_title}</div>
|
|
|
+ <div class=\"question_type\" data-type=\"{$answer_type}\">/{$sanswer_type}</div>
|
|
|
+ </div>
|
|
|
+ <div class=\"question_options\">";
|
|
|
+ $opindex = 65;
|
|
|
+ $soptions = '';
|
|
|
+ foreach ($options as $val)
|
|
|
+ {
|
|
|
+ $key = $val['id'];
|
|
|
+ $option = $val['text'];
|
|
|
+
|
|
|
+ $si = sprintf("%c",$opindex++);
|
|
|
+ $soptions .= "<div class=\"question_option\">
|
|
|
+ <label>
|
|
|
+ <input type=\"{$box}\" value=\"{$key}\" class=\"check\" name=\"question{$qindex}\">
|
|
|
+ <span class=\"label\">{$si}、{$option}</span>
|
|
|
+ </label>
|
|
|
+ </div>";
|
|
|
+ }
|
|
|
+ $end = "</div>
|
|
|
+ </div>
|
|
|
+ </div>";
|
|
|
+ $str = "{$header}{$soptions}{$end}";
|
|
|
+ echo $str;
|
|
|
}
|
|
|
|
|
|
private function show_vote($item)
|
|
@@ -262,21 +328,18 @@ class tpl_ugc
|
|
|
$vote_type = intval($vote_type);
|
|
|
if($vote_type == 0) {
|
|
|
$svote_type = '单选';
|
|
|
+ $box = "radio";
|
|
|
}
|
|
|
elseif ($vote_type == 1) {
|
|
|
$svote_type = '最多选两项';
|
|
|
+ $box = "checkbox";
|
|
|
}
|
|
|
else {
|
|
|
$svote_type = '多选';
|
|
|
+ $box = "checkbox";
|
|
|
}
|
|
|
|
|
|
- if($this->special_info != null) {
|
|
|
- $special_id = $this->special_info->special_id();
|
|
|
- } else {
|
|
|
- $special_id = -1;
|
|
|
- }
|
|
|
-
|
|
|
- $str = "<div class=\"vote\" data-special_id=\"{$special_id}\">
|
|
|
+ $str = "<div class=\"vote\">
|
|
|
<div class=\"vote_pro\">
|
|
|
<div class=\"vote_question\">{$title}</div>
|
|
|
<div class=\"vote_type\">/{$svote_type}</div>
|
|
@@ -284,11 +347,12 @@ class tpl_ugc
|
|
|
<div class=\"vote_options\">";
|
|
|
foreach ($options as $val)
|
|
|
{
|
|
|
+
|
|
|
$key = $val['id'];
|
|
|
$option = $val['text'];
|
|
|
$soption = "<div class=\"vote_option\">
|
|
|
<label>
|
|
|
- <input type=\"checkbox\" value=\"{$key}\" class=\"check\" name=\"submit_vote\">
|
|
|
+ <input type=\"{$box}\" value=\"{$key}\" class=\"check\" name=\"submit_vote\">
|
|
|
<span class=\"label\">{$option}</span>
|
|
|
</label>
|
|
|
</div>";
|
|
@@ -326,12 +390,8 @@ class tpl_ugc
|
|
|
{
|
|
|
$video = $item['data'];
|
|
|
$str = "<div class=\"thumbnail\">
|
|
|
- <video poster=\"$image\" src=\"{$video}\">
|
|
|
- 您的设备不支持视频播放
|
|
|
- </video>
|
|
|
- <div class=\"thumbnail_pro\">
|
|
|
- 《化妆小教程》
|
|
|
- </div>
|
|
|
+ <div class=\"video_box\" data-poster=\"{$image}\" data-src=\"{$video}\"></div>
|
|
|
+ <div class=\"thumbnail_pro\">$title</div>
|
|
|
</div>";
|
|
|
}
|
|
|
else
|