Commit 8b5ca475 authored by shajiaiming's avatar shajiaiming

Merge branch 'master' into feature/ucenter

parents 8a403411 2eebd9e6
...@@ -57,7 +57,8 @@ class CoinRecommendController extends BaseController ...@@ -57,7 +57,8 @@ class CoinRecommendController extends BaseController
} else { } else {
$platforms = CoinPlatform::find()->where(['id' => $user_platform_id])->asArray()->all(); $platforms = CoinPlatform::find()->where(['id' => $user_platform_id])->asArray()->all();
} }
return $this->render('index', ['platforms' => $platforms]); $chains = Coin::getPlatformList();
return $this->render('index', ['platforms' => $platforms, 'chains' => $chains]);
} }
public function actionAdd() public function actionAdd()
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
<div style="display: none; padding: 5px 5px;" id="_form"> <div style="display: none; padding: 5px 5px;" id="_form">
<form class="layui-form" id="form1" lay-filter="form1"> <form class="layui-form" id="form1" lay-filter="form1">
<input type="hidden" name="id" value=""> <input type="hidden" name="id" value="">
<input type="hidden" name="platform_id_hidden" id = 'platform_id_hidden' value="">
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">钱包</label> <label class="layui-form-label">钱包</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
...@@ -88,6 +89,17 @@ ...@@ -88,6 +89,17 @@
</select> </select>
</div> </div>
</div> </div>
<div class="layui-form-item">
<label class="layui-form-label">所属链</label>
<div class="layui-input-inline">
<select class="layui-select" name="chain">
<option value="">请选择一个链</option>
<?php foreach ($chains as $chain): ?>
<option value="<?= $chain ?>"><?= $chain ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
</form> </form>
</div> </div>
...@@ -162,6 +174,10 @@ table.render({ ...@@ -162,6 +174,10 @@ table.render({
templet: '#type_tpl' templet: '#type_tpl'
}, },
{ {
field: 'chain',
title: '所属链',
},
{
field: 'sort', field: 'sort',
title: '排序' title: '排序'
}, },
...@@ -191,7 +207,8 @@ table.on('toolbar(table1)', function(obj) { ...@@ -191,7 +207,8 @@ table.on('toolbar(table1)', function(obj) {
coin: '', coin: '',
sort: '', sort: '',
recommend: '', recommend: '',
type:'' type:'',
chain:'',
}); });
}, },
btn1: function() { btn1: function() {
...@@ -238,12 +255,14 @@ table.on('tool(table1)', function(obj) { ...@@ -238,12 +255,14 @@ table.on('tool(table1)', function(obj) {
coin: data.coin, coin: data.coin,
sort: data.sort, sort: data.sort,
recommend: data.recommend, recommend: data.recommend,
type: data.type type: data.type,
chain: data.chain,
platform_id_hidden: data.platform_id
}); });
}, },
btn1: function() { btn1: function() {
var data = $("#form1").serialize(); var data = $("#form1").serialize();
data += "&platform_id="+$('#platform_id').val(); data += "&platform_id="+$('#platform_id_hidden').val();
$.get('/admin/coin-recommend/add', data, function(rev) { $.get('/admin/coin-recommend/add', data, function(rev) {
layer.msg(rev.msg); layer.msg(rev.msg);
if (0 == rev.code) { if (0 == rev.code) {
......
...@@ -82,6 +82,7 @@ class CoinRecommend extends BaseActiveRecord ...@@ -82,6 +82,7 @@ class CoinRecommend extends BaseActiveRecord
$recommend_type = $params['recommend'] ?? 1; $recommend_type = $params['recommend'] ?? 1;
$sort = $params['sort'] ?? 0; $sort = $params['sort'] ?? 0;
$type = $params['type'] ?? 1; $type = $params['type'] ?? 1;
$chain = $params['chain'] ?? '';
$coin = Coin::findOne(['name' => strtoupper($coin_name)]); $coin = Coin::findOne(['name' => strtoupper($coin_name)]);
if (empty($coin)) { if (empty($coin)) {
...@@ -92,7 +93,7 @@ class CoinRecommend extends BaseActiveRecord ...@@ -92,7 +93,7 @@ class CoinRecommend extends BaseActiveRecord
$coin_recommend = CoinRecommend::findOne($id); $coin_recommend = CoinRecommend::findOne($id);
} else { } else {
$coin_recommend = new CoinRecommend(); $coin_recommend = new CoinRecommend();
$count = self::find()->where(['cid' => $coin->id, 'platform_id' => $platform_id, 'type' => $type])->count(); $count = self::find()->where(['cid' => $coin->id, 'platform_id' => $platform_id, 'type' => $type, 'chain' => $chain])->count();
if ($count > 0) { if ($count > 0) {
return ['code' => -1, 'msg' => '推荐币种已经存在']; return ['code' => -1, 'msg' => '推荐币种已经存在'];
} }
...@@ -106,6 +107,7 @@ class CoinRecommend extends BaseActiveRecord ...@@ -106,6 +107,7 @@ class CoinRecommend extends BaseActiveRecord
$coin_recommend->platform_id = $platform_id; $coin_recommend->platform_id = $platform_id;
$coin_recommend->sort = $sort; $coin_recommend->sort = $sort;
$coin_recommend->type = $type; $coin_recommend->type = $type;
$coin_recommend->chain = $chain;
if ($coin_recommend->save()) { if ($coin_recommend->save()) {
return ['code' => 0, 'msg' => '保存成功']; return ['code' => 0, 'msg' => '保存成功'];
} }
......
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