소스 검색

权限编辑isShow

xiaosongshu007 5 년 전
부모
커밋
9caff06036

+ 110 - 0
Application/Admin/Controller/ThemeController.class.php

@@ -0,0 +1,110 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 样式管理
+ * @author   xusong
+ * @version  0.0.1
+ */
+class ThemeController extends CommonController {
+
+    /**
+     * [_initialize 前置操作-继承公共前置方法]
+     */
+
+    public function _initialize() {
+        // 调用父类前置方法
+        parent::_initialize();
+        // 登录校验
+        $this->Is_Login();
+        // 权限校验
+        $this->Is_Power();
+        //要执行的表
+    }
+
+    /**
+     * 主题列表
+     * @author   Devil
+     */
+    public function Index() {
+        $List = M('theme')->order('id desc')->select();
+        $this->assign('List', $List);
+        $this->display('Index');
+    }
+
+    /**
+     * [SaveInfo 文章添加/编辑页面]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-14T21:37:02+0800
+     */
+    public function SaveInfo() {
+        $data = M('theme')->find(I('id'));
+        $this->assign('data', $data);
+        $this->display($data['view']);
+    }
+
+    /**
+     * [Save 文章添加/编辑]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-14T21:37:02+0800
+     */
+    public function Save() {
+        if (!IS_AjAX) {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        $data['name'] = trim(I('name'));
+        $data['type'] = trim(I('type'));
+        // 添加
+        if ($id = I('id')) {
+            $data['id'] = $id;
+            if (M('theme')->save($data)) {
+                $this->ajaxReturn('更新成功');
+            } else {
+                $this->ajaxReturn('更新失败',400);
+            }
+        } else {
+            $data['created_at'] = date('Y-m-d H:i:s');
+            if ($bool=M('theme')->add($data)) {
+                $this->ajaxReturn('新增成功');
+            } else {
+                echo M()->getLastSql();
+                $this->ajaxReturn('新增失败',400);
+            }
+        }
+
+
+    }
+
+    /**
+     * [Delete 删除]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-15T11:03:30+0800
+     */
+    public function Delete() {
+        // 是否ajax请求
+        if (!IS_AJAX) {
+            $this->error(L('common_unauthorized_access'));
+        }
+        // 删除数据
+        if (I('id')) {
+            // 更新
+            if (M('theme')->delete(I('id'))) {
+                $this->ajaxReturn(L('common_operation_delete_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_delete_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn(L('common_param_error'), -1);
+        }
+    }
+
+
+}

+ 12 - 0
Application/Admin/View/Default/Lib/IsShow.html

@@ -0,0 +1,12 @@
+<!-- 是否显示 开始 -->
+<div class="am-form-group">
+	<label>{{:L('common_view_is_show_title')}}</label>
+	<div>
+		<foreach name="common_is_show_list" item="v">
+			<label class="am-radio-inline m-r-10">
+				<input type="radio" name="is_show" value="{{$v.id}}" <if condition="isset($data['is_show']) and $data['is_show'] eq $v['id']">checked="checked"<else /><if condition="!isset($data['is_show']) and isset($v['checked']) and $v['checked'] eq true">checked="checked"</if></if> data-am-ucheck /> {{$v.name}}
+			</label>
+		</foreach>
+	</div>
+</div>
+<!-- 是否显示 结束 -->

+ 76 - 0
Application/Admin/View/Default/Theme/Index.html

@@ -0,0 +1,76 @@
+<!-- header start -->
+<include file="Public/Header" />
+<!-- header end -->
+
+<!-- right content start  -->
+<div class="content-right">
+	<div class="content">
+        <form class="am-form view-list" id="form" action="{{:U('Admin/Theme/Save')}}" method="POST">
+            <div class="am-g">
+                <label>名称</label>
+                <input type="text" required="required" class="am-radius form-keyword" style="width: 20rem;display: inline-block;" placeholder="活动名称" name="name"/>
+				<label>类型</label>
+				<select name="type" id="type" style="display: inline-block;width: 10rem;margin-right: 1rem;">
+					<option value="1" <if condition="isset($type) && $type eq 1">selected</if>>活动</option>
+					<option value="2" <if condition="isset($type) && $type eq 2">selected</if>>专题</option>
+				</select>
+                <button type="submit" class="am-btn am-btn-secondary am-btn-sm am-radius form-submit">增加</button>
+            </div>
+        </form>
+		<table class="am-table am-table-striped am-table-hover am-text-middle m-t-10">
+			<thead>
+				<tr>
+					<th>序号</th>
+					<th class="am-hide-sm-only">ThemeID</th>
+					<th class="am-hide-sm-only">名称</th>
+					<th class="am-hide-sm-only">类型</th>
+					<th class="am-hide-sm-only">pv</th>
+					<th class="am-hide-sm-only">uv</th>
+					<th class="am-hide-sm-only">同步时间</th>
+					<th>{{:L('common_operation_name')}}</th>
+				</tr>
+			</thead>
+			<tbody>
+				<if condition="!empty($List)">
+					<foreach name="List" item="v">
+						<tr id="data-list-{{$v.id}}">
+							<input type="hidden" value="{{$v.id}}" />
+							<td class="am-hide-sm-only">{{$key+1}}</td>
+							<td class="am-hide-sm-only">{{$v.id}}</td>
+							<td class="am-hide-sm-only">{{$v.name}}</td>
+							<td class="am-hide-sm-only">
+								<?php
+									if($v['type'] == 1){
+										echo "活动";
+									}elseif($v['type'] == 2){
+										echo "专题";
+									}
+								?>
+							</td>
+							<td class="am-hide-sm-only">{{$v.page_view}}</td>
+							<td class="am-hide-sm-only">{{$v.user_view}}</td>
+							<td class="am-hide-sm-only">{{$v.data_update}}</td>
+							<td class="view-operation">
+							<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-trash-o submit-delete" data-url="{{:U('Admin/SourceOrigin/Delete')}}" data-am-popover="{content: '{{:L('common_operation_delete')}}', trigger: 'hover focus'}" data-id="{{$v.id}}"></button>
+							</td>
+						</tr>
+					</foreach>
+				<else />
+					<tr><td colspan="10" class="table-no">{{:L('common_not_data_tips')}}</td></tr>
+				</if>
+			</tbody>
+		</table>
+		<!-- list end -->
+
+		<!-- page start -->
+		<if condition="!empty($List)">
+			{{$page_html}}
+		</if>
+		<!-- page end -->
+	</div>
+</div>
+<!-- right content end  -->
+		
+<!-- footer start -->
+<include file="Public/Footer" />
+<!-- footer end

+ 56 - 0
Application/Home/Controller/ThemeDataController.class.php

@@ -0,0 +1,56 @@
+<?php
+
+namespace Home\Controller;
+
+use Think\Model;
+
+/**
+ * @author   Xusong
+ */
+class ThemeDataController extends CommonController {
+
+    public function _initialize() {
+        // 调用父类前置方法
+        parent::_initialize();
+    }
+
+    /**
+     * 新增主题运营数据
+     */
+    public function addData()
+    {
+        $uid            = I('uid');
+        $theme_id       = I('theme_id',0,'intval');
+        $user_origin    = I('user_origin');
+
+
+        $insertData = array(
+            'uid'           =>$uid,
+            'theme_id'      =>$theme_id,
+            'user_origin'   =>$user_origin,
+            'created_at'    =>date('Y-m-d H:i:s'),
+            'date'          =>date('Ymd')
+        );
+
+        if(!$theme_data = M('theme')->where(['id'=>$theme_id])->find()){
+            $this->responseError('params invalid');
+        }
+
+        //汇总数据更新
+        if(M('theme_detail')->where(['uid'=>$uid,'theme_id'=>$theme_id])->find()){
+            //如果数据存在,只更新pv,不更新uv
+            $update['page_view'] = $theme_data['page_view'] + 1;
+            M('theme')->where(['id'=>$theme_id])->save($update);
+        }else{
+            //如果数据存在,更新pv,更新uv
+            $update['page_view'] = $theme_data['page_view'] + 1;
+            $update['user_view'] = $theme_data['user_view'] + 1;
+            M('theme')->where(['id'=>$theme_id])->save($update);
+        }
+        if(!M('theme_detail')->add($insertData)){
+            echo M()->getLastSql();
+        }
+        $this->responseSuccess();
+    }
+
+}