Activity.php 5.2 KB

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