Example #1
0
    }
    //首页推荐商品
    $product_list = M('Product')->getSelling('quantity>0 AND status=1 AND is_recommend = 1', '', '', 0, 4);
    //D('Product')->where('quantity>0 AND status=1 AND is_recommend = 1')->limit('4')->select();
    //首页推荐活动
    $active_list = D('Activity_recommend')->order("is_rec desc,ucount desc")->limit(4)->select();
    $activity = M('activity');
    foreach ($active_list as $k => $value) {
        $active_list[$k]["url"] = $activity->createUrl($value, $value['model'], '1');
        $active_list[$k]["image"] = getAttachmentUrl($value['image']);
    }
} else {
    if (empty($config['platform_mall_index_page'])) {
        pigcms_tips('请管理员在管理后台【系统设置】=》【站点配置】=》【平台商城配置】选取微页面', 'none');
    }
    //首页的微杂志
    $homePage = D('Wei_page')->where(array('page_id' => $config['platform_mall_index_page']))->find();
    if (empty($homePage)) {
        pigcms_tips('您访问的店铺没有首页', 'none');
    }
}
$imUrl = getImUrl($_SESSION['wap_user']['uid'], $store_id);
$is_have_activity = option('config.is_have_activity');
//分享配置 start
$share_conf = array('title' => option('config.site_name'), 'desc' => str_replace(array("\r", "\n"), array('', ''), option('config.seo_description')), 'link' => option('config.wap_site_url'), 'imgUrl' => option('config.site_logo'), 'type' => '', 'dataUrl' => '');
import('WechatShare');
$share = new WechatShare();
$shareData = $share->getSgin($share_conf);
//分享配置 end
include display('index');
echo ob_get_clean();
Example #2
0
 public function attention_store()
 {
     if (empty($this->user_session)) {
         $referer = url('account:collect_store');
         redirect(url('account:login', array('referer' => $referer)));
         exit;
     }
     // 基本参数设定
     $page = max(1, $_GET['page']);
     $limit = 10;
     $count = D('')->table(array('User_attention' => 'ua', 'Store' => 's'))->where("`ua`.`data_type` = '2' AND `ua`.`user_id` = '" . $this->user_session['uid'] . "' AND `ua`.`data_id` = `s`.`store_id`")->count("`ua`.`id`");
     $store_list = array();
     $pages = '';
     if ($count > 0) {
         $total_pages = ceil($count / $limit);
         $page = min($page, $total_pages);
         $offset = ($page - 1) * $limit;
         $product_model = M('Product');
         $store_list = D('')->table(array('User_attention' => 'ua', 'Store' => 's'))->where("`ua`.`data_type` = '2' AND `ua`.`user_id` = '" . $this->user_session['uid'] . "' AND `ua`.`data_id` = `s`.`store_id`")->order("`ua`.`id` DESC")->limit($offset . ',' . $limit)->select();
         foreach ($store_list as &$store) {
             if (empty($store['logo'])) {
                 $store['logo'] = getAttachmentUrl('images/default_shop_2.jpg', false);
             } else {
                 $store['logo'] = getAttachmentUrl($store['logo']);
             }
             //每个店铺获取 10个热销商品 10个新品
             // 店铺热销个产品
             $store['hot_list'] = $product_model->getSelling(array('store_id' => $store['store_id'], 'status' => 1), 'sales', 'desc', 0, 9);
             $store['hot_list_count'] = count($store['hot_list']);
             /*新品*/
             $store['news_list'] = $product_model->getSelling(array('store_id' => $store['store_id'], 'status' => 1), '', '', 0, 9);
             $store['news_list_count'] = count($store['news_list']);
             // 评论满意,一般,不满意数量,以及满意百分比
             $where = array();
             $where['type'] = 'STORE';
             $where['relation_id'] = $store['store_id'];
             $comment_type_count = M('Comment')->getCountList($where);
             $satisfaction_pre = '100%';
             if ($comment_type_count['total'] > 0) {
                 $satisfaction_pre = round($comment_type_count['t3'] / $comment_type_count['total'] * 100) . '%';
             }
             $store['satisfaction_pre'] = $satisfaction_pre;
             $store['imUrl'] = getImUrl($_SESSION['user']['uid'], $store['store_id']);
         }
         // 分页
         import('source.class.user_page');
         $user_page = new Page($count, $limit, $page);
         $pages = $user_page->show();
     }
     $this->assign('store_list', $store_list);
     $this->assign('pages', $pages);
     $this->display();
 }
