index.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <?php
  2. /**
  3. * cms首页
  4. *
  5. *
  6. *
  7. */
  8. //use Shopnc\Tpl;
  9. defined('InShopNC') or exit('Access Invalid!');
  10. require_once(BASE_ROOT_PATH . '/helper/goods_helper.php');
  11. require_once(BASE_ROOT_PATH . '/helper/special_helper.php');
  12. require_once(BASE_ROOT_PATH . '/helper/index_tab.php');
  13. require_once(BASE_ROOT_PATH . '/helper/util_helper.php');
  14. require_once(BASE_ROOT_PATH . '/helper/third_author/wxauthor.php');
  15. require_once(BASE_ROOT_PATH . '/mobile/control/special.php');
  16. require_once (BASE_ROOT_PATH . '/helper/third_author/wxauthor.php');
  17. require_once(BASE_ROOT_PATH . '/helper/session_helper.php');
  18. class indexControl extends specialControl
  19. {
  20. const HomeSpecialID = 0;
  21. public function __construct()
  22. {
  23. parent::__construct();
  24. }
  25. public function tabsOp()
  26. {
  27. $tabs = index_tab::instance()->tabs();
  28. return self::outsuccess(array('tabs' => $tabs));
  29. }
  30. public function splashOp()
  31. {
  32. $sig = $_GET['sig'];
  33. $ret = $this->get_special($this->splash_id());
  34. if(empty($ret['special_list'])) {
  35. return self::outsuccess(null);
  36. }
  37. $block = $ret['special_list'][0];
  38. if(empty($block) || empty($block['items'])) {
  39. return self::outsuccess(null);
  40. }
  41. $image = $block['items'][0]['image'];
  42. if(empty($sig) || $sig != md5($image)) {
  43. return self::outsuccess(array('sig' => md5($image),'url' => $image));
  44. } else {
  45. return self::outsuccess(null);
  46. }
  47. }
  48. private function splash_id()
  49. {
  50. if(is_publish()) {
  51. return 144;
  52. } else {
  53. return 38;
  54. }
  55. }
  56. public function inoherbOp()
  57. {
  58. fcgi_header('location:http://p.lrlz.com/hfive/inoherb/index.html?2');
  59. // if(session_helper::need_wechat_author())
  60. // {
  61. // $author = new thrid_author\wxauthor();
  62. // $url = "http://p.lrlz.com/hfive/inoherb/index.html?2";
  63. // $author->enter($url);
  64. // return;
  65. // }
  66. // else {
  67. // fcgi_header('location:http://p.lrlz.com/hfive/inoherb/index.html?2');
  68. // }
  69. }
  70. public function memberOp()
  71. {
  72. $relay_id = $_GET['member_id'];
  73. if(empty($relay_id)) {
  74. return self::outerr(errcode::ErrParamter);
  75. }
  76. if(session_helper::need_wechat_author()) {
  77. $author = new thrid_author\wxauthor();
  78. $url = BASE_SITE_URL . "/mobile/index.php?act=index&op=member&member_id={$relay_id}";
  79. $author->enter($url);
  80. return;
  81. }
  82. $relay_id = urldecode($relay_id);
  83. $relay_id = intval(util::decrypt_data($relay_id));
  84. if(session_helper::logined())
  85. {
  86. $member_id = $_SESSION['member_id'];
  87. $relateion = new \relation\mem_relation($member_id);
  88. $isfriend = $relateion->is_follower($relay_id);
  89. $minfo = new member_info($relay_id);
  90. return self::outsuccess(array('info' => $minfo,'is_friend' => $isfriend),"member/index",'wap');
  91. }
  92. else
  93. {
  94. $type_sn = account_helper::invite_bonus($relay_id);
  95. if($type_sn == false) {
  96. return self::outerr(errcode::ErrBonus,"生成邀请红包失败.");
  97. }
  98. else
  99. {
  100. $ref_url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=open&client_type=wap&type_sn={$type_sn}&relay_id={$relay_id}";
  101. fcgi_header("location:{$ref_url}");
  102. return;
  103. }
  104. }
  105. }
  106. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  107. public function homeOp()
  108. {
  109. if($this->cur_page == 1) {
  110. $start = microtime(true);
  111. $ret = $this->get_special(self::HomeSpecialID);
  112. $ret['mobile_page'] = mobile_page(2);
  113. perfor_period("home",$start,"index");
  114. return self::outsuccess($ret,"shop/home");
  115. }
  116. else
  117. {
  118. $goods_ids = activity_helper::recomoned_goodsids();
  119. $ret = array_chunk($goods_ids,$this->page_size());
  120. $pages = count($ret);
  121. $page_no = $pages >= $this->page_no() ? $this->page_no() : $pages;
  122. $goods_ids = $ret[$page_no - 1];
  123. $helper = new goods_helper();
  124. $ret = $helper->online_summary($goods_ids,$other_goods);
  125. $blocks = [];
  126. $blocks[] = special_formater::format_goods($goods_ids,"热门推荐",$ret['sort_summary']);
  127. self::outsuccess(array('special_list' => $blocks,
  128. 'summary' => $ret['summary'],
  129. 'groupbuy' => $ret['groupbuy'],
  130. 'limitime' => $ret['limitime'],
  131. 'bundling' => $ret['bundling'],
  132. 'mobile_page' => mobile_page($pages + 1)));
  133. }
  134. }
  135. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  136. private function old_homeid()
  137. {
  138. if(is_publish()) {
  139. return 61;
  140. } else {
  141. return 36;
  142. }
  143. }
  144. public function indexOp()
  145. {
  146. $mb_special = Model('mb_special');
  147. $special_list = $mb_special->getMbSpecialItemUsableListByIDEx($this->old_homeid());
  148. $sale_list = $this->sale_list();
  149. return self::outsuccess(array('special_list' => $special_list, 'sale_list' => $sale_list));
  150. }
  151. public function indexexOp()
  152. {
  153. $helper = new special_formater($this->old_homeid());
  154. $ret = $helper->format($goods_ids);
  155. $sale_list = $this->sale_list();
  156. $helper = new goods_helper();
  157. $goods_list = $helper->get_infos($goods_ids);
  158. return self::outsuccess(array('special_list' => $ret,'goods_list' =>$goods_list, 'sale_list' => $sale_list));
  159. }
  160. /**
  161. * 专题
  162. */
  163. public function specialOp()
  164. {
  165. if(!isset($_GET['special_id']) || empty($_GET['special_id'])) {
  166. return self::outerr(errcode::ErrParamter);
  167. }
  168. $mb_special = Model('mb_special');
  169. $special_list = $mb_special->getMbSpecialItemUsableListByIDEx($_GET['special_id']);
  170. return self::outsuccess(array('special_list' => $special_list));
  171. }
  172. public function specialexOp()
  173. {
  174. if(!isset($_GET['special_id']) || empty($_GET['special_id'])) {
  175. return self::outerr(errcode::ErrParamter);
  176. }
  177. $special_id = intval($_GET['special_id']);
  178. $helper = new special_formater($special_id);
  179. $ret = $helper->format($goods_ids);
  180. $mod_goods = Model('goods');
  181. $items = $mod_goods->field('goods_commonid')->where(array('goods_id' => array('in',$goods_ids)))->limit(false)->select();
  182. $goods_commonids = array();
  183. foreach ($items as $val) {
  184. array_push($goods_commonids,intval($val['goods_commonid']));
  185. }
  186. $helper = new goods_helper();
  187. $goods_list = $helper->get_distinct($goods_commonids);
  188. return self::outsuccess(array('special_list' => $ret,'goods_list' =>$goods_list));
  189. }
  190. static private function validate_type($type, $data)
  191. {
  192. $types = array('keyword', 'special', 'goods', 'url');
  193. if (empty($type) || !in_array($type, $types)) {
  194. return array('code' => errcode::ErrSpecial, 'msg' => '错误的参数.');
  195. }
  196. $validator = new Validator();
  197. if ($type === 'special') {
  198. $validator->setValidate(Validator::verify_number($data, 'special data error.'));
  199. } elseif ($type === 'keyword') {
  200. } elseif ($type === 'goods') {
  201. } else {
  202. }
  203. $err = $validator->validate();
  204. if ($err != '') {
  205. return array('code' => errcode::ErrSpecial,'msg' => $err);
  206. } else {
  207. return true;
  208. }
  209. }
  210. public function advOp()
  211. {
  212. $type = $_GET['type'];
  213. $data = $_GET['data'];
  214. $ret = self::validate_type($type, $data);
  215. if ($ret != true) {
  216. return self::outerr($ret['code'],$ret['msg']);
  217. }
  218. if ($type === 'special') {
  219. $mb_special = Model('mb_special');
  220. $ret = $mb_special->getMbSpecialItemUsableListByID($data);
  221. } elseif ($type === 'keyword') {
  222. } elseif ($type === 'goods') {
  223. } else {
  224. }
  225. self::outsuccess($ret);
  226. }
  227. /**
  228. * 获取打赏接口数据
  229. */
  230. private function sale_list()
  231. {
  232. $prefix = 'mb_salelist';
  233. $codeid = 122;
  234. $ret = rcache($codeid, $prefix);
  235. if (empty($ret))
  236. {
  237. $web_code = Model('web_code');
  238. $result = $web_code->where(array('code_id' => 122, 'web_id' => 122))->select();
  239. if (!empty($result)) {
  240. $top = $result[0];
  241. $tops = unserialize($top['code_info']);
  242. }
  243. if (empty($tops)) return array();
  244. $ret = array();
  245. foreach ($tops as $id => $val) {
  246. $item = array();
  247. $item['id'] = $id;
  248. $img = $val['img_name'];
  249. if (!empty($img)) {
  250. $item['image'] = UPLOAD_SITE_URL . DS . $img;
  251. $item['title'] = $val['recommend']['name'];
  252. array_push($ret, $item);
  253. }
  254. }
  255. wcache($codeid, array("salelist" => serialize($ret)), $prefix);
  256. } else {
  257. $ret = unserialize($ret['salelist']);
  258. }
  259. return $ret;
  260. }
  261. public function sale_listOp()
  262. {
  263. $prefix = 'mb_salelist_content';
  264. $codeid = 122;
  265. $ret = rcache($codeid, $prefix);
  266. if (empty($ret))
  267. {
  268. $web_code = Model('web_code');
  269. $result = $web_code->where(array('code_id' => 122, 'web_id' => 122))->select();
  270. if (!empty($result)) {
  271. $top = $result[0];
  272. $tops = unserialize($top['code_info']);
  273. }
  274. if (empty($tops)) return NULL;
  275. $ret = array();
  276. foreach ($tops as $id => $val) {
  277. $item['id'] = $id;
  278. $item['image'] = UPLOAD_SITE_URL . DS . $val['img_name'];
  279. $item['title'] = $val['recommend']['name'];
  280. $goods_list = $val['goods_list'];
  281. $item['goods_list'] = array();
  282. foreach ($goods_list as $goods_val) {
  283. $goods_val['goods_pic'] = UPLOAD_SITE_URL . DS . $goods_val['goods_pic'];
  284. array_push($item['goods_list'], $goods_val);
  285. }
  286. array_push($ret, $item);
  287. }
  288. wcache($codeid, array("salelist_content" => serialize($ret)), $prefix);
  289. } else {
  290. $ret = unserialize($ret['salelist_content']);
  291. }
  292. self::outsuccess(array('sale_list' => $ret));
  293. }
  294. /**
  295. * android客户端版本号
  296. */
  297. public function apk_versionOp()
  298. {
  299. $version = C('mobile_apk_version');
  300. $url = C('mobile_apk');
  301. if (empty($version)) {
  302. $version = '';
  303. }
  304. if (empty($url)) {
  305. $url = '';
  306. }
  307. return self::outsuccess(array('version' => $version, 'url' => $url));
  308. }
  309. public function show_goodsOp()
  310. {
  311. $goods_ids = activity_helper::recomoned_goodsids();
  312. $ret = array_chunk($goods_ids,$this->page_size());
  313. $pages = count($ret);
  314. $page_no = $pages >= $this->page_no() ? $this->page_no() : $pages;
  315. $goods_ids = $ret[$page_no - 1];
  316. $helper = new goods_helper();
  317. $goods_list = $helper->get_infos($goods_ids);
  318. self::outsuccess(array('goods_list' => $goods_list, 'mobile_page' => mobile_page($pages)));
  319. }
  320. }