Browse Source

增加数据统计页

linwu 1 năm trước cách đây
mục cha
commit
4c5d61f05d

+ 76 - 0
app/admin/controller/MainController.php

@@ -0,0 +1,76 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +----------------------------------------------------------------------
+// | Author: 小夏 < 449134904@qq.com>
+// +----------------------------------------------------------------------
+namespace app\admin\controller;
+
+use app\admin\model\UserModel;
+use app\common\Fun;
+use app\love\model\UserAuthModel;
+use cmf\controller\AdminBaseController;
+use think\Db;
+
+class MainController extends AdminBaseController
+{
+
+    /**
+     *  后台欢迎页
+     */
+    public function index()
+    {
+        $auth      = [
+            'total'   => 0,
+            'man'   => 0,
+            'woman' => 0,
+        ];
+        $auth_list = UserAuthModel::column('idcard');
+        foreach ($auth_list as $v) {
+            $auth['total']++;
+            Fun::getSexByIdCard($v) == 1 ? $auth['man']++ : $auth['woman']++;
+        }
+
+        $user = [];
+        $user_where = [
+            ['user_type', '=', 2],
+            ['is_complete', '=', 1],
+        ];
+        $user['total'] = UserModel::where($user_where)->count();
+        $user['man'] = UserModel::where($user_where)->where('sex',1)->count();
+        $user['woman'] = UserModel::where($user_where)->where('sex',2)->count();
+
+        $config = Db::name('config')->find();
+
+        $this->assign('auth',$auth);
+        $this->assign('user',$user);
+        $this->assign('config',$config);
+
+        return $this->fetch();
+    }
+
+    public function dashboardWidget()
+    {
+        $dashboardWidgets = [];
+        $widgets          = $this->request->param('widgets/a');
+        if (!empty($widgets)) {
+            foreach ($widgets as $widget) {
+                if ($widget['is_system']) {
+                    array_push($dashboardWidgets, ['name' => $widget['name'], 'is_system' => 1]);
+                } else {
+                    array_push($dashboardWidgets, ['name' => $widget['name'], 'is_system' => 0]);
+                }
+            }
+        }
+
+        cmf_set_option('admin_dashboard_widgets', $dashboardWidgets, true);
+
+        $this->success('更新成功!');
+
+    }
+
+}

+ 23 - 0
app/love/controller/ActiveController.php

@@ -118,6 +118,29 @@ class ActiveController extends LoveBaseController
         $this->success('报名成功');
     }
 
+    /**
+     * 取消参加活动
+     */
+    public function cancel()
+    {
+        $id = $this->request->param('id');
+        if (empty($id)) {
+            $this->error('活动不存在或已结束');
+        }
+        $active = ActiveModel::get($id);
+        if (empty($active)) {
+            $this->error('活动不存在或已结束');
+        }
+
+        $check = ActiveApplyModel::get(['active_id'=>$id,'user_id'=>$this->user['id']]);
+        if (empty($check)) {
+            $this->error('您未报名,无需取消!');
+        }
+
+        $check->delete();
+        $this->success('取消成功');
+    }
+
     /**
      * 嘉宾
      */

+ 4 - 0
app/love/controller/AdminLotteryController.php

@@ -15,6 +15,7 @@ use app\love\model\LotteryLogModel;
 use app\love\model\LotteryPrizeModel;
 use app\love\model\UserModel;
 use cmf\controller\AdminBaseController;
+use think\Db;
 
 class AdminLotteryController extends AdminBaseController
 {
@@ -165,6 +166,9 @@ class AdminLotteryController extends AdminBaseController
         $id = input('param.id', 0, 'intval');
         LotteryLogModel::update(['status' => 1,'out_at'=>time()], ['id' => $id]);
 
+        //增加领证次数
+        Db::name('config')->where('id',1)->setInc('lottery_num');
+
         $this->success('操作成功!');
 
     }

+ 6 - 0
app/love/controller/MyController.php

@@ -23,6 +23,7 @@ use app\love\model\UserModel;
 use app\love\model\UserSelectLogModel;
 use app\love\model\UserSelectModel;
 use app\love\model\UserVisitModel;
+use think\Db;
 
 class MyController extends LoveBaseController
 {
@@ -532,6 +533,8 @@ class MyController extends LoveBaseController
             ]);
         }
 
