Index.php
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/10/18
* Time: 11:19
*/
namespace app\home\controller;
use app\common\controller\Frontend;
use think\Controller;
use think\Db;
class Index extends Controller
{
public function login(){
$title = "登录";
$this->assign('title',$title);
return $this->fetch();
}
public function login_verify(){
$param = $this->request->param();
if(empty($param['password'])){
$this->error('404');
}
/*$password = Db::name('password')->where(['id'=>1])->value('password');
if($param['password'] != $password){
$this->error('密码错误');
}*/
$data = Db::name('goods')->where(['password'=>$param['password']])->order('id desc')->find();
if(empty($data)){
$this->error('密码错误');
}
session("status_$data[id]",1);
$this->success('SUCCESS','',$data);
}
public function index(){
$goods_id = $this->request->param('goods_id',0,'intval');
if(empty($goods_id)){
$this->error('404');
}
if(empty(session("status_$goods_id"))){
$this->redirect('login');
}
$data = Db::name('goods')->where(['id'=>$goods_id])->find();
$data = collection($data)->toArray();
$images = explode(',',$data['images']);
foreach($images as $key => $i){
$images[$key] = request()->domain().$i;
}
$data['images'] = $images;
$this->assign('title',$data['title']);
$this->assign('data',$data);
return $this->fetch();
}
}