Browse Source

谷歌验证码

afa 10 tháng trước cách đây
mục cha
commit
a1138b8543

+ 5 - 19
application/admin/controller/user/User.php

@@ -93,14 +93,13 @@ class User extends Backend
 
 
     /**
-     * 编辑
-     *
+     * 茶宝调整
      * @param $ids
      * @return string
      * @throws DbException
      * @throws \think\Exception
      */
-    public function edit($ids = null)
+    public function approve($ids = null)
     {
         $ids = intval($ids);
         $row = $this->model->get($ids);
@@ -113,14 +112,12 @@ class User extends Backend
         }
         if (false === $this->request->isPost()) {
             $wallet             = (new LedgerWalletModel())->get($ids);
-            $row['power']       = $wallet['power'] ?? "-";
-
-            $google=new GoogleAuthenticator();
+            $row['token']       = $wallet['token'] ?? "-";
+            //$google=new GoogleAuthenticator();
             //生成验证秘钥
             //$secret=$google->createSecret();
-            $qrCodeUrl = $google->getQRCodeGoogleUrl('RWACHA',  config('google_secret'));
+            //$qrCodeUrl = $google->getQRCodeGoogleUrl('RWACHA',  config('google_secret'));
             $this->view->assign('row', $row);
-            $this->view->assign('qrCodeUrl', $qrCodeUrl);
             return $this->view->fetch();
         }
         $params = $this->request->post('row/a');
@@ -128,10 +125,6 @@ class User extends Backend
             $this->error(__('Parameter %s can not be empty', ''));
         }
         $params = $this->preExcludeFields($params);
-        $newLevelId = $params['team_level_id'];
-        if($newLevelId > 0 && empty((new TeamLevelModel())->getTeamLevelName($newLevelId))){
-            $this->error('会员等级错误');
-        }
         $google=new GoogleAuthenticator();
         $checkResult = $google->verifyCode(config('google_secret'), $params['code'], 6);
         if (!$checkResult) $this->error('谷歌验证码错误');
