瀏覽代碼

签到图片

zhangxiaobin 1 年之前
父節點
當前提交
6355280e1d

+ 74 - 0
application/admin/controller/UserSign.php

@@ -0,0 +1,74 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\common\controller\Backend;
+
+/**
+ * 用户签到日志管理
+ *
+ * @icon fa fa-circle-o
+ */
+class UserSign extends Backend
+{
+    
+    /**
+     * UserSign模型对象
+     * @var \app\admin\model\UserSign
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\UserSign;
+
+    }
+
+    public function import()
+    {
+        parent::import();
+    }
+
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+    
+
+    /**
+     * 查看
+     */
+    public function index()
+    {
+        //当前是否为关联查询
+        $this->relationSearch = true;
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if ($this->request->isAjax()) {
+            //如果发送的来源是Selectpage,则转发到Selectpage
+            if ($this->request->request('keyField')) {
+                return $this->selectpage();
+            }
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+
+            $list = $this->model
+                    ->with(['user'])
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->paginate($limit);
+
+            foreach ($list as $row) {
+                
+                $row->getRelation('user')->visible(['nickname']);
+            }
+
+            $result = array("total" => $list->total(), "rows" => $list->items());
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+
+}

+ 10 - 0
application/admin/lang/zh-cn/user_sign.php

@@ -0,0 +1,10 @@
+<?php
+
+return [
+    'Id'            => 'ID',
+    'Uid'           => 'uid',
+    'Times'         => '第几次',
+    'Goldnum'       => '经验',
+    'Createtime'    => '签到时间',
+    'User.nickname' => '昵称'
+];

+ 44 - 0
application/admin/model/UserSign.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class UserSign extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'user_sign';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+
+    ];
+    
+
+    
+
+
+
+
+
+
+
+    public function user()
+    {
+        return $this->belongsTo('User', 'uid', 'id', [], 'LEFT')->setEagerlyType(0);
+    }
+}

+ 27 - 0
application/admin/validate/UserSign.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace app\admin\validate;
+
+use think\Validate;
+
+class UserSign extends Validate
+{
+    /**
+     * 验证规则
+     */
+    protected $rule = [
+    ];
+    /**
+     * 提示消息
+     */
+    protected $message = [
+    ];
+    /**
+     * 验证场景
+     */
+    protected $scene = [
+        'add'  => [],
+        'edit' => [],
+    ];
+    
+}

+ 28 - 0
application/admin/view/user_sign/add.html

@@ -0,0 +1,28 @@
+<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Uid')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-uid" class="form-control" name="row[uid]" type="number" value="0">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Times')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-times" class="form-control" name="row[times]" type="number">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Goldnum')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-goldnum" class="form-control" name="row[goldnum]" type="number">
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 28 - 0
application/admin/view/user_sign/edit.html

