2024-11-04 15:00:20 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\manystore\controller\general;
|
|
|
|
|
|
|
|
use app\manystore\model\Manystore;
|
|
|
|
use app\manystore\model\ManystoreShop;
|
|
|
|
use app\common\controller\ManystoreBase;
|
|
|
|
use fast\Random;
|
|
|
|
use think\Exception;
|
|
|
|
use think\Session;
|
2025-01-04 18:09:51 +08:00
|
|
|
use think\Url;
|
2024-11-04 15:00:20 +08:00
|
|
|
use think\Validate;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 商家信息配置
|
|
|
|
*
|
|
|
|
* @icon fa fa-user
|
|
|
|
*/
|
|
|
|
class Profile extends ManystoreBase
|
|
|
|
{
|
2025-01-04 18:09:51 +08:00
|
|
|
protected $noNeedLogin = ["miniqrcode"];
|
2024-11-04 15:00:20 +08:00
|
|
|
/**
|
|
|
|
* 查看
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$shopModel = new ManystoreShop();
|
|
|
|
$shop_info = $shopModel->where(array('id'=>SHOP_ID))->find();
|
|
|
|
$this->view->assign('statusList',[0=>'待审核',1=>'审核通过',2=>'审核拒绝']);
|
2024-11-18 19:01:04 +08:00
|
|
|
$this->view->assign('typeList',$shop_info->getTypeList());
|
|
|
|
|
2024-11-04 15:00:20 +08:00
|
|
|
$this->view->assign('shop_info',$shop_info);
|
2024-12-13 18:37:50 +08:00
|
|
|
$this->view->assign('check_full',(new \app\common\model\dyqc\ManystoreShop)->checkFull(SHOP_ID));
|
|
|
|
$this->view->assign('check_full_msg',(new \app\common\model\dyqc\ManystoreShop)->checkFullMsg(SHOP_ID));
|
|
|
|
|
2024-12-06 18:47:05 +08:00
|
|
|
$this->getCity();
|
2025-01-04 18:09:51 +08:00
|
|
|
$this->view->assign('miniqrcode_link',Url::build("/manystore/general/profile/miniqrcode", ["ids" => SHOP_ID]));
|
2024-11-04 15:00:20 +08:00
|
|
|
return $this->view->fetch();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 更新个人信息
|
|
|
|
*/
|
|
|
|
public function update()
|
|
|
|
{
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
$this->token();
|
|
|
|
$params = $this->request->post("row/a");
|
|
|
|
$params = array_filter(array_intersect_key(
|
|
|
|
$params,
|
|
|
|
array_flip(array('email', 'nickname', 'password', 'avatar'))
|
|
|
|
));
|
|
|
|
unset($v);
|
|
|
|
if (!Validate::is($params['email'], "email")) {
|
|
|
|
$this->error(__("Please input correct email"));
|
|
|
|
}
|
2024-12-13 18:37:50 +08:00
|
|
|
// if (!Validate::is($params['nickname'], "/^[\x{4e00}-\x{9fa5}a-zA-Z0-9_-]+$/u")) {
|
|
|
|
// $this->error(__("Please input correct nickname"));
|
|
|
|
// }
|
2024-11-04 15:00:20 +08:00
|
|
|
if (isset($params['password'])) {
|
|
|
|
if (!Validate::is($params['password'], "/^[\S]{6,16}$/")) {
|
|
|
|
$this->error(__("Please input correct password"));
|
|
|
|
}
|
|
|
|
$params['salt'] = Random::alnum();
|
|
|
|
$params['password'] = md5(md5($params['password']) . $params['salt']);
|
|
|
|
}
|
|
|
|
$exist = Manystore::where('email', $params['email'])->where('id', '<>', $this->auth->id)->find();
|
|
|
|
if ($exist) {
|
|
|
|
$this->error(__("Email already exists"));
|
|
|
|
}
|
|
|
|
if ($params) {
|
|
|
|
$manystore = Manystore::get($this->auth->id);
|
|
|
|
$manystore->save($params);
|
|
|
|
|
|
|
|
Session::set("manystore", $manystore->toArray());
|
2024-11-27 18:15:32 +08:00
|
|
|
|
2025-01-04 18:09:51 +08:00
|
|
|
|
2024-11-04 15:00:20 +08:00
|
|
|
$this->success();
|
|
|
|
}
|
|
|
|
$this->error();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function shop_update(){
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
$this->token();
|
|
|
|
$shop = $this->request->post("shop/a");
|
2024-12-13 18:37:50 +08:00
|
|
|
if($shop["address_city"] && !$shop["district"])$this->error("请选择所在城市");
|
2024-12-04 18:17:08 +08:00
|
|
|
|
2024-11-04 15:00:20 +08:00
|
|
|
|
|
|
|
$shopModel = new ManystoreShop();
|
|
|
|
$shopModel->save($shop,array('id'=>SHOP_ID));
|
2025-01-04 18:09:51 +08:00
|
|
|
//调用事件
|
|
|
|
$data = ['shop' => $shopModel];
|
|
|
|
\think\Hook::listen('shop_update_after', $data);
|
2024-11-04 15:00:20 +08:00
|
|
|
|
|
|
|
$this->success();
|
|
|
|
}
|
|
|
|
$this->error();
|
|
|
|
}
|
2025-01-04 18:09:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 微信小程序码
|
|
|
|
* @return string
|
|
|
|
* @throws \think\Exception
|
|
|
|
* @throws \think\db\exception\BindParamException
|
|
|
|
* @throws \think\exception\DbException
|
|
|
|
* @throws \think\exception\PDOException
|
|
|
|
*/
|
|
|
|
public function miniqrcode($ids = ''){
|
|
|
|
$param = $this->request->param();
|
|
|
|
try{
|
|
|
|
if(isset($param['ids']))$ids = $param['ids'];
|
|
|
|
//设置模拟资格
|
|
|
|
$url = \app\common\model\dyqc\ManystoreShop::getMiniQrcodeLink($ids);
|
|
|
|
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->error($e->getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
return $url["response"];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查看微信小程序码
|
|
|
|
* @return string
|
|
|
|
* @throws \think\Exception
|
|
|
|
* @throws \think\db\exception\BindParamException
|
|
|
|
* @throws \think\exception\DbException
|
|
|
|
* @throws \think\exception\PDOException
|
|
|
|
*/
|
|
|
|
public function lookminiqrcode($ids = ''){
|
|
|
|
$param = $this->request->param();
|
|
|
|
if($this->request->isPost()){
|
|
|
|
try{
|
|
|
|
if(isset($param['ids']))$ids = $param['ids'];
|
|
|
|
//设置模拟资格
|
|
|
|
$url = \app\common\model\dyqc\ManystoreShop::getMiniQrcodeLink($ids);
|
|
|
|
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->error($e->getMessage());
|
|
|
|
}
|
|
|
|
$this->success("生成小程序码成功",null,$url);
|
|
|
|
}
|
|
|
|
$row = $this->model->get($ids);
|
|
|
|
$this->view->assign('vo', $row);
|
|
|
|
return $this->view->fetch();
|
|
|
|
}
|
2024-11-04 15:00:20 +08:00
|
|
|
}
|