assign('adimg', $rr['data']); // $this->assign('adimg_width', $rr['img_width']); // $this->assign('adimg_height', $rr['img_height']); // } $data_team["pt_status"]=2; $data_team["is_pt"]=1; $user = session('user'); $userids=$user["user_id"]; $this->assign('userids',$userids); /*调用拼团成功的人员 get 就不用后面的json*/ $data['storeId'] = $id; //后台是否开启了初始化 $init_data = getApiData_mini("/api/weshop/users/grade/vip/init/get",$data,$stoid); $isBool = 0; if ($init_data) { $init_data = json_decode($init_data, true); if ($init_data['code'] === 0 && $init_data['data']) { $isBool = $init_data['data']['isBool']; $this->assign('isBool', $init_data['data']['isBool']); } } $rm = M('store_module')->where('store_id', $id)->where('type', 0)->where('isdefault', 1)->find(); /*--更新会员的登录时间--*/ $user = session('user'); $rank_switch = tpCache('shopping.rank_switch',$id);//等级价格 $mz_switch = tpCache('shopping.is_beauty',$id);//美妆价格 $this->assign('rank_switch',$rank_switch); $this->assign('mz_switch',$mz_switch); if (!empty($rank_switch)){ //$this->assign('rank_field',$user['card_field']); $rand_end= empty($user['card_expiredate'])?0:strtotime($user['card_expiredate']); $card_field=$rand_end>time()?$user['card_field']:0; $this->assign('rank_field',$card_field); //----读取等级卡标签--- $all_card=get_plus_price_arr($id); if($all_card) { //--读取卡的分类--- $new_card_dd = null; foreach ($all_card as $kl => $vl) { if ($vl) { switch ($vl['CorrPrice']) { case "Price1": $new_card_dd['cardprice1'] = $vl['CardName']; break; case "Price2": $new_card_dd['cardprice2'] = $vl['CardName']; break; case "Price3": $new_card_dd['cardprice3'] = $vl['CardName']; break; } } } $card_label = $new_card_dd[$card_field]; $this->assign("all_card", $all_card); $len = mb_strlen($card_label, "utf-8"); if ($len > 4) $card_label = mb_substr($card_label, 0, 4, "utf-8"); $this->assign('card_label', $card_label); } } if (!empty($mz_switch)){ $this->assign('mz_vip',$user['is_mzvip']); } //APP $getylpres=getylapp_res($id,'1'); if ($getylpres) { $this->assign('ylpres',$getylpres); } //是否关闭免费使用优惠券 $switch = tpCache('shopping.switch_list',getMobileStoId());//获取开关json $switch=json_decode($switch,true); $is_closecoupon=$switch['is_closecoupon']; $this->assign('is_closecoupon', $is_closecoupon); //是否缴费 $isopen=0; //先判断缴费记录是否有该商家的记录 $rss=M('store_module_endtime')->where('store_id='.$id)->where('type',0)->find(); if($rss){ if($rss['end_time']>time()) $isopen=1; }else { if ($rm) { $tt=C('m_end_time'); if($tt>time()) $isopen=1; } } if($isopen==1){ $fid=$rm['from_id']; if($fid){ $ru=M('store_renew_module')->where('store_id='.$id)->where('module_id',$fid)->find(); if($ru){ if($ru['end_time']==0){} else{ if($ru['end_time']assign('p', $p); $this->assign('title', $title); $this->assign('descr', $descr); $this->assign('bk', $bk); $this->assign('isright', $rm['isright']); return $this->fetch('template', $id,0); } else { $t=time(); //新品上市 $new_goods = M('goods') ->where(['store_id'=>$id,'is_mainshow'=>1]) ->where("is_new=1 and is_on_sale=1 and on_time<".$t." and (down_time>".$t." or down_time=0 or down_time='')") ->field('goods_id,goods_name,original_img,cardprice1,cardprice2,cardprice3,mz_price,prom_type,shop_price,market_price') ->order("sort")->limit(9) ->cache("new_goods_" . getMobileStoId(), TPSHOP_CACHE_TIME)->select(); $new_goods_count = count($new_goods); $this->assign('new_goods_count', $new_goods_count); $this->assign('new_goods', $new_goods); //天天拼单 $fsql = "select g.goods_id,g.goods_name,g.original_img,g.prom_type,g.shop_price,g.market_price,(case when ".$t." < f.start_time then 1 else 0 end) as isyure,f.kttype,f.ct_num,f.price as tuanprice,f.goods_num,f.title,f.buy_num from __PREFIX__goods as g inner join __PREFIX__teamlist as f on g.goods_id = f.goods_id where g.store_id=" . $id . " and f.show_time<=".$t." and f.end_time>=".$t." and g.on_time<".$t." and (g.down_time>".$t." or g.down_time=0 or g.down_time='') and g.is_on_sale=1 and g.is_mainshow=1 and f.is_end=0 and f.is_show=1 order by f.ordid limit 9 "; $team_goods = Db::query($fsql); mlog("index:".$fsql,"index/".$id); $this->assign('team_goods', $team_goods); //拼团成人员功的数据 $team_sql = "SELECT a.user_id,b.nickname,b.head_pic FROM wxd_order a left join wxd_users b on a.user_id=b.user_id WHERE a.store_id = $id and a.pt_status = 2 and a.pt_prom_id>0 and a.pay_time>0 and a.pt_prom_id>0 and a.pay_time>0 order by a.order_id desc LIMIT 0,6 "; $team_user = Db::query($team_sql); $this->assign('team_user', $team_user); //倒计时 $fsql = "select g.goods_id,g.goods_name,g.original_img,g.prom_type,g.shop_price,g.market_price,(case when ".$t." < f.start_time then 1 else 0 end) as isyure,f.goods_num,f.buy_num,f.title,f.price,f.start_time,f.end_time,f.show_time from __PREFIX__goods as g inner join __PREFIX__flash_sale as f on g.goods_id = f.goods_id where g.store_id=" . $id . " and f.show_time<=".$t." and f.end_time>=".$t." and g.on_time<".$t." and (g.down_time>".$t." or g.down_time=0 or g.down_time='' ) and g.is_on_sale=1 and g.is_mainshow=1 and f.is_end=0 order by f.ordid asc,f.id desc limit 9 "; $act_goods = Db::query($fsql); $act_goods_count = count($act_goods); $this->assign('act_goods_count', $act_goods_count); $this->assign('act_goods', $act_goods); //热销商品 $hot_goods = M('goods')->where(['store_id'=>$id,'is_mainshow'=>1]) ->where("is_hot=1 and is_on_sale=1 and on_time<".$t." and (down_time>".$t." or down_time=0)") ->field('goods_id,goods_name,original_img,cardprice1,cardprice2,cardprice3,mz_price,prom_type,shop_price,market_price') ->order('sort')->limit(9) ->cache("hot_goods_" . getMobileStoId(), TPSHOP_CACHE_TIME)->select();//首页热卖商品 $hot_goods_count = count($hot_goods); $this->assign('hot_goods_count', $hot_goods_count); $this->assign('hot_goods', $hot_goods); $this->assign('stoid', $id); upload_ylp_log('商城首页'); $goods_category_tree = M('goods_category')->where(array('store_id'=>$id,'parent_id'=>0,'is_show'=>1))->order('sort_order asc')->limit(0,5)->select(); if ($goods_category_tree) { $this->assign('service_class', $goods_category_tree); } return $this->fetch('', getMobileStoId()); } } /** * 分类列表显示 */ public function categoryList() { $id = getMobileStoId(); return $this->fetch('', getMobileStoId()); } /** * 模板列表 */ public function mobanlist() { $arr = glob("D:/wamp/www/svn_tpshop/mobile--html/*.html"); foreach ($arr as $key => $val) { $html = end(explode('/', $val)); echo "{$html}
"; } } /** * 商品列表页 */ public function goodsList() { $id = I('get.id', 0); // 当前分类id $lists = getCatGrandson($id); $this->assign('lists', $lists); return $this->fetch('', getMobileStoId()); } public function ajaxGetMore() { $p = I('p/d', 1); $stoid=getMobileStoId(); $t=time(); $favourite_goods = M('goods')->where("store_id=".$stoid." and is_recommend=1 and is_on_sale=1 and on_time<".$t." and (down_time>".$t." or down_time=0) and is_mainshow=1 ")->order('sort')->page($p, 10) ->field('goods_id,goods_name,original_img,cardprice1,cardprice2,cardprice3,mz_price,prom_type,shop_price,market_price,sales_sum') ->select();//首页推荐商品 $cout = M('goods')->where("store_id=".$stoid." and is_recommend=1 and is_on_sale=1 and on_time<".$t." and (down_time>".$t." or down_time=0) and is_mainshow=1 ")->count(); // foreach ($favourite_goods as $k => $v){ // if ($v['mz_price'] == 0) // $favourite_goods[$k]['mz_price'] = $v['shop_price']; // } if ($cout <= $p * 10) { $this->assign('mshow', 0); } else { $this->assign('mshow', 1); } $this->assign('favourite_goods', $favourite_goods); $user = session('user'); $card_field=$user['card_field']; $rank_switch = tpCache('shopping.rank_switch',getMobileStoId());//等级价格 $mz_switch = tpCache('shopping.is_beauty',getMobileStoId());//美妆价格 $this->assign('rank_switch',$rank_switch); $this->assign('mz_switch',$mz_switch); if($rank_switch ) { //----读取等级卡标签--- $all_card = get_plus_price_arr($stoid); if($all_card) { $new_card_dd = null; //读取卡的分类 foreach ($all_card as $kl => $vl) { if ($vl) { switch ($vl['CorrPrice']) { case "Price1": $new_card_dd['cardprice1'] = $vl['CardName']; break; case "Price2": $new_card_dd['cardprice2'] = $vl['CardName']; break; case "Price3": $new_card_dd['cardprice3'] = $vl['CardName']; break; } } } $this->assign("all_card", $all_card); if($card_field) { $card_label = $new_card_dd[$card_field]; $len = mb_strlen($card_label, "utf-8"); if ($len > 4) $card_label = mb_substr($card_label, 0, 4, "utf-8"); $this->assign('card_label', $card_label); } } } if (!empty($rank_switch)){ //$this->assign('rank_field',$user['card_field']); $rand_end= empty($user['card_expiredate'])?0:strtotime($user['card_expiredate']); $card_field=$rand_end>time()?$user['card_field']:0; $this->assign('rank_field',$card_field); } if (!empty($mz_switch)){ $this->assign('mz_vip',$user['is_mzvip']); } return $this->fetch('', getMobileStoId()); } //微信Jssdk 操作类 用分享朋友圈 JS public function ajaxGetWxConfig() { $askUrl = I('askUrl');//分享URL $weixin_config = M('wx_user')->where("store_id", getMobileStoId())->find(); //获取微信配置 if (empty($weixin_config)) { return ""; } $jssdk = new \app\mobile\logic\Jssdk($weixin_config['appid'], $weixin_config['appsecret']); $signPackage = $jssdk->GetSignPackage(urldecode($askUrl)); if ($signPackage) { $this->ajaxReturn($signPackage, 'JSON'); } else { return false; } } //微信Jssdk 操作类 用分享朋友圈 JS public function ajaxGetWxConfig_wxcard() { $weixin_config = M('wx_user')->where("store_id", getMobileStoId())->find(); //获取微信配置 $stoid_card=M('store_wxcard')->where(array('store_id'=>getMobileStoId(),'state'=>1))->find(); if ($stoid_card) { $getcardid = $stoid_card['card_id'];//分享URL $getcode = I('code');//手机号 $getopenid = I('openid');// $jssdk = new \app\mobile\logic\Jssdk($weixin_config['appid'], $weixin_config['appsecret']); $signPackage = $jssdk->getSignPackage_card($getcardid, $getcode, $getopenid); if ($signPackage) { $this->ajaxReturn($signPackage, 'JSON'); } else { return false; } }else { return false; } } public function issub() { if (session('?user')) { $r = M('wx_openlist')->where("wxopenid", session('user')['openid']) ->where("store_id", getMobileStoId())->find(); if ($r['issubscribe'] == 1) { return json(['code' => -1]); } else { $stoid= getMobileStoId(); $weixin_config = M('wx_user')->where('store_id=' . getMobileStoId())->field("appid,appsecret")->find(); //获取微信配置 if (empty($weixin_config)) { return json(['code' => -1]); } $access_token = m_get_access_token($weixin_config); mlog('关注开始2:','mobileindex/'.$stoid); $url=""; $return = M('wx_ewmlist')->where(array('store_id' => $stoid, 'scene_id' =>''))->find(); if (empty($return)) { if ($access_token) { //获取数据的地址(微信提供) $url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" . $access_token; //发送给微信服务器的数据 $jsonstr = '{"expire_seconds": 1800, "action_name": "QR_LIMIT_SCENE", "action_info": {"scene": {"scene_id": ""}}}'; $return = httpRequest($url, 'POST', $jsonstr); mlog('关注二维码返回:'.$return,'mobileindex/'.$stoid); $return = json_decode($return, 1); if (!empty($return['ticket'])) { $v['ticket'] = $return['ticket']; $v['store_id'] = $stoid; $v['scene_id'] = ''; $v['date'] = time(); $v['loadurl'] = $return['url']; M('wx_ewmlist')->add($v); $url="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=".$v['ticket']; mlog('关注二维码生成成功','mobileindex/'.$stoid); } else { mlog('关注二维码生成失败','mobileindex/'.$stoid); } }else{ mlog('关注access_token失败','mobileindex/'.$stoid); } }else{ $url="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=".$return['ticket']; } return json(['code' => 1, 'url' =>$url]); } } else { return json(['code' => -1]); } } }