瀏覽代碼

后台用户列表显示修改

lizhen_gitee 1 年之前
父節點
當前提交
5e1a181367

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

@@ -30,6 +30,8 @@ class User extends Backend
      */
     public function index()
     {
+        //当前是否为关联查询
+        $this->relationSearch = true;
         $this->selectpageFields = ['id','nickname'];
         //设置过滤方法
         $this->request->filter(['strip_tags', 'trim']);
@@ -42,9 +44,15 @@ class User extends Backend
         }
         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 = ['total' => $list->total(), 'rows' => $list->items()];
         return json($result);
     }

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

@@ -40,5 +40,6 @@ return [
     'Intro_uid'       => '邀请人uid',
     'Intro_ids'       => '所有上级网体推荐人id',
     'Intro_level'     => '推荐网等级',
-    'Id'              => 'ID'
+    'Id'              => 'ID',
+    'Userwallet.score' => '积分',
 ];

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

@@ -113,4 +113,9 @@ class User extends Model
     }
 
 
+    public function userwallet()
+    {
+        return $this->belongsTo('Userwallet', 'id', 'user_id', [], 'LEFT')->setEagerlyType(0);
+    }
+
 }

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

@@ -0,0 +1,20 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class Userwallet extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $table = 'user_wallet';
+    
+
+
+}

+ 3 - 1
public/assets/js/backend/user/user.js

@@ -35,7 +35,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
 //                        {field: 'salt', title: __('Salt'), operate: 'LIKE'},
 //                        {field: 'email', title: __('Email'), operate: 'LIKE'},
                         {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
-                        {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
+                        {field: 'userwallet.score', title: __('Userwallet.score'), operate: false},
+//                        {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
 //                        {field: 'level', title: __('Level')},
 //                        {field: 'gender', title: __('Gender')},
 //                        {field: 'birthday', title: __('Birthday'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
@@ -110,6 +111,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
 //                        {field: 'salt', title: __('Salt'), operate: 'LIKE'},
 //                        {field: 'email', title: __('Email'), operate: 'LIKE'},
                         {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
+
 //                        {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
 //                        {field: 'level', title: __('Level')},
 //                        {field: 'gender', title: __('Gender')},