special.php 30 KB

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