special.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 16/9/7
  6. * Time: 下午3:52
  7. */
  8. defined('InShopNC') or exit('Access Invalid!');
  9. require_once(BASE_ROOT_PATH . '/helper/goods_helper.php');
  10. require_once(BASE_ROOT_PATH . '/helper/special_helper.php');
  11. require_once(BASE_ROOT_PATH . '/helper/activity_helper.php');
  12. require_once(BASE_ROOT_PATH . '/helper/model_helper.php');
  13. require_once(BASE_ROOT_PATH . '/helper/user_session/storage.php');
  14. require_once(BASE_ROOT_PATH . '/helper/ugc_helper.php');
  15. require_once(BASE_ROOT_PATH . '/helper/url_helper.php');
  16. class specialControl extends mobileHomeControl
  17. {
  18. public function __construct() {
  19. parent::__construct();
  20. }
  21. public function indexOp()
  22. {
  23. $special_id = intval($_GET['special_id']);
  24. if($special_id < 0) {
  25. return self::outerr(errcode::ErrParamter);
  26. }
  27. $spitem = spid_helper::instance()->special($special_id);
  28. if($spitem == false) {
  29. return self::outerr(errcode::ErrParamter,"该专题不存在");
  30. }
  31. QueueClient::push('onClickSpecial',['special_id' => $special_id]);
  32. if($spitem->from_user())
  33. {
  34. if(session_helper::need_wechat_author())
  35. {
  36. $author = new thrid_author\wxauthor();
  37. $url = author_url::ugc_url($special_id);
  38. $url = $author->enter($url);
  39. return self::outsuccess(['direct_uri' => $url],"redirect");
  40. }
  41. $ret = $this->pri_special($special_id);
  42. $ret['spitem'] = $spitem;
  43. $tpl_obj = new tpl_ugc($ret);
  44. self::outsuccess(['tpl_obj' => $tpl_obj],'ugc/content');
  45. } else {
  46. $ret = $this->pub_special($special_id);
  47. self::outsuccess($ret);
  48. }
  49. }
  50. public function submitOp()
  51. {
  52. $special_id = intval($_GET['special_id']);
  53. $spitem = spid_helper::instance()->special($special_id);
  54. if($special_id < 0 || $spitem == false) {
  55. return self::outerr(errcode::ErrParamter,"该文章不存在");
  56. }
  57. $content = urldecode($_GET['content']);
  58. if(empty($content)) {
  59. $options = false;
  60. }
  61. else {
  62. $options = json_decode($content,true);
  63. if($options == null) $options = false;
  64. }
  65. $result = ugc_helper::submit($special_id,$options,$err);
  66. if($result == false) {
  67. return self::outerr($err['code'],$err['msg']);
  68. }
  69. else
  70. {
  71. $vote_result = $result['vote_result'];
  72. $type_sn = $result['type_sn'];
  73. if(!empty($type_sn)) {
  74. $url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=open&type_sn={$type_sn}";
  75. $type = bonus\type::create_by_sn($type_sn);
  76. $sender_id = $type->sender_id();
  77. $minfo = new member_info($sender_id);
  78. $avatar = $minfo->avatar();
  79. } else {
  80. $url = "";
  81. $avatar = '';
  82. }
  83. $answer_diff = $result['answer_diff'];
  84. return self::outsuccess(['special_id' => $special_id,
  85. 'vote_result' => $vote_result,
  86. 'answer_diff' => $answer_diff,
  87. 'bonus_url' => $url,
  88. 'num' => $result['num'],
  89. 'amount' => $result['amount'],
  90. 'bonus_type' => $result['bonus_type'],
  91. 'sender_avatar' => $avatar]);
  92. }
  93. }
  94. protected function pub_special($special_id)
  95. {
  96. $specials = special_manager::instance()->special($special_id,$goods_ids,true);
  97. if (!empty($goods_ids))
  98. {
  99. $helper = new goods_helper();
  100. $goodsex = $helper->online_summary($goods_ids, $related_goods);
  101. return array('special_list' => $specials,
  102. 'tabs' => special_manager::instance()->tabs($special_id),
  103. 'summary' => $goodsex['summary'],
  104. 'groupbuy' => $goodsex['groupbuy'],
  105. 'limitime' => $goodsex['limitime'],
  106. 'bundling' => $goodsex['bundling'],
  107. 'mobile_page' => mobile_page(1));
  108. }
  109. else
  110. {
  111. return array('special_list' => $specials,
  112. 'summary' => array(),
  113. 'groupbuy' => array(),
  114. 'limitime' => array(),
  115. 'bundling' => array(),
  116. 'mobile_page' => mobile_page(1));
  117. }
  118. }
  119. protected function pri_special($special_id)
  120. {
  121. $result = special_manager::instance()->special($special_id,$goods_ids,false);
  122. if (!empty($goods_ids))
  123. {
  124. $helper = new goods_helper();
  125. $goodsex = $helper->online_summary($goods_ids, $related_goods);
  126. return array('special_list' => $result['specials'],
  127. 'sender_info' => $result['sender_info'],
  128. 'special_info' => $result['special_info'],
  129. 'summary' => $goodsex['summary'],
  130. 'groupbuy' => $goodsex['groupbuy'],
  131. 'limitime' => $goodsex['limitime'],
  132. 'bundling' => $goodsex['bundling'],
  133. 'mobile_page' => mobile_page(1));
  134. }
  135. else
  136. {
  137. return array('special_list' => $result['specials'],
  138. 'sender_info' => $result['sender_info'],
  139. 'special_info' => $result['special_info'],
  140. 'summary' => array(),
  141. 'groupbuy' => array(),
  142. 'limitime' => array(),
  143. 'bundling' => array(),
  144. 'mobile_page' => mobile_page(1));
  145. }
  146. }
  147. }
  148. class tpl_ugc
  149. {
  150. private $spitem;
  151. private $special_list;
  152. private $summary;
  153. private $mem_info;
  154. private $special;
  155. private $mQuestionIndex;
  156. private $mVoteIndex;
  157. private $mAuthorRelation;
  158. public function __construct($output)
  159. {
  160. $this->mQuestionIndex = 0;
  161. $this->mVoteIndex = 0;
  162. $this->spitem = $output['spitem'];
  163. $this->special_list = $output['special_list'];
  164. $this->summary = $output['summary'];
  165. if(!empty($output['sender_info'])) {
  166. $this->mem_info = new member_info($output['sender_info']);
  167. } else {
  168. $this->mem_info = null;
  169. }
  170. $special_id = $output['special_info']['special_id'];
  171. $mod_special = Model('mb_special');
  172. $special_info = $mod_special->getMbSpecialByID($special_id,'*',true);
  173. if(!empty($special_info)) {
  174. $this->special = new ugc\special($special_info);
  175. } else {
  176. $this->special = null;
  177. }
  178. if(session_helper::logined()) {
  179. $memberid = session_helper::memberid();
  180. if($this->special->memberid() == $memberid) {
  181. $this->mAuthorRelation = 2;
  182. }
  183. else
  184. {
  185. $ret = relation_helper::subscribed($memberid,$this->special->memberid());
  186. $this->mAuthorRelation = $ret == true ? 1 : 0;
  187. }
  188. } else {
  189. $this->mAuthorRelation = false;
  190. }
  191. }
  192. public function preview()
  193. {
  194. return $this->special->preview();
  195. }
  196. public function special_id()
  197. {
  198. return $this->special->special_id();
  199. }
  200. public function browse_title()
  201. {
  202. if(session_helper::isapp()) {
  203. return "文章内容";
  204. } else {
  205. $title = $this->special->share_title();
  206. return $title;
  207. }
  208. }
  209. public function title() {
  210. $title = $this->special->share_title();
  211. $title = str_replace( array( "\n", "\r" ), array( " ", " " ), $title );
  212. return $title;
  213. }
  214. public function image() {
  215. return $this->special->share_img();
  216. }
  217. public function url() {
  218. $special_id = $this->special_id();
  219. return url_helper::ugc_url($special_id);
  220. }
  221. public function sub_title()
  222. {
  223. $desc = $this->special->description();
  224. $desc = str_replace( array( "\n", "\r" ), array( " ", " " ), $desc);
  225. if(empty($desc)) return "";
  226. else
  227. return $desc;
  228. }
  229. public function last_title()
  230. {
  231. $submit_rule = $this->special->submit_rule();
  232. if(!empty($submit_rule)) {
  233. $submit_rule->avaliable();
  234. $desc = "点击领取红包";
  235. } else {
  236. $desc = "熊猫美妆";
  237. }
  238. return $desc;
  239. }
  240. public function show_title()
  241. {
  242. $title = $this->spitem->share_title();
  243. if(!empty($title))
  244. {
  245. $str = "<div class=\"title\">
  246. <h3>{$title}</h3>
  247. </div>";
  248. echo $str;
  249. }
  250. }
  251. private function format_time($tm)
  252. {
  253. $cur_tm = time();
  254. $delta = $cur_tm - $tm;
  255. if($delta < 600) {
  256. return "刚刚";
  257. }
  258. elseif ($delta < 3600) {
  259. $delta = intval($delta / 60);
  260. return "{$delta}分钟前";
  261. }
  262. elseif($delta < 3600 * 24) {
  263. $delta = intval($delta / 3600);
  264. return "{$delta}小时前";
  265. }
  266. else {
  267. return strftime("%m-%d",$tm);
  268. }
  269. }
  270. public function show_sender()
  271. {
  272. if($this->mem_info != null)
  273. {
  274. $nick_name = $this->mem_info->nickname();
  275. $avatar = $this->mem_info->avatar();
  276. $pubtime = $this->special->pubtime();
  277. $pubtime = $this->format_time($pubtime);
  278. $av_str = "<img src=\"{$avatar}\" alt=\"熊猫美妆\">";//
  279. $name_str = "<div class=\"author_pro\">
  280. <span>文/{$nick_name}</span >
  281. <span class=\"release_date\">{$pubtime}</span>
  282. </div>";
  283. $str = $av_str . $name_str;
  284. } else {
  285. $str = '';
  286. }
  287. echo $str;
  288. }
  289. public function show_blocks()
  290. {
  291. $this->mQuestionIndex = 0;
  292. foreach ($this->special_list as $block)
  293. {
  294. $item_type = $block['item_type'];
  295. $items = $block['items'];
  296. if($item_type == 'home_ugc' && !empty($items)) {
  297. $this->show_items($items);
  298. }
  299. }
  300. $this->show_submit();
  301. $this->show_answer_page();
  302. $this->show_appreciate();
  303. $this->show_comment_header();
  304. }
  305. private function show_submit()
  306. {
  307. $vote_single = $this->special->vote_single();
  308. $submitor = new ugc\special_submitor($this->special_id(),$vote_single);
  309. $special = $this->special;
  310. if(!$submitor->submited())
  311. {
  312. $rule = $special->submit_rule();
  313. if($rule != false) {
  314. $avaliable = $rule->avaliable();
  315. } else {
  316. $avaliable = false;
  317. }
  318. if($special->has_vote() || $special->has_question())
  319. {
  320. if($special->has_vote() && $special->has_question()) {
  321. $content = "提交";
  322. }
  323. elseif($special->has_vote()) {
  324. $content = "投票";
  325. }
  326. else{
  327. $content = "提交";
  328. }
  329. if($rule != false && $avaliable == true)
  330. {
  331. $content .= " (领红包)";
  332. }
  333. if($special->has_over()) {
  334. $str = "<button class=\"button_vote button_null\" id=\"submit_btn\" disabled>{$content} 已过期</button>";
  335. } else {
  336. $str = "<button class=\"button_vote\" id=\"submit_btn\">{$content}</button>";
  337. }
  338. }
  339. else
  340. {
  341. if($rule == false) {
  342. return;
  343. }
  344. else
  345. {
  346. if($avaliable)
  347. {
  348. $content = "领红包";
  349. if($special->has_over()) {
  350. $str = "<button class=\"button_vote button_null\" id=\"submit_btn\" disabled>{$content} 已过期</button>";
  351. } else {
  352. $str = "<button class=\"button_vote\" id=\"submit_btn\">{$content}</button>";
  353. }
  354. }
  355. }
  356. }
  357. }
  358. else {
  359. $str = "<button class=\"button_vote button_null\" disabled>您已经提交过</button>";
  360. }
  361. echo $str;
  362. }
  363. private function show_comment_header()
  364. {
  365. $report_url = BASE_SITE_URL . "/mobile/index.php?act=member_ugc&op=report_page&special_id={$this->special_id()}";
  366. $str = '';
  367. $clicks = $this->special->clicks();
  368. if(!$this->preview())
  369. {
  370. $str .= "<div class=\"comment\">
  371. <div class=\"pro\">
  372. <div class=\"pro_title\">评论</div>
  373. <div class=\"reading\">浏览数 {$clicks}</div>
  374. <div class=\"complaint\">
  375. <a href=\"{$report_url}\">投诉</a>
  376. </div>
  377. </div>
  378. <div class=\"comment_list\"></div>
  379. </div>";
  380. }
  381. echo $str;
  382. }
  383. private function show_items($items)
  384. {
  385. foreach ($items as $item)
  386. {
  387. $show_type = $item['show_type'];
  388. if($show_type == 'image') {
  389. $this->show_image($item);
  390. }
  391. elseif($show_type == 'text') {
  392. $this->show_text($item);
  393. }
  394. elseif($show_type == 'vote')
  395. {
  396. $vote_single = $this->special->vote_single();
  397. $submitor = new ugc\special_submitor($this->special_id(),$vote_single);
  398. if($submitor->submited()) {
  399. $this->show_vote_result($item);
  400. } else {
  401. $this->show_vote($item);
  402. }
  403. $this->mVoteIndex++;
  404. }
  405. elseif($show_type == 'question') {
  406. $this->show_question($item);
  407. $this->mQuestionIndex++;
  408. }
  409. elseif($show_type == 'goods') {
  410. $this->show_goods($item);
  411. }
  412. else {
  413. }
  414. }
  415. }
  416. private function goods_summary($goods_id)
  417. {
  418. foreach ($this->summary as $summary)
  419. {
  420. if($summary['goods_id'] == $goods_id) {
  421. return $summary;
  422. }
  423. }
  424. return false;
  425. }
  426. private function show_goods($item)
  427. {
  428. $goods_id = intval($item['data']);
  429. $summary = $this->goods_summary($goods_id);
  430. if($summary == false) return;
  431. $recoment = $item['reserved'];
  432. if(session_helper::isapp()) {
  433. $url = "xmmz://p.lrlz.com/goods/goods?goodsId={$goods_id}";
  434. } else {
  435. $url = BASE_SITE_URL . "/mshop/goods_detail?goods_id={$goods_id}";
  436. }
  437. if($summary['goods_storage'] <= 0) {
  438. $state = '<span class="badge_null">已经售罄</span>';
  439. }
  440. elseif($summary['act_id'] > 0) {
  441. $state = '<span class="badge_limit">限时特价</span>';
  442. }
  443. elseif($summary['is_new']) {
  444. $state = '<span class="badge_new">熊猫新品</span>';
  445. }
  446. else {
  447. $state = '';
  448. }
  449. $goods_price = $summary['goods_price'];
  450. $bonus_price = $summary['bonus_price'];
  451. $discount = $goods_price - $bonus_price;
  452. $str = "<div class=\"recommend_goods\">
  453. <div class=\"goods_item\">
  454. <a href=\"{$url}\">
  455. {$state}
  456. <div class=\"goods\">
  457. <div class=\"goods_img\"><img src=\"{$summary['goods_image_url']}\" alt=\"熊猫美妆\"></div>
  458. <div class=\"goods_desc\">
  459. <p class=\"goods_title\">{$summary['goods_mobile_name']}</p>
  460. <p class=\"goods_pro\">{$summary['goods_jingle']}</p>
  461. <p class=\"goods_price\">
  462. ¥{$bonus_price}
  463. <span class=\"shoppe\">专柜价 {$goods_price} / 红包抵<span class=\"bonus_price\">{$discount}</span>元</span>
  464. </p>
  465. </div>
  466. </div>";
  467. if(!empty($recoment))
  468. {
  469. $str .= "<div class=\"recommend\">
  470. <span class=\"label\">推荐理由:</span><span>{$recoment}</span>
  471. </div>";
  472. }
  473. $str .= "</a>
  474. </div>
  475. </div>";
  476. echo $str;
  477. }
  478. private function show_question($item)
  479. {
  480. if(empty($item['data'])) return false;
  481. $options = json_decode($item['data'],true);
  482. $title = $item['title'];
  483. $qindex = $this->mQuestionIndex;
  484. $i = $qindex + 1;
  485. $show_title = "第{$i}题、{$title}";
  486. $reserved = $item['reserved'];
  487. $kv = preg_split('/=/',$reserved);
  488. if(!empty($kv))
  489. {
  490. $k = trim($kv[0]);
  491. $v = trim($kv[1]);
  492. if(!empty($k) && $k == 'answer_type') {
  493. $answer_type = $v;
  494. }
  495. }
  496. $answer_type = intval($answer_type);
  497. if($answer_type == 0) {
  498. $sanswer_type = '单选';
  499. $box = "radio";
  500. }
  501. else {
  502. $sanswer_type = '多选';
  503. $box = "checkbox";
  504. }
  505. $header = "<div class=\"question_list\">
  506. <div class=\"question\">
  507. <div class=\"question_pro\">
  508. <div class=\"question_title\">{$show_title}</div>
  509. <div class=\"question_type\" data-type=\"{$answer_type}\">/{$sanswer_type}</div>
  510. </div>
  511. <div class=\"question_options\">";
  512. $opindex = 65;
  513. $soptions = '';
  514. foreach ($options as $val)
  515. {
  516. $key = $val['id'];
  517. $option = $val['text'];
  518. $si = sprintf("%c",$opindex++);
  519. $soptions .= "<div class=\"question_option\">
  520. <label>
  521. <input type=\"{$box}\" value=\"{$key}\" class=\"check\" name=\"question{$qindex}\">
  522. <span class=\"label\">{$si}、{$option}</span>
  523. </label>
  524. </div>";
  525. }
  526. $end = '</div>
  527. </div>
  528. </div>';
  529. $str = "{$header}{$soptions}{$end}";
  530. echo $str;
  531. }
  532. private function show_vote($item)
  533. {
  534. if(empty($item['data'])) return false;
  535. $options = json_decode($item['data'],true);
  536. if(empty($options)) return false;
  537. $title = $item['title'];
  538. $reserved = $item['reserved'];
  539. $kv = preg_split('/=/',$reserved);
  540. if(!empty($kv))
  541. {
  542. $k = trim($kv[0]);
  543. $v = trim($kv[1]);
  544. if(!empty($k) && $k == 'vote_type') {
  545. $vote_type = $v;
  546. }
  547. }
  548. $vote_type = intval($vote_type);
  549. if($vote_type == 0) {
  550. $svote_type = '单选';
  551. $box = "radio";
  552. }
  553. elseif ($vote_type == 1) {
  554. $svote_type = '多选';
  555. $box = "checkbox";
  556. }
  557. else {
  558. $svote_type = '最多选两项';
  559. $box = "checkbox";
  560. }
  561. $index = $this->mVoteIndex + 1;
  562. $str = "<div class=\"vote\">
  563. <div class=\"vote_pro\">
  564. <div class=\"vote_question\">投票{$index}: {$title}</div>
  565. <div class=\"vote_type\" data-type=\"{$vote_type}\">/{$svote_type}</div>
  566. </div>
  567. <div class=\"vote_options\">";
  568. foreach ($options as $val)
  569. {
  570. $key = $val['id'];
  571. $option = $val['text'];
  572. $soption = "<div class=\"vote_option\">
  573. <label>
  574. <input type=\"{$box}\" value=\"{$key}\" class=\"check\" name=\"vote{$this->mVoteIndex}\">
  575. <span class=\"label\">{$option}</span>
  576. </label>
  577. </div>";
  578. $str .= $soption;
  579. }
  580. $str .= '</div>';
  581. $str .= '</div>';
  582. echo $str;
  583. }
  584. private function show_vote_result($item)
  585. {
  586. if(empty($item['data'])) return false;
  587. $options = json_decode($item['data'],true);
  588. if(empty($options)) return false;
  589. $title = $item['title'];
  590. $reserved = $item['reserved'];
  591. $kv = preg_split('/=/',$reserved);
  592. if(!empty($kv))
  593. {
  594. $k = trim($kv[0]);
  595. $v = trim($kv[1]);
  596. if(!empty($k) && $k == 'vote_type') {
  597. $vote_type = $v;
  598. }
  599. }
  600. $vote_type = intval($vote_type);
  601. if($vote_type == 0) {
  602. $svote_type = '单选';
  603. }
  604. elseif ($vote_type == 1) {
  605. $svote_type = '多选';
  606. }
  607. else {
  608. $svote_type = '最多选两项';
  609. }
  610. $str = "<div class=\"vote\">
  611. <div class=\"vote_pro\">
  612. <div class=\"vote_question\">{$title}</div>
  613. <div class=\"vote_type\" data-type=\"{$vote_type}\">/{$svote_type}</div>
  614. </div>";
  615. $str .= '<div class="results">';
  616. $vote_result = $this->special->vote_result();
  617. $result = $vote_result[$this->mVoteIndex];
  618. $total = 0;
  619. foreach ($result as $key => $val) {
  620. $total += $val;
  621. }
  622. foreach ($options as $val)
  623. {
  624. $id = $val['id'];
  625. $title = $val['text'];
  626. $count = $result[$id];
  627. if($total > 0) {
  628. $per = intval($count * 100 / $total + 0.5);
  629. } else {
  630. $per = 0;
  631. }
  632. $option = "<div class=\"result\">
  633. <div class=\"result_option\">{$title}</div>
  634. <div class=\"status\">
  635. <div class=\"status_line\">
  636. <div class=\"stat\"></div>
  637. <div class=\"status_bg\"></div>
  638. </div>
  639. <span class=\"num\">{$count}票</span>
  640. <span class=\"percentage\">{$per}%</span>
  641. </div>
  642. </div>";
  643. $str .= $option;
  644. }
  645. $str .= '</div>';
  646. $str .= '</div>';
  647. echo $str;
  648. }
  649. private function show_text($item)
  650. {
  651. $data = $item['data'];
  652. echo "<article>{$data}</article>";
  653. }
  654. private function show_image($item)
  655. {
  656. $image = $item['show_data'];
  657. $type = $item['type'];
  658. $title = $item['title'];
  659. if($type == 'url')
  660. {
  661. $url = $item['data'];
  662. $str = "<div class=\"thumbnail\">
  663. <a href=\"{$url}\">
  664. <div class=\"thumbnail_image\">
  665. <img src=\"/data/resource/mobile/ugc/images/picLazy_load.png\" data-original=\"{$image}\" alt=\"熊猫美妆\">
  666. </div>
  667. </a>
  668. <div class=\"thumbnail_pro\">{$title}</div>
  669. </div>";
  670. }
  671. elseif($type == 'video')
  672. {
  673. $video = $item['data'];
  674. $str = "<div class=\"thumbnail\">
  675. <div class=\"video_box\" data-poster=\"{$image}\" data-src=\"{$video}\"></div>
  676. <div class=\"thumbnail_pro\">$title</div>
  677. </div>";
  678. }
  679. else
  680. {
  681. $str = "<div class=\"thumbnail\">
  682. <div class=\"thumbnail_image\">
  683. <img src=\"/data/resource/mobile/ugc/images/picLazy_load.png\" data-original=\"{$image}\" alt=\"熊猫美妆\">
  684. </div>
  685. <div class=\"thumbnail_pro\">{$title}</div>
  686. </div>";
  687. }
  688. echo $str;
  689. }
  690. public function show_comments()
  691. {
  692. if($this->preview()) return;
  693. $supporter = new ugc\special_support($this->special_id(),0);
  694. $supported = $supporter->supported();
  695. $str = "<div class=\"bottom_flex\">
  696. <div class=\"msg_btn\">我来说两句</div>";
  697. if($supported) {
  698. $str .= "<a href=\"javascript:void(0)\" class=\"like_btn active\">
  699. <span class=\"like_icon_null like_icon\"></span>
  700. </a>";
  701. } else {
  702. $str .= "<a href=\"javascript:void(0)\" class=\"like_btn active\">
  703. <span class=\"like_icon_null\"></span>
  704. </a>";
  705. }
  706. $str .= "<a href=\"javascript:void(0)\" class=\"comment_label\">
  707. <span class=\"msg_icon_null\"></span>";
  708. $comments = $this->special->comments();
  709. if($comments > 0) {
  710. $str .= "<span class=\"superscript\">{$comments}</span>";
  711. }
  712. $str .= "</a>";
  713. if(session_helper::isapp())
  714. {
  715. $str .= "<a href=\"javascript:void(0)\">
  716. <span class=\"share_icon_null\"></span>
  717. </a>
  718. </div>";
  719. } else {
  720. $str .= "<a href=\" \" class=\"open_app_btn\">打开APP</a></div>";
  721. }
  722. echo $str;
  723. }
  724. private function show_appreciate()
  725. {
  726. $fappreciate = $this->special->has_appreciate();
  727. if($fappreciate == false) return;
  728. $nums = $this->special->appreciates();
  729. $header = "<div class=\"appreciate\">
  730. <p class=\"appreciate_pro\">如果你喜欢该文章,请随意打赏。</p >
  731. <div class=\"appreciate_box\">
  732. <div class=\"btn_appreciate\">";
  733. if($nums > 0)
  734. {
  735. $header .= "打赏<span class=\"appreciate_num\"> | 已有{$nums}次打赏</span>";
  736. $header .= "</div>
  737. </div>
  738. <div class=\"appreciate_users\">";
  739. $avatars = $this->appreciate_avatars($this->special_id(),20);
  740. $sAvatars = '';
  741. foreach ($avatars as $avatar) {
  742. $sAvatars .= "<img src=\"{$avatar}\">";
  743. }
  744. $header .= $sAvatars;
  745. $header .= '</div>';
  746. if($nums > 20) {
  747. $header .= '<div class="appreciate_label">....超20人打赏</div>';
  748. }
  749. }
  750. else {
  751. $header .= "打赏";
  752. $header .= "</div>";
  753. $header .= "</div>";
  754. }
  755. $header .='</div>';
  756. echo $header;
  757. }
  758. private function appreciate_avatars($special_id,$count)
  759. {
  760. $mod = Model('appreciate');
  761. $items = $mod->getTopAppreciate($special_id,'*',$count);
  762. $uids = [];
  763. foreach ($items as $item) {
  764. $uid = intval($item['member_id']);
  765. $uids[] = $uid;
  766. }
  767. $avatars = [];
  768. if(!empty($uids))
  769. {
  770. $mod_member = Model('member');
  771. $mInfos = $mod_member->getMemberList(array('member_id' => ['in',$uids]));
  772. foreach ($mInfos as $info) {
  773. $minfo = new member_info($info);
  774. $avatar = $minfo->avatar();
  775. $avatars[] = $avatar;
  776. }
  777. }
  778. return $avatars;
  779. }
  780. private function show_answer_page()
  781. {
  782. $specialid = $this->special_id();
  783. if($specialid <= 0) return;
  784. $special = $this->special;
  785. if($special->has_question()) {
  786. $answer_page = true;
  787. }
  788. if(isset($answer_page) && $answer_page == true)
  789. {
  790. $mod_answer = Model('ugc_answer');
  791. $count = $mod_answer->counts($specialid);
  792. if($count > 0) {
  793. $url = BASE_SITE_URL . "/mobile/index.php?act=member_ugc&op=answer_page&client_type=wap&special_id={$specialid}";
  794. $str = "<p class=\"look_question_result\" style=\"margin-top:40px; color: #FF4E4E; line-height: 70px; text-align: center;font-size: 26px;\"><a href=\"{$url}\">查看答题情况>></a></p >";
  795. echo $str;
  796. return;
  797. }
  798. }
  799. $rule = $this->special->submit_rule();
  800. if(!empty($rule))
  801. {
  802. $type_sn = $rule->type_sn();
  803. if(!empty($type_sn)) {
  804. $url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=detail&client_type=wap&type_sn={$type_sn}";
  805. $str = "<p class=\"look_question_result\" style=\"margin-top:40px; color: #FF4E4E; line-height: 70px; text-align: center;font-size: 26px;\"><a href=\"{$url}\">查看红包领取情况>></a></p >";
  806. echo $str;
  807. return;
  808. }
  809. }
  810. }
  811. public function show_relation()
  812. {
  813. if($this->mAuthorRelation == 0) {
  814. echo '<div class="focus">+关注</div>';
  815. }
  816. elseif($this->mAuthorRelation == 1) {
  817. echo '<div class="focus active">已关注</div>';
  818. }
  819. else {
  820. }
  821. }
  822. }