71 lines
2.2 KiB
PHP
71 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace app\index\controller;
|
|
|
|
use think\Controller;
|
|
use think\Db;
|
|
|
|
class Index extends Controller
|
|
{
|
|
|
|
public function index($name = '-')
|
|
{
|
|
return 'hello,' . $name;
|
|
}
|
|
|
|
|
|
//单页
|
|
public function page_show()
|
|
{
|
|
$aid = input('id', 0);
|
|
$map = [];
|
|
$map[] = ['aid', '=', $aid];
|
|
$map[] = ['is_delete', '=', 1];
|
|
$page_info = db::name('page')->field('title,content')->where($map)->find();
|
|
if (empty($page_info)) {
|
|
// return ['code' => 201, 'msg' => '信息不存在', 'data' => null];
|
|
return json(['code' => 201, 'msg' => '信息不存在', 'data' => null]);
|
|
}
|
|
$page_info['content'] = $this->getImgAllSrc($page_info['content']);
|
|
$this->assign('data', $page_info);
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
|
|
//邀请二维码
|
|
public function invitation()
|
|
{
|
|
$uid = input('uid', 0);
|
|
$user_info = db::name('user')->where(['uid' => $uid])->field('uid,reg_code,reg_code_path')->find();
|
|
if (empty($user_info)) {
|
|
// return ['code' => 200, 'msg' => '信息不存在', 'data' => null];
|
|
return json(['code' => 201, 'msg' => '信息不存在', 'data' => null]);
|
|
}
|
|
if (empty($user_info['reg_code_path'])) {
|
|
// $user_info['reg_code_path'] = model('Api/User')->get_user_reg_qrcode($user_info['uid']);
|
|
$data=model('api/User')->get_user_reg_qrcode($user_info['uid']);
|
|
$user_info['reg_code_path'] =$data['data'];
|
|
}
|
|
$user_info['qrcode'] = localpath_to_netpath($user_info['reg_code_path']);
|
|
// $this->assign('qrcode', $user_info['reg_code_path']);
|
|
$this->assign('qrcode',$user_info['qrcode']);
|
|
$this->assign('reg_code', $user_info['reg_code']);
|
|
return $this->fetch();
|
|
}
|
|
|
|
//注册页
|
|
public function register()
|
|
{
|
|
return $this->fetch();
|
|
}
|
|
|
|
public function getImgAllSrc($tag)
|
|
{
|
|
$preg = "/<img.*?src=[\"|\'](.*?)[\"|\'].*?>/";
|
|
$style = "width: 100%";
|
|
$img = '<img src="$1" style="width: 100%" title="image" alt="$1">';
|
|
$data = preg_replace($preg,$img,$tag);
|
|
return $data;
|
|
}
|
|
}
|