BaseStore.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /*
  3. * 店铺的类
  4. */
  5. namespace app\home\controller;
  6. use think\facade\View;
  7. use think\facade\Lang;
  8. /**
  9. * ============================================================================
  10. *
  11. * ============================================================================
  12. *
  13. * ----------------------------------------------------------------------------
  14. *
  15. * ============================================================================
  16. * 控制器
  17. */
  18. class BaseStore extends BaseHome {
  19. protected $store_info;
  20. public function initialize() {
  21. parent::initialize();
  22. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/baseseller.lang.php');
  23. //店铺模板路径
  24. $this->template_dir = 'default/store/default/' . strtolower(request()->controller()) . '/';
  25. View::assign('store_theme', 'default');
  26. //当方法为 store 进行执行
  27. if (in_array(request()->controller(),array('Store','StoreSpecial'))) {
  28. //输出会员信息
  29. $this->getMemberAndGradeInfo(false);
  30. $store_id = intval(input('param.store_id'));
  31. if ($store_id <= 0) {
  32. $this->error(lang('ds_store_close'));
  33. }
  34. $store_model = model('store');
  35. $store_info = $store_model->getStoreOnlineInfoByID($store_id);
  36. if (empty($store_info)) {
  37. $this->error(lang('ds_store_close'));
  38. } else {
  39. $this->store_info = $store_info;
  40. }
  41. $storejoinin_model=model('storejoinin');
  42. if(!$store_info['is_platform_store']){
  43. $storejoinin_info=$storejoinin_model->getOneStorejoinin(array('member_id'=>$store_info['member_id']));
  44. //营业执照
  45. if($storejoinin_info){
  46. $this->store_info['business_licence_number_electronic']=($storejoinin_info['business_licence_number_electronic'] && $storejoinin_info['store_type']==0)?get_store_joinin_imageurl($storejoinin_info['business_licence_number_electronic']):'';
  47. }
  48. }
  49. $this->outputStoreInfo($this->store_info);
  50. $this->getStorenavigation($store_id);
  51. $this->outputSeoInfo($this->store_info);
  52. }
  53. }
  54. /**
  55. * 检查店铺开启状态
  56. *
  57. * @param int $store_id 店铺编号
  58. * @param string $msg 警告信息
  59. */
  60. protected function outputStoreInfo($store_info) {
  61. $store_model = model('store');
  62. //店铺分类
  63. $goodsclass_model = model('storegoodsclass');
  64. $goods_class_list = $goodsclass_model->getShowTreeList($store_info['store_id']);
  65. View::assign('goods_class_list', $goods_class_list);
  66. //热销排行
  67. $hot_sales = $store_model->getHotSalesList($store_info['store_id'], 5);
  68. View::assign('hot_sales', $hot_sales);
  69. //收藏排行
  70. $hot_collect = $store_model->getHotCollectList($store_info['store_id'], 5);
  71. View::assign('hot_collect', $hot_collect);
  72. View::assign('store_info', $store_info);
  73. View::assign('page_title', $store_info['store_name']);
  74. }
  75. protected function getStorenavigation($store_id) {
  76. $storenavigation_model = model('storenavigation');
  77. $store_navigation_list = $storenavigation_model->getStorenavigationList(array('storenav_store_id' => $store_id));
  78. View::assign('store_navigation_list', $store_navigation_list);
  79. }
  80. protected function outputSeoInfo($store_info) {
  81. $seo_param = array();
  82. $seo_param['shopname'] = $store_info['store_name'];
  83. $seo_param['key'] = $store_info['store_keywords'];
  84. $seo_param['description'] = $store_info['store_description'];
  85. //SEO 设置
  86. $this->_assign_seo(model('seo')->type('shop')->param($seo_param)->show());
  87. }
  88. }