edit修改相關內容
This commit is contained in:
parent
6ef8cf3fc7
commit
a3589dab7d
@ -1,38 +1,40 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\controllers;
|
namespace app\controllers;
|
||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\filters\AccessControl;
|
use yii\filters\AccessControl;
|
||||||
use yii\web\Response;
|
use yii\web\Response;
|
||||||
use yii\filters\VerbFilter;
|
use yii\filters\VerbFilter;
|
||||||
|
|
||||||
|
|
||||||
class SiteController extends Controller
|
class SiteController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function actions()
|
public function actions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'error' => [
|
'error' => [
|
||||||
'class' => 'yii\web\ErrorAction',
|
'class' => 'yii\web\ErrorAction',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays homepage.
|
* Displays homepage.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function actionIndex()
|
public function actionIndex()
|
||||||
{
|
{
|
||||||
$code = $this->request->get('code');
|
$code = $this->request->get('code');
|
||||||
echo($code);
|
$url = "https://app.3dxh.h5.dev.1nww.com/#/White?code={$code}";
|
||||||
exit();
|
return $this->redirect($url);
|
||||||
return $this->render('index');
|
echo($code);
|
||||||
}
|
exit();
|
||||||
|
return $this->render('index');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
59
models/Dev.php
Normal file
59
models/Dev.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the model class for table "cx_dev".
|
||||||
|
*
|
||||||
|
* @property int $id
|
||||||
|
* @property int $store_id 门店ID
|
||||||
|
* @property string $name 设备名称
|
||||||
|
* @property string $dev_number 设备编号
|
||||||
|
* @property int $status 0-正常 1-租赁
|
||||||
|
* @property int $created_at 添加时间
|
||||||
|
* @property int $updated_at 更新时间
|
||||||
|
* @property int|null $is_delete 是否删除,0=否,1=是
|
||||||
|
* @property int|null $deleted_at 删除时间
|
||||||
|
*/
|
||||||
|
class Dev extends \yii\db\ActiveRecord
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function tableName()
|
||||||
|
{
|
||||||
|
return 'cx_dev';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['store_id', 'name', 'dev_number', 'created_at'], 'required'],
|
||||||
|
[['store_id', 'status', 'created_at', 'updated_at', 'is_delete', 'deleted_at'], 'integer'],
|
||||||
|
[['name', 'dev_number'], 'string', 'max' => 50],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function attributeLabels()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => 'ID',
|
||||||
|
'store_id' => 'Store ID',
|
||||||
|
'name' => 'Name',
|
||||||
|
'dev_number' => 'Dev Number',
|
||||||
|
'status' => 'Status',
|
||||||
|
'created_at' => 'Created At',
|
||||||
|
'updated_at' => 'Updated At',
|
||||||
|
'is_delete' => 'Is Delete',
|
||||||
|
'deleted_at' => 'Deleted At',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -25,6 +25,8 @@ use app\modules\api\models\CommentForm;
|
|||||||
use app\modules\api\models\LoginForm;
|
use app\modules\api\models\LoginForm;
|
||||||
use app\modules\api\models\UserBasicInfoForm;
|
use app\modules\api\models\UserBasicInfoForm;
|
||||||
use app\modules\api\models\UserModifyForm;
|
use app\modules\api\models\UserModifyForm;
|
||||||
|
use app\modules\api\models\ReportEditForm;
|
||||||
|
|
||||||
|
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
{
|
{
|
||||||
@ -56,10 +58,12 @@ class UserController extends Controller
|
|||||||
$post = \Yii::$app->request->post(); // attributes 转成键值对形式 key=> value
|
$post = \Yii::$app->request->post(); // attributes 转成键值对形式 key=> value
|
||||||
$user_outh = UserOauth::findOne(['openid' => $post['code']]);
|
$user_outh = UserOauth::findOne(['openid' => $post['code']]);
|
||||||
if ($user_outh == null) {
|
if ($user_outh == null) {
|
||||||
return ['code' => 1, 'msg' => '授权失败,请重新进行微信公众号授权',];
|
$data = ['code' => 1, 'msg' => '授权失败,请重新进行微信公众号授权',];
|
||||||
|
return $this->responseHandler($data);
|
||||||
}
|
}
|
||||||
if ($user_outh->user_id == 0) {
|
if ($user_outh->user_id == 0) {
|
||||||
return ['code' => 1, 'msg' => '暂未填写信息',];
|
$data = ['code' => 1, 'msg' => '暂未填写信息',];
|
||||||
|
return $this->responseHandler($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查用户信息
|
// 查用户信息
|
||||||
@ -98,4 +102,25 @@ class UserController extends Controller
|
|||||||
$data = $form->modify_user();
|
$data = $form->modify_user();
|
||||||
return $this->responseHandler($data);
|
return $this->responseHandler($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* showdoc
|
||||||
|
* @catalog 会员注册
|
||||||
|
* @method post
|
||||||
|
* @url /api/user/user-create
|
||||||
|
* @return {"code":0,"msg":"ok","data":{}}
|
||||||
|
* @remark
|
||||||
|
*/
|
||||||
|
public function actionUserCreate()
|
||||||
|
{
|
||||||
|
$post = \Yii::$app->request->post(); // attributes 转成键值对形式 key=> value
|
||||||
|
$form = new ReportEditForm();
|
||||||
|
// $form->cx_mch_id = $this->cx_mch_id; //商户ID 没看到传参赋值 默认给0
|
||||||
|
$form->attributes = $post;
|
||||||
|
$form->user_id = \Yii::$app->user->identity->id; //获取用户登陆ID
|
||||||
|
$data = $form->edit();
|
||||||
|
|
||||||
|
return $this->responseHandler($data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,148 +1,148 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Any
|
* @author Any
|
||||||
* @description KISS
|
* @description KISS
|
||||||
* @date 2020-12-3
|
* @date 2020-12-3
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
*
|
*
|
||||||
* _____LOG_____
|
* _____LOG_____
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace app\modules\api\models;
|
namespace app\modules\api\models;
|
||||||
|
|
||||||
|
|
||||||
use app\models\User;
|
use app\models\User;
|
||||||
use app\components\auth\AToken;
|
use app\components\auth\AToken;
|
||||||
use app\components\wechat\aes\WxBizDataCrypt;
|
use app\components\wechat\aes\WxBizDataCrypt;
|
||||||
use app\models\UserOauth;
|
use app\models\UserOauth;
|
||||||
use app\models\common\CommonUserEditForm;
|
use app\models\common\CommonUserEditForm;
|
||||||
use app\components\SysConst;
|
use app\components\SysConst;
|
||||||
use app\components\FlashStorage;
|
use app\components\FlashStorage;
|
||||||
|
|
||||||
class LoginByWxoaForm extends ApiModel
|
class LoginByWxoaForm extends ApiModel
|
||||||
{
|
{
|
||||||
public $code;
|
public $code;
|
||||||
|
|
||||||
|
|
||||||
public $code_expires;//code是否过期,0=否,1=是
|
public $code_expires;//code是否过期,0=否,1=是
|
||||||
|
|
||||||
public $cx_mch_id;
|
public $cx_mch_id;
|
||||||
public $token_type;
|
public $token_type;
|
||||||
public $wechat_mp;
|
public $wechat_mp;
|
||||||
|
|
||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[['code'], 'trim'],
|
[['code'], 'trim'],
|
||||||
[['code'], 'string'],
|
[['code'], 'string'],
|
||||||
[['code_expires'], 'integer'],
|
[['code_expires'], 'integer'],
|
||||||
[['code', 'token_type', 'wechat_mp'], 'required'],
|
[['code', 'token_type', 'wechat_mp'], 'required'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function login()
|
public function login()
|
||||||
{
|
{
|
||||||
if (!$this->validate()) {
|
if (!$this->validate()) {
|
||||||
return $this->getModelError();
|
return $this->getModelError();
|
||||||
}
|
}
|
||||||
$res = FlashStorage::getCache("m{$this->cx_mch_id}_c{$this->code}");
|
$res = FlashStorage::getCache("m{$this->cx_mch_id}_c{$this->code}");
|
||||||
if ($this->code_expires == 1 || $res === false) {
|
if ($this->code_expires == 1 || $res === false) {
|
||||||
$res = $this->code2session($this->code);
|
$res = $this->code2session($this->code);
|
||||||
if ($res['code'] != 0)
|
if ($res['code'] != 0)
|
||||||
return $res;
|
return $res;
|
||||||
FlashStorage::setCache("m{$this->cx_mch_id}_c{$this->code}", $res, 864000);
|
FlashStorage::setCache("m{$this->cx_mch_id}_c{$this->code}", $res, 864000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($res['code'] != 0) {
|
if ($res['code'] != 0) {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
$access_token = $res['data']['access_token'];
|
$access_token = $res['data']['access_token'];
|
||||||
$openid = $res['data']['openid'];
|
$openid = $res['data']['openid'];
|
||||||
|
|
||||||
//用户是否存在
|
//用户是否存在
|
||||||
$user_oauth = null;
|
$user_oauth = null;
|
||||||
if ($openid != 0) {
|
if ($openid != 0) {
|
||||||
//优选使用unionid
|
//优选使用unionid
|
||||||
$user_oauth = UserOauth::findOne([
|
$user_oauth = UserOauth::findOne([
|
||||||
'cx_mch_id' => $this->cx_mch_id,
|
'cx_mch_id' => $this->cx_mch_id,
|
||||||
'is_delete' => 0,
|
'is_delete' => 0,
|
||||||
'openid' => $openid
|
'openid' => $openid
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
if ($user_oauth == null) {
|
if ($user_oauth == null) {
|
||||||
$user_oauth = new UserOauth();
|
$user_oauth = new UserOauth();
|
||||||
$user_oauth->cx_mch_id = 0;
|
$user_oauth->cx_mch_id = 0;
|
||||||
$user_oauth->type = 'wxoa';
|
$user_oauth->type = 'wxoa';
|
||||||
$user_oauth->openid = $openid;
|
$user_oauth->openid = $openid;
|
||||||
$user_oauth->created_at = time();
|
$user_oauth->created_at = time();
|
||||||
$res = $user_oauth->save();
|
$res = $user_oauth->save();
|
||||||
if ($res['code'] != 0) {
|
if ($res['code'] != 0) {
|
||||||
return ['code' => 1, 'msg' => '登陆失败'];
|
return ['code' => 1, 'msg' => '登陆失败'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$data = ['code' => 1, 'msg' => '登陆成功', 'data' => $openid];
|
$data = ['code' => 0, 'msg' => '登陆成功', 'data' => $openid];
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* 用户数据解密
|
* 用户数据解密
|
||||||
*/
|
*/
|
||||||
private function curl_wechat_user($access_token, $openid)
|
private function curl_wechat_user($access_token, $openid)
|
||||||
{
|
{
|
||||||
|
|
||||||
$api = "https://api.weixin.qq.com/sns/userinfo?access_token=" . $access_token . "&openid=" . $openid . "&lang=zh_CN";
|
$api = "https://api.weixin.qq.com/sns/userinfo?access_token=" . $access_token . "&openid=" . $openid . "&lang=zh_CN";
|
||||||
$this->wechat_mp->curl->get($api);
|
$this->wechat_mp->curl->get($api);
|
||||||
|
|
||||||
if ($this->wechat_mp->curl->error_code != 0) {
|
if ($this->wechat_mp->curl->error_code != 0) {
|
||||||
return [
|
return [
|
||||||
'code' => 1,
|
'code' => 1,
|
||||||
'msg' => "err_code:{$this->wechat_mp->curl->error_code}err_msg:{$this->wechat_mp->curl->error_msg}"
|
'msg' => "err_code:{$this->wechat_mp->curl->error_code}err_msg:{$this->wechat_mp->curl->error_msg}"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$resp = $this->wechat_mp->curl->response;
|
$resp = $this->wechat_mp->curl->response;
|
||||||
$res = json_decode($resp, true);
|
$res = json_decode($resp, true);
|
||||||
if (!isset($res['nickname']) || !isset($res['headimgurl'])) {
|
if (!isset($res['nickname']) || !isset($res['headimgurl'])) {
|
||||||
return [
|
return [
|
||||||
'code' => 1,
|
'code' => 1,
|
||||||
'msg' => isset($res['errmsg']) ? $res['errmsg'] : 'error'
|
'msg' => isset($res['errmsg']) ? $res['errmsg'] : 'error'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
'code' => 0,
|
'code' => 0,
|
||||||
'msg' => 'ok',
|
'msg' => 'ok',
|
||||||
'data' => $res
|
'data' => $res
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function code2session($code)
|
private function code2session($code)
|
||||||
{
|
{
|
||||||
$api = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$this->wechat_mp->appId}&secret={$this->wechat_mp->appSecret}&code=" . $code . "&grant_type=authorization_code";
|
$api = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$this->wechat_mp->appId}&secret={$this->wechat_mp->appSecret}&code=" . $code . "&grant_type=authorization_code";
|
||||||
$this->wechat_mp->curl->get($api);
|
$this->wechat_mp->curl->get($api);
|
||||||
if ($this->wechat_mp->curl->error_code != 0) {
|
if ($this->wechat_mp->curl->error_code != 0) {
|
||||||
return [
|
return [
|
||||||
'code' => 1,
|
'code' => 1,
|
||||||
'msg' => "err_code:{$this->wechat_mp->curl->error_code}err_msg:{$this->wechat_mp->curl->error_msg}"
|
'msg' => "err_code:{$this->wechat_mp->curl->error_code}err_msg:{$this->wechat_mp->curl->error_msg}"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$resp = $this->wechat_mp->curl->response;
|
$resp = $this->wechat_mp->curl->response;
|
||||||
$res = json_decode($resp, true);
|
$res = json_decode($resp, true);
|
||||||
if (!isset($res['access_token']) || !isset($res['openid'])) {
|
if (!isset($res['access_token']) || !isset($res['openid'])) {
|
||||||
return [
|
return [
|
||||||
'code' => 1,
|
'code' => 1,
|
||||||
'msg' => isset($res['errmsg']) ? $res['errmsg'] : 'error'
|
'msg' => isset($res['errmsg']) ? $res['errmsg'] : 'error'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
'code' => 0,
|
'code' => 0,
|
||||||
'msg' => 'ok',
|
'msg' => 'ok',
|
||||||
'data' => $res
|
'data' => $res
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,32 +45,36 @@ class LoginForm extends ApiModel
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function login()
|
public function login($user=null)
|
||||||
{
|
{
|
||||||
|
$this->cx_mch_id = 0;
|
||||||
if(!$this->validate()){
|
if(!$this->validate()){
|
||||||
return $this->getModelError();
|
return $this->getModelError();
|
||||||
}
|
}
|
||||||
$mobile_phone = EncryptHelper::encryptMobilePhone($this->username);
|
if(empty($user)){
|
||||||
$mobile_phone = $mobile_phone ? $mobile_phone : $this->username;
|
$mobile_phone = EncryptHelper::encryptMobilePhone($this->username);
|
||||||
$user = User::find()
|
$mobile_phone = $mobile_phone ? $mobile_phone : $this->username;
|
||||||
->where([
|
$user = User::find()
|
||||||
'cx_mch_id' => $this->cx_mch_id,
|
->where([
|
||||||
'is_delete' => 0,
|
'cx_mch_id' => $this->cx_mch_id,
|
||||||
'status' => User::STATUS_NORMAL
|
'is_delete' => 0,
|
||||||
])
|
'status' => User::STATUS_NORMAL
|
||||||
->andWhere([
|
])
|
||||||
'OR',
|
->andWhere([
|
||||||
['username' => $this->username],
|
'OR',
|
||||||
['mobile_phone' => $mobile_phone],
|
['username' => $this->username],
|
||||||
])
|
['mobile_phone' => $mobile_phone],
|
||||||
->one();
|
])
|
||||||
if($user == null){
|
->one();
|
||||||
return [
|
if($user == null){
|
||||||
'code' => 1,
|
return [
|
||||||
'msg' => '用户名或者密码错误'
|
'code' => 1,
|
||||||
];
|
'msg' => '用户名或者密码错误1'
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(!$user->validatePassword($this->password)){
|
|
||||||
|
/*if(!$user->validatePassword($this->password)){
|
||||||
$err_msg = "密码错误";
|
$err_msg = "密码错误";
|
||||||
User::lastLogin($user->id, 0, $err_msg, $this->cx_mch_id);
|
User::lastLogin($user->id, 0, $err_msg, $this->cx_mch_id);
|
||||||
|
|
||||||
@ -78,7 +82,7 @@ class LoginForm extends ApiModel
|
|||||||
'code' => 1,
|
'code' => 1,
|
||||||
'msg' => '用户名或者密码错误'
|
'msg' => '用户名或者密码错误'
|
||||||
];
|
];
|
||||||
}
|
} */
|
||||||
if(\Yii::$app->user->login($user,\Yii::$app->params['loginAuthExpireTime'])){
|
if(\Yii::$app->user->login($user,\Yii::$app->params['loginAuthExpireTime'])){
|
||||||
$args = [];
|
$args = [];
|
||||||
$args['cx_mch_id'] = $this->cx_mch_id;
|
$args['cx_mch_id'] = $this->cx_mch_id;
|
||||||
|
|||||||
79
modules/api/models/ReportEditForm.php
Normal file
79
modules/api/models/ReportEditForm.php
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Any
|
||||||
|
* @description KISS
|
||||||
|
* @date 2020-12-2
|
||||||
|
* @version 1.0.0
|
||||||
|
*
|
||||||
|
* _____LOG_____
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace app\modules\api\models;
|
||||||
|
|
||||||
|
use function AlibabaCloud\Client\value;
|
||||||
|
use app\components\FlashStorage;
|
||||||
|
use app\components\SiteHelper;
|
||||||
|
use app\models\BallMark;
|
||||||
|
use app\models\Coach;
|
||||||
|
use app\models\Dev;
|
||||||
|
use app\models\DeviceUniqueBindUser;
|
||||||
|
use app\models\Model;
|
||||||
|
use app\models\Report;
|
||||||
|
use app\models\Store;
|
||||||
|
use app\models\User;
|
||||||
|
use app\components\auth\AToken;
|
||||||
|
use app\components\EncryptHelper;
|
||||||
|
use app\modules\api\components\ApiHelper;
|
||||||
|
use app\modules\api\components\GetDistance;
|
||||||
|
use yii\data\Pagination;
|
||||||
|
|
||||||
|
|
||||||
|
class ReportEditForm extends ApiModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public $dev_id;
|
||||||
|
public $store_id;
|
||||||
|
|
||||||
|
|
||||||
|
public $user_id;
|
||||||
|
public $model_number;
|
||||||
|
|
||||||
|
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['dev_id', 'store_id'], 'integer'],
|
||||||
|
[['dev_id', 'store_id'], 'required'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 型号列表
|
||||||
|
*/
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
|
||||||
|
$dev = Dev::findOne(['id' => $this->dev_id]);
|
||||||
|
|
||||||
|
if ($dev == null) {
|
||||||
|
return ['code' => 1, 'msg' => '无效设备,请联系管理员'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$model = new Report();
|
||||||
|
$model->user_id = $this->user_id;
|
||||||
|
$model->model_number = $dev->dev_number;
|
||||||
|
$model->store_id = $this->store_id;
|
||||||
|
$model->created_at = time();
|
||||||
|
if (!$model->save()) {
|
||||||
|
return Model::getModelErrorInfo($model);
|
||||||
|
}
|
||||||
|
return ['code' => 0, 'msg' => '成功'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -82,7 +82,7 @@ class UserModifyForm extends ApiModel
|
|||||||
$form->username = $user->username;
|
$form->username = $user->username;
|
||||||
$form->password = '123456';
|
$form->password = '123456';
|
||||||
$form->token_type = 3;
|
$form->token_type = 3;
|
||||||
return $form->login();
|
return $form->login($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
//没有信息 去绑定
|
//没有信息 去绑定
|
||||||
@ -134,13 +134,18 @@ class UserModifyForm extends ApiModel
|
|||||||
$form->username = $username;
|
$form->username = $username;
|
||||||
$form->password = $password;
|
$form->password = $password;
|
||||||
$form->token_type = 3;
|
$form->token_type = 3;
|
||||||
$data = $form->login();
|
$data = $form->login($user);
|
||||||
return $data;
|
return $data;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$t->rollBack();
|
$t->rollBack();
|
||||||
return [
|
return [
|
||||||
'code' => 1,
|
'code' => 1,
|
||||||
'msg' => '失败',
|
'msg' => '失败',
|
||||||
|
'data' => [
|
||||||
|
'msg' => $e->getMessage(),
|
||||||
|
'line' => $e->getLine(),
|
||||||
|
'file' => $e->getFile(),
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,157 +1,159 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Any
|
* @author Any
|
||||||
* @description KISS
|
* @description KISS
|
||||||
* @date 2022年6月5日
|
* @date 2022年6月5日
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
*
|
*
|
||||||
* _____LOG_____
|
* _____LOG_____
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
namespace app\modules\api\models;
|
namespace app\modules\api\models;
|
||||||
|
|
||||||
|
|
||||||
use app\models\User;
|
use app\models\User;
|
||||||
use app\components\auth\AToken;
|
use app\components\auth\AToken;
|
||||||
use app\components\wechat\aes\WxBizDataCrypt;
|
use app\components\wechat\aes\WxBizDataCrypt;
|
||||||
use app\models\UserOauth;
|
use app\models\UserOauth;
|
||||||
use app\models\common\CommonUserEditForm;
|
use app\models\common\CommonUserEditForm;
|
||||||
use app\components\SysConst;
|
use app\components\SysConst;
|
||||||
use app\components\FlashStorage;
|
use app\components\FlashStorage;
|
||||||
use app\components\EncryptHelper;
|
use app\components\EncryptHelper;
|
||||||
use app\models\sms\SmsMsgHelper;
|
use app\models\sms\SmsMsgHelper;
|
||||||
use app\models\sms\SmsTpl;
|
use app\models\sms\SmsTpl;
|
||||||
|
|
||||||
class WxmpAuthMobileForm extends ApiModel
|
class WxmpAuthMobileForm extends ApiModel
|
||||||
{
|
{
|
||||||
|
|
||||||
public $iv;
|
public $iv;
|
||||||
public $code;
|
public $code;
|
||||||
public $encrypted_data;
|
public $encrypted_data;
|
||||||
|
|
||||||
public $wechat_mp;
|
public $wechat_mp;
|
||||||
public $cx_mch_id;
|
public $cx_mch_id;
|
||||||
public $url;
|
public $url;
|
||||||
|
|
||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[['iv', 'code', 'encrypted_data','code'], 'trim'],
|
[['iv', 'code', 'encrypted_data','code'], 'trim'],
|
||||||
[['iv', 'code', 'encrypted_data', 'code'], 'string'],
|
[['iv', 'code', 'encrypted_data', 'code'], 'string'],
|
||||||
[['cx_mch_id',], 'required'],
|
[['cx_mch_id',], 'required'],
|
||||||
[['iv', 'code', 'encrypted_data', 'wechat_mp',], 'required'],
|
[['iv', 'code', 'encrypted_data', 'wechat_mp',], 'required'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
//微信授权手机号
|
//微信授权手机号
|
||||||
public function auth()
|
public function auth()
|
||||||
{
|
{
|
||||||
$res = $this->code2session($this->code);
|
$res = $this->code2session($this->code);
|
||||||
if($res['code'] != 0)
|
if($res['code'] != 0)
|
||||||
return $res;
|
return $res;
|
||||||
$session_key = $res['data']['session_key'];
|
$session_key = $res['data']['session_key'];
|
||||||
$res = $this->decrypted_data($session_key);
|
$res = $this->decrypted_data($session_key);
|
||||||
if($res['code'] != 0){
|
if($res['code'] != 0){
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
$res['data'] = json_decode($res['data'],true);
|
$res['data'] = json_decode($res['data'],true);
|
||||||
if(!isset($res['data']['purePhoneNumber'])){
|
if(!isset($res['data']['purePhoneNumber'])){
|
||||||
return [
|
return [
|
||||||
'code' => 1,
|
'code' => 1,
|
||||||
'msg' => '数据解析失败',
|
'msg' => '数据解析失败',
|
||||||
'data' => $res['data']
|
'data' => $res['data']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$mobile = $res['data']['purePhoneNumber'];//不带区号的手机号
|
$mobile = $res['data']['purePhoneNumber'];//不带区号的手机号
|
||||||
$mobile_prefix = $res['data']['countryCode'];
|
$mobile_prefix = $res['data']['countryCode'];
|
||||||
$data = [
|
$data = [
|
||||||
'code' => 0,
|
'code' => 0,
|
||||||
'msg' => 'ok',
|
'msg' => 'ok',
|
||||||
'data' => [
|
'data' => [
|
||||||
'mobile' => $mobile,
|
'mobile' => $mobile,
|
||||||
'mobile_prefix' => $mobile_prefix
|
'mobile_prefix' => $mobile_prefix
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* 用户数据解密
|
* 用户数据解密
|
||||||
*/
|
*/
|
||||||
private function decrypted_data($session_key){
|
private function decrypted_data($session_key){
|
||||||
$pc = new WxBizDataCrypt($this->wechat_mp->appId, $session_key);
|
$pc = new WxBizDataCrypt($this->wechat_mp->appId, $session_key);
|
||||||
$errCode = $pc->decryptData($this->encrypted_data, $this->iv, $data );
|
$errCode = $pc->decryptData($this->encrypted_data, $this->iv, $data );
|
||||||
if ($errCode == 0) {
|
if ($errCode == 0) {
|
||||||
return [
|
return [
|
||||||
'code' => 0,
|
'code' => 0,
|
||||||
'msg' => 'success',
|
'msg' => 'success',
|
||||||
'data' => $data
|
'data' => $data
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
return [
|
return [
|
||||||
'code' => 1,
|
'code' => 1,
|
||||||
'msg' => $errCode,
|
'msg' => $errCode,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function code2session($code)
|
private function code2session($code)
|
||||||
{
|
{
|
||||||
$api = "https://api.weixin.qq.com/sns/jscode2session?appid={$this->wechat_mp->appId}&secret={$this->wechat_mp->appSecret}&js_code={$code}&grant_type=authorization_code";
|
$api = "https://api.weixin.qq.com/sns/jscode2session?appid={$this->wechat_mp->appId}&secret={$this->wechat_mp->appSecret}&js_code={$code}&grant_type=authorization_code";
|
||||||
$this->wechat_mp->curl->get($api);
|
$this->wechat_mp->curl->get($api);
|
||||||
if($this->wechat_mp->curl->error_code != 0){
|
if($this->wechat_mp->curl->error_code != 0){
|
||||||
return [
|
return [
|
||||||
'code' => 1,
|
'code' => 1,
|
||||||
'msg' => "err_code:{$this->wechat_mp->curl->error_code}err_msg:{$this->wechat_mp->curl->error_msg}"
|
'msg' => "err_code:{$this->wechat_mp->curl->error_code}err_msg:{$this->wechat_mp->curl->error_msg}"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$resp = $this->wechat_mp->curl->response;
|
$resp = $this->wechat_mp->curl->response;
|
||||||
$res = json_decode($resp, true);
|
$res = json_decode($resp, true);
|
||||||
if(!isset($res['openid'])){
|
if(!isset($res['openid'])){
|
||||||
return [
|
return [
|
||||||
'code' => 1,
|
'code' => 1,
|
||||||
'msg' => isset($res['errmsg']) ? $res['errmsg'] : 'error'
|
'msg' => isset($res['errmsg']) ? $res['errmsg'] : 'error'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
'code' => 0,
|
'code' => 0,
|
||||||
'msg' => 'ok',
|
'msg' => 'ok',
|
||||||
'data' => $res
|
'data' => $res
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ 获取js-sdk前端所需参数
|
* @ 获取js-sdk前端所需参数
|
||||||
*/
|
*/
|
||||||
public function actionGetJssdk(){
|
public function actionGetJssdk(){
|
||||||
$redis_name = "api:{$this->wechat_mp->appId}:actionGetJssdk_1";
|
$redis_name = "api:{$this->wechat_mp->appId}:actionGetJssdk_1";
|
||||||
$get = \Yii::$app->redis->get($redis_name);
|
$get = \Yii::$app->redis->get($redis_name);
|
||||||
if(empty($get)){
|
if(empty($get)){
|
||||||
$accessToken = $this->wechat_mp->getAccessToken();
|
$accessToken = $this->wechat_mp->getAccessToken();
|
||||||
// $url = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token=$accessToken";
|
// $url = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token=$accessToken";
|
||||||
$url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=".$accessToken;
|
$url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=".$accessToken;
|
||||||
$this->wechat_mp->curl->get($url);
|
$this->wechat_mp->curl->get($url);
|
||||||
$res = json_decode($this->wechat_mp->curl->response);
|
$res = json_decode($this->wechat_mp->curl->response);
|
||||||
$get = $res->ticket;
|
$get = $res->ticket;
|
||||||
\Yii::$app->redis->setex($redis_name,6800,$get);
|
\Yii::$app->redis->setex($redis_name,6800,$get);
|
||||||
}
|
}
|
||||||
$uniq = uniqid();
|
$uniq = uniqid();
|
||||||
$time = time();
|
$time = time();
|
||||||
$str = "jsapi_ticket={$get}&noncestr={$uniq}×tamp={$time}&url={$this->url}";
|
$this->url = urldecode($this->url);
|
||||||
$sign = sha1($str);
|
$str = "jsapi_ticket={$get}&noncestr={$uniq}×tamp={$time}&url={$this->url}";
|
||||||
$return = [
|
$sign = sha1($str);
|
||||||
'appId' => $this->wechat_mp->appId,
|
$return = [
|
||||||
'timestamp' => $time,
|
'appId' => $this->wechat_mp->appId,
|
||||||
'nonceStr' => $uniq,
|
'timestamp' => $time,
|
||||||
'signature' => $sign,
|
'nonceStr' => $uniq,
|
||||||
'jsApiList' => [
|
'signature' => $sign,
|
||||||
'scanQRCode',
|
'jsApiList' => [
|
||||||
],
|
'scanQRCode',
|
||||||
];
|
],
|
||||||
return $this->apiReturnSuccess('ok',$return);
|
'url' => $this->url,
|
||||||
}
|
];
|
||||||
}
|
return $this->apiReturnSuccess('ok',$return);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
104
modules/store/controllers/DevController.php
Normal file
104
modules/store/controllers/DevController.php
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Any
|
||||||
|
* @description KISS
|
||||||
|
* @date 2020-11-5
|
||||||
|
* @version 1.0.0
|
||||||
|
*
|
||||||
|
* _____LOG_____
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace app\modules\store\controllers;
|
||||||
|
|
||||||
|
|
||||||
|
use app\components\SiteHelper;
|
||||||
|
use app\models\Dev;
|
||||||
|
use app\models\Report;
|
||||||
|
use app\models\StoreUser;
|
||||||
|
use app\models\User;
|
||||||
|
use app\modules\store\behaviors\LoginBehavior;
|
||||||
|
use app\components\EncryptHelper;
|
||||||
|
use app\modules\store\models\dev\DevActionForm;
|
||||||
|
use app\modules\store\models\dev\DevEditForm;
|
||||||
|
use app\modules\store\models\dev\DevtListForm;
|
||||||
|
use app\modules\store\models\report\ReportEditForm;
|
||||||
|
use app\modules\store\models\report\ReportListForm;
|
||||||
|
|
||||||
|
|
||||||
|
class DevController extends Controller
|
||||||
|
{
|
||||||
|
public function behaviors()
|
||||||
|
{
|
||||||
|
return array_merge(parent::behaviors(), [
|
||||||
|
'login' => [
|
||||||
|
'class' => LoginBehavior::className(),
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//设备列表
|
||||||
|
public function actionIndex()
|
||||||
|
{
|
||||||
|
if (\Yii::$app->request->isAjax) {
|
||||||
|
$form = new DevtListForm();
|
||||||
|
$form->store_id = \Yii::$app->store->identity->store_id;
|
||||||
|
$form->attributes = \Yii::$app->request->get();
|
||||||
|
$data = $form->search();
|
||||||
|
return $this->responseHandler($data);
|
||||||
|
}
|
||||||
|
return $this->render('index', []);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//添加设备
|
||||||
|
public function actionEdit($id = 0)
|
||||||
|
{
|
||||||
|
$model = Dev::findOne([
|
||||||
|
'id' => $id,
|
||||||
|
]);
|
||||||
|
if ($model == null)
|
||||||
|
$model = new Dev();
|
||||||
|
|
||||||
|
|
||||||
|
if (\Yii::$app->request->isAjax) {
|
||||||
|
$form = new DevEditForm();
|
||||||
|
$form->store_id = \Yii::$app->store->identity->store_id;
|
||||||
|
$form->model = $model;
|
||||||
|
$form->attributes = \Yii::$app->request->post();
|
||||||
|
|
||||||
|
$data = $form->edit();
|
||||||
|
return $this->responseHandler($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
$return_url = \Yii::$app->request->referrer;
|
||||||
|
return $this->render("edit", [
|
||||||
|
'model' => $model,
|
||||||
|
'return_url' => $return_url,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//设备二维码
|
||||||
|
public function actionQrcode($id = 0)
|
||||||
|
{
|
||||||
|
if (!\Yii::$app->request->isPost) {
|
||||||
|
$data = $this->invaildRequest();
|
||||||
|
return $this->responseHandler($data);
|
||||||
|
}
|
||||||
|
$form = new DevActionForm();
|
||||||
|
$form->attributes = \Yii::$app->request->post();
|
||||||
|
$data = $form->getBallQrcode();
|
||||||
|
return $this->responseHandler($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionBatchQrcode()
|
||||||
|
{
|
||||||
|
$form = new DevActionForm();
|
||||||
|
$data = $form->BatchQrcode();
|
||||||
|
return $this->responseHandler($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,91 +1,92 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Any
|
* @author Any
|
||||||
* @description KISS
|
* @description KISS
|
||||||
* @date 2020-11-5
|
* @date 2020-11-5
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
*
|
*
|
||||||
* _____LOG_____
|
* _____LOG_____
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace app\modules\store\controllers;
|
namespace app\modules\store\controllers;
|
||||||
|
|
||||||
|
|
||||||
use app\models\Report;
|
use app\models\Report;
|
||||||
use app\models\StoreUser;
|
use app\models\StoreUser;
|
||||||
use app\models\User;
|
use app\models\User;
|
||||||
use app\modules\store\behaviors\LoginBehavior;
|
use app\modules\store\behaviors\LoginBehavior;
|
||||||
use app\components\EncryptHelper;
|
use app\components\EncryptHelper;
|
||||||
use app\modules\store\models\report\ReportEditForm;
|
use app\modules\store\models\report\ReportEditForm;
|
||||||
use app\modules\store\models\report\ReportListForm;
|
use app\modules\store\models\report\ReportListForm;
|
||||||
|
|
||||||
|
|
||||||
class ReportController extends Controller
|
class ReportController extends Controller
|
||||||
{
|
{
|
||||||
public function behaviors()
|
public function behaviors()
|
||||||
{
|
{
|
||||||
return array_merge(parent::behaviors(), [
|
return array_merge(parent::behaviors(), [
|
||||||
'login' => [
|
'login' => [
|
||||||
'class' => LoginBehavior::className(),
|
'class' => LoginBehavior::className(),
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//报告列表
|
//报告列表
|
||||||
public function actionIndex()
|
public function actionIndex()
|
||||||
{
|
{
|
||||||
if (\Yii::$app->request->isAjax) {
|
if (\Yii::$app->request->isAjax) {
|
||||||
$form = new ReportListForm();
|
$form = new ReportListForm();
|
||||||
$form->store_id = \Yii::$app->store->identity->store_id;
|
$form->store_id = \Yii::$app->store->identity->store_id;
|
||||||
$form->attributes = \Yii::$app->request->get();
|
$form->user_id = \Yii::$app->store->identity->user_id;
|
||||||
$data = $form->search();
|
$form->attributes = \Yii::$app->request->get();
|
||||||
return $this->responseHandler($data);
|
$data = $form->search();
|
||||||
}
|
return $this->responseHandler($data);
|
||||||
return $this->render('index', []);
|
}
|
||||||
|
return $this->render('index', []);
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
public function actionEdit($id = 0)
|
|
||||||
{
|
public function actionEdit($id = 0)
|
||||||
$model = Report::findOne([
|
{
|
||||||
'id' => $id,
|
$model = Report::findOne([
|
||||||
]);
|
'id' => $id,
|
||||||
if ($model == null)
|
]);
|
||||||
$model = new Report();
|
if ($model == null)
|
||||||
|
$model = new Report();
|
||||||
|
|
||||||
$store_user_id = \Yii::$app->store->identity->user_id;
|
|
||||||
$storeUser = StoreUser::findOne(['user_id' => $store_user_id]);
|
$store_user_id = \Yii::$app->store->identity->user_id;
|
||||||
|
$storeUser = StoreUser::findOne(['user_id' => $store_user_id]);
|
||||||
if (\Yii::$app->request->isAjax) {
|
|
||||||
$form = new ReportEditForm();
|
if (\Yii::$app->request->isAjax) {
|
||||||
$form->store_id = \Yii::$app->store->identity->store_id;
|
$form = new ReportEditForm();
|
||||||
$form->model = $model;
|
$form->store_id = \Yii::$app->store->identity->store_id;
|
||||||
$form->user_type = $storeUser->user_type;
|
$form->model = $model;
|
||||||
$form->attributes = \Yii::$app->request->post();
|
$form->user_type = $storeUser->user_type;
|
||||||
|
$form->attributes = \Yii::$app->request->post();
|
||||||
$data = $form->edit();
|
|
||||||
return $this->responseHandler($data);
|
$data = $form->edit();
|
||||||
}
|
return $this->responseHandler($data);
|
||||||
|
}
|
||||||
if ($model != null) {
|
|
||||||
$user = User::findOne(['id' => $model->user_id]);
|
if ($model != null) {
|
||||||
}
|
$user = User::findOne(['id' => $model->user_id]);
|
||||||
|
}
|
||||||
|
|
||||||
$report_name = $storeUser->user_type == 1 ? '初始模型' : '最终模型';
|
|
||||||
|
$report_name = $storeUser->user_type == 1 ? '初始模型' : '最终模型';
|
||||||
$return_url = \Yii::$app->request->referrer;
|
|
||||||
|
$return_url = \Yii::$app->request->referrer;
|
||||||
return $this->render("edit", [
|
|
||||||
'model' => $model,
|
return $this->render("edit", [
|
||||||
'return_url' => $return_url,
|
'model' => $model,
|
||||||
'user' => $user,
|
'return_url' => $return_url,
|
||||||
'storeUser' => $storeUser,
|
'user' => $user,
|
||||||
'report_name' => $report_name
|
'storeUser' => $storeUser,
|
||||||
]);
|
'report_name' => $report_name
|
||||||
}
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,133 +1,156 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Any
|
* @author Any
|
||||||
* @description KISS
|
* @description KISS
|
||||||
* @date 2020-11-4
|
* @date 2020-11-4
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
*
|
*
|
||||||
* _____LOG_____
|
* _____LOG_____
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace app\modules\store\models;
|
namespace app\modules\store\models;
|
||||||
|
|
||||||
class Menu
|
class Menu
|
||||||
{
|
{
|
||||||
public static function getMenu()
|
public static function getMenu()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
'name' => '主页',
|
'name' => '主页',
|
||||||
'is_menu' => true,
|
'is_menu' => true,
|
||||||
'is_show' => true,
|
'is_show' => true,
|
||||||
'route' => "store/default/index",
|
'route' => "store/default/index",
|
||||||
'icon' => 'layui-icon-home',
|
'icon' => 'layui-icon-home',
|
||||||
'children' => [
|
'children' => [
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
/*[
|
/*[
|
||||||
'name' => '人员管理',
|
'name' => '人员管理',
|
||||||
'is_menu' => true,
|
'is_menu' => true,
|
||||||
'is_show' => true,
|
'is_show' => true,
|
||||||
'route' => null,
|
'route' => null,
|
||||||
'icon' => 'layui-icon-user',
|
'icon' => 'layui-icon-user',
|
||||||
'children' => [
|
'children' => [
|
||||||
[
|
[
|
||||||
'name' => '人员列表',
|
'name' => '人员列表',
|
||||||
'is_menu' => true,
|
'is_menu' => true,
|
||||||
'is_show' => true,
|
'is_show' => true,
|
||||||
'route' => 'store/store/store-user',
|
'route' => 'store/store/store-user',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => '创建/编辑人员',
|
'name' => '创建/编辑人员',
|
||||||
'is_menu' => true,
|
'is_menu' => true,
|
||||||
'is_show' => true,
|
'is_show' => true,
|
||||||
'route' => 'store/store/store-user-edit',
|
'route' => 'store/store/store-user-edit',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],*/
|
],*/
|
||||||
|
|
||||||
[
|
[
|
||||||
'name' => '报告管理',
|
'name' => '报告管理',
|
||||||
'is_menu' => true,
|
'is_menu' => true,
|
||||||
'is_show' => true,
|
'is_show' => true,
|
||||||
'route' => null,
|
'route' => null,
|
||||||
'icon' => 'layui-icon-list',
|
'icon' => 'layui-icon-list',
|
||||||
'children' => [
|
'children' => [
|
||||||
[
|
[
|
||||||
'name' => '报告列表',
|
'name' => '报告列表',
|
||||||
'is_menu' => true,
|
'is_menu' => true,
|
||||||
'is_show' => true,
|
'is_show' => true,
|
||||||
'route' => 'store/report/index',
|
'route' => 'store/report/index',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => '上传报告',
|
'name' => '上传报告',
|
||||||
'is_menu' => true,
|
'is_menu' => true,
|
||||||
'is_show' => false,
|
'is_show' => false,
|
||||||
'route' => 'store/report/edit',
|
'route' => 'store/report/edit',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
// [
|
[
|
||||||
// 'name' => '财务管理',
|
'name' => '设备管理',
|
||||||
// 'is_menu' => true,
|
'is_menu' => true,
|
||||||
// 'is_show' => true,
|
'is_show' => true,
|
||||||
// 'route' => null,
|
'route' => null,
|
||||||
// 'icon' => 'layui-icon-rmb',
|
'icon' => 'layui-icon-list',
|
||||||
// 'children' => [
|
'children' => [
|
||||||
// /**
|
[
|
||||||
// * [
|
'name' => '设备列表',
|
||||||
// * 'name' => '提现管理',
|
'is_menu' => true,
|
||||||
// * 'is_menu' => true,
|
'is_show' => true,
|
||||||
// * 'is_show' => true,
|
'route' => 'store/dev/index',
|
||||||
// * 'route' => null,
|
],
|
||||||
// * 'children' => [
|
[
|
||||||
// * [
|
'name' => '添加/编辑设备',
|
||||||
// * 'name' => '提现列表',
|
'is_menu' => true,
|
||||||
// * 'is_menu' => true,
|
'is_show' => true,
|
||||||
// * 'is_show' => true,
|
'route' => 'store/dev/edit',
|
||||||
// * 'route' => 'store/cash/index',
|
],
|
||||||
// * ],
|
],
|
||||||
// * [
|
],
|
||||||
// * 'name' => '提现设置',
|
|
||||||
// * 'is_menu' => true,
|
|
||||||
// * 'is_show' => true,
|
// [
|
||||||
// * 'route' => 'store/cash/setting',
|
// 'name' => '财务管理',
|
||||||
// * ],
|
// 'is_menu' => true,
|
||||||
// * ],
|
// 'is_show' => true,
|
||||||
// * ],
|
// 'route' => null,
|
||||||
// * */
|
// 'icon' => 'layui-icon-rmb',
|
||||||
// [
|
// 'children' => [
|
||||||
// 'name' => '门店收益',
|
// /**
|
||||||
// 'is_menu' => true,
|
// * [
|
||||||
// 'is_show' => true,
|
// * 'name' => '提现管理',
|
||||||
// 'route' => 'store/store/store-earings',
|
// * 'is_menu' => true,
|
||||||
// ],
|
// * 'is_show' => true,
|
||||||
// [
|
// * 'route' => null,
|
||||||
// 'name' => '数据图表',
|
// * 'children' => [
|
||||||
// 'is_menu' => true,
|
// * [
|
||||||
// 'is_show' => true,
|
// * 'name' => '提现列表',
|
||||||
// 'route' => 'store/store/bind',
|
// * 'is_menu' => true,
|
||||||
// ],
|
// * 'is_show' => true,
|
||||||
//
|
// * 'route' => 'store/cash/index',
|
||||||
// ],
|
// * ],
|
||||||
// ],
|
// * [
|
||||||
[
|
// * 'name' => '提现设置',
|
||||||
'name' => '设置',
|
// * 'is_menu' => true,
|
||||||
'is_menu' => true,
|
// * 'is_show' => true,
|
||||||
'is_show' => true,
|
// * 'route' => 'store/cash/setting',
|
||||||
'route' => null,
|
// * ],
|
||||||
'icon' => 'layui-icon-set',
|
// * ],
|
||||||
'children' => [
|
// * ],
|
||||||
[
|
// * */
|
||||||
'name' => '密码修改',
|
// [
|
||||||
'is_menu' => true,
|
// 'name' => '门店收益',
|
||||||
'is_show' => true,
|
// 'is_menu' => true,
|
||||||
'route' => 'store/setting/password',
|
// 'is_show' => true,
|
||||||
],
|
// 'route' => 'store/store/store-earings',
|
||||||
]
|
// ],
|
||||||
],
|
// [
|
||||||
];
|
// 'name' => '数据图表',
|
||||||
}
|
// 'is_menu' => true,
|
||||||
}
|
// 'is_show' => true,
|
||||||
|
// 'route' => 'store/store/bind',
|
||||||
|
// ],
|
||||||
|
//
|
||||||
|
// ],
|
||||||
|
// ],
|
||||||
|
[
|
||||||
|
'name' => '设置',
|
||||||
|
'is_menu' => true,
|
||||||
|
'is_show' => true,
|
||||||
|
'route' => null,
|
||||||
|
'icon' => 'layui-icon-set',
|
||||||
|
'children' => [
|
||||||
|
[
|
||||||
|
'name' => '密码修改',
|
||||||
|
'is_menu' => true,
|
||||||
|
'is_show' => true,
|
||||||
|
'route' => 'store/setting/password',
|
||||||
|
],
|
||||||
|
]
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
178
modules/store/models/dev/DevActionForm.php
Normal file
178
modules/store/models/dev/DevActionForm.php
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Any
|
||||||
|
* @description KISS
|
||||||
|
* @date 2020-11-5
|
||||||
|
* @version 1.0.0
|
||||||
|
*
|
||||||
|
* _____LOG_____
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace app\modules\store\models\dev;
|
||||||
|
|
||||||
|
use app\components\FlashStorage;
|
||||||
|
use app\components\SiteHelper;
|
||||||
|
use app\components\ZipFile;
|
||||||
|
use app\models\auth\RoleUser;
|
||||||
|
use app\models\BallCart;
|
||||||
|
use app\models\Coach;
|
||||||
|
use app\models\Dev;
|
||||||
|
use app\models\District;
|
||||||
|
use app\models\Model;
|
||||||
|
use app\models\Store;
|
||||||
|
use app\models\StoreUser;
|
||||||
|
use app\models\User;
|
||||||
|
use app\models\Admin;
|
||||||
|
use app\modules\store\models\AdminModel;
|
||||||
|
use app\models\common\CommonUserEditForm;
|
||||||
|
use app\modules\api\components\Mqtt;
|
||||||
|
use app\modules\api\models\StoreCityForm;
|
||||||
|
use PHPQRCode\QRcode;
|
||||||
|
|
||||||
|
class DevActionForm extends AdminModel
|
||||||
|
{
|
||||||
|
public $ids;
|
||||||
|
|
||||||
|
|
||||||
|
private $url = 'https://app.3dxh.h5.dev.1nww.com/#/White';
|
||||||
|
|
||||||
|
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['ids'], 'required'],
|
||||||
|
[['ids'], 'safe'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function attributeLabels()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ids' => '选择项',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getBallQrcode()
|
||||||
|
{
|
||||||
|
$ball = Dev::findOne($this->ids);
|
||||||
|
if ($ball == null) {
|
||||||
|
return ['code' => 1, 'msg' => '该设备不存在'];
|
||||||
|
}
|
||||||
|
$store = Store::findOne($ball->store_id);
|
||||||
|
if ($store == null) {
|
||||||
|
return ['code' => 1, 'msg' => '该设备所在门店不存在'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->getQrcode($store, $ball);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $store
|
||||||
|
* @param $ball
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getQrcode($store, $ball)
|
||||||
|
{
|
||||||
|
|
||||||
|
$path = 'qrcode/';
|
||||||
|
if (!is_dir($path)) {
|
||||||
|
mkdir($path, 0777, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$hostname = $this->url;
|
||||||
|
$filename = 'qrcode/' . $ball->dev_number . '.png';
|
||||||
|
|
||||||
|
|
||||||
|
if (!file_exists($filename)) {
|
||||||
|
|
||||||
|
|
||||||
|
$qr_data = $hostname . "?dev_id={$ball->id}&store_id={$ball->store_id}&time={$ball->created_at}&path=basicsInfo";
|
||||||
|
$errorCorrectionLevel = 'L'; //容错级别
|
||||||
|
$matrixPointSize = 5; //生成图片大小
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
QRcode::png($qr_data, $filename, $errorCorrectionLevel, $matrixPointSize, 2, true);
|
||||||
|
|
||||||
|
$url = \Yii::$app->request->getHostInfo() . '/' . $filename;
|
||||||
|
if (!file_exists($filename)) {
|
||||||
|
return ['code' => 1, 'msg' => '生成二维码失败'];
|
||||||
|
} else {
|
||||||
|
return ['code' => 0, 'msg' => 'ok', 'data' => $url];
|
||||||
|
}
|
||||||
|
// if (!file_exists($filename)) {
|
||||||
|
// return [
|
||||||
|
// 'code' => 1,
|
||||||
|
// 'msg' => 'Failed to generate QR code.'
|
||||||
|
// ];
|
||||||
|
// } else {
|
||||||
|
|
||||||
|
|
||||||
|
// $url = $hostname . '/' . $filename;
|
||||||
|
|
||||||
|
// $file = fopen($filename, "w");//打开文件准备写入
|
||||||
|
// fwrite($file, $url);//写入,$res为图片二进制内容
|
||||||
|
// fclose($file);//关闭
|
||||||
|
|
||||||
|
|
||||||
|
// //图片是否存在
|
||||||
|
// if (!file_exists($filename)) {
|
||||||
|
// return ['code' => 1, 'msg' => '生成二维码失败'];
|
||||||
|
// } else {
|
||||||
|
// return ['code' => 0, 'msg' => 'ok', 'data' => $url];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
} else {
|
||||||
|
return ['code' => 0, 'msg' => 'ok', 'data' => \Yii::$app->request->getHostInfo() . '/' . $filename];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取小程序二维码
|
||||||
|
public function wxmpQrcode($body)
|
||||||
|
{
|
||||||
|
$plugin = new \app\models\common\PluginService();
|
||||||
|
$wxmpService = $plugin->getWxmpService(0);
|
||||||
|
$accessToken = $wxmpService->getAccessToken();
|
||||||
|
if (empty($accessToken)) {
|
||||||
|
$accessToken = $wxmpService->getAccessToken(true);
|
||||||
|
}
|
||||||
|
$body = json_encode($body);
|
||||||
|
return $wxmpService->Qrcode->getWxappQrcode($accessToken, $body);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function BatchQrcode()
|
||||||
|
{
|
||||||
|
$ball = Dev::find()->select('id,store_id,name,dev_number,created_at')->where(['is_delete' => 0])->all();
|
||||||
|
if ($ball == null) {
|
||||||
|
return ['code' => 1, 'msg' => '该设备不存在'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = 'qrcode/dev_qrcode_zip';
|
||||||
|
if (!is_dir($path)) {
|
||||||
|
mkdir($path, 0777, true);
|
||||||
|
}
|
||||||
|
$paths = [];
|
||||||
|
foreach ($ball as $value) {
|
||||||
|
$store = Store::findOne($value->store_id);
|
||||||
|
if ($store == null) {
|
||||||
|
return $value->dev_number . '编号设备所在门店不存在';
|
||||||
|
}
|
||||||
|
$r = $this->getQrcode($store, $value);
|
||||||
|
if ($r['code'] != 0) {
|
||||||
|
return $r['msg'];
|
||||||
|
}
|
||||||
|
$name = $store->name . '_' . $value->dev_number . '.png';
|
||||||
|
array_push($paths, ['name' => $name, 'path' => $r['data']]);
|
||||||
|
}
|
||||||
|
if (empty($paths)) {
|
||||||
|
return '无下载数据';
|
||||||
|
}
|
||||||
|
$zipName = '设备二维码_' . date('Y年m月d日') . '下载' . '.zip'; // 压缩包文件名
|
||||||
|
return (new ZipFile())->downloadZipImg($zipName, $path, $paths);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
89
modules/store/models/dev/DevEditForm.php
Normal file
89
modules/store/models/dev/DevEditForm.php
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Any
|
||||||
|
* @description KISS
|
||||||
|
* @date 2020-11-5
|
||||||
|
* @version 1.0.0
|
||||||
|
*
|
||||||
|
* _____LOG_____
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace app\modules\store\models\dev;
|
||||||
|
|
||||||
|
use app\components\EncryptHelper;
|
||||||
|
use app\components\FlashStorage;
|
||||||
|
use app\models\Admin;
|
||||||
|
use app\models\auth\RoleUser;
|
||||||
|
use app\models\CardUnion;
|
||||||
|
use app\models\Dev;
|
||||||
|
use app\models\District;
|
||||||
|
use app\models\Model;
|
||||||
|
use app\models\StoreUser;
|
||||||
|
use app\models\SysAdmin;
|
||||||
|
use app\models\User;
|
||||||
|
use app\modules\store\models\AdminModel;
|
||||||
|
use app\models\common\CommonUserEditForm;
|
||||||
|
use app\modules\api\models\StoreCityForm;
|
||||||
|
use Wechat\Wechat;
|
||||||
|
|
||||||
|
class DevEditForm extends AdminModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public $store_id;
|
||||||
|
|
||||||
|
public $model;
|
||||||
|
|
||||||
|
public $dev_number;
|
||||||
|
public $name;
|
||||||
|
|
||||||
|
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['name', 'dev_number'], 'string'],
|
||||||
|
[['name', 'dev_number'], 'required'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function attributeLabels()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => '设备名称',
|
||||||
|
'dev_number' => '设备编号',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
if (!$this->validate()) {
|
||||||
|
return $this->getModelError();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($this->model->isNewRecord) {
|
||||||
|
$this->model->created_at = time();
|
||||||
|
|
||||||
|
|
||||||
|
$exists = Dev::find()->where(['dev_number' => $this->dev_number, 'is_delete' => 0])->exists();
|
||||||
|
if ($exists) {
|
||||||
|
return $this->apiReturnError('设备编号已存在');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->model->name = $this->name;
|
||||||
|
$this->model->dev_number = $this->dev_number;
|
||||||
|
$this->model->store_id = $this->store_id;
|
||||||
|
$this->model->updated_at = time();
|
||||||
|
|
||||||
|
if (!$this->model->save()) {
|
||||||
|
return $this->getModelError($this->model);
|
||||||
|
}
|
||||||
|
return $this->apiReturnSuccess('保存成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
95
modules/store/models/dev/DevtListForm.php
Normal file
95
modules/store/models/dev/DevtListForm.php
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Any
|
||||||
|
* @description KISS
|
||||||
|
* @date 2020-11-5
|
||||||
|
* @version 1.0.0
|
||||||
|
*
|
||||||
|
* _____LOG_____
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace app\modules\store\models\dev;
|
||||||
|
|
||||||
|
use app\components\EncryptHelper;
|
||||||
|
use app\components\Utils;
|
||||||
|
use app\models\Dev;
|
||||||
|
use app\models\District;
|
||||||
|
use app\models\Model;
|
||||||
|
use app\models\Report;
|
||||||
|
use app\models\Store;
|
||||||
|
use app\models\StoreUser;
|
||||||
|
use app\models\User;
|
||||||
|
use app\modules\store\models\AdminModel;
|
||||||
|
use app\models\common\CommonUserEditForm;
|
||||||
|
use yii\data\Pagination;
|
||||||
|
|
||||||
|
class DevtListForm extends AdminModel
|
||||||
|
{
|
||||||
|
public $page;
|
||||||
|
public $limit;
|
||||||
|
|
||||||
|
public $keywords;
|
||||||
|
public $status;
|
||||||
|
public $store_id;
|
||||||
|
|
||||||
|
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['keywords',], 'trim'],
|
||||||
|
[['keywords',], 'string'],
|
||||||
|
[['page', 'limit'], 'integer'],
|
||||||
|
[['page'], 'default', 'value' => 1],
|
||||||
|
[['limit'], 'default', 'value' => 20],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function search()
|
||||||
|
{
|
||||||
|
if (!$this->validate()) {
|
||||||
|
return $this->getModelError();
|
||||||
|
}
|
||||||
|
|
||||||
|
$where = ['o.store_id' => $this->store_id];
|
||||||
|
if (!empty($this->times)) {
|
||||||
|
$explode = explode(' - ', $this->times);
|
||||||
|
$where = [
|
||||||
|
'and',
|
||||||
|
['>=', 'o.created_at', strtotime($explode[0])],
|
||||||
|
['<=', 'o.created_at', strtotime($explode[1])],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = Dev::find()->alias('o')
|
||||||
|
->select('o.id,o.name,o.dev_number,o.created_at,o.status,s.name as store_name')
|
||||||
|
->leftJoin(['s' => Store::tableName()], 'o.store_id=s.id')
|
||||||
|
->where([
|
||||||
|
|
||||||
|
])->andWhere($where)
|
||||||
|
->andFilterWhere([
|
||||||
|
'OR',
|
||||||
|
['like', 'o.name', $this->keywords],
|
||||||
|
['like', 'o.dev_numbe', $this->keywords],
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
$count = $query->count();
|
||||||
|
$pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]);
|
||||||
|
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['o.created_at' => SORT_DESC])->asArray()->all();
|
||||||
|
foreach ($list as $index => $item) {
|
||||||
|
$item['created_at_cn'] = date("Y-m-d H:i", $item['created_at']);
|
||||||
|
$list[$index] = $item;
|
||||||
|
}
|
||||||
|
$data = [];
|
||||||
|
$data['code'] = 0;
|
||||||
|
$data['msg'] = 'ok';
|
||||||
|
$data['data'] = $list;
|
||||||
|
$data['count'] = $count;
|
||||||
|
return $data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,123 +1,133 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Any
|
* @author Any
|
||||||
* @description KISS
|
* @description KISS
|
||||||
* @date 2020-11-5
|
* @date 2020-11-5
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
*
|
*
|
||||||
* _____LOG_____
|
* _____LOG_____
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace app\modules\store\models\report;
|
namespace app\modules\store\models\report;
|
||||||
|
|
||||||
use app\components\EncryptHelper;
|
use app\components\EncryptHelper;
|
||||||
use app\components\Utils;
|
use app\components\Utils;
|
||||||
use app\models\District;
|
use app\models\District;
|
||||||
use app\models\Model;
|
use app\models\Model;
|
||||||
use app\models\Report;
|
use app\models\Report;
|
||||||
use app\models\Store;
|
use app\models\Store;
|
||||||
use app\models\StoreUser;
|
use app\models\StoreUser;
|
||||||
use app\models\User;
|
use app\models\User;
|
||||||
use app\modules\store\models\AdminModel;
|
use app\modules\store\models\AdminModel;
|
||||||
use app\models\common\CommonUserEditForm;
|
use app\models\common\CommonUserEditForm;
|
||||||
use yii\data\Pagination;
|
use yii\data\Pagination;
|
||||||
|
|
||||||
class ReportListForm extends AdminModel
|
class ReportListForm extends AdminModel
|
||||||
{
|
{
|
||||||
public $page;
|
public $page;
|
||||||
public $limit;
|
public $limit;
|
||||||
|
|
||||||
public $keywords;
|
public $keywords;
|
||||||
public $status;
|
public $status;
|
||||||
public $store_id;
|
public $store_id;
|
||||||
|
|
||||||
|
public $user_id;
|
||||||
public function rules()
|
|
||||||
{
|
|
||||||
return [
|
public function rules()
|
||||||
[['keywords',], 'trim'],
|
{
|
||||||
[['keywords',], 'string'],
|
return [
|
||||||
[['page', 'limit'], 'integer'],
|
[['keywords',], 'trim'],
|
||||||
[['page'], 'default', 'value' => 1],
|
[['keywords',], 'string'],
|
||||||
[['limit'], 'default', 'value' => 20],
|
[['page', 'limit'], 'integer'],
|
||||||
];
|
[['page'], 'default', 'value' => 1],
|
||||||
}
|
[['limit'], 'default', 'value' => 20],
|
||||||
|
];
|
||||||
public function search()
|
}
|
||||||
{
|
|
||||||
if (!$this->validate()) {
|
public function search()
|
||||||
return $this->getModelError();
|
{
|
||||||
}
|
if (!$this->validate()) {
|
||||||
|
return $this->getModelError();
|
||||||
$where = ['o.store_id' => $this->store_id];
|
}
|
||||||
if (!empty($this->times)) {
|
|
||||||
$explode = explode(' - ', $this->times);
|
$where = ['o.store_id' => $this->store_id];
|
||||||
$where = [
|
if (!empty($this->times)) {
|
||||||
'and',
|
$explode = explode(' - ', $this->times);
|
||||||
['>=', 'o.created_at', strtotime($explode[0])],
|
$where = [
|
||||||
['<=', 'o.created_at', strtotime($explode[1])],
|
'and',
|
||||||
];
|
['>=', 'o.created_at', strtotime($explode[0])],
|
||||||
}
|
['<=', 'o.created_at', strtotime($explode[1])],
|
||||||
|
];
|
||||||
$query = Report::find()->alias('o')
|
}
|
||||||
->select('o.id,o.model_number,o.initial_path,o.final_path,o.pdf_path,o.step,u.real_name,u.mobile_phone,s.name as store_name,o.created_at')
|
|
||||||
->leftJoin(['u' => User::tableName()], 'o.user_id=u.id')
|
$query = Report::find()->alias('o')
|
||||||
->leftJoin(['s' => Store::tableName()], 'o.store_id=s.id')
|
->select('o.id,o.model_number,o.initial_path,o.final_path,o.pdf_path,o.step,u.real_name,u.mobile_phone,s.name as store_name,o.created_at')
|
||||||
->where([
|
->leftJoin(['u' => User::tableName()], 'o.user_id=u.id')
|
||||||
|
->leftJoin(['s' => Store::tableName()], 'o.store_id=s.id')
|
||||||
])->andWhere($where)
|
->where([
|
||||||
->andFilterWhere([
|
|
||||||
'OR',
|
])->andWhere($where)
|
||||||
['like', 'u.mobile_phone', $this->keywords],
|
->andFilterWhere([
|
||||||
['like', 'u.nickname', $this->keywords],
|
'OR',
|
||||||
['like', 'u.real_name', $this->keywords],
|
['like', 'u.mobile_phone', $this->keywords],
|
||||||
]);
|
['like', 'u.nickname', $this->keywords],
|
||||||
|
['like', 'u.real_name', $this->keywords],
|
||||||
|
]);
|
||||||
$count = $query->count();
|
|
||||||
$pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]);
|
|
||||||
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['o.created_at' => SORT_DESC])->asArray()->all();
|
$count = $query->count();
|
||||||
foreach ($list as $index => $item) {
|
$pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]);
|
||||||
$item['created_at_cn'] = date("Y-m-d H:i", $item['created_at']);
|
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['o.created_at' => SORT_DESC])->asArray()->all();
|
||||||
|
|
||||||
$item['initial_path_ext'] = "";
|
$storeUser = StoreUser::findOne(['user_id' => $this->user_id]);
|
||||||
$item['initial_name'] = '';
|
|
||||||
if (!empty($item['initial_path'])) {
|
|
||||||
$item['initial_name'] = $item['model_number'] . '初始报告';
|
foreach ($list as $index => $item) {
|
||||||
$explode = explode('.', $item['initial_path']);
|
|
||||||
$item['initial_path_ext'] = end($explode);
|
$item['user_type'] = $storeUser->user_type;
|
||||||
}
|
|
||||||
|
|
||||||
$item['final_path_ext'] = '';
|
$item['created_at_cn'] = date("Y-m-d H:i", $item['created_at']);
|
||||||
$item['final_name'] = '';
|
|
||||||
if (!empty($item['final_path'])) {
|
$item['initial_path_ext'] = "";
|
||||||
$item['final_name'] = $item['model_number'] . '最终报告';
|
$item['initial_name'] = '';
|
||||||
$explode = explode('.', $item['final_path']);
|
if (!empty($item['initial_path'])) {
|
||||||
$item['final_path_ext'] = end($explode);
|
$item['initial_name'] = $item['model_number'] . '初始模型';
|
||||||
}
|
$explode = explode('.', $item['initial_path']);
|
||||||
|
$item['initial_path_ext'] = end($explode);
|
||||||
|
}
|
||||||
$item['pdf_path_ext'] = "";
|
|
||||||
$item['pdf_name'] = '';
|
$item['final_path_ext'] = '';
|
||||||
if (!empty($item['pdf_path'])) {
|
$item['final_name'] = '';
|
||||||
$item['pdf_name'] = $item['model_number'] . 'PDF报告';
|
if (!empty($item['final_path'])) {
|
||||||
$explode = explode('.', $item['pdf_path']);
|
$item['final_name'] = $item['model_number'] . '最终模型';
|
||||||
$item['pdf_path_ext'] = end($explode);
|
$explode = explode('.', $item['final_path']);
|
||||||
}
|
$item['final_path_ext'] = end($explode);
|
||||||
|
}
|
||||||
|
|
||||||
$list[$index] = $item;
|
|
||||||
}
|
$item['pdf_path_ext'] = "";
|
||||||
$data = [];
|
$item['pdf_name'] = '';
|
||||||
$data['code'] = 0;
|
if (!empty($item['pdf_path'])) {
|
||||||
$data['msg'] = 'ok';
|
$item['pdf_name'] = $item['model_number'] . 'PDF报告';
|
||||||
$data['data'] = $list;
|
$explode = explode('.', $item['pdf_path']);
|
||||||
$data['count'] = $count;
|
$item['pdf_path_ext'] = end($explode);
|
||||||
return $data;
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
$list[$index] = $item;
|
||||||
|
}
|
||||||
|
$data = [];
|
||||||
|
$data['code'] = 0;
|
||||||
|
$data['msg'] = 'ok';
|
||||||
|
$data['data'] = $list;
|
||||||
|
$data['count'] = $count;
|
||||||
|
return $data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
129
modules/store/views/dev/edit.php
Normal file
129
modules/store/views/dev/edit.php
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Any
|
||||||
|
* @description KISS
|
||||||
|
* @date 2020-11-5
|
||||||
|
* @version 1.0.0
|
||||||
|
*
|
||||||
|
* _____LOG_____
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
use app\components\SiteHelper;
|
||||||
|
use app\widgets\PickFile;
|
||||||
|
|
||||||
|
$layui_js_file = "/statics/layuiadmin/layui/layui.all.2.5.5.js?v=1.0.0";
|
||||||
|
$this->registerJsFile($layui_js_file, ['depends' => 'app\modules\admin\assets\AppAsset']);
|
||||||
|
|
||||||
|
$this->title = '添加/编辑设备';
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="layui-fluid">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header"><?= $this->title ?></div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
<div class="layui-form">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label required">设备名称</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" name="name" placeholder="请输入设备名称" autocomplete="off" class="layui-input"
|
||||||
|
value="<?= $model->name ?>"
|
||||||
|
lay-verify="required">
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-mid layui-word-aux"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label required">设备编号</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" name="dev_number" placeholder="请输入设备编号" autocomplete="off" class="layui-input"
|
||||||
|
value="<?= $model->dev_number ?>"
|
||||||
|
lay-verify="required">
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-mid layui-word-aux"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="">
|
||||||
|
<button class="layui-btn" lay-submit="" lay-filter="admin-theme-customise">立即提交</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
<?php $this->beginBlock('js_script_wrap') ?>
|
||||||
|
layui.config({
|
||||||
|
base: '/statics/layuiadmin/' //静态资源所在路径
|
||||||
|
}).extend({
|
||||||
|
index: 'lib/index' //主入口模块
|
||||||
|
}).use(['index', 'user', 'upload'], function () {
|
||||||
|
var $ = layui.$
|
||||||
|
, setter = layui.setter
|
||||||
|
, admin = layui.admin
|
||||||
|
, form = layui.form
|
||||||
|
, router = layui.router()
|
||||||
|
, upload = layui.upload
|
||||||
|
, search = router.search;
|
||||||
|
|
||||||
|
form.render();
|
||||||
|
//提交
|
||||||
|
var submitLock = false;
|
||||||
|
form.on('submit(admin-theme-customise)', function (obj) {
|
||||||
|
if (submitLock) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
submitLock = true;
|
||||||
|
//请求登入接口
|
||||||
|
//console.log(obj)
|
||||||
|
var url = '<?= \Yii::$app->urlManager->createUrl(["/store/dev/edit", 'id' => $model->id ? $model->id : 0]) ?>';
|
||||||
|
var returnUrl = "<?= \Yii::$app->urlManager->createUrl(["/store/dev/index"]) ?>";
|
||||||
|
var data = obj.field;
|
||||||
|
data._csrf = _csrf;
|
||||||
|
$.ajax(url, {
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
data: data,
|
||||||
|
timeout: 10000,
|
||||||
|
success: function (res) {
|
||||||
|
if (res.code == 0) {
|
||||||
|
layer.msg(res.msg, {
|
||||||
|
offset: '15px'
|
||||||
|
, icon: 1
|
||||||
|
, time: 1000
|
||||||
|
}, function () {
|
||||||
|
if (returnUrl) {
|
||||||
|
location.href = returnUrl;
|
||||||
|
} else {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
layer.msg(res.msg, {
|
||||||
|
offset: '15px'
|
||||||
|
, icon: 2
|
||||||
|
, time: 1000
|
||||||
|
}, function () {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (xhr, type, err) {
|
||||||
|
|
||||||
|
},
|
||||||
|
complete: function () {
|
||||||
|
submitLock = false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
<?php $this->endBlock(); ?>
|
||||||
|
</script>
|
||||||
|
<?php $this->registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?>
|
||||||
488
modules/store/views/dev/index.php
Normal file
488
modules/store/views/dev/index.php
Normal file
@ -0,0 +1,488 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use app\models\Store;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Any
|
||||||
|
* @description KISS
|
||||||
|
* @date 2021年6月30日
|
||||||
|
* @version 1.0.0
|
||||||
|
*
|
||||||
|
* _____LOG_____
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$this->title = '设备列表';
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
<style type="text/css">
|
||||||
|
.layui-table-cell {
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="layui-fluid">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">
|
||||||
|
<?= $this->title ?>
|
||||||
|
</div>
|
||||||
|
<div class="layui-card-header layuiadmin-card-header-auto">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="layui-inline">
|
||||||
|
<!--<a class=" layui-btn" href="<?= \Yii::$app->urlManager->createUrl(["store/feedback/edit"]) ?>">添加反馈</a>-->
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline layui-float-right layui-form">
|
||||||
|
|
||||||
|
<!-- <div class="layui-inline layui-form-item">-->
|
||||||
|
<!-- <div class="layui-input-inline">-->
|
||||||
|
<!-- <select class="layui-select" name="status">-->
|
||||||
|
<!-- <option value="" -->
|
||||||
|
<? //=$status === null ? 'selected' : ''?><!--全部状态</option>
|
||||||
|
<!-- --><?php //foreach ($status_labels as $key => $val):?>
|
||||||
|
<!-- <option value="--><? //=$key?><!--" -->
|
||||||
|
<? //=$status == $key && $status != null ? 'selected' : ''?><!--><? //=$val?><!--</option>-->
|
||||||
|
<!-- --><?php //endforeach;?>
|
||||||
|
<!-- </select>-->
|
||||||
|
<!-- </div>-->
|
||||||
|
<!-- </div>-->
|
||||||
|
<div class="layui-inline layui-form-item">
|
||||||
|
<label class="layui-form-label">关键词</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="keywords" placeholder="搜索设备名称,设备编号" autocomplete="off"
|
||||||
|
class="layui-input"
|
||||||
|
value="<?= \Yii::$app->request->get("keywords") ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="dtable-search">
|
||||||
|
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
<table id="dtable" lay-filter="dtable"></table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--工具栏模板-->
|
||||||
|
<script type="text/html" id="toolBarTpl">
|
||||||
|
<div class="layui-btn-container">
|
||||||
|
<!-- <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="batch_status_yes">批量营业</button>-->
|
||||||
|
<!-- <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="batch_status_no">批量停业</button>-->
|
||||||
|
<!-- <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="batch_delete">批量删除</button> -->
|
||||||
|
<button class="layui-btn layui-btn-sm" lay-event="batch_qrcode">打包二维码</button>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!--行操作列模板-->
|
||||||
|
<script type="text/html" id="rowBarTpl">
|
||||||
|
|
||||||
|
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="qrcode">查看二维码</button>
|
||||||
|
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">编辑</button>
|
||||||
|
|
||||||
|
|
||||||
|
{{# if(d.initial_path){ }}
|
||||||
|
<a href="{{d.initial_path}}"
|
||||||
|
download="{{d.initial_name}}.{{d.initial_path_ext}}">
|
||||||
|
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="">下载初始模型</button>
|
||||||
|
</a>
|
||||||
|
{{# } }}
|
||||||
|
|
||||||
|
{{# if(d.final_path){ }}
|
||||||
|
<a href="{{d.final_path}}"
|
||||||
|
download="{{d.final_name}}.{{d.final_path_ext}}">
|
||||||
|
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="">下载最终模型</button>
|
||||||
|
</a>
|
||||||
|
{{# } }}
|
||||||
|
|
||||||
|
|
||||||
|
{{# if(d.pdf_path){ }}
|
||||||
|
<a href="{{d.pdf_path}}"
|
||||||
|
download="{{d.pdf_name}}.{{d.pdf_path_ext}}">
|
||||||
|
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="">下载PDF报告</button>
|
||||||
|
</a>
|
||||||
|
{{# } }}
|
||||||
|
<!-- <button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button>-->
|
||||||
|
<!-- <button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="delete">删除</button>-->
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/html" id="statusTpl">
|
||||||
|
{{# if(d.status == '0'){ }}
|
||||||
|
<span class="layui-badge layui-bg-blue">正常</span>
|
||||||
|
{{# } else{ }}
|
||||||
|
<span class="layui-badge layui-bg-red">停用</span>
|
||||||
|
{{# } }}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
<?php $this->beginBlock('js_script_wrap') ?>
|
||||||
|
|
||||||
|
|
||||||
|
layui.config({
|
||||||
|
base: '/statics/layuiadmin/' //静态资源所在路径
|
||||||
|
}).extend({
|
||||||
|
index: 'lib/index' //主入口模块
|
||||||
|
}).use(['index', 'user', 'table', 'form'], function () {
|
||||||
|
var $ = layui.$
|
||||||
|
, form = layui.form
|
||||||
|
, table = layui.table
|
||||||
|
, admin = layui.admin;
|
||||||
|
|
||||||
|
|
||||||
|
form.render();
|
||||||
|
|
||||||
|
//search
|
||||||
|
form.on('submit(dtable-search)', function (obj) {
|
||||||
|
var field = obj.field;
|
||||||
|
reload_table_data(field);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//重新加载表格数据
|
||||||
|
function reload_table_data(conf) {
|
||||||
|
table.reload('dtable', {
|
||||||
|
url: '<?=\Yii::$app->urlManager->createUrl(['store/report/index'])?>'
|
||||||
|
, page: true
|
||||||
|
, where: conf
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
//执行渲染
|
||||||
|
table.render({
|
||||||
|
//指定原始表格元素选择器(推荐id选择器)
|
||||||
|
elem: '#dtable'
|
||||||
|
//容器高度
|
||||||
|
//,height: 315
|
||||||
|
//容器宽度
|
||||||
|
//,width: 720
|
||||||
|
//设置表头
|
||||||
|
, cols: [[
|
||||||
|
{checkbox: true}
|
||||||
|
, {field: 'id', title: 'ID', width: 80}
|
||||||
|
, {field: 'name', title: '设备名称', width: 150}
|
||||||
|
, {field: 'dev_number', title: '设备编号', width: 180}
|
||||||
|
, {field: 'store_name', title: '门店名称'}
|
||||||
|
// , {field: 'model_number', title: '模型编号'}
|
||||||
|
// , {field: 'initial_name', title: '初始模型'}
|
||||||
|
// , {field: 'final_name', title: '最终模型'}
|
||||||
|
// , {field: 'pdf_name', title: 'PDF报告'}
|
||||||
|
, {field: 'status', title: '状态', templet: '#statusTpl', width: 80}
|
||||||
|
, {field: 'created_at_cn', title: '创建时间', width: 150}
|
||||||
|
, {title: '操作', fixed: 'right', toolbar: '#rowBarTpl', width: 240}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
, url: '<?=\Yii::$app->urlManager->createUrl(['store/dev/index'])?>'
|
||||||
|
, page: true
|
||||||
|
//指向自定义工具栏模板选择器
|
||||||
|
, toolbar: '#toolBarTpl'
|
||||||
|
//头部工具栏右侧的图标按钮
|
||||||
|
, defaultToolbar: []
|
||||||
|
, limit: 20
|
||||||
|
, limits: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
|
||||||
|
, title: '<?=$this->title?>'
|
||||||
|
, data: []
|
||||||
|
, done: function (res, curr, count) {
|
||||||
|
setTimeout(function () {
|
||||||
|
$(".layui-table-main tr").each(function (index, val) {
|
||||||
|
$(".layui-table-fixed").each(function () {
|
||||||
|
$($(this).find(".layui-table-body tbody tr")[index]).height($(val).height());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$(".layui-table-header tr").each(function (index, val) {
|
||||||
|
$(".layui-table-fixed").each(function () {
|
||||||
|
$($(this).find(".layui-table-header thead tr")[index]).height($(val).height());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//监听工具条
|
||||||
|
table.on('tool(dtable)', function (obj) {
|
||||||
|
var row_data = obj.data;
|
||||||
|
var lay_event = obj.event;
|
||||||
|
var id = row_data.id;
|
||||||
|
var confirm_url = null;
|
||||||
|
var confirm_tip = null;
|
||||||
|
var ids = [];
|
||||||
|
ids.push(id);
|
||||||
|
|
||||||
|
if (lay_event == "delete") {
|
||||||
|
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/delete'])?>";
|
||||||
|
confirm_tip = "确定删除此门店吗";
|
||||||
|
}
|
||||||
|
if (lay_event == "status_yes") {
|
||||||
|
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/status-yes'])?>";
|
||||||
|
confirm_tip = "确定此门店变更为营业吗?";
|
||||||
|
}
|
||||||
|
if (lay_event == "status_no") {
|
||||||
|
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/status-no'])?>";
|
||||||
|
confirm_tip = "确定此门店变更为停业吗?";
|
||||||
|
}
|
||||||
|
//if (lay_event == "find_qrcode") {
|
||||||
|
// confirm_url = "<?//=\Yii::$app->urlManager->createUrl(['store/report/edit'])?>//";
|
||||||
|
// confirm_tip = "确定上传报告吗?";
|
||||||
|
//}
|
||||||
|
if (lay_event == 'edit') {
|
||||||
|
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/dev/edit'])?>" + "?id=" + id;
|
||||||
|
location.href = confirm_url;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lay_event == "qrcode") {
|
||||||
|
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/dev/qrcode'])?>";
|
||||||
|
confirm_tip = "确定查看此设备二维码吗?";
|
||||||
|
layer.closeAll()
|
||||||
|
layer.load(2);
|
||||||
|
return $.ajax(confirm_url, {
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
data: {
|
||||||
|
ids: ids,
|
||||||
|
_csrf: _csrf
|
||||||
|
},
|
||||||
|
success: function (res) {
|
||||||
|
layer.closeAll('loading');
|
||||||
|
if (res.code == 0) {
|
||||||
|
var imgHtml = "<img src='" + res.data + "' width='500px' height='500px'/>";
|
||||||
|
//弹出层
|
||||||
|
layer.open({
|
||||||
|
type: 1,
|
||||||
|
shade: 0,
|
||||||
|
offset: 'auto',
|
||||||
|
area: 'auth',
|
||||||
|
shadeClose: true,
|
||||||
|
scrollbar: false,
|
||||||
|
title: "图片预览", //不显示标题
|
||||||
|
content: imgHtml, //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
layer.msg(res.msg, {
|
||||||
|
offset: '15px'
|
||||||
|
, icon: 2
|
||||||
|
, time: 1000
|
||||||
|
}, function () {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (xhr, type, err) {
|
||||||
|
layer.closeAll('loading');
|
||||||
|
layer.msg(xhr.responseText, {
|
||||||
|
offset: '15px'
|
||||||
|
, icon: 2
|
||||||
|
, time: 1000
|
||||||
|
}, function () {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (confirm_url != null) {
|
||||||
|
layer.confirm(confirm_tip, {
|
||||||
|
btn: ['确定', '取消']
|
||||||
|
}, function (index) {
|
||||||
|
layer.close(index)
|
||||||
|
$.ajax(confirm_url, {
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
data: {
|
||||||
|
ids: ids,
|
||||||
|
_csrf: _csrf
|
||||||
|
},
|
||||||
|
success: function (res) {
|
||||||
|
if (res.code == 0) {
|
||||||
|
if (lay_event == 'find_qrcode') {
|
||||||
|
var imgHtml = "<img src='" + res.data + "' width='500px' height='500px'/>";
|
||||||
|
//弹出层
|
||||||
|
layer.open({
|
||||||
|
type: 1,
|
||||||
|
shade: 0,
|
||||||
|
offset: 'auto',
|
||||||
|
area: 'auth',
|
||||||
|
shadeClose: true,
|
||||||
|
scrollbar: false,
|
||||||
|
title: "图片预览", //不显示标题
|
||||||
|
content: imgHtml, //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
layer.msg(res.msg, {
|
||||||
|
offset: '15px'
|
||||||
|
, icon: 1
|
||||||
|
, time: 1000
|
||||||
|
}, function () {
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
layer.msg(res.msg, {
|
||||||
|
offset: '15px'
|
||||||
|
, icon: 2
|
||||||
|
, time: 1000
|
||||||
|
}, function () {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (xhr, type, err) {
|
||||||
|
layer.msg(xhr.responseText, {
|
||||||
|
offset: '15px'
|
||||||
|
, icon: 2
|
||||||
|
, time: 1000
|
||||||
|
}, function () {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, function () {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//监听工具栏
|
||||||
|
table.on('toolbar(dtable)', function (obj) {
|
||||||
|
var lay_event = obj.event;
|
||||||
|
var check_status = table.checkStatus('dtable');
|
||||||
|
var ids = [];
|
||||||
|
$(check_status.data).each(function (index) {
|
||||||
|
ids.push(check_status.data[index]['id']);
|
||||||
|
});
|
||||||
|
if (lay_event == 'batch_qrcode') {
|
||||||
|
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/dev/batch-qrcode'])?>";
|
||||||
|
location.href = confirm_url;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ids.length == 0) {
|
||||||
|
return layer.msg("请选择需要操作项");
|
||||||
|
}
|
||||||
|
|
||||||
|
var confirm_url = null;
|
||||||
|
var confirm_tip = null;
|
||||||
|
if (lay_event == 'batch_delete') {
|
||||||
|
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/delete'])?>";
|
||||||
|
confirm_tip = "确定将选中门店删除吗";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lay_event == 'batch_status_yes') {
|
||||||
|
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/status-yes'])?>";
|
||||||
|
confirm_tip = "确定将选中门店变更为营业吗";
|
||||||
|
}
|
||||||
|
if (lay_event == 'batch_status_no') {
|
||||||
|
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['store/store/status-no'])?>";
|
||||||
|
confirm_tip = "确定将选中门店变更为停业吗";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (confirm_url != null) {
|
||||||
|
layer.confirm(confirm_tip, {
|
||||||
|
btn: ['确定', '取消']
|
||||||
|
}, function () {
|
||||||
|
$.ajax(confirm_url, {
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
data: {
|
||||||
|
ids: ids,
|
||||||
|
_csrf: _csrf
|
||||||
|
},
|
||||||
|
success: function (res) {
|
||||||
|
if (res.code == 0) {
|
||||||
|
layer.msg(res.msg, {
|
||||||
|
offset: '15px'
|
||||||
|
, icon: 1
|
||||||
|
, time: 1000
|
||||||
|
}, function () {
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
layer.msg(res.msg, {
|
||||||
|
offset: '15px'
|
||||||
|
, icon: 2
|
||||||
|
, time: 1000
|
||||||
|
}, function () {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (xhr, type, err) {
|
||||||
|
layer.msg(xhr.responseText, {
|
||||||
|
offset: '15px'
|
||||||
|
, icon: 2
|
||||||
|
, time: 1000
|
||||||
|
}, function () {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, function () {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
form.on('select(province)', function (res) {
|
||||||
|
app.province_id = res.value;
|
||||||
|
$(app.province).each(function (i) {
|
||||||
|
if (app.province[i].id == app.province_id) {
|
||||||
|
app.city = app.province_id != 0 ? app.province[i].list : [];
|
||||||
|
//app.city_id = app.province_id != 0 ? app.province[i].list[0]['id'] : 0;
|
||||||
|
app.area = app.province_id != 0 ? app.city[0].list : [];
|
||||||
|
//app.area_id = app.province_id != 0 ? app.city[0].list[0]['id'] : 0;
|
||||||
|
app.province_id = app.province_id == 0 ? '' : app.province_id;
|
||||||
|
app.$forceUpdate();
|
||||||
|
setTimeout(function () {
|
||||||
|
form.render('select');
|
||||||
|
}, 500);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
form.on('select(city)', function (res) {
|
||||||
|
app.city_id = res.value;
|
||||||
|
$(app.city).each(function (i) {
|
||||||
|
if (app.city[i].id == app.city_id) {
|
||||||
|
app.area = app.city[i].list;
|
||||||
|
//app.area_id = app.city[i].list[0]['id'];
|
||||||
|
app.$forceUpdate();
|
||||||
|
setTimeout(function () {
|
||||||
|
form.render('select');
|
||||||
|
}, 500);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
form.on('select(area)', function (res) {
|
||||||
|
app.area_id = res.value;
|
||||||
|
setTimeout(function () {
|
||||||
|
form.render('select');
|
||||||
|
}, 500);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function previewImg(obj) {
|
||||||
|
var img = new Image();
|
||||||
|
img.src = obj.src;
|
||||||
|
var imgw = img.width;
|
||||||
|
var imgh = img.height;
|
||||||
|
var img_th = imgh / imgw * 500;
|
||||||
|
var imgHtml = "<img src='" + obj.src + "' width='500px' height='" + img_th + "px'/>";
|
||||||
|
//弹出层
|
||||||
|
layer.open({
|
||||||
|
type: 1,
|
||||||
|
shade: 0.8,
|
||||||
|
offset: 'auto',
|
||||||
|
area: [500 + 'px', (img_th + 50) + 'px'],
|
||||||
|
shadeClose: true,
|
||||||
|
scrollbar: false,
|
||||||
|
title: "图片预览", //不显示标题
|
||||||
|
content: imgHtml, //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响
|
||||||
|
cancel: function () {
|
||||||
|
//layer.msg('捕获就是从页面已经存在的元素上,包裹layer的结构', { time: 5000, icon: 6 });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
<?php $this->endBlock(); ?>
|
||||||
|
</script>
|
||||||
|
<?php $this->registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?>
|
||||||
|
|
||||||
@ -1,151 +1,151 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Any
|
* @author Any
|
||||||
* @description KISS
|
* @description KISS
|
||||||
* @date 2020-11-4
|
* @date 2020-11-4
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
*
|
*
|
||||||
* _____LOG_____
|
* _____LOG_____
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$this->title = '登录';
|
$this->title = '登录';
|
||||||
|
|
||||||
use app\components\SiteHelper;
|
use app\components\SiteHelper;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
|
<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
|
||||||
|
|
||||||
<div class="layadmin-user-login-main">
|
<div class="layadmin-user-login-main">
|
||||||
<div class="layadmin-user-login-box layadmin-user-login-header">
|
<div class="layadmin-user-login-box layadmin-user-login-header">
|
||||||
<h2>
|
<h2>
|
||||||
<img src="<?= SiteHelper::getSiteMiniLogo() ?>" alt="<?= SiteHelper::getSiteShortName() ?>"
|
<img src="<?= SiteHelper::getSiteMiniLogo() ?>" alt="<?= SiteHelper::getSiteShortName() ?>"
|
||||||
style="width:100px;height: 100px;border-radius: 100px">
|
style="width:100px;height: 100px;border-radius: 100px">
|
||||||
</h2>
|
</h2>
|
||||||
<p>场地管理员管理系统</p>
|
<p>门店管理系统</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="layadmin-user-login-box layadmin-user-login-body layui-form">
|
<div class="layadmin-user-login-box layadmin-user-login-body layui-form">
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layadmin-user-login-icon layui-icon layui-icon-username"
|
<label class="layadmin-user-login-icon layui-icon layui-icon-username"
|
||||||
for="LAY-user-login-username"></label>
|
for="LAY-user-login-username"></label>
|
||||||
<input type="text" name="username" id="LAY-user-login-username" lay-verify="required"
|
<input type="text" name="username" id="LAY-user-login-username" lay-verify="required"
|
||||||
placeholder="用户名" class="layui-input">
|
placeholder="用户名" class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layadmin-user-login-icon layui-icon layui-icon-password"
|
<label class="layadmin-user-login-icon layui-icon layui-icon-password"
|
||||||
for="LAY-user-login-password"></label>
|
for="LAY-user-login-password"></label>
|
||||||
<input type="password" name="password" id="LAY-user-login-password" lay-verify="required"
|
<input type="password" name="password" id="LAY-user-login-password" lay-verify="required"
|
||||||
placeholder="密码" class="layui-input">
|
placeholder="密码" class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<div class="layui-row">
|
<div class="layui-row">
|
||||||
<div class="layui-col-xs7">
|
<div class="layui-col-xs7">
|
||||||
<label class="layadmin-user-login-icon layui-icon layui-icon-vercode"
|
<label class="layadmin-user-login-icon layui-icon layui-icon-vercode"
|
||||||
for="LAY-user-login-vercode"></label>
|
for="LAY-user-login-vercode"></label>
|
||||||
<input type="text" name="captcha_code" id="LAY-user-login-vercode" lay-verify="required"
|
<input type="text" name="captcha_code" id="LAY-user-login-vercode" lay-verify="required"
|
||||||
placeholder="图形验证码" class="layui-input">
|
placeholder="图形验证码" class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-col-xs5">
|
<div class="layui-col-xs5">
|
||||||
<div style="margin-left: 10px;">
|
<div style="margin-left: 10px;">
|
||||||
<img
|
<img
|
||||||
data-refresh="<?= Yii::$app->urlManager->createUrl(['store/passport/captcha', 'refresh' => 1,]) ?>"
|
data-refresh="<?= Yii::$app->urlManager->createUrl(['store/passport/captcha', 'refresh' => 1,]) ?>"
|
||||||
src="<?= Yii::$app->urlManager->createUrl(['store/passport/captcha',]) ?>"
|
src="<?= Yii::$app->urlManager->createUrl(['store/passport/captcha',]) ?>"
|
||||||
style="cursor: pointer;" title="点击刷新验证码"
|
style="cursor: pointer;" title="点击刷新验证码"
|
||||||
class="layadmin-user-login-codeimg refresh-captcha">
|
class="layadmin-user-login-codeimg refresh-captcha">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item" style="margin-bottom: 20px;">
|
<div class="layui-form-item" style="margin-bottom: 20px;">
|
||||||
<input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
|
<input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit">登 入</button>
|
<button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit">登 入</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="layui-trans layadmin-user-login-footer">
|
<div class="layui-trans layadmin-user-login-footer">
|
||||||
|
|
||||||
<p>© <?= date("Y", time()) ?> <a href="//<?= SiteHelper::getSiteDomain() ?>/"
|
<p>© <?= date("Y", time()) ?> <a href="//<?= SiteHelper::getSiteDomain() ?>/"
|
||||||
target="_blank"><?= SiteHelper::getSiteShortName() ?></a> 版权所有</p>
|
target="_blank"><?= SiteHelper::getSiteShortName() ?></a> 版权所有</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
<?php $this->beginBlock('js_script_wrap') ?>
|
<?php $this->beginBlock('js_script_wrap') ?>
|
||||||
layui.config({
|
layui.config({
|
||||||
base: '/statics/layuiadmin/' //静态资源所在路径
|
base: '/statics/layuiadmin/' //静态资源所在路径
|
||||||
}).extend({
|
}).extend({
|
||||||
index: 'lib/index' //主入口模块
|
index: 'lib/index' //主入口模块
|
||||||
}).use(['index', 'user'], function () {
|
}).use(['index', 'user'], function () {
|
||||||
var $ = layui.$
|
var $ = layui.$
|
||||||
, setter = layui.setter
|
, setter = layui.setter
|
||||||
, admin = layui.admin
|
, admin = layui.admin
|
||||||
, form = layui.form
|
, form = layui.form
|
||||||
, router = layui.router()
|
, router = layui.router()
|
||||||
, search = router.search;
|
, search = router.search;
|
||||||
|
|
||||||
form.render();
|
form.render();
|
||||||
//提交
|
//提交
|
||||||
var submitLock = false;
|
var submitLock = false;
|
||||||
form.on('submit(LAY-user-login-submit)', function (obj) {
|
form.on('submit(LAY-user-login-submit)', function (obj) {
|
||||||
if (submitLock) {
|
if (submitLock) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
submitLock = true;
|
submitLock = true;
|
||||||
//请求登入接口
|
//请求登入接口
|
||||||
//console.log(obj)
|
//console.log(obj)
|
||||||
var url = '<?=\Yii::$app->urlManager->createUrl(["/store/passport/login"])?>';
|
var url = '<?=\Yii::$app->urlManager->createUrl(["/store/passport/login"])?>';
|
||||||
var returnUrl = "<?=\Yii::$app->request->get('return_url')?>";
|
var returnUrl = "<?=\Yii::$app->request->get('return_url')?>";
|
||||||
var data = obj.field;
|
var data = obj.field;
|
||||||
data._csrf = _csrf;
|
data._csrf = _csrf;
|
||||||
$.ajax(url, {
|
$.ajax(url, {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: data,
|
data: data,
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
layer.msg(res.msg, {
|
layer.msg(res.msg, {
|
||||||
offset: '15px'
|
offset: '15px'
|
||||||
, icon: 1
|
, icon: 1
|
||||||
, time: 1000
|
, time: 1000
|
||||||
}, function () {
|
}, function () {
|
||||||
if (returnUrl) {
|
if (returnUrl) {
|
||||||
location.href = returnUrl;
|
location.href = returnUrl;
|
||||||
} else {
|
} else {
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
layer.msg(res.msg, {
|
layer.msg(res.msg, {
|
||||||
offset: '15px'
|
offset: '15px'
|
||||||
, icon: 2
|
, icon: 2
|
||||||
, time: 1000
|
, time: 1000
|
||||||
}, function () {
|
}, function () {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function (xhr, type, err) {
|
error: function (xhr, type, err) {
|
||||||
|
|
||||||
},
|
},
|
||||||
complete: function () {
|
complete: function () {
|
||||||
submitLock = false;
|
submitLock = false;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
//refresh captcha
|
//refresh captcha
|
||||||
$('.layui-form').on('click', '.refresh-captcha', function () {
|
$('.layui-form').on('click', '.refresh-captcha', function () {
|
||||||
var url = $(this).attr('data-refresh');
|
var url = $(this).attr('data-refresh');
|
||||||
url += '&t=' + (new Date()).getTime();
|
url += '&t=' + (new Date()).getTime();
|
||||||
var that = $(this);
|
var that = $(this);
|
||||||
$.get(url, function (res) {
|
$.get(url, function (res) {
|
||||||
that.attr('src', res.url);
|
that.attr('src', res.url);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
<?php $this->endBlock(); ?>
|
<?php $this->endBlock(); ?>
|
||||||
</script>
|
</script>
|
||||||
<?php $this->registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?>
|
<?php $this->registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?>
|
||||||
@ -79,7 +79,14 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
|
|
||||||
<!--行操作列模板-->
|
<!--行操作列模板-->
|
||||||
<script type="text/html" id="rowBarTpl">
|
<script type="text/html" id="rowBarTpl">
|
||||||
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">模型上传</button>
|
|
||||||
|
{{# if(d.user_type == 1){ }}
|
||||||
|
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">初始模型上传</button>
|
||||||
|
{{# } }}
|
||||||
|
|
||||||
|
{{# if(d.user_type == 3){ }}
|
||||||
|
<button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">最终模型上传</button>
|
||||||
|
{{# } }}
|
||||||
|
|
||||||
|
|
||||||
{{# if(d.initial_path){ }}
|
{{# if(d.initial_path){ }}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user