作者 陈程

123

... ... @@ -139,4 +139,63 @@ class Order extends Backend
$thisuser=Db::name("user")->find($id);//查询到当前用户
return json($thisuser);
}
/**
* 编辑
*
* @param $ids
* @return string
* @throws DbException
* @throws \think\Exception
*/
public function edit_share($ids = null)
{
$row = $this->model->get($ids);
if (!$row) {
$this->error(__('No Results were found'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
//查询到用户信息
if($row){
$user=Db::name("user")->find($row['user_id']);
if($user['pid']>0){
$row['p_user']=Db::name("user")->find($user['pid']);
}else{
$row['p_user'] = [];
}
}
if (false === $this->request->isPost()) {
$this->view->assign('row', $row);
return $this->view->fetch();
}
$params = $this->request->post('row/a');
if (empty($params)) {
$this->error(__('Parameter %s can not be empty', ''));
}
$params = $this->preExcludeFields($params);
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException()->validate($validate);
}
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if (false === $result) {
$this->error(__('No rows were updated'));
}
$this->success();
}
}
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">推广关系:</label>
<div class="col-xs-12 col-sm-8">
<?php
if(!empty($row['p_user'])){
?>
<input type="hidden" name="pid" id="pid" value="{$row.p_user.pid}" />
<div id="users">
<p>上级微信昵称:{$row.p_user.nickname|htmlentities},上级ID:{$row.p_user.pid|htmlentities},上级联系电话:{$row.p_user.mobile|default=""} </p>
<a onclick="findupuser()" id="arraw" class="fa fa-arrow-right" style="cursor:pointer; margin-left:10px; font-size: 20px;"></a>
</div>
<?php
}else{
?>
<div id="users">
<p>暂无上级信息</p>
<a
</div>
<?php
}
?>
</div>
</div>
</form>
<script>
function findupuser(){
var id = $("#pid").val();
$.ajax({
type: 'get',
url: 'verification/order/findidbyid',
data: { id: id },
contentType: 'application/x-www-form-urlencoded',
// 会自动帮我们把返回的数据根据响应头设置的类型进行转换好(也就是会自动转成json对象)
success: function (res) {
if(res){
var html = '<p>上级微信昵称:'+res.nickname+',上级ID:'+res.pid+',上级联系电话:'+res.mobile+'</p>';
$("#arraw").before(html);
$("#pid").val(res.pid);
}else{
alert('没有了');
}
},
// xhr是ajax对象
error: function (xhr) {}
});
}
</script>
... ...
... ... @@ -40,7 +40,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'coupon.name', title: __('Coupon.name'), operate: 'LIKE'},
{field: 'activity.title', title: __('Activity.title'), operate: 'LIKE'},
{field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
buttons:[
{
name: 'cv_verification_activity',
text:"订单溯源",
title: function (row) {
return "订单溯源,"+row.name+"的上级微信用户信息"
},
// extend:'data-area=["94%","94%"]',
classname: 'btn btn-xs btn-danger btn-dialog',
icon: 'fa fa-ticket',
url: 'verification/order/edit_share?id={id}',
visible: function (row) {
return true;
},
}
]
}
]
]
});
... ...