Browse Source

Merge remote-tracking branch 'origin/yuenan' into yuenan

yuenan
xubin 3 years ago
parent
commit
b2245bad2c
12 changed files with 247 additions and 1 deletions
  1. +1
    -0
      addons/unishop/controller/Order.php
  2. +5
    -0
      addons/unishop/controller/Product.php
  3. +35
    -0
      application/admin/controller/Qa.php
  4. +2
    -1
      application/admin/controller/unishop/Order.php
  5. +6
    -0
      application/admin/lang/zh-cn/qa.php
  6. +40
    -0
      application/admin/model/Qa.php
  7. +27
    -0
      application/admin/validate/Qa.php
  8. +22
    -0
      application/admin/view/qa/add.html
  9. +22
    -0
      application/admin/view/qa/edit.html
  10. +35
    -0
      application/admin/view/qa/index.html
  11. +51
    -0
      public/assets/js/backend/qa.js
  12. +1
    -0
      public/assets/js/backend/unishop/order.js

+ 1
- 0
addons/unishop/controller/Order.php View File

@@ -160,6 +160,7 @@ class Order extends Base
'address'=>$data["address"],
'email'=>$data["email"],
"spec"=>$data["spec"],
"number"=>$data["number"],
]);
$this->success('', []);
return ;


+ 5
- 0
addons/unishop/controller/Product.php View File

@@ -8,6 +8,7 @@ use addons\unishop\model\Evaluate;
use addons\unishop\model\Favorite;
use addons\unishop\model\Product as productModel;
use addons\unishop\model\Coupon;
use app\admin\model\Qa;
use think\Exception;

class Product extends Base
@@ -81,6 +82,10 @@ class Product extends Base
$data->evaluate_list = collection($evaluate)->append(['createtime_text'])->toArray();
}
$data = $data->append(['images_text', "detail_images_text",'spec_list', 'spec_table_list'])->toArray();
$qaModel = new Qa();
$qa=$qaModel->field("question,answer")->select();
$list = collection($qa)->toArray();
$data['qa']=$list;
$this->success('', $data);
} catch (Exception $e) {
$this->error($e->getMessage());


+ 35
- 0
application/admin/controller/Qa.php View File

@@ -0,0 +1,35 @@
<?php

namespace app\admin\controller;

use app\common\controller\Backend;

/**
* 问答
*
* @icon fa fa-circle-o
*/
class Qa extends Backend
{
/**
* Qa模型对象
* @var \app\admin\model\Qa
*/
protected $model = null;

public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\Qa;

}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/

}

+ 2
- 1
application/admin/controller/unishop/Order.php View File

@@ -525,13 +525,14 @@ class Order extends Backend
order.address,
unishop_product.title,
order.spec,
order.number,
order.order_price,
order.createtime,
FROM_UNIXTIME(order.createtime,'%Y-%m-%d %H:%i:%S')
")
->select();
$list = collection($list)->toArray();
$title = ['订单号','姓名','手机号','地址','商品','商品规格','总金额','下单时间','备注'];
$title = ['订单号','姓名','手机号','地址','商品','商品规格','购买数量','总金额','下单时间','备注'];
// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();


+ 6
- 0
application/admin/lang/zh-cn/qa.php View File

@@ -0,0 +1,6 @@
<?php

return [
'Question' => '问题',
'Answer' => '回答'
];

+ 40
- 0
application/admin/model/Qa.php View File

@@ -0,0 +1,40 @@
<?php

namespace app\admin\model;

use think\Model;


class Qa extends Model
{



// 表名
protected $name = 'qa';
// 自动写入时间戳字段
protected $autoWriteTimestamp = false;

// 定义时间戳字段名
protected $createTime = false;
protected $updateTime = false;
protected $deleteTime = false;

// 追加属性
protected $append = [

];








}

+ 27
- 0
application/admin/validate/Qa.php View File

@@ -0,0 +1,27 @@
<?php

namespace app\admin\validate;

use think\Validate;

class Qa extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}

+ 22
- 0
application/admin/view/qa/add.html View File

@@ -0,0 +1,22 @@
<form id="add-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">{:__('Question')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-question" data-rule="required" class="form-control" name="row[question]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Answer')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-answer" data-rule="required" class="form-control" name="row[answer]"></textarea>
</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-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>

+ 22
- 0
application/admin/view/qa/edit.html View File

@@ -0,0 +1,22 @@
<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">{:__('Question')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-question" data-rule="required" class="form-control" name="row[question]" type="text" value="{$row.question|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Answer')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-answer" data-rule="required" class="form-control" name="row[answer]">{$row.answer|htmlentities}</textarea>
</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-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>

+ 35
- 0
application/admin/view/qa/index.html View File

@@ -0,0 +1,35 @@
<div class="panel panel-default panel-intro">
{:build_heading()}

<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('qa/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('qa/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('qa/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('qa/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>

<div class="dropdown btn-group {:$auth->check('qa/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
</ul>
</div>

</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('qa/edit')}"
data-operate-del="{:$auth->check('qa/del')}"
width="100%">
</table>
</div>
</div>

</div>
</div>
</div>

+ 51
- 0
public/assets/js/backend/qa.js View File

@@ -0,0 +1,51 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'qa/index' + location.search,
add_url: 'qa/add',
edit_url: 'qa/edit',
del_url: 'qa/del',
multi_url: 'qa/multi',
table: 'qa',
}
});

var table = $("#table");

// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'question', title: __('Question')},
{field: 'answer', title: __('Answer')},
{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;
});

+ 1
- 0
public/assets/js/backend/unishop/order.js View File

@@ -94,6 +94,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'address', title: __('地址'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
{field: 'title', title: __('商品')},
{field: 'spec', title: __('规格')},
{field: 'number', title: __('购买数量')},
// {field: 'user_id', title: __('User_id')},
// {field: 'user.username', title: __('User name')},
{field: 'out_trade_no', title: __('Out_trade_no')},


Loading…
Cancel
Save