作者 魏强

online

<?php
namespace app\admin\controller;
use app\common\controller\Backend;
/**
* 提现审核管理
*
* @icon fa fa-circle-o
*/
class GetCash extends Backend
{
/**
* GetCash模型对象
* @var \app\admin\model\GetCash
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\GetCash;
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*/
public function index()
{
//当前是否为关联查询
$this->relationSearch = true;
//设置过滤方法
$this->request->filter(['strip_tags']);
if ($this->request->isAjax())
{
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField'))
{
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->with(['user'])
->where($where)
->order($sort, $order)
->count();
$list = $this->model
->with(['user'])
->where($where)
->order($sort, $order)
->limit($offset, $limit)
->select();
foreach ($list as $row) {
$row->getRelation('user')->visible(['nickname','avatar']);
}
$list = collection($list)->toArray();
$result = array("total" => $total, "rows" => $list);
return json($result);
}
return $this->view->fetch();
}
}
<?php
namespace app\admin\controller;
use addons\third\library\Application;
use addons\third\Third;
use app\common\controller\Backend;
use think\Db;
/**
* 提现审核管理
*
* @icon fa fa-circle-o
*/
class GetCash extends Backend
{
/**
* GetCash模型对象
* @var \app\admin\model\GetCash
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\GetCash;
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*/
public function index()
{
//当前是否为关联查询
$this->relationSearch = true;
//设置过滤方法
$this->request->filter(['strip_tags']);
if ($this->request->isAjax())
{
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField'))
{
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->with(['user'])
->where($where)
->order($sort, $order)
->count();
$list = $this->model
->with(['user'])
->where($where)
->order($sort, $order)
->limit($offset, $limit)
->select();
foreach ($list as $row) {
$row->getRelation('user')->visible(['nickname','avatar']);
}
$list = collection($list)->toArray();
$result = array("total" => $total, "rows" => $list);
return json($result);
}
return $this->view->fetch();
}
public function pay(){
$id=input('ids');
$info=\app\admin\model\GetCash::get($id);
if ($info['paytime']!=0){
$this->error('已支付,请勿重复支付!');
}
Db::startTrans();
try{
$path=APP_PATH.'cert/';
$map['user_id']=$info['user_id'];
$openid=db('third')->where($map)->value('openid');
$options = [
'app_id' => 'wxf8b3359982b87214',
'payment' => [
'merchant_id' => '1558514191',
'key' => 'yUKuA7HxasJ3l6m4BaCZrbRhiPapKPAP',
'cert_path' => $path.'apiclient_cert.pem',
'key_path' => $path.'apiclient_key.pem',
],
];
$money=$info['fee'];
$Wechat=new \EasyWeChat\Foundation\Application($options);
$merchantPay = $Wechat->merchant_pay;
$order= cmf_get_order_sn();
$merchantPayData = [
'partner_trade_no' => $order, //随机字符串作为订单号,跟红包和支付一个概念。
'openid' =>$openid, //收款人的openid
'check_name' => 'NO_CHECK', //文档中有三种校验实名的方法 NO_CHECK OPTION_CHECK FORCE_CHECK
//'re_user_name'=>'张三', //OPTION_CHECK FORCE_CHECK 校验实名的时候必须提交
'amount' => $money*100, //单位为分
'desc' => '企业付款',
// 'spbill_create_ip' => '192.168.0.1', //发起交易的IP地址
];
$result = $merchantPay->send($merchantPayData);
$User=new \app\admin\model\User();
if ($result['result_code']=='SUCCESS'){
/*扣除对应金额*/
/*记入现金log*/
$save['paytime']=time();
\app\admin\model\GetCash::get($id)->save($save);
Db::commit();
}else{
Db::rollback();
$this->error($result['err_code_des']);
}
/*修改用户支付状态*/
}catch (\Exception $e) {
// 回滚事务
$this->error($e->getMessage());
Db::rollback();
}
$this->success('付款成功!');
}
}
... ...
... ... @@ -64,7 +64,7 @@ class Group extends Backend
foreach ($list as $row) {
$row->getRelation('area')->visible(['shortname']);
}
$list = collection($list)->toArray();
$result = array("total" => $total, "rows" => $list);
... ...
... ... @@ -6,5 +6,18 @@ return [
'Name' => '群名称',
'Intro' => '群简介',
'Area_id' => '区域id',
'Area.shortname' => '简称'
'Media_id' => '微信永久素材id',
'Qrcodeimage' => '二维码图片',
'Area.id' => 'ID',
'Area.pid' => '父id',
'Area.shortname' => '简称',
'Area.name' => '名称',
'Area.mergename' => '全称',
'Area.level' => '层级 0 1 2 省市区县',
'Area.pinyin' => '拼音',
'Area.code' => '长途区号',
'Area.zip' => '邮编',
'Area.first' => '首字母',
'Area.lng' => '经度',
'Area.lat' => '纬度'
];
... ...
... ... @@ -25,31 +25,20 @@ class Group extends Model
// 追加属性
protected $append = [
'group_image_url'
];
public function getGroupImageUrlAttr($value,$data)
{
return cdnurl($data['group_image']);
}
public function area()
{
return $this->belongsTo('Area', 'area_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function getGropuList($where=[]){
$info=$this->with(['area'])->where($where)->select();
if (!empty($info)){
$info=$info->toArray();
foreach($info as $k=>$v){
// $info[$k]['area_name']=$v[]['name'];
unset($info[$k]['area']);
}
}
return $info;
}
public function area()
{
return $this->belongsTo('Area', 'area_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
... ...
<?php
namespace app\admin\model;
use think\Model;
class Group extends Model
{
// 表名
protected $name = 'group';
// 自动写入时间戳字段
protected $autoWriteTimestamp = false;
// 定义时间戳字段名
protected $createTime = false;
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
'group_image_url'
];
public function getGroupImageUrlAttr($value,$data)
{
return cdnurl($data['group_image']);
}
public function area()
{
return $this->belongsTo('Area', 'area_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function getGropuList($where=[]){
$info=$this->with(['area'])->where($where)->select();
if (!empty($info)){
$info=$info->toArray();
foreach($info as $k=>$v){
// $info[$k]['area_name']=$v[]['name'];
unset($info[$k]['area']);
}
}
return $info;
}
}
... ...
... ... @@ -32,6 +32,26 @@
<input id="c-area_id" data-rule="required" data-source="area/index" class="form-control selectpage" name="row[area_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Media_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-media_id" data-rule="required" data-source="media/index" class="form-control selectpage" name="row[media_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Qrcodeimage')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-qrcodeimage" data-rule="required" class="form-control" size="50" name="row[qrcodeimage]" type="text" value="">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-qrcodeimage" class="btn btn-danger plupload" data-input-id="c-qrcodeimage" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-qrcodeimage"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-qrcodeimage" class="btn btn-primary fachoose" data-input-id="c-qrcodeimage" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-qrcodeimage"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-qrcodeimage"></ul>
</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">
... ...
... ... @@ -32,6 +32,26 @@
<input id="c-area_id" data-rule="required" data-source="area/index" class="form-control selectpage" name="row[area_id]" type="text" value="{$row.area_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Media_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-media_id" data-rule="required" data-source="media/index" class="form-control selectpage" name="row[media_id]" type="text" value="{$row.media_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Qrcodeimage')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-qrcodeimage" data-rule="required" class="form-control" size="50" name="row[qrcodeimage]" type="text" value="{$row.qrcodeimage|htmlentities}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-qrcodeimage" class="btn btn-danger plupload" data-input-id="c-qrcodeimage" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-qrcodeimage"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-qrcodeimage" class="btn btn-primary fachoose" data-input-id="c-qrcodeimage" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-qrcodeimage"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-qrcodeimage"></ul>
</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">
... ...
... ... @@ -6,25 +6,61 @@ use addons\cms\model\Archives;
use addons\third\library\Service;
use app\admin\model\Area;
use app\admin\model\FormId;
use app\admin\model\Group;
use app\admin\model\Mission;
use app\admin\model\MissionJoin;
use app\admin\model\Suggest;
use app\common\controller\Api;
use app\common\library\Auth;
use EasyWeChat\Foundation\Application;
use fast\Http;
use fast\Random;
use PhpOffice\PhpSpreadsheet\Shared\OLE\PPS\Root;
use think\Config;
use think\Db;
use app\common\model\Attachment;
use think\Log;
/**
* 公共接口
*/
class Common extends Api
{
protected $noNeedLogin = ['getSessionKey','login','codeToToken','notifyx'];
protected $noNeedLogin = ['getSessionKey','login','index','codeToToken','notifyx'];
protected $noNeedRight = '*';
public function index(){
$img_url=ROOT_PATH.'public/assets/img/32px.png';
/* dump($img_url);
$media=$this->getMedia($img_url);
dump($media);*/
// exit();
Log::init([
'type' => 'File',
'path' => APP_PATH.'logs/'
]);
$signature = $_GET["signature"];
$timestamp = $_GET["timestamp"];
$nonce = $_GET["nonce"];
$token='bronet'; //TOKEN 写自己在微信平台填入的token
$tmpArr = array($token, $timestamp, $nonce);
sort($tmpArr, SORT_STRING);
$tmpStr = implode( $tmpArr );
$tmpStr = sha1( $tmpStr );
if( $tmpStr == $signature ){
}else {
return false;
}
Log::write('验签通过');
$this->responseMsg();
}
/**
* @ApiTitle (获取SessionKey)
* @ApiSummary (解密微信加密信息)
... ... @@ -98,7 +134,7 @@ class Common extends Api
$result = [
'openid' => $json['openid'],
'userinfo' => [
'nickname' => $userInfo['nickName'],
'nickname' => $userInfo['nickName'],
],
'access_token' => $json['session_key'],
'refresh_token' => '',
... ... @@ -633,5 +669,173 @@ class Common extends Api
}
}
private function checkSignature(){
$signature = $_GET["signature"];
$timestamp = $_GET["timestamp"];
$nonce = $_GET["nonce"];
$token = 'bronet';
$tmpArr = array($token, $timestamp, $nonce);
sort($tmpArr, SORT_STRING);
$tmpStr = implode( $tmpArr );
$tmpStr = sha1( $tmpStr );
if( $tmpStr == $signature ){
return true;
}else{
return false;
}
}
private function responseMsg()
{
$postStr = file_get_contents('php://input'); //此处推荐使用file_get_contents('php://input')获取后台post过来的数据
Log::write($postStr);
if (!empty($postStr) && is_string($postStr)) {
$postArr = json_decode($postStr, true);
Log::write($postArr);
if (!empty($postArr['MsgType']) && $postArr['MsgType'] == 'text') { //用户发送文本消息
$fromUsername = $postArr['FromUserName']; //发送者openid
$media_id = ''; //输入想要回复的图片消息的media_id
$data = array(
"touser" => $fromUsername,
"msgtype" => "image",
"image" => array("media_id" => $media_id)
);
$json = json_encode($data, JSON_UNESCAPED_UNICODE); //php5.4+
$this->requestAPI($json);
} elseif (!empty($postArr['MsgType']) && $postArr['MsgType'] == 'image') { //用户发送图文消息
$fromUsername = $postArr['FromUserName']; //此处为文字回复,不同的回复方式可参考文章顶部第三个链接“回复客户消息”里查看
$content = '你好,你的专属海报正在制作中,请稍后回复“1”获取海报';
$data = array(
"touser" => $fromUsername,
"msgtype" => "text",
"text" => array("content" => $content)
);
$json = json_encode($data, JSON_UNESCAPED_UNICODE); //php5.4+
$this->requestAPI($json);
$fromUsername = $postArr['FromUserName']; //发送者openid
$media_id = ''; //输入想要回复的图片消息的media_id
$data = array(
"touser" => $fromUsername,
"msgtype" => "image",
"image" => array("media_id" => $media_id)
);
$json = json_encode($data, JSON_UNESCAPED_UNICODE); //php5.4以上版本才可使用
$this->requestAPI($json);
} elseif ($postArr['MsgType'] == 'miniprogrampage') { //用户进入客服
$fromUsername = $postArr['FromUserName'];
/*获取对应的图片地址*/
$user_id=db('third')->where('openid',$fromUsername)->value('user_id');
Log::write('用户id');
Log::write($user_id);
$id=\db('group_log')->where('user_id',$user_id)->value('group_id');
$info=explode('=',$postArr['PagePath']);
$num=count($info);
if (empty($id)) {
$id = 1;
}
Log::write($num);
/*查询对应的群信息*/
$image=Group::get($id)->group_image;
$image_url=ROOT_PATH.'public/'.$image;
$media_id=$this->getMedia($image_url);
//发送者openid
//输入想要回复的图片消息的media_id
$data = array(
"touser" => $fromUsername,
"msgtype" => "image",
"image" => array("media_id" => $media_id)
);
Log::write($data);
$json = json_encode($data, JSON_UNESCAPED_UNICODE); //php5.4+
$this->requestAPI($json);
exit();
$fromUsername = $postArr['FromUserName']; //此处为文字回复,不同的回复方式可参考文章顶部第三个链接“回复客户消息”里查看
$content = '你好,你的专属海报正在制作中,请稍后回复“1”获取海报';
$data = array(
"touser" => $fromUsername,
"msgtype" => "text",
"text" => array("content" => $content)
);
$json = json_encode($data, JSON_UNESCAPED_UNICODE); //php5.4+
$this->requestAPI($json);
} else {
exit('error');
}
} else {
echo "empty";
exit;
}
}
function requestAPI($json){
$access_token = $this->get_accessToken();
/*
* POST发送https请求客服接口api
*/
$url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=".$access_token;
//以'json'格式发送post的https请求
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
if (!empty($json)){
curl_setopt($curl, CURLOPT_POSTFIELDS,$json);
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($curl, CURLOPT_HTTPHEADER, $headers );
$output = curl_exec($curl);
if (curl_errno($curl)) {
echo 'Errno'.curl_error($curl);//捕抓异常
}
curl_close($curl);
if($output == 0){
echo 'success';exit;
}
}
function get_accessToken(){
$config=\config('wechat');
$app = new Application($config);
$accessToken = $app->access_token; // EasyWeChat\Core\AccessToken 实例
$token = $accessToken->getToken(); // token 字符串
return $token;
}
/**
* 生成永久素材
* @param $access_token
* @param $daka_url
*/
public function getMedia($daka_url) {
$config=\config('wechat');
$app = new Application($config);
$material = $app->material_temporary;
$result = $material->uploadImage($daka_url);
return $result['media_id'];
}
private function https_request($url, $data = null)
{
$curl = curl_init();
//curl_setopt ( $curl, CURLOPT_SAFE_UPLOAD, false);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
if (!empty ($data)) {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
curl_close($curl);
return $output;
}
}
... ...
... ... @@ -186,6 +186,66 @@ class Square extends Api
$group['same_city']=$Group->getGropuList($where);
$this->success('',$group);
}
/**
* @ApiTitle (获取养生群详情)
* @ApiSummary (获取养生群详情)
* @ApiMethod (POST)
* @ApiParams (name="id", type="integer", required=true, description="群id")
* @ApiReturnParams (name="msg", type="string", required=true, description="提示语")
* @ApiReturnParams (name="group_image", type="string", required=true, description="群头像地址")
* @ApiReturnParams (name="name", type="string", required=true, description="养生群名称")
* @ApiReturnParams (name="intro", type="string", required=true, description="养生群介绍")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
"code": 1,
"msg": "",
"time": "1571035960",
"data": {
"id": 1,
"group_image": "/uploads/20191014/FiwnVkUbW5J-3I0n9AMKALsc83LF.jpg",
"name": "养生群",
"intro": "这个是群介绍",
"area_id": 1,
"group_image_url": "http://pyffam7jw.bkt.clouddn.com/uploads/20191014/FiwnVkUbW5J-3I0n9AMKALsc83LF.jpg"
}
})
*/
public function groupInfo(){
$id=input('id');
$Group=new Group();
$group_info=$Group->where('id',$id)->find();
if (empty($group_info)){
$this->error('没有找到对应的群');
}
$this->success('',$group_info);
}
/**
* @ApiTitle (存储养生群记录)
* @ApiSummary (存储养生群记录)
* @ApiMethod (POST)
* @ApiParams (name="group_id", type="integer", required=true, description="群id")
* @ApiParams (name="user_id", type="integer", required=true, description="用户id")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
})
*/
public function saveGroupLog(){
$user_id=$this->auth->id;
$group_id=input('group_id');
$add['user_id']=$user_id;
$add['group_id']=$group_id;
$log=\db('group_log')->where('user_id',$user_id)->find();
if (empty($log)){
\db('group_log')->insert($add);
$this->success('编辑成功!');
}
$update['group_id']=$group_id;
\db('group_log')->where('id',$log['id'])->update($update);
$this->success('编辑成功!');
}
/**
* @ApiTitle (发布帖子)
* @ApiSummary (发布帖子)
... ... @@ -260,7 +320,7 @@ class Square extends Api
$Price->changeStatus($info['id'],'two_status');
$return['two_status']=1;
}
if ($info['three_status']==0 && $info['three']>=10){
if ($info['three_status']==0 && $info['three']>=1){
$Price->changeStatus($info['id'],'three_status');
$return['three_status']=1;
}
... ... @@ -317,7 +377,7 @@ class Square extends Api
/*更改本条状态*/
$restult=db('price_status')->where($map)->update([$field=>'2']);
//dump($restult);
echo db('price_status')->getLastSql();
// echo db('price_status')->getLastSql();
/*用户添加积分*/
db('user')->where('id',$user_id)->setInc('score',10);
/*写积分日志*/
... ...
... ... @@ -34,7 +34,7 @@ class ScoreLog Extends Model
$list=$this->where($where)
->order('createtime','desc')
->field('id,score,memo as des')
->paginate('10');
->paginate('15');
return $list;
}
... ...
<?php
return array (
'name' => '微养生1',
'name' => '微养生',
'beian' => '浙ICP备19028672号-1',
'cdnurl' => '',
'version' => '1.0.1',
... ...
此 diff 太大无法显示。
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'get_cash/index' + location.search,
add_url: 'get_cash/add',
edit_url: 'get_cash/edit',
del_url: 'get_cash/del',
multi_url: 'get_cash/multi',
table: 'get_cash',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'user_id', title: __('User_id')},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'fee', title: __('Fee')},
{field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'user.nickname', title: __('User.nickname')},
{field: 'user.avatar', title: __('User.avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'get_cash/index' + location.search,
add_url: 'get_cash/add',
edit_url: 'get_cash/edit',
del_url: 'get_cash/del',
multi_url: 'get_cash/multi',
table: 'get_cash',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'user_id', title: __('User_id')},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'fee', title: __('Fee')},
{field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'user.nickname', title: __('User.nickname')},
{field: 'user.avatar', title: __('User.avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image},
{
field: 'operate',
title: __('Operate'),
table: table, events: Table.api.events.operate,
buttons: [
{
name: 'ajax',
title: __('支付'),
classname: 'btn btn-xs btn-success btn-magic btn-ajax',
icon: 'fa fa-magic',
url: 'get_cash/pay',
success: function (data, ret) {
Layer.alert(ret.msg);
//如果需要阻止成功提示,则必须使用return false;
// return false;
},
error: function (data, ret) {
console.log(data, ret);
Layer.alert(ret.msg);
return false;
}
},
],
formatter: Table.api.formatter.operate
}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});
\ No newline at end of file
... ...
... ... @@ -29,7 +29,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'name', title: __('Name')},
{field: 'intro', title: __('Intro')},
{field: 'area_id', title: __('Area_id')},
{field: 'media_id', title: __('Media_id')},
{field: 'qrcodeimage', title: __('Qrcodeimage'), events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'area.id', title: __('Area.id')},
{field: 'area.pid', title: __('Area.pid')},
{field: 'area.shortname', title: __('Area.shortname')},
{field: 'area.name', title: __('Area.name')},
{field: 'area.mergename', title: __('Area.mergename')},
{field: 'area.level', title: __('Area.level')},
{field: 'area.pinyin', title: __('Area.pinyin')},
{field: 'area.code', title: __('Area.code')},
{field: 'area.zip', title: __('Area.zip')},
{field: 'area.first', title: __('Area.first')},
{field: 'area.lng', title: __('Area.lng')},
{field: 'area.lat', title: __('Area.lat')},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
... ...