lyzflash
2025-11-17 91a56a9b83ec23a1580aa586a24b34aba6990ffa
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
 
namespace app\admin\controller;
 
use app\admin\model\app\App as AppModel;
use app\admin\model\Shop as ShopModel;
 
class Shop extends Controller
{
    /**
     * 小程序列表
     */
    public function index()
    {
        $model = new AppModel;
        $list = $model->getList($this->postData());
        return $this->renderSuccess('', compact('list'));
    }
 
    /**
     * 进入商城
     */
    public function enter($app_id)
    {
        $model = new ShopModel;
        $model->login($app_id);
        return redirect('/shop#/login?from=admin');
    }
 
    /**
     * 添加应用
     */
    public function add()
    {
        $model = new AppModel;
        // 新增记录
        if ($model->add($this->postData())) {
            return $this->renderSuccess('添加成功');
        }
        return $this->renderError($model->getError() ?: '添加失败');
    }
 
    /**
     * 添加应用
     */
    public function edit($app_id)
    {
        $model = AppModel::detail($app_id);
        // 新增记录
        if ($model->edit($this->postData())) {
            return $this->renderSuccess('修改成功');
        }
        return $this->renderError($model->getError() ?: '修改失败');
    }
 
    /**
     * 删除小程序
     */
    public function delete($app_id)
    {
        // 小程序详情
        $model = AppModel::detail($app_id);
        if (!$model->setDelete()) {
            return $this->renderError('操作失败');
        }
        return $this->renderSuccess('操作成功');
    }
 
    /*
     *启用禁用
    */
    public function updateStatus($app_id)
    {
        $model = AppModel::detail($app_id);
        if (!$model->updateStatus()) {
            return $this->renderError('操作失败');
        }
        return $this->renderSuccess('操作成功');
    }
 
    /*
     *启用禁用
    */
    public function updateWxStatus($app_id)
    {
        $model = AppModel::detail($app_id);
        if (!$model->updateWxStatus()) {
            return $this->renderError('操作失败');
        }
        return $this->renderSuccess('操作成功');
    }
}