Browse Source

后台设置支付方式

mashouyi 2 years ago
parent
commit
a6260d40fd

+ 53 - 0
application/admin/controller/Payway.php

@@ -0,0 +1,53 @@
+<?php
+/*
+ * Created by PhpStorm.
+ * User: mashouyi
+ * Date: 2022-04-28 8:20
+ */
+namespace app\admin\controller;
+use library\Controller;
+use think\Db;
+
+/**
+ * 支付方式管理
+ * @package app\admin\controller
+ */
+class Payway extends Controller
+{
+
+    /**
+     * 当前操作数据库
+     * @var string
+     */
+    protected $table = 'SystemPayWay';
+    public function index()
+    {
+        $this->title = '支付方式管理';
+        $this->_page($this->table, false);
+    }
+    public function edit()
+    {
+        $this->applyCsrfToken();
+        $this->_form($this->table, 'form');
+    }
+    /**
+     * 禁用支付方式
+     */
+    public function forbid()
+    {
+        if (in_array('10000', explode(',', $this->request->post('id')))) {
+            $this->error('系统超级账号禁止操作!');
+        }
+        $this->applyCsrfToken();
+        $this->_save($this->table, ['status' => '0']);
+    }
+
+    /**
+     * 启用支付方式
+     */
+    public function resume()
+    {
+        $this->applyCsrfToken();
+        $this->_save($this->table, ['status' => '1']);
+    }
+}

+ 29 - 0
application/admin/view/payway/form.html

@@ -0,0 +1,29 @@
+<form class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">
+    <div class="layui-card-body padding-left-40">
+
+        <div class="layui-form-item">
+            <span class="color-green label-required-prev">logo</span>
+            <table class="layui-table">
+                <thead>
+                <tr>
+                    <td width="90px" class="text-left"><input name="img" lay-verify="required" type="hidden" value="{$vo.img|default=''}"></td>
+                </tr>
+                </thead>
+            </table>
+            <script>$('[name="img"]').uploadOneImage()</script>
+        </div>
+        <div class="layui-form-item">
+            <label class="relative block">
+                <span class="color-green font-w7">支付方式</span>
+                <input name="name" value='{$vo.name|default=""}' required class="layui-input">
+            </label>
+        </div>
+    </div>
+    <div class="hr-line-dashed"></div>
+    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
+    <div class="layui-form-item text-center">
+        <button class="layui-btn" type='submit'>保存数据</button>
+        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
+    </div>
+
+</form>

+ 53 - 0
application/admin/view/payway/index.html

@@ -0,0 +1,53 @@
+{extend name='main'}
+{block name="content"}
+<div class="think-box-shadow">
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <thead>
+        <tr>
+            <th class='text-left nowrap'>logo</th>
+            <th class='text-left nowrap'>支付方式</th>
+            <th class='text-left nowrap'>code</th>
+            <th class='text-center nowrap'>使用状态</th>
+            <th class='text-left nowrap'></th>
+        </tr>
+        </thead>
+        {/notempty}
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr data-dbclick>
+            <td class='text-left nowrap'>
+                {notempty name='vo.img'}
+                <img data-tips-image style="width:40px;height:40px;vertical-align:top" src="{$vo.img|default=''}" class="margin-right-5">
+                {/notempty}
+            </td>
+            <td class='text-left nowrap'>{$vo.name|default=''}</td>
+            <td class='text-left nowrap'>{$vo.code|default='-'}</td>
+            <td class='text-center nowrap'>
+                {eq name='vo.status' value='0'}
+                <span class="color-red">已禁用</span>
+                {else}
+                <span class="color-green">使用中</span>
+                {/eq}
+            </td>
+            <td class='text-left nowrap'>
+                {if auth("edit")}
+                <a data-dbclick class="layui-btn layui-btn-sm" data-title="编辑用户" data-modal='{:url("edit")}?id={$vo.id}'>编 辑</a>
+                {/if}
+
+                {if $vo.status eq 1 and auth("forbid")}
+                <a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('forbid')}" data-value="id#{$vo.id};status#0" data-csrf="{:systoken('forbid')}">禁 用</a>
+                {elseif $vo.status eq 0 and auth("resume")}
+                <a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('resume')}" data-value="id#{$vo.id};status#1" data-csrf="{:systoken('resume')}">启 用</a>
+                {/if}
+            </td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+
+</div>
+
+{/block}