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/"; } 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']); } } }