qifengquan 1 سال پیش
والد
کامیت
ae42800a1f

+ 26 - 1
application/admin/controller/user/User.php

@@ -103,7 +103,7 @@ class User extends Backend
     }
 
     /**
-     * 切换
+     * 推荐切换
      */
     public function change($ids = '')
     {
@@ -117,8 +117,15 @@ class User extends Backend
         }
         if($row->is_recommend){
             $is_recommend = ['is_recommend'=>0];
+            $row->save(['recommend_weight'=>'']);
         }else{
             $is_recommend = ['is_recommend'=>1];
+            $max = \app\common\model\User::max('recommend_weight');
+            if($max){
+                $row->save(['recommend_weight'=>$max+1]);
+            }else{
+                $row->save(['recommend_weight'=>1]);
+            }
         }
         $this->model->update($is_recommend,['id'=>$ids]);
         $this->success("模拟切换成功");
@@ -157,4 +164,22 @@ class User extends Backend
         $row->save($row->status);
         $this->success("解封成功");
     }
+    /**
+     * 详情
+     */
+    public function detail($ids)
+    {
+        $row = $this->model->get(function ($query){
+            $query->field('id,username,mobile,gender,birthday,money,score,createtime,status');
+        });
+        if (!$row) {
+            $this->error(__('No Results were found'));
+        }
+        if ($this->request->isAjax()) {
+            $this->success("Ajax请求成功", null, ['id' => $ids]);
+        }
+
+        $this->view->assign("row", $row->toArray());
+        return $this->view->fetch();
+    }
 }

+ 3 - 3
application/admin/model/User.php

@@ -18,9 +18,9 @@ class User extends Model
     protected $updateTime = 'updatetime';
     // 追加属性
     protected $append = [
-        'prevtime_text',
-        'logintime_text',
-        'jointime_text'
+//        'prevtime_text',
+//        'logintime_text',
+//        'jointime_text'
     ];
 
     public function getOriginData()

+ 8 - 0
application/admin/view/user/user/edit.html

@@ -87,6 +87,14 @@
             <input id="c-score" data-rule="required" class="form-control" name="row[score]" type="number" value="{$row.score}">
         </div>
     </div>
+    {if $row['is_recommend']}
+        <div class="form-group">
+            <label for="c-mobile" class="control-label col-xs-12 col-sm-2">{:__('推荐排序')}:</label>
+            <div class="col-xs-12 col-sm-4">
+                <input id="c-recommend_weight" data-rule="" class="form-control" name="row[recommend_weight]" type="text" value="{$row.recommend_weight|htmlentities}">
+            </div>
+        </div>
+    {/if}
 <!--    <div class="form-group">-->
 <!--        <label for="c-successions" class="control-label col-xs-12 col-sm-2">{:__('Successions')}:</label>-->
 <!--        <div class="col-xs-12 col-sm-4">-->

+ 9 - 2
public/assets/js/backend/user/user.js

@@ -55,7 +55,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         // {field: 'jointime', title: __('Jointime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                         // {field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search},
                         {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('封禁'), destruction: __('注销')}},
-                        // {field: 'is_recommend', title: '推荐', formatter: Table.api.formatter.status, searchList: {1: '推荐', 0: '不推荐'}},
+                        {field: 'recommend_weight', title: __('推荐排序'), sortable: true},
                         {field: 'is_recommend', title: __('推荐'), operate: false, formatter: Controller.api.custom},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
                         buttons:[{
@@ -104,7 +104,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                 table.bootstrapTable('refresh');
                                 return false;
                             }
-                        },]
+                        },{
+                            name: '详情',
+                            text: '详情',
+                            title: __('详情'),
+                            classname: 'btn btn-xs btn-warning btn-addtabs',
+                            // icon: 'fa fa-folder-o',
+                            url: 'user/user/detail'
+                        }]
                         }
                     ]
                 ]