Commit f1593aa5 authored by rlgy's avatar rlgy

上架交易所

parent 4130d346
......@@ -25,9 +25,9 @@ return [
'baseUrl' => '/interface',
'cookieValidationKey' => '123456',
'enableCsrfValidation' => false,
// 'parsers' => [
// 'application/json' => 'yii\web\JsonParser',
// ],
'parsers' => [
'application/json' => 'yii\web\JsonParser',
],
],
'response' => [
'class' => 'api\base\BaseResponse',
......
......@@ -8,7 +8,6 @@
namespace backend\controllers;
use backend\controllers\BaseController;
use Yii;
use common\models\pwallet\Coin;
use backend\models\coin\CoinForm;
......@@ -16,6 +15,7 @@ use yii\base\InvalidConfigException;
use yii\db\Exception;
use yii\web\UploadedFile;
use yii\validators\ImageValidator;
use common\business\CoinBusiness;
/**
* 币种管理控制器
......@@ -27,14 +27,22 @@ class CoinController extends BaseController
public function actionIndex()
{
if (Yii::$app->request->isAjax) {
$request = Yii::$app->request;
$page = $request->get('page', 1);
$limit = $request->get('limit', 10);
$name = $request->get('name', null);
$request = Yii::$app->request;
$page = $request->get('page', 1);
$limit = $request->get('limit', 10);
$name = $request->get('name', null);
$platform = $request->get('platform', null);
$condition = [];
if ($name) {
$condition[] = ['like', 'name', $name];
}
if ($platform) {
$condition[] = ['platform' => $platform];
}
$data = CoinBusiness::getList($page, $limit, $condition);
$data['code'] = 0;
//ajax return
Yii::$app->response->format = 'json';
$data = Coin::getList($page, $limit, ['like', 'name', $name]);
$data['code'] = 0;
return $data;
}
return $this->render('index');
......@@ -129,4 +137,9 @@ class CoinController extends BaseController
return ['code' => $exception->getCode(), 'msg' => $exception->getMessage()];
}
}
public function actionCost()
{
return '';
}
}
\ No newline at end of file
......@@ -28,18 +28,28 @@
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label" style="margin-bottom: 0; width: 100px;">平台</label>
<div class="layui-input-inline">
<select name="platform">
<option>all</option>
<option value="ethereum">eth</option>
</select>
</div>
</div>
<div class="layui-inline">
<button class="layui-btn" lay-submit lay-filter="form1">搜索</button>
</div>
</form>
</div>
</div>
<div class="layui-row">
<table class="layui-table" id="table1"></table>
<table class="layui-table" id="table1" lay-filter="table1"></table>
</div>
<script>
var table = layui.table;
var form = layui.form;
var layer = layui.layer;
form.render();
table.render({
elem: "#table1",
url: '/admin/coin/index',
......@@ -55,6 +65,13 @@
{field: 'official', title: '官网', templet: "#officialTpl"},
{field: 'paper', title: '白皮书', templet: "#paperTpl"},
{field: 'platform', title: '平台'},
{
field: 'exchange',
title: '上架交易所',
templet: "#exchangeTpl",
style: 'cursor: pointer;',
event: 'getExchange'
},
{field: 'price', title: '众筹价格'},
{field: 'release', title: '发行时间'},
{field: 'id', title: '操作', templet: '#operationTpl'}
......@@ -68,6 +85,23 @@
});
return false;
});
//监听单元格事件
table.on('tool(table1)', function (obj) {
var data = obj.data;
console.log(data);
if (obj.event === 'getExchange') {
var content = '';
$.each(data.exchange.data, function (index, item) {
content += '<li>' + item + '</li>';
});
layer.open({
type: 0,
title: '上架交易所列表',
content: content,
tips: 3
});
}
});
</script>
<script type="text/html" id="iconTpl">
<img src="{{d.icon}}" style="max-width: 32px; max-height: 32px;"/>
......@@ -94,4 +128,7 @@
<a href="/admin/coin/edit?id={{d.id}}">
<button class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe642;</i></button>
</a>
</script>
<script type="text/html" id="exchangeTpl">
{{d.exchange.count}}
</script>
\ No newline at end of file
......@@ -2,30 +2,38 @@
$chain_url = "121.196.205.182:45656";
return [
'adminEmail' => 'admin@example.com',
'supportEmail' => 'support@example.com',
'adminEmail' => 'admin@example.com',
'supportEmail' => 'support@example.com',
'user.passwordResetTokenExpire' => 3600,
'admin' => 1,
'admin' => 1,
/* 后台页面属性配置 */
'config_page' => [
'add' => '添加',
'delete' => '删除',
'update' => '更新',
'tool_bar' => '工具箱',
'export' => '导出Excel',
'others' => '其它',
'details' => '详情',
'color_opt' => 'btn-primary',
'color_bar' => 'btn-primary',
],
/* 后台页面属性配置 */
'config_page' => [
'add' => '添加',
'delete' => '删除',
'update' => '更新',
'tool_bar' => '工具箱',
'export' => '导出Excel',
'others' => '其它',
'details' => '详情',
'color_opt' => 'btn-primary',
'color_bar' => 'btn-primary',
],
'pager' => [
'options' => ['class'=>'pagination','style'=>'visibility: visible;'],
'firstPageLabel' => "首页",
'prevPageLabel' => '上一页',
'nextPageLabel' => '下一页',
'lastPageLabel' => '末页',
],
'pager' => [
'options' => ['class' => 'pagination', 'style' => 'visibility: visible;'],
'firstPageLabel' => "首页",
'prevPageLabel' => '上一页',
'nextPageLabel' => '下一页',
'lastPageLabel' => '末页',
],
/** 非小号数据爬取地址 */
'feixiaohao_domain' => 'https://www.feixiaohao.com',
'feixiaohao_page' => [
'assets' => '/assets/',//代币
'currencies' => '/currencies/',//币种详情
'coinmarket' => '/coinmarket/',//上市交易所
],
];
......@@ -28,13 +28,17 @@ class Coin extends BaseActiveRecord
* 获取币种信息列表
* @param int $page
* @param int $limit
* @param array $config
* @param array $condition
* @return array|\yii\db\ActiveRecord[]
*/
public static function getList($page = 1, $limit = 10, $config = [])
public static function getList($page = 1, $limit = 10, $condition = [])
{
$count = self::find()->filterWhere($config)->count();
$data = self::find()->offset(($page - 1) * 10)->limit($limit)->filterWhere($config)->asArray()->all();
$query = self::find();
foreach ($condition as $item) {
$query = $query->andFilterWhere($item);
}
$count = $query->count();
$data = $query->offset(($page - 1) * 10)->limit($limit)->asArray()->all();
foreach ($data as $key => $item) {
$data[$key]['price'] = sprintf("%0.6f", $item['price']);
// $data[$key]['release'] = date('Y-m-d', $item['release']);
......
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