Example #3
0
 public function index()
 {
     $product_model = M('Product');
     $this->product = $product_model->get(array('product_id' => $this->id, 'status' => 1));
     if (empty($this->product) || $this->product['status'] != 1) {
         pigcms_tips('未找到相应产品', 'none');
     }
     $this->product['wx_image'] = option('config.site_url') . '/source/qrcode.php?type=good&id=' . $this->product['product_id'];
     $is_preview = $_GET['is_preview'];
     if (!is_mobile() && $this->user_session && $this->product['uid'] == $this->user_session['uid']) {
         $this->assign('is_preview', $is_preview);
     }
     // 猜你喜欢,抽取方法为同类型的热销产品
     $condition_arr = array();
     //$condition_arr['category_id'] = $this->product['category_id'];
     $condition_arr['status'] = 1;
     $condition_arr['product_id'] = array('!=', $this->product['product_id']);
     $condition_arr['store_id'] = $this->product['store_id'];
     $similar_product_list = $product_model->getSelling($condition_arr, 'sort', 'desc', 0, 6);
     //->where($condition_arr)->order('sort desc')->limit('0, 6')->select();
     // 本店铺热卖产品,抽取方法本店铺同类型热买
     //$hot_product_list = $product_model->getSelling($condition_arr, 'sales', 'desc', 0, 6);
     // 检查商品库存情况
     $product_sku_list = array();
     $property_new_list = array();
     if ($this->product['has_property']) {
         //$product_sku_list = D('Product_sku')->field('`sku_id`, `properties`, `quantity`, `price`')->where(array('product_id' => $this->id, 'quantity'=>array('!=', '0')))->order('`sku_id` ASC')->select();
         $product_sku_list = D('Product_sku')->field('`sku_id`, `properties`, `quantity`, `price`')->where(array('product_id' => $this->id))->order('`sku_id` ASC')->select();
         $sku_price_arr = $sku_property_arr = array();
         foreach ($product_sku_list as $value) {
             $sku_price_arr[] = $value['price'];
             $sku_property_arr[$value['properties']] = true;
         }
         $property_list = D('')->field('`pp`.`pid`,`pp`.`name`')->table(array('Product_to_property' => 'ptp', 'Product_property' => 'pp'))->where("`ptp`.`product_id`='" . $this->id . "' AND `pp`.`pid`=`ptp`.`pid`")->order('`ptp`.`pigcms_id` ASC')->select();
         if (!empty($property_list)) {
             $property_value_list = D('')->field('`ppv`.`vid`,`ppv`.`value`,`ppv`.`pid`, `ppv`.`image`')->table(array('Product_to_property_value' => 'ptpv', 'Product_property_value' => 'ppv'))->where("`ptpv`.`product_id`='" . $this->id . "' AND `ppv`.`vid`=`ptpv`.`vid`")->order('`ptpv`.`pigcms_id` ASC')->select();
             if (!empty($property_value_list)) {
                 foreach ($property_value_list as $value) {
                     $propertyValueList[$value['pid']][] = array('vid' => $value['vid'], 'value' => $value['value'], 'image' => getAttachmentUrl($value['image']));
                 }
                 foreach ($property_list as $value) {
                     $property_new_list[] = array('pid' => $value['pid'], 'name' => $value['name'], 'image' => getAttachmentUrl($value['image']), 'values' => $propertyValueList[$value['pid']]);
                 }
                 if (count($property_new_list) == 1) {
                     foreach ($property_new_list[0]['values'] as $key => $value) {
                         $tmpKey = $property_new_list[0]['pid'] . ':' . $value['vid'];
                         if (empty($sku_property_arr[$tmpKey])) {
                             unset($property_new_list[0]['values'][$key]);
                         }
                     }
                 }
                 $returnArr['sku_list'] = $product_sku_list;
                 $returnArr['property_list'] = $property_new_list;
             }
         }
     }
     // 抽出店铺
     $store = M('Store')->getStore($this->product['store_id']);
     if (empty($store) || $store['status'] != 1) {
         pigcms_tips('未找到相应的店铺或已关闭', 'none');
     }
     $store_contact = array();
     if ($this->product['supplier_id']) {
         $store_contact = M('Store_contact')->get($this->product['supplier_id']);
     } else {
         $store_contact = M('Store_contact')->get($this->product['store_id']);
     }
     // 设置浏览记录,只记录产品的product_id,只记录最近5条记录
     $history_product_list = $_COOKIE['history_product_list'];
     if (empty($history_product_list)) {
         setcookie('history_product_list', $this->id, $_SERVER['REQUEST_TIME'] + 86400 * 365, '/');
     } else {
         $tmp_product_list = explode(',', $history_product_list);
         array_unshift($tmp_product_list, $this->id);
         $tmp_product_list = array_slice($tmp_product_list, 0, 6);
         $tmp_product_list = array_unique($tmp_product_list);
         $tmp_product_list = array_slice($tmp_product_list, 0, 5);
         $product_id_str = join(',', $tmp_product_list);
         setcookie('history_product_list', $product_id_str, $_SERVER['REQUEST_TIME'] + 86400 * 365, '/');
     }
     // 更改浏览次数
     M('Product')->analytics(array('product_id' => $this->id));
     // 主营分类
     $sale_category = M('Store')->getSaleCategory($this->product['store_id'], $this->product['uid']);
     // 检查是否已经收藏
     $user_collect = array('click' => 'userCollect', 'title' => '收藏');
     if (!empty($this->user_session)) {
         $collect = D('User_collect')->where(array('type' => 1, 'user_id' => $this->user_session['uid'], 'dataid' => $this->id))->find();
         if (!empty($collect)) {
             $user_collect = array('click' => 'cancelCollect', 'title' => '取消收藏');
         }
     }
     // 查看本产品是否参与活动
     $reward = '';
     if ($this->product['source_product_id'] == 0) {
         $reward = M('Reward')->getRewardByProduct($this->product);
     }
     // 查找产品的图片
     $product_image_list = M('Product_image')->getImages($this->id);
     // 查找评论TAG数量
     $where = array();
     $where['type'] = 'PRODUCT';
     $where['relation_id'] = $this->id;
     $comment_tag_count_list = M('Comment_tag')->getCountList($where);
     // 评论满意,一般,不满意数量,以及满意百分比
     $comment_type_count = M('Comment')->getCountList($where);
     $satisfaction_pre = '100%';
     if ($comment_type_count['total'] > 0) {
         $satisfaction_pre = round($comment_type_count['t3'] / $comment_type_count['total'] * 100) . '%';
     }
     $comment_type_count['satisfaction_pre'] = $satisfaction_pre;
     // 查找系统评论TAG
     $product_category_tag_list = array();
     $product_category = M('Product_category')->getCategory($this->product['category_id']);
     if (!empty($product_category['tag_str'])) {
         $where = array();
         $where['id'] = array('in', explode(',', $product_category['tag_str']));
         $product_category_tag_list = M('System_tag')->geNameList($where);
     }
     // 店铺信息下面的评论
     $where = array();
     $where = array();
     $where['type'] = 'PRODUCT';
     $where['relation_id'] = $this->id;
     $where['status'] = 1;
     $where['delete_flg'] = 0;
     $comment_list = M('Comment')->getSimiplyList($where);
     // 最新动态
     $sns_list = M('Financial_record')->sns();
     $this->assign('imUrl', getImUrl($_SESSION['user']['uid'], $store['store_id']));
     $this->assign('product', $this->product);
     $this->assign('product_image_list', $product_image_list);
     $this->assign('similar_product_list', $similar_product_list);
     $this->assign('comment_type_count', $comment_type_count);
     $this->assign('comment_tag_count_list', $comment_tag_count_list);
     $this->assign('product_category_tag_list', $product_category_tag_list);
     $this->assign('store', $store);
     $this->assign('store_contact', $store_contact);
     $this->assign('property_list', $property_new_list);
     $this->assign('product_sku_list', $product_sku_list);
     $this->assign('sale_category', $sale_category);
     $this->assign('user_collect', $user_collect);
     $this->assign('reward', $reward);
     $this->assign('sns_list', $sns_list);
     $this->assign('comment_list', $comment_list);
     $this->display();
 }
