lizhen_gitee 7 ヶ月 前
コミット
6e65ee8250

+ 35 - 0
application/admin/controller/user/User.php

@@ -38,6 +38,41 @@ class User extends Backend
      * 需要将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(['userwallet'])
+                ->where($where)
+                ->order($sort, $order)
+                ->paginate($limit);
+
+            foreach ($list as $row) {
+
+                $row->getRelation('userwallet')->visible(['score']);
+            }
+
+            $result = array("total" => $list->total(), "rows" => $list->items());
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+
+
 
     public function selectpagenew()
     {

+ 2 - 1
application/admin/lang/zh-cn/user/user.php

@@ -52,5 +52,6 @@ return [
     'Is_first'          => '是否上过课',
     'Is_first 0'        => '否',
     'Is_first 1'        => '是',
-    'Residential'        => '居住地'
+    'Residential'        => '居住地',
+    'userwallet.score'  => '积分',
 ];

+ 4 - 0
application/admin/model/User.php

@@ -124,5 +124,9 @@ class User extends Model
         return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
     }
 
+    public function userwallet()
+    {
+        return $this->belongsTo('Userwallet', 'id', 'user_id', [], 'LEFT')->setEagerlyType(0);
+    }
 
 }

+ 16 - 0
application/admin/model/Userwallet.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+class Userwallet extends Model
+{
+
+    // 表名
+    protected $name = 'user_wallet';
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+
+}

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

@@ -35,6 +35,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
 //                        {field: 'password', title: __('Password'), operate: 'LIKE'},
 //                        {field: 'salt', title: __('Salt'), operate: 'LIKE'},
                         {field: 'email', title: __('Email'), operate: 'LIKE'},
+                        {field: 'userwallet.score', title: __('userwallet.score'), operate: false},
+
                         {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
                         {field: 'simplemobile', title: __('Simplemobile'), operate: 'LIKE'},
                         {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},