webpush.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 2017/10/31
  6. * Time: 下午4:11
  7. */
  8. defined('InShopNC') or exit('Access Invalid!');
  9. require_once (BASE_ROOT_PATH . '/helper/schema_helper.php');
  10. class webpushControl extends mobileHomeControl
  11. {
  12. public function __construct()
  13. {
  14. parent::__construct();
  15. }
  16. public function fcodeOp()
  17. {
  18. $fc_id = intval($_GET['fc_id']);
  19. return self::outsuccess(['tpl' => new tpl_wpush_fcode($fc_id,$this->price_calcer())],"webpush/fcode",'wap');
  20. }
  21. public function updateOp()
  22. {
  23. return self::outsuccess(['tpl' => new tpl_wpush_update()],"webpush/fcode",'wap');
  24. }
  25. public function bonusOp()
  26. {
  27. }
  28. }
  29. class tpl_wpush_fcode
  30. {
  31. private $mFcode;
  32. private $mPriceCalcer;
  33. public function __construct($fc_id,bonus\IPriceCalculate $price_calcer)
  34. {
  35. $this->mPriceCalcer = $price_calcer;
  36. $mod_fcode = Model('goods_fcode');
  37. $this->mFcode = $mod_fcode->getGoodsFCode(['fc_id' => $fc_id],true);
  38. }
  39. private function schema() {
  40. $common_id = $this->mFcode['goods_commonid'];
  41. $batch_code = $this->mFcode['batch_code'];
  42. $mobile = $this->mFcode['mobile'];
  43. $url = BASE_SITE_URL . "/mobile/index.php?act=fcode&op=index&common_id={$common_id}&batch_code={$batch_code}&mobile={$mobile}";
  44. $schema = schema_helper::openurl("购物首单礼",$url);
  45. return $schema;
  46. }
  47. private function summary()
  48. {
  49. $common_id = intval($this->mFcode['goods_commonid']);
  50. $helper = new goods_helper($this->mPriceCalcer,false);
  51. $gids = commonid_helper::instance()->goods_ids($common_id);
  52. $ret = $helper->get_spu($common_id,$gids[0],$err);
  53. $summarys = $ret['summary'];
  54. foreach ($summarys as $summary)
  55. {
  56. if($common_id == $summary['goods_commonid'])
  57. return $summary;
  58. }
  59. return false;
  60. }
  61. public function show()
  62. {
  63. $schema = $this->schema();
  64. $summary = $this->summary();
  65. $price = intval($summary['goods_price'] * 100 + 0.5) / 100;
  66. $marketprice = intval($summary['goods_marketprice'] * 100 + 0.5) / 100;
  67. $str = "<div class=\"push_content\">
  68. <a href=\"{$schema}\" class=\"schema_link\">
  69. <p class=\"push_label\">恭喜您获得新客专享礼</p>
  70. <h3 class=\"push_title\">{$summary['goods_mobile_name']}</h3>
  71. <div class=\"goods_img\">
  72. <img src=\"{$summary['goods_image_url']}\" class=\"img\">
  73. <div class=\"label\">
  74. <p class=\"sale_price\">{$price}元购</p>
  75. <p class=\"original_price\"><span>天猫价{$marketprice}</span></p>
  76. </div>
  77. </div>
  78. <div class=\"btn\"><span class=\"look_btn\">查看详情</span></div>
  79. </a>
  80. </div>";
  81. return $str;
  82. }
  83. }
  84. class tpl_wpush_update
  85. {
  86. public function __construct()
  87. {
  88. }
  89. public function show()
  90. {
  91. $head_img = RESOURCE_SITE_URL . "/mobile/push/update/head_img.png";
  92. echo "<div class=\"push_content\">
  93. <a href=\" \" class=\"schema_link\">
  94. <div class=\"head_img\">
  95. <img src=\"{$head_img}\" class=\"img\">
  96. </div>
  97. <div class=\"push_title t_center\">升级到新版本</div>";
  98. echo "<div class=\"updata_focus\">";
  99. $tips = $this->tips();
  100. if(count($tips) == 1){
  101. echo "<p>{$tips[0]}</p >";
  102. }else{
  103. $i = 1;
  104. foreach ($tips as $tip) {
  105. echo "<p>{$i}.{$tip}</p >";
  106. ++$i;
  107. }
  108. }
  109. echo "</div>
  110. <div class=\"btn updata_btn\">
  111. <span class=\"look_btn\">立即升级</span>
  112. </div>
  113. </a>
  114. <span class=\"close_btn\"><img src=\"" . RESOURCE_SITE_URL . "/mobile/push/fcode/close.png\" class=\"img\"></span>
  115. </div>";
  116. }
  117. private function tips()
  118. {
  119. $tips = $GLOBALS['setting_config']['mobile_update_tips'];
  120. $artips = explode('#',$tips);
  121. return $artips;
  122. }
  123. }