Commit bef37105 authored by rlgy's avatar rlgy

钱包用户

parent dd205671
......@@ -10,6 +10,7 @@ namespace backend\controllers;
use Yii;
use common\models\pwallet\Member;
use common\models\pwallet\MemberAsset;
class MemberController extends BaseController
{
......@@ -99,4 +100,24 @@ class MemberController extends BaseController
}
$this->error('用户不存在', '/admin/member/index');
}
public function actionWallet()
{
if (Yii::$app->request->isAjax) {
$request = Yii::$app->request;
$page = $request->get('page', 1);
$limit = $request->get('limit', 10);
$uid = $request->get('uid', '');
$where = [];
if ($uid) {
$where[] = ['uid' => $uid];
}
$data = MemberAsset::getList($page, $limit, $where);
Yii::$app->response->format = 'json';
Yii::$app->response->data = $data;
Yii::$app->response->send();
}
return $this->render('wallet');
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-7-5
* Time: 上午9:57
*/
?>
<div class="layui-row">
<div class="layui-col-md8">
<form class="layui-form">
<div class="layui-inline">
<input class="layui-input" placeholder="UID" name="uid">
</div>
<div class="layui-inline">
<button class="layui-btn" lay-submit lay-filter="submit1">筛选</button>
</div>
</form>
</div>
</div>
<div class="layui-row">
<div class="layui-col-md8">
<table id="table1" lay-filter="table1"></table>
</div>
</div>
<script>
var table = layui.table;
var form = layui.form;
table.render({
elem: '#table1',
url: '/admin/member/wallet',
page: 1,
cols: [[
{field: 'uid', title: 'UID'},
{field: 'public_key', title: '钱包公钥'},
{title: '操作', toolbar: '#tools', fixed: 'right'}
]],
});
table.on('tool(table1)', function (obj) {
var data = obj.data;
var event = obj.event;
if (event == 'view_assets') {
var assets = JSON.parse(data.asset);
//TODO 资产显示
var content = '<table class="layui-table" style="margin: 5px; width: 340px">';
content += '<tr><td>币种</td><td>数量</td></tr>';
$.each(assets, function (key, val) {
content += '<tr><td>' + key + '</td>' + '<td>' + val + '</td></tr>';
});
content += '</table>';
var index = layer.open({
type: 1,
content: content,
title: '用户(UID:' + data.uid + ')资产',
area: '350px',
resize: false,
});
}
});
//表单提交
form.on('submit(submit1)', function (data) {
table.reload('table1', {
where: data.field,
page: {curr: 1},
});
return false;
});
</script>
<script type="text/html" id="tools">
<a class="layui-btn layui-btn-sm" lay-event="view_assets">查看资产</a>
</script>
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-7-5
* Time: 上午10:27
*/
namespace common\models\pwallet;
use common\core\BaseActiveRecord;
/**
* Class MemberAsset
* 用户资产表
*
* @property integer $id
* @property integer $uid
* @property string $asset
* @property string $create_at
* @property string $update_at
* @package common\models\pwallet
*/
class MemberAsset extends BaseActiveRecord
{
public static function getDb()
{
return \Yii::$app->get('db_pwallet');
}
public function formName()
{
return '';
}
public function attributeLabels()
{
return [
'id' => 'ID',
'uid' => '用户ID',
'asset' => '资产信息',
'create_at' => '创建时间',
'update_at' => '更新时间'
];
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment