作者 陈程

123

@@ -139,4 +139,63 @@ class Order extends Backend @@ -139,4 +139,63 @@ class Order extends Backend
139 $thisuser=Db::name("user")->find($id);//查询到当前用户 139 $thisuser=Db::name("user")->find($id);//查询到当前用户
140 return json($thisuser); 140 return json($thisuser);
141 } 141 }
  142 +
  143 +
  144 + /**
  145 + * 编辑
  146 + *
  147 + * @param $ids
  148 + * @return string
  149 + * @throws DbException
  150 + * @throws \think\Exception
  151 + */
  152 + public function edit_share($ids = null)
  153 + {
  154 + $row = $this->model->get($ids);
  155 + if (!$row) {
  156 + $this->error(__('No Results were found'));
  157 + }
  158 + $adminIds = $this->getDataLimitAdminIds();
  159 + if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
  160 + $this->error(__('You have no permission'));
  161 + }
  162 + //查询到用户信息
  163 + if($row){
  164 + $user=Db::name("user")->find($row['user_id']);
  165 + if($user['pid']>0){
  166 + $row['p_user']=Db::name("user")->find($user['pid']);
  167 + }else{
  168 + $row['p_user'] = [];
  169 + }
  170 + }
  171 +
  172 + if (false === $this->request->isPost()) {
  173 + $this->view->assign('row', $row);
  174 + return $this->view->fetch();
  175 + }
  176 + $params = $this->request->post('row/a');
  177 + if (empty($params)) {
  178 + $this->error(__('Parameter %s can not be empty', ''));
  179 + }
  180 + $params = $this->preExcludeFields($params);
  181 + $result = false;
  182 + Db::startTrans();
  183 + try {
  184 + //是否采用模型验证
  185 + if ($this->modelValidate) {
  186 + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
  187 + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
  188 + $row->validateFailException()->validate($validate);
  189 + }
  190 + $result = $row->allowField(true)->save($params);
  191 + Db::commit();
  192 + } catch (ValidateException|PDOException|Exception $e) {
  193 + Db::rollback();
  194 + $this->error($e->getMessage());
  195 + }
  196 + if (false === $result) {
  197 + $this->error(__('No rows were updated'));
  198 + }
  199 + $this->success();
  200 + }
142 } 201 }
  1 +<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  2 +
  3 +
  4 + <div class="form-group">
  5 + <label class="control-label col-xs-12 col-sm-2">推广关系:</label>
  6 + <div class="col-xs-12 col-sm-8">
  7 + <?php
  8 + if(!empty($row['p_user'])){
  9 + ?>
  10 + <input type="hidden" name="pid" id="pid" value="{$row.p_user.pid}" />
  11 + <div id="users">
  12 + <p>上级微信昵称:{$row.p_user.nickname|htmlentities},上级ID:{$row.p_user.pid|htmlentities},上级联系电话:{$row.p_user.mobile|default=""} </p>
  13 + <a onclick="findupuser()" id="arraw" class="fa fa-arrow-right" style="cursor:pointer; margin-left:10px; font-size: 20px;"></a>
  14 + </div>
  15 + <?php
  16 + }else{
  17 + ?>
  18 + <div id="users">
  19 + <p>暂无上级信息</p>
  20 + <a
  21 + </div>
  22 + <?php
  23 + }
  24 + ?>
  25 +
  26 + </div>
  27 + </div>
  28 +
  29 +</form>
  30 +<script>
  31 + function findupuser(){
  32 + var id = $("#pid").val();
  33 + $.ajax({
  34 + type: 'get',
  35 + url: 'verification/order/findidbyid',
  36 + data: { id: id },
  37 + contentType: 'application/x-www-form-urlencoded',
  38 +
  39 + // 会自动帮我们把返回的数据根据响应头设置的类型进行转换好(也就是会自动转成json对象)
  40 + success: function (res) {
  41 +
  42 + if(res){
  43 + var html = '<p>上级微信昵称:'+res.nickname+',上级ID:'+res.pid+',上级联系电话:'+res.mobile+'</p>';
  44 + $("#arraw").before(html);
  45 + $("#pid").val(res.pid);
  46 + }else{
  47 + alert('没有了');
  48 + }
  49 + },
  50 + // xhr是ajax对象
  51 + error: function (xhr) {}
  52 + });
  53 + }
  54 +</script>
@@ -40,7 +40,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -40,7 +40,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
40 {field: 'coupon.name', title: __('Coupon.name'), operate: 'LIKE'}, 40 {field: 'coupon.name', title: __('Coupon.name'), operate: 'LIKE'},
41 {field: 'activity.title', title: __('Activity.title'), operate: 'LIKE'}, 41 {field: 'activity.title', title: __('Activity.title'), operate: 'LIKE'},
42 {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'}, 42 {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
43 - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} 43 + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
  44 + buttons:[
  45 + {
  46 + name: 'cv_verification_activity',
  47 + text:"订单溯源",
  48 + title: function (row) {
  49 + return "订单溯源,"+row.name+"的上级微信用户信息"
  50 + },
  51 + // extend:'data-area=["94%","94%"]',
  52 + classname: 'btn btn-xs btn-danger btn-dialog',
  53 + icon: 'fa fa-ticket',
  54 + url: 'verification/order/edit_share?id={id}',
  55 + visible: function (row) {
  56 + return true;
  57 + },
  58 + }
  59 + ]
  60 + }
44 ] 61 ]
45 ] 62 ]
46 }); 63 });