Parcourir la source

add home page

stanley-king il y a 9 ans
Parent
commit
3a8fd97294

+ 2 - 1
admin/control/adv.php

@@ -8,7 +8,8 @@
 
 defined('InShopNC') or exit('Access Invalid!');
 
-class advControl extends SystemControl{
+class advControl extends SystemControl
+{
 	public function __construct(){
 		parent::__construct();
 		Language::read('adv');

+ 44 - 24
admin/control/mb_ad.php

@@ -10,7 +10,8 @@
 
 
 defined('InShopNC') or exit('Access Invalid!');
-class mb_adControl extends SystemControl{
+class mb_adControl extends SystemControl
+{
 	public function __construct(){
 		parent::__construct();
 		Language::read('mobile');
@@ -18,23 +19,22 @@ class mb_adControl extends SystemControl{
 	/**
 	 *
 	 */
-	public function mb_ad_listOp(){
+	public function mb_ad_listOp()
+	{
 		$model_mb_ad = Model('mb_ad');
-
 		$link_list = $model_mb_ad->getMbAdList(array());
 		Tpl::output('link_list',$link_list);
-
 		Tpl::showpage('mb_ad.list');
 	}
 
 	/**
 	 * 广告删除
 	 */
-	public function mb_ad_delOp(){
+	public function mb_ad_delOp()
+	{
         $link_id = intval($_GET['link_id']);
 		if ($link_id > 0){
 			$model_mb_ad = Model('mb_ad');
-
 			//删除图片
 			$model_mb_ad->delMbAd($link_id);
 			showMessage(L('link_index_del_succ'),'index.php?act=mb_ad&op=mb_ad_list');
@@ -46,15 +46,16 @@ class mb_adControl extends SystemControl{
 	/**
 	 * 添加
 	 */
-	public function mb_ad_addOp(){
+	public function mb_ad_addOp()
+	{
 		$model_mb_ad = Model('mb_ad');
-
 		//最多发布6条
 		$count = $model_mb_ad->getMbAdCount();
 		if ($count > 5){
 			showMessage(L('link_add_count_limit'));
 		}
-		if ($_POST['form_submit'] == 'ok'){
+		if ($_POST['form_submit'] == 'ok')
+		{
 			/**
 			 * 验证
 			 */
@@ -65,9 +66,12 @@ class mb_adControl extends SystemControl{
 				array("input"=>$_POST["link_sort"], "require"=>"true", 'validator'=>'Number', "message"=>L('link_add_sort_int')),
 			);
 			$error = $obj_validate->validate();
-			if ($error != ''){
+			if ($error != '')
+			{
 				showMessage($error);
-			}else {
+			}
+			else
+			{
 				/**
 				 * 上传图片
 				 */
@@ -90,7 +94,8 @@ class mb_adControl extends SystemControl{
 				$insert_array['link_sort'] = trim($_POST['link_sort']);
 
 				$result = $model_mb_ad->addMbAd($insert_array);
-				if ($result){
+				if ($result)
+				{
 					$url = array(
 						array(
 							'url'=>'index.php?act=mb_ad&op=mb_ad_list',
@@ -110,9 +115,11 @@ class mb_adControl extends SystemControl{
 	/**
 	 * 编辑
 	 */
-	public function mb_ad_editOp(){
+	public function mb_ad_editOp()
+	{
 		$model_mb_ad = Model('mb_ad');
-		if ($_POST['form_submit'] == 'ok'){
+		if ($_POST['form_submit'] == 'ok')
+		{
 			/**
 			 * 验证
 			 */
@@ -123,38 +130,47 @@ class mb_adControl extends SystemControl{
 				array("input"=>$_POST["link_sort"], "require"=>"true", 'validator'=>'Number', "message"=>L('link_add_sort_int')),
 			);
 			$error = $obj_validate->validate();
-			if ($error != ''){
+			if ($error != '')
+			{
 				showMessage($error);
-			}else {
+			}
+			else
+			{
 				/**
 				 * 上传图片
 				 */
-				if ($_FILES['link_pic']['name'] != ''){
+				if ($_FILES['link_pic']['name'] != '')
+				{
 					$upload = new UploadFile();
 					$upload->set('default_dir',ATTACH_MOBILE.'/ad');
 
 					$result = $upload->upfile('link_pic');
 					if ($result){
 						$_POST['link_pic'] = $upload->file_name;
-					}else {
+					} else {
 						showMessage($upload->error);
 					}
 				}
+
 				$link_array = $model_mb_ad->getMbAdInfoByID(intval($_POST['link_id']));
 				$update_array = array();
 				$update_array['link_title'] = trim($_POST['link_title']);
 				$update_array['link_keyword'] = trim($_POST['link_keyword']);
-				if ($_POST['link_pic']){
+
+				if ($_POST['link_pic']) {
 					$update_array['link_pic'] = $_POST['link_pic'];
 				}
+
 				$update_array['link_sort'] = trim($_POST['link_sort']);
 
                 $result = $model_mb_ad->editMbAd($update_array, array('link_id' => intval($_POST['link_id'])));
-				if ($result){
+				if ($result)
+				{
 				    //删除图片
-				    if (!empty($_POST['link_pic']) && !empty($link_array['link_pic'])){
+				    if (!empty($_POST['link_pic']) && !empty($link_array['link_pic'])) {
 				        @unlink(BASE_ROOT_PATH.DS.DIR_UPLOAD.DS.ATTACH_MOBILE.'/ad'.DS.$link_array['link_pic']);
 				    }
+
 					$url = array(
 						array(
 							'url'=>'index.php?act=mb_ad&op=mb_ad_list',
@@ -162,7 +178,9 @@ class mb_adControl extends SystemControl{
 						)
 					);
 					showMessage(L('link_edit_succ'),$url);
-				}else {
+				}
+				else
+				{
 					showMessage(L('link_edit_fail'));
 				}
 			}
@@ -179,8 +197,10 @@ class mb_adControl extends SystemControl{
 	/**
 	 * ajax操作
 	 */
-	public function ajaxOp(){
-		switch ($_GET['branch']){
+	public function ajaxOp()
+	{
+		switch ($_GET['branch'])
+		{
 			/**
 			 * 合作伙伴 排序
 			 */

+ 56 - 11
data/model/mb_special.model.php

@@ -5,11 +5,11 @@
  *
  *
  *
- 
  */
-defined('InShopNC') or exit('Access Invalid!');
-class mb_specialModel extends Model{
 
+defined('InShopNC') or exit('Access Invalid!');
+class mb_specialModel extends Model
+{
     //专题项目不可用状态
     const SPECIAL_ITEM_UNUSABLE = 0;
     //专题项目可用状态
@@ -103,7 +103,8 @@ class mb_specialModel extends Model{
 	 * @param int $special_id
      *
      */
-    public function getMbSpecialItemUsableListByID($special_id) {
+    public function getMbSpecialItemUsableListByID($special_id)
+    {
         $prefix = 'mb_special';
 
         $item_list = rcache($special_id, $prefix);
@@ -117,16 +118,24 @@ class mb_specialModel extends Model{
         $condition['special_id'] = $special_id;
         $condition['item_usable'] = self::SPECIAL_ITEM_USABLE;
         $item_list = $this->_getMbSpecialItemList($condition);
-        if(!empty($item_list)) 
+
+        $home_specials = array();
+        if(!empty($item_list))
         {
-            $new_item_list = array();
             foreach ($item_list as $value) {
                 //处理图片
-                $item_data = $this->_formatMbSpecialData($value['item_data'], $value['item_type']);
-                $new_item_list[] = array($value['item_type'] => $item_data);
+                $item_data = $this->_formatMbSpecialDataEx($value['item_data'], $value['item_type']);
+                switch($value['item_type'])
+                {
+                    case 'home1' :
+                        array_push($home_specials,$item_data);
+                        break;
+                    case 'adv_list':
+                        $home_advs = $item_data;
+                }
             }
-            $item_list = $new_item_list;
         }
+        $item_list = array('adv_list' => $home_advs,'specials' => $home_specials);
         $cache = array('special' => serialize($item_list));
         wcache($special_id, $cache, $prefix);
         return $item_list;
@@ -142,7 +151,42 @@ class mb_specialModel extends Model{
     /**
      * 处理专题数据,拼接图片URL
      */
-    private function _formatMbSpecialData($item_data, $item_type) {
+    private function _formatMbSpecialDataEx($item_data, $item_type)
+    {
+        switch ($item_type) {
+            case 'home1':
+                $item_data['image'] = getMbSpecialImageUrl($item_data['image']);
+                break;
+            case 'home2':
+            case 'home4':
+                $item_data['square_image'] = getMbSpecialImageUrl($item_data['square_image']);
+                $item_data['rectangle1_image'] = getMbSpecialImageUrl($item_data['rectangle1_image']);
+                $item_data['rectangle2_image'] = getMbSpecialImageUrl($item_data['rectangle2_image']);
+                break;
+            case 'goods':
+                $new_item = array();
+                foreach ((array) $item_data['item'] as $value) {
+                    $value['goods_image'] = cthumb($value['goods_image']);
+                    $new_item[] = $value;
+                }
+                $item_data['item'] = $new_item;
+                break;
+            default:
+                $new_item = array();
+                foreach ((array) $item_data['item'] as $key => $value) {
+                    $value['image'] = getMbSpecialImageUrl($value['image']);
+                    $new_item[] = $value;
+                }
+                $item_data = $new_item;
+        }
+        return $item_data;
+    }
+
+    /**
+     * 处理专题数据,拼接图片URL
+     */
+    private function _formatMbSpecialData($item_data, $item_type)
+    {
         switch ($item_type) {
             case 'home1':
                 $item_data['image'] = getMbSpecialImageUrl($item_data['image']);
@@ -175,7 +219,8 @@ class mb_specialModel extends Model{
     /**
      * 查询专题项目列表
      */
-    private function _getMbSpecialItemList($condition, $order = 'item_sort asc') {
+    private function _getMbSpecialItemList($condition, $order = 'item_sort asc')
+    {
         $item_list = $this->table('mb_special_item')->where($condition)->order($order)->select();
         foreach ($item_list as $key => $value) {
             $item_list[$key]['item_data'] = $this->_initMbSpecialItemData($value['item_data'], $value['item_type']);

+ 9 - 5
data/model/web_config.model.php

@@ -5,10 +5,11 @@
  *
  *
  *
- 
  */
+
 defined('InShopNC') or exit('Access Invalid!');
-class web_configModel extends Model{
+class web_configModel extends Model
+{
 	/**
 	 * 读取模块内容记录
 	 *
@@ -86,7 +87,8 @@ class web_configModel extends Model{
 	 * 更新模块html信息
 	 *
 	 */
-	public function updateWebHtml($web_id = 1,$style_name = 'orange'){
+	public function updateWebHtml($web_id = 1,$style_name = 'orange')
+	{
 		$web_html = '';
 		$code_list = $this->getCodeList(array('web_id'=>"$web_id"));
 		if(!empty($code_list) && is_array($code_list)) {
@@ -129,7 +131,8 @@ class web_configModel extends Model{
 	 * 模块html信息
 	 *
 	 */
-	public function getWebHtml($web_page = 'index',$update_all = 0){
+	public function getWebHtml($web_page = 'index',$update_all = 0)
+	{
 		$web_array = array();
 		$web_list = $this->getWebList(array('web_show'=>1,'web_page'=> array('like',$web_page.'%')));
 		if(!empty($web_list) && is_array($web_list)) {
@@ -149,7 +152,8 @@ class web_configModel extends Model{
 	 * 读取广告位记录列表
 	 *
 	 */
-	public function getAdvList($type = 'screen'){
+	public function getAdvList($type = 'screen')
+	{
 		$condition = array();
 		$condition['screen'] = array(
 			'ap_class' => '0',//图片

+ 0 - 0
data/session/index.html


+ 49 - 3
mobile/control/index.php

@@ -11,8 +11,10 @@
 defined('InShopNC') or exit('Access Invalid!');
 class indexControl extends mobileHomeControl
 {
-	public function __construct() {
+    private $mb_special;
+    public function __construct() {
         parent::__construct();
+        $this->mb_special = Model('mb_special');
     }
 
     /**
@@ -20,11 +22,55 @@ class indexControl extends mobileHomeControl
      */
 	public function indexOp()
     {
-        $model_mb_special = Model('mb_special'); 
-        $data = $model_mb_special->getMbSpecialIndex();
+        $data = $this->mb_special->getMbSpecialIndex();
+        $tops = $this->toplist();
+        $data['sale_list'] = $tops;
         $this->_output_special($data, $_GET['type']);
 	}
+    /**
+     * 获取打赏接口数据
+     */
+    private function toplist()
+    {
+        $prefix = 'mb_salelist';
+        $codeid = 122;
+
+        $ret = rcache($codeid, $prefix);
+        if(empty($ret))
+        {
+            $web_code = Model('web_code');
+            $result = $web_code->where(array('code_id' => 122,'web_id' => 122))->select();
+            if(!empty($result)) {
+                $top = $result[0];
+                $tops = unserialize($top['code_info']);
+            }
+            if(empty($tops)) return NULL;
+            $ret = array();
+            foreach($tops as $id => $val)
+            {
+                $item = array();
+                $item['id'] = $id;
+                $img = $val['img_name'];
+                if(!empty($img)) {
+                    $item['image'] = substr($img,0,-4);
+                    $item['title'] = $val['recommend']['name'];
+                    array_push($ret,$item);
+                }
+            }
+            wcache($codeid,serialize($ret),$prefix);
+        }
+        else
+        {
+            $ret = unserialize($ret);
+        }
+
+        return $ret;
+    }
+
+    public function toplistOp()
+    {
 
+    }
     /**
      * 专题
      */