Example #4
0
 public function index()
 {
     $id = $_GET['id'];
     $page = max(1, $_GET['page']);
     $limit = 120;
     if (empty($id)) {
         pigcms_tips('缺少最基本的参数', 'none');
     }
     $store_model = M('Store');
     $store = $store_model->getStore($id);
     if (empty($store)) {
         pigcms_tips('未找到相应的店铺', 'none');
     }
     $is_preview = $_GET['is_preview'];
     if (!is_mobile() && $this->user_session && $id == $_SESSION['store']['store_id']) {
         $homePage = D('Wei_page')->where(array('is_home' => 1, 'store_id' => $_SESSION['store']['store_id']))->find();
         $this->assign('homePage', $homePage);
         $this->assign('is_preview', $is_preview);
     }
     $product_model = M('Product');
     // 抽出店铺产品
     $where = array();
     $where['store_id'] = $id;
     $where['status'] = 1;
     $count = $product_model->getSellingTotal($where);
     $product_list = array();
     $pages = '';
     $total_pages = ceil($count / $limit);
     if ($count > 0) {
         $page = min($page, $total_pages);
         $offset = ($page - 1) * $limit;
         $product_list = $product_model->getSelling($where, 'sort', 'desc', $offset, $limit);
         // 分页
         import('source.class.user_page');
         $user_page = new Page($count, $limit, $page);
         $pages = $user_page->show();
     }
     // 主营分类
     $sale_category = M('Store')->getSaleCategory($id, $store['uid']);
     // 检查是否已经收藏
     $user_collect = array('click' => 'userCollect', 'title' => '收藏店铺');
     if (!empty($this->user_session)) {
         $collect = D('User_collect')->where(array('type' => 2, 'user_id' => $this->user_session['uid'], 'dataid' => $id))->find();
         if (!empty($collect)) {
             $user_collect = array('click' => 'cancelCollect', 'title' => '取消收藏');
         }
     }
     //该店铺下分享链接的:优惠券列表
     $Coupon_model = M('Coupon');
     $where = array();
     $where['store_id'] = $id;
     $where['type'] = 1;
     $where['status'] = 1;
     //$where['is_share'] = 1;
     $couponlist_count = $Coupon_model->getCount($where);
     // 店铺满减
     $where = array();
     $where['status'] = 1;
     $where['store_id'] = $id;
     $where['start_time'] = array('<=', time());
     $where['end_time'] = array('>=', time());
     $reward_list = M('Reward')->getList($where);
     // 店铺联系信息
     $store_contact = M('Store_contact')->get($id);
     // 评论满意,一般,不满意数量,以及满意百分比
     $where = array();
     $where['type'] = 'STORE';
     $where['relation_id'] = $id;
     $comment_type_count = M('Comment')->getCountList($where);
     $satisfaction_pre = '100%';
     if ($comment_type_count['total'] > 0) {
         $satisfaction_pre = round($comment_type_count['t3'] / $comment_type_count['total'] * 100) . '%';
     }
     $comment_type_count['satisfaction_pre'] = $satisfaction_pre;
     $this->assign('imUrl', getImUrl($_SESSION['user']['uid'], $store['store_id']));
     $this->assign('product_count', $count);
     $this->assign('pages', $pages);
     $this->assign('store', $store);
     $this->assign('product_list', $product_list);
     $this->assign('sale_category', $sale_category);
     $this->assign('user_collect', $user_collect);
     $this->assign('couponlist_count', $couponlist_count);
     $this->assign('reward_list', $reward_list);
     $this->assign('store_contact', $store_contact);
     $this->assign('comment_type_count', $comment_type_count);
     $this->display();
 }