public function getMobilePageData() { $cus_id = Auth::id(); $mobile = new PrintController('preview', 'mobile'); $m_catlist = Classify::where('mobile_show', 1)->where('cus_id', $mobile->cus_id)->whereIn('type', [1, 2, 3, 4])->orderBy('sort')->select('id', 'name', 'p_id', 'type')->get()->toArray(); $showtypetotal = WebsiteInfo::where('website_info.cus_id', $cus_id)->LeftJoin('template', 'mobile_tpl_id', '=', 'template.id')->select('template.list1showtypetotal', 'template.list2showtypetotal', 'template.list3showtypetotal', 'template.list4showtypetotal')->first(); if (count($m_catlist) > 0) { foreach ($m_catlist as &$m_arr) { $liststr = 'list' . $m_arr['type'] . 'showtypetotal'; $mobilehome_config = MobileHomepage::where('c_id', $m_arr['id'])->first(); if ($mobilehome_config) { $m_arr['showtypetotal'] = $showtypetotal->{$liststr}; if ($m_arr['showtypetotal']) { $m_arr['index_show'] = $mobilehome_config->index_show; if ($m_arr['showtypetotal'] < $mobilehome_config->m_index_showtype) { $m_arr['showtype'] = 1; } else { $m_arr['showtype'] = $mobilehome_config->m_index_showtype; } } else { $m_arr['showtype'] = 1; $m_arr['index_show'] = 0; } MobileHomepage::where('id', $mobilehome_config->id)->update(array('m_index_showtype' => $m_arr['showtype'], 'index_show' => $m_arr['index_show'])); $m_arr['show_num'] = $mobilehome_config->show_num; $m_arr['star_only'] = $mobilehome_config->star_only; $m_arr['s_sort'] = $mobilehome_config->s_sort; } else { $m_arr['index_show'] = 0; $m_arr['show_num'] = 0; $m_arr['star_only'] = 0; $m_arr['s_sort'] = 0; $m_arr['showtypetotal'] = $showtypetotal->{$liststr}; $m_arr['showtype'] = 0; } $sort_key[] = $m_arr['s_sort']; } } if (!empty($sort_key) || !empty($m_catlist)) { array_multisort($sort_key, $m_catlist); } //$m_catlist=$this->toTree($m_catlist); $data = array(); $pagelist[] = array('page' => 'index', 'title' => '栏目排序', 'type' => 'category'); $template_id = WebsiteInfo::where('cus_id', $mobile->cus_id)->pluck('mobile_tpl_id'); $config_str = WebsiteConfig::where('cus_id', $mobile->cus_id)->where('type', 2)->where('template_id', $template_id)->pluck('value'); if ($config_str) { $config_arr = unserialize($config_str); if ($config_arr['slidepics']['value']) { ksort($config_arr['slidepics']['value'], SORT_NUMERIC); } if ($config_arr['slidepics']['value']) { $config_arr['slidepics']['value'] = array_merge($config_arr['slidepics']['value']); } } else { $config_arr = $mobile->mobilePageList('global', true); } foreach ($config_arr as $key => $val) { $pagelist[] = array('page' => $key, 'title' => $config_arr[$key]['description'], 'type' => $config_arr[$key]['type']); $data[$key] = $config_arr[$key]; } $templatedata['templatedata'] = $data; $templatedata['pagelist'] = $pagelist; $templatedata['m_catlist'] = $m_catlist; $mobile->replaceUrl($templatedata); $return_msg = array('err' => 0, 'msg' => '', 'data' => $templatedata); return Response::json($return_msg); }