Activity.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  10. * 网站地址: https://www.valimart.net/
  11. * ----------------------------------------------------------------------------
  12. *
  13. * ============================================================================
  14. * 控制器
  15. */
  16. class Activity extends BaseMall {
  17. public function initialize() {
  18. parent::initialize();
  19. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/activity.lang.php');
  20. }
  21. /*
  22. * 显示所有活动列表
  23. */
  24. function index()
  25. {
  26. $condition = array();
  27. $activity_model = model('activity');
  28. $condition[]=array('activity_type','=',1);
  29. $condition[]=array('activity_startdate','<=',TIMESTAMP);
  30. $condition[]=array('activity_enddate','>=',TIMESTAMP);
  31. $condition[]=array('activity_state','=',1);
  32. $activity_list = $activity_model->getActivityList($condition, 10);
  33. View::assign('activity_list', $activity_list);
  34. View::assign('show_page', $activity_model->page_info->render());
  35. View::assign('html_title', config('ds_config.site_name') . ' - '.lang('activity_list'));
  36. return View::fetch($this->template_dir.'activity_index');
  37. }
  38. /**
  39. * 单个活动信息页
  40. */
  41. public function detail() {
  42. //得到导航ID
  43. $nav_id = intval(input('param.nav_id'));
  44. View::assign('index_sign', $nav_id);
  45. //查询活动信息
  46. $activity_id = intval(input('param.activity_id'));
  47. if ($activity_id <= 0) {
  48. $this->error(lang('param_error')); //'缺少参数:活动编号'
  49. }
  50. $activity = model('activity')->getOneActivityById($activity_id);
  51. if (empty($activity) || $activity['activity_type'] != '1' || $activity['activity_state'] != 1 || $activity['activity_startdate'] > TIMESTAMP || $activity['activity_enddate'] < TIMESTAMP) {
  52. $this->error(lang('activity_index_activity_not_exists')); //'指定活动并不存在'
  53. }
  54. View::assign('activity', $activity);
  55. $editable_page_model = model('editable_page');
  56. $editable_page_info = $editable_page_model->getOneEditablePage(array('editable_page_path' => 'activity/detail','editable_page_client'=>'pc','editable_page_item_id'=>$activity_id));
  57. if ($editable_page_info) {
  58. $editable_page_info['editable_page_theme_config'] = json_decode($editable_page_info['editable_page_theme_config'], true);
  59. View::assign('editable_page', $editable_page_info);
  60. $editable_page_config_model = model('editable_page_config');
  61. $editable_page_config_list=$editable_page_config_model->getEditablePageConfigList(array(array('editable_page_id', '=', $editable_page_info['editable_page_id'])));
  62. $config_list=array();
  63. foreach($editable_page_config_list as $key => $val){
  64. $config_info=json_decode($val['editable_page_config_content'], true);
  65. $model_id=$val['editable_page_model_id'];
  66. $var_html=array();
  67. if(!empty($config_info)){
  68. require_once PLUGINS_PATH.'/editable_page_model/'.$model_id.'/config.php';
  69. $model_name='Model'.$model_id;
  70. $model=new $model_name();
  71. $res=$model->filterData($config_info);
  72. if($res['code']){
  73. $res=$model->formatData(json_encode($res['data']));
  74. if($res['code']){
  75. $var_html['config_info']=$res['data'];
  76. }
  77. }
  78. }
  79. $html=View::fetch('../../../plugins/editable_page_model/'.$model_id.'/index',$var_html);
  80. $config_list[]=array(
  81. 'val'=>$val,
  82. 'html'=>$html,
  83. );
  84. }
  85. View::assign('config_list', $config_list);
  86. View::assign('editable_page', $editable_page_info);
  87. }else{
  88. //查询活动内容信息
  89. $condition = array();
  90. $condition[] = array('activitydetail.activity_id','=',$activity_id);
  91. $condition[] = array('activitydetail.activitydetail_state','=','1');
  92. $activitydetail_model=model('activitydetail');
  93. $activitydetail_list = $activitydetail_model->getGoodsJoinList($condition,100,'activitydetail_sort asc','goods.goods_commonid');
  94. View::assign('show_page', $activitydetail_model->page_info->render());
  95. View::assign('activitydetail_list', $activitydetail_list);
  96. }
  97. View::assign('html_title', config('ds_config.site_name') . ' - ' . $activity['activity_title']);
  98. return View::fetch($this->template_dir.'activity_show');
  99. }
  100. }
  101. ?>