123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- <?php
- /**
- * Created by PhpStorm.
- * User: stanley-king
- * Date: 2017/6/13
- * Time: 下午3:51
- */
- use bonus\account;
- defined('InShopNC') or exit('Access Invalid!');
- require_once(BASE_ROOT_PATH . '/helper/goods_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/special_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/index_tab.php');
- require_once(BASE_ROOT_PATH . '/helper/util_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/third_author/wxauthor.php');
- require_once(BASE_ROOT_PATH . '/mobile/control/special.php');
- require_once(BASE_ROOT_PATH . '/helper/third_author/wxauthor.php');
- require_once(BASE_ROOT_PATH . '/helper/session_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/third_author/signaturer.php');
- require_once(BASE_ROOT_PATH . '/helper/bonus_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/url_helper.php');
- class mshopControl extends specialControl
- {
- public function __construct() {
- parent::__construct();
- }
- public function indexOp()
- {
- $this->topup();
- if(session_helper::need_wechat_author())
- {
- $url = BASE_SITE_URL . "/mobile/index.php?act=mshop&op=index";
- $author = new thrid_author\wxauthor();
- $url = $author->enter($url);
- } else {
- $url = BASE_SITE_URL . "/mshop/";
- }
- Log::record("url={$url}",Log::DEBUG);
- return self::outsuccess(['direct_uri' => $url],"redirect");
- }
- public function authorOp()
- {
- $url = $_GET['url'];
- $msg = "跳转的地址不能为空.";
- if(empty($url)) {
- return self::outerr(errcode::ErrParamter,$msg);
- }
- $url = urldecode($url);
- if(empty($url)) {
- return self::outerr(errcode::ErrParamter,$msg);
- }
- if(session_helper::need_wechat_author())
- {
- $author = new thrid_author\wxauthor();
- $url = $author->enter($url);
- return self::outsuccess(['direct_uri' => $url],"redirect");
- }
- else {
- return self::outsuccess(['direct_uri' => $url],"redirect");
- }
- }
- public function tabsOp()
- {
- return self::outsuccess(['tabs' => [['special_id' => 0,'name' => "首页"]]]);
- }
- public function goodsOp()
- {
- $this->topup();
- $goods_id = intval($_GET['goods_id']);
- $relay_id = session_helper::relay_id();
- fcgi_setcookie("relay_id","{$relay_id}",time() + 86400,'/',COOKIE_DOMAIN);
- if(session_helper::need_wechat_author())
- {
- $url = url_helper::mshop_goods($goods_id);
- $author = new thrid_author\wxauthor();
- $url = $author->enter($url);
- return self::outsuccess(['direct_uri' => $url],"redirect");
- }
- else
- {
- if($goods_id <= 0) {
- $url = BASE_SITE_URL . "/mshop";
- }
- else {
- $url = BASE_SITE_URL . "/mshop/goods_detail?goods_id={$goods_id}";
- }
- return self::outsuccess(['direct_uri' => $url],"redirect");
- }
- }
- public function specialOp()
- {
- $this->topup();
- $special_id = intval($_GET['special_id']);
- $title = $_GET['title'];
- $relay_id = session_helper::relay_id();
- fcgi_setcookie("relay_id","{$relay_id}",time() + 86400,'/',COOKIE_DOMAIN);
- if(session_helper::need_wechat_author())
- {
- $url = BASE_SITE_URL . "/mobile/index.php?act=mshop&op=special&special_id={$special_id}&title={$title}";
- $author = new thrid_author\wxauthor();
- $url = $author->enter($url);
- return self::outsuccess(['direct_uri' => $url],"redirect");
- }
- else
- {
- if($special_id <= 0) {
- $url = BASE_SITE_URL . "/mshop";
- }
- else
- {
- if(empty($title)) {
- $title = $this->special_name($special_id);
- $title = util::base64url_encode($title);
- }
- $url = BASE_SITE_URL . "/mshop/special?special_id={$special_id}&is_special=true&title={$title}";
- }
- return self::outsuccess(['direct_uri' => $url],"redirect");
- }
- }
- private function special_name($special_id)
- {
- $mod = Model('mb_special');
- $special = $mod->getMbSpecialList(['special_id' => $special_id]);
- if(empty($special)) return false;
- return $special[0]['special_desc'];
- }
- private function special_shareimg($special_id)
- {
- $defimg = RESOURCE_SITE_URL . "/mobile/defimg/panda.jpeg";
- $mod = Model('mb_special');
- $special = $mod->getMbSpecialList(['special_id' => $special_id]);
- if(empty($special)) return $defimg;
- $share_img = $special[0]['share_image'];
- if(empty($share_img)) {
- return $defimg;
- } else {
- return $share_img;
- }
- }
- public function signurlOp()
- {
- $sign_url = urldecode($_GET['sign_url']);
- if(empty($sign_url)) {
- return self::outerr(errcode::ErrParamter);
- }
- Log::record("signurl={$sign_url}",Log::DEBUG);
- $result = thrid_author\signaturer::instance()->signurl($sign_url);
- if($result == false) {
- return self::outerr(errcode::ErrAuthor);
- } else {
- return self::outsuccess($result);
- }
- }
- public function testOp()
- {
- return self::outsuccess("",'signature');
- }
- public function shareOp()
- {
- $type = $_GET['type'];
- $valid = intval($_GET['data']);
- if(empty($type) || $valid <= 0) {
- return self::outerr(errcode::ErrParamter);
- }
- $success = false;
- if($type == 'special')
- {
- $url = url_helper::mshop_special($valid);
- $title = $this->special_name($valid);
- if($title != false) {
- $success = true;
- $sub_title = "椰子 内买商城\n\n点击浏览";
- $img_url = $this->special_shareimg($valid);
- $mini_url = "pages/special/special?title={$title}&special_id={$valid}";
- } else {
- $mini_url = "pages/special/special?special_id={$valid}";
- }
- }
- elseif($type == 'goods')
- {
- $url = url_helper::mshop_goods($valid);
- $goods_info = $this->goods_share($valid);
- if ($goods_info != false)
- {
- $success = true;
- $name = $goods_info['goods_mobile_name'];
- if (session_helper::logined()) {
- $nick_name = session_helper::nickname();
- $title = "{$nick_name}向您推荐 {$name}";
- } else {
- $title = "熊猫美妆向您推荐{$name}";;
- }
- $tip = $goods_info['goods_jingle'];
- if(empty($title)) {
- $sub_title = "椰子 内买商城\n\n点击浏览";
- } else {
- $sub_title = "{$tip}\n\n点击浏览";
- }
- $img_url = $this->img_url($goods_info['goods_image'],$goods_info['store_id']);
- $mini_url = "pages/details/details?goods_id={$valid}";
- }
- }
- if($success == false) {
- return self::outerr(errcode::ErrParamter);
- } else {
- return self::outsuccess(['url' => $url,'title' => $title,'sub_title' => $sub_title,'img_url' => $img_url,'path' => $mini_url]);
- }
- }
- private function goods_share($goods_id)
- {
- $mod_goods = Model('goods');
- $info = $mod_goods->getGoodsInfoByID($goods_id);
- if(empty($info)) {
- return false;
- } else {
- return $info;
- }
- }
- private function img_url($value,$store_id)
- {
- return cthumb($value, 240, $store_id);
- }
- private function topup()
- {
- if(session_helper::logined()) {
- $pred = new account($_SESSION['member_id'],true);
- $pred->topup_bonus($_SESSION['member_mobile']);
- }
- }
- }
|