+        //增加互选次数
+         Db::name('config')->where('id',1)->setInc('select_num');
         /*//发送提示
         $time = time();
         UserMessageModel::create([
@@ -581,6 +584,9 @@ class MyController extends LoveBaseController
             UserModel::where('id','in',[$id,$user_id])->update(['is_marry'=>1]);
         }
 
+        //增加结婚次数
+        Db::name('config')->where('id',1)->setInc('marry_num');
+
         $this->success('操作成功');
     }
 

+ 40 - 7
public/themes/admin_simpleboot3/admin/main/index.html

@@ -1,5 +1,38 @@
-<h1>晋江婚恋系统</h1>
-
+<div style="padding:0 20px;">
+    <h1>晋江婚恋系统</h1>
+    <div class="row">
+        <div class="col-md-6">
+            <div class="list-group">
+                <a href="#" class="list-group-item active">
+                    允许注册人数
+                </a>
+                <a href="#" class="list-group-item">总:{$auth.total}人</a>
+                <a href="#" class="list-group-item">男:{$auth.man}人</a>
+                <a href="#" class="list-group-item">女:{$auth.woman}人</a>
+            </div>
+        </div>
+        <div class="col-md-6">
+            <div class="list-group">
+                <a href="#" class="list-group-item active">
+                    已注册成功人数
+                </a>
+                <a href="#" class="list-group-item">总:{$user.total}人</a>
+                <a href="#" class="list-group-item">男:{$user.man}人</a>
+                <a href="#" class="list-group-item">女:{$user.woman}人</a>
+            </div>
+        </div>
+        <div class="col-md-6">
+            <div class="list-group">
+                <a href="#" class="list-group-item active">
+                    相恋情况
+                </a>
+                <a href="#" class="list-group-item">配对:{$config.select_num}人</a>
+                <a href="#" class="list-group-item">结婚:{$config.marry_num}人</a>
+                <a href="#" class="list-group-item">领奖:{$config.lottery_num}人</a>
+            </div>
+        </div>
+    </div>
+</div>
 <include file="public@header"/>
 <hook name="admin_before_head_end"/>
 </head>
@@ -55,12 +88,12 @@
             mirrorContainer: document.body,    // set the element that gets mirror elements appended
             ignoreInputTextSelection: true     // allows users to select input text, see details below
         }).on('drop', function (el, target, source, sibling) {
-            var $target          = $(target);
-            var targetClasses    = $target.attr('class');
+            var $target = $(target);
+            var targetClasses = $target.attr('class');
             var targetDataWidget = $target.data('widget');
             var targetDataSystem = $target.data('system');
-            var $source          = $(source);
-            var sourceClasses    = $source.attr('class');
+            var $source = $(source);
+            var sourceClasses = $source.attr('class');
             var sourceDataWidget = $source.data('widget');
             var sourceDataSystem = $source.data('system');
             $(source).append($(target).find('.dashboard-box').not('.gu-transit'));
@@ -114,7 +147,7 @@
     //获取官方通知
     $.getJSON("//www.thinkcmf.com/service/sms_jsonp.php?lang={$lang_set}&v={$thinkcmf_version}&callback=?",
         function (data) {
-            var tpl      = '<li><em class="title"></em><span class="content"></span></li>';
+            var tpl = '<li><em class="title"></em><span class="content"></span></li>';
             var $notices = $("#thinkcmf-notices");
             $notices.empty();
             if (data.length > 0) {

+ 27 - 3
public/themes/simpleboot3/love/active/detail.html

@@ -51,8 +51,8 @@
         <template v-if="info.time_status == 0">
             <van-goods-action-button
                     type="danger"
-                    disabled
-                    text="等待审核中"
+                    text="取消报名"
+                    @click="onCancel"
                     v-if="apply && apply.check_status == 1"
             ></van-goods-action-button>
             <van-goods-action-button
@@ -98,6 +98,7 @@
                 return {
                     info:{$info},
                     apply:{$apply},
+                    disabled: false,
                 };
             },
             methods: {
@@ -122,6 +123,10 @@
                     location.href = "{:url('rank')}?id={$id}";
                 },
                 onApply() {
+                    if (this.disabled) {
+                        return false;
+                    }
+                    this.disabled = true;
                     let self = this;
                     $.post("{:url('apply')}",{id:this.info.id},function(json){
                         self.$toast(json.msg);
@@ -129,9 +134,28 @@
                             setTimeout(function(){
                                 location.reload();
                             },2000);
+                        } else {
+                            self.disabled = false;
+                        }
+                    },'json')
+                },
+                onCancel() {
+                    if (this.disabled) {
+                        return false;
+                    }
+                    this.disabled = true;
+                    const self = this;
+                    $.post("{:url('cancel')}",{id:this.info.id},function(json){
+                        self.$toast(json.msg);
+                        if (json.code == 1) {
+                            setTimeout(function(){
+                                location.reload();
+                            },2000);
+                        } else {
+                            self.disabled = false;
                         }
                     },'json')
-                }
+                },
             },
         });
     </script>