@@ -0,0 +1,28 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Uid')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-uid" class="form-control" name="row[uid]" type="number" value="{$row.uid|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Times')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-times" class="form-control" name="row[times]" type="number" value="{$row.times|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Goldnum')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-goldnum" class="form-control" name="row[goldnum]" type="number" value="{$row.goldnum|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 35 - 0
application/admin/view/user_sign/index.html

@@ -0,0 +1,35 @@
+<div class="panel panel-default panel-intro">
+    {:build_heading()}
+
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="one">
+                <div class="widget-body no-padding">
+                    <div id="toolbar" class="toolbar">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
+                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('user_sign/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
+                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('user_sign/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('user_sign/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('user_sign/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
+
+                        <div class="dropdown btn-group {:$auth->check('user_sign/multi')?'':'hide'}">
+                            <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
+                            <ul class="dropdown-menu text-left" role="menu">
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
+                            </ul>
+                        </div>
+
+                        
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           data-operate-edit="{:$auth->check('user_sign/edit')}" 
+                           data-operate-del="{:$auth->check('user_sign/del')}" 
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 39 - 34
application/api/controller/Attire.php

@@ -4,6 +4,7 @@ namespace app\api\controller;
 
 use app\common\controller\Api;
 use think\Db;
+use think\Exception;
 
 /**
  * 装扮商城接口
@@ -141,45 +142,49 @@ class Attire extends Api
      * 获取我的背包装饰列表
      */
     public function getBackAttireList() {
-        $page = $this->request->request('page',1); // 分页
-        $pageNum = $this->request->request('pageNum',10); // 分页
-        $type = $this->request->request("type"); // 装扮类型:1=座驾,2=头饰,3=聊天气泡,4=消息尾灯
-        // 分页搜索构建
-        $pageStart = ($page-1)*$pageNum;
-        global $where;
-        $where = [];$whereOr=[];
-        $where["user_id"] = $this->auth->id;
-        $type && $where["type"] = $type;
+        try {
+            $page = $this->request->request('page',1); // 分页
+            $pageNum = $this->request->request('pageNum',10); // 分页
+            $type = $this->request->request("type"); // 装扮类型:1=座驾,2=头饰,3=聊天气泡,4=消息尾灯
+            // 分页搜索构建
+            $pageStart = ($page-1)*$pageNum;
+            global $where;
+            $where = [];$whereOr=[];
+            $where["user_id"] = $this->auth->id;
+            $type && $where["type"] = $type;
 
-        $whereOr["is_use"] = "0";
-        $whereOr["duetime"] = ["gt",time()];
-        $list = $this->attirebackModel
-            ->field("id,type,file_image,gif_image,attire_name as title,limit_day,duetime,is_use,is_using")
-            ->where(function ($query) {
-                global $where;
-                $query->where($where);
-            })
-            ->where(function ($query) {
-                $query->whereOr(["is_use"=>0,"duetime"=>["gt",time()]]);
-            })
-            ->limit($pageStart,$pageNum)
-            ->select();
+            $whereOr["is_use"] = "0";
+            $whereOr["duetime"] = ["gt",time()];
+            $list = $this->attirebackModel
+                ->field("id,type,file_image,gif_image,attire_name as title,limit_day,duetime,is_use,is_using")
+                ->where(function ($query) {
+                    global $where;
+                    $query->where($where);
+                })
+                ->where(function ($query) {
+                    $query->whereOr(["is_use"=>0,"duetime"=>["gt",time()]]);
+                })
+                ->limit($pageStart,$pageNum)
+                ->select();
 
-        if(!$list) {
-            $this->success("背包空空如也!");
-        }
-
-        foreach($list as $k => $v) {
-            // 有效期/剩余天数
-            if($v["is_use"] == 1 && $v["duetime"]>time()) { // 正在使用,未过期
-                $dtime = "剩余".ceil(($v["duetime"]-time())/86400)."天";
+            if(!$list) {
+                $this->success("背包空空如也!");
             }
-            if($v["is_use"] == 0) {
-                $dtime = "有效期".$v["limit_day"]."天";
+
+            foreach($list as $k => $v) {
+                // 有效期/剩余天数
+                if($v["is_use"] == 1 && $v["duetime"]>time()) { // 正在使用,未过期
+                    $dtime = "剩余".ceil(($v["duetime"]-time())/86400)."天";
+                }
+                if($v["is_use"] == 0) {
+                    $dtime = "有效期".$v["limit_day"]."天";
+                }
+                $list[$k]["dtime"] = $dtime;
             }
-            $list[$k]["dtime"] = $dtime;
+            $this->success("获取成功!",$list);
+        } catch (Exception $e) {echo '<pre>';var_dump($e->getMessage());exit;
+            $this->error($e->getMessage());
         }
-        $this->success("获取成功!",$list);
     }
     /**
      * 使用并装上装饰

+ 3 - 1
application/api/controller/Usersign.php

@@ -129,8 +129,10 @@ class Usersign extends Api
         $msg_id = \app\common\model\Message::addMessage($this->auth->id,'签到奖励','签到成功,获得奖励');
 
         Db::commit();
+        $signImg = config('site.sign_img');
+        $signImg = cdnurl($signImg);
         $result = [
-            'image' => isset($gift['image']) ? $gift['image'] : '',
+            'image' => isset($gift['image']) ? $gift['image'] : $signImg,
             'goldnum' => isset($gift['num']) ? $gift['num'] : $data['goldnum'],
         ];
         $this->success('签到成功', $result);

+ 3 - 2
application/extra/site.php

@@ -110,6 +110,7 @@ return [
     'money_to_jewel' => '10',
     'eggplay_paymoney_min' => '1000',
     'invite_money' => '1',
-    'exchange_define' => '0',
-    'withdraw_define' => '0',
+    'exchange_define' => '1',
+    'withdraw_define' => '1',
+    'sign_img' => '/uploads/20230714/f02676a5491e5a88141ce9a9a8c20a77.png',
 ];

+ 55 - 0
public/assets/js/backend/user_sign.js

@@ -0,0 +1,55 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'user_sign/index' + location.search,
+                    add_url: 'user_sign/add',
+                    edit_url: 'user_sign/edit',
+                    del_url: 'user_sign/del',
+                    multi_url: 'user_sign/multi',
+                    import_url: 'user_sign/import',
+                    table: 'user_sign',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id')},
+                        {field: 'uid', title: __('Uid')},
+                        {field: 'times', title: __('Times')},
+                        {field: 'goldnum', title: __('Goldnum')},
+                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
+                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+        add: function () {
+            Controller.api.bindevent();
+        },
+        edit: function () {
+            Controller.api.bindevent();
+        },
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});