@@ -140,13 +133,6 @@ class User extends Backend
         // 启动事务
         Db::startTrans();
         try {
-            // 更新会员等级
-            if ($newLevelId != $row['team_level_id']) {
-                $updated = (new UserModel())->save(['team_level_id' => $newLevelId], ['id' => $row['id']]);
-                if (empty($updated)) {
-                    throw new Exception('更新会员等级影响行数为0');
-                }
-            }
             // 更新茶宝
             if (bccomp($newPower, 0, 6) !== 0) {
                 (new LedgerWalletModel)->changeWalletAccount($ids, Asset::TOKEN, $newPower, LedgerWalletModel::System);

+ 47 - 0
application/admin/view/user/user/approve.html

@@ -0,0 +1,47 @@
+<form id="edit-form" role="form" data-toggle="validator" method="POST" action="">
+      <div class="form-horizontal">
+      <div class="form-group">
+          <label class="control-label col-xs-12 col-sm-2">用户ID:</label>
+          <div class="col-xs-12 col-sm-2">
+              <label class="control-label col-xs-12 col-sm-2">{$row.id}</label>
+          </div>
+      </div>
+  
+      <div class="form-group">
+          <label class="control-label col-xs-12 col-sm-2">用户地址:</label>
+          <div class="col-xs-12 col-sm-2">
+              <label class="control-label col-xs-12 col-sm-2">{$row.address}</label>
+          </div>
+      </div>
+  
+      <div class="form-group">
+          <label class="control-label col-xs-12 col-sm-2">当前茶宝:</label>
+          <div class="col-xs-12 col-sm-2">
+              <label class="control-label col-xs-12 col-sm-2">{$row.token}</label>
+          </div>
+      </div>
+  
+      <div class="form-group">
+          <label class="control-label col-xs-12 col-sm-2">茶宝调整(+/-):</label>
+          <div class="col-xs-12 col-sm-8">
+              <input id="c-power" class="form-control" placeholder="不填则不调整" name="row[new_power]" type="text" value="" />
+          </div>
+      </div>
+  
+      <div class="form-group">
+          <label class="control-label col-xs-12 col-sm-2">谷歌验证:</label>
+          <div class="col-xs-12 col-sm-8">
+              <input id="c-code" class="form-control" data-rule="required" placeholder="请输入验证码" name="row[code]" type="text" value="" />
+          </div>
+      </div>
+
+      <div class="form-group layer-footer">
+          <label class="control-label col-xs-12 col-sm-2"></label>
+          <div class="col-xs-12 col-sm-8">
+              <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
+              <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+          </div>
+      </div>
+  </div>
+  </form>
+  

+ 7 - 23
application/admin/view/user/user/edit.html

@@ -15,40 +15,24 @@
     </div>
 
     <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">当前算力:</label>
-        <div class="col-xs-12 col-sm-2">
-            <label class="control-label col-xs-12 col-sm-2">{$row.power}</label>
-        </div>
-    </div>
-
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">茶宝调整(+/-):</label>
+        <label class="control-label col-xs-12 col-sm-2">昵称:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-power" class="form-control" placeholder="不填则不调整" name="row[new_power]" type="text" value="" />
+            <input id="c-nickname" class="form-control" data-rule="required" name="row[nickname]" type="text" value="{$row.nickname|htmlentities}" />
         </div>
     </div>
 
     <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">谷歌验证:</label>
+        <label class="control-label col-xs-12 col-sm-2">姓名:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-code" class="form-control" data-rule="required" placeholder="请输入验证码" name="row[code]" type="text" value="" />
-        </div>
-    </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2"></label>
-        <div class="col-xs-12 col-sm-8">
-            <img src="{$qrCodeUrl}" />
+            <input id="c-name" class="form-control" data-rule="required" placeholder="请输入姓名" name="row[name]" type="text" value="{$row.name|htmlentities}" />
         </div>
     </div>
  
+ 
     <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">会员等级调整:</label>
+        <label class="control-label col-xs-12 col-sm-2">手机号:</label>
         <div class="col-xs-8">
-            <input type="hidden" class="form-control operate" name="team_level_id-operate" data-name="team_level_id" value="FIND_IN_SET" readonly="">
-            <select class="form-control" name="row[team_level_id]">
-                <option value="0" {eq name="$row.team_level_id" value="0"}selected{/eq}>金矿</option>
-                <option value="1" {eq name="$row.team_level_id" value="1"}selected{/eq}>股东</option>
-            </select>
+            <input id="c-phone" type="text" class="form-control" name="row[phone]" value="{$row.phone|htmlentities}" data-rule="required">
         </div>
     </div>
 

+ 1 - 0
application/admin/view/user/user/index.html

@@ -22,6 +22,7 @@
                     </div>
                     <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
                            data-operate-edit="{:$auth->check('user/user/edit')}"
+                           data-operate-approve="{:$auth->check('user/user/approve')}"
                            data-operate-del="false">
                     </table>
                 </div>

+ 4 - 4
public/assets/js/backend/user/user.js

@@ -7,7 +7,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 extend: {
                     index_url: 'user/user/index' + location.search,
                     //add_url: 'user/user/add',
-                    //edit_url: 'user/user/edit',
+                    edit_url: 'user/user/edit',
                     del_url: 'user/user/del',
                     multi_url: 'user/user/multi',
                     import_url: 'user/user/import',
@@ -57,8 +57,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                 title: '茶宝调整',
                                 classname: 'btn btn-xs btn-info btn-dialog btn-receivable',
                                 icon: 'fa fa-pencil',
-                                url: 'user/user/edit',
-                                extend: 'data-area=\'["50%", "70%"]\'',
+                                url: 'user/user/approve',
+                                extend: 'data-area=\'["50%", "50%"]\'',
                             },],
                             formatter: Table.api.formatter.operate
                         }
@@ -69,7 +69,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             // 为表格绑定事件
             Table.api.bindevent(table);
         },
-        add: function () {
+        approve: function () {
             Controller.api.bindevent();
         },
         edit: function () {