quanwei
2025-11-21 2d9362ae6f528f57e6133d5d80f0b633c24e8eb6
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
 
namespace app\common\model\page;
 
use think\facade\Cache;
use app\common\model\BaseModel;
 
/**
 * 个人中心菜单模型
 */
class CenterMenu extends BaseModel
{
    protected $name = 'center_menu';
    protected $pk = 'menu_id';
 
    /**
     * 详情
     */
    public static function detail($menu_id)
    {
        return (new static())->find($menu_id);
    }
 
    /**
     * 查询所有
     */
    public static function getAll()
    {
        $model = new static();
        if (!Cache::get('center_menu_' . $model::$app_id)) {
            $list = $model->order(['sort' => 'asc'])->select();
            if(count($list) == 0){
                $sys_menus = $model->getSysMenu();
                $save_data = [];
                foreach($sys_menus as $menu){
                    $save_data[] = array_merge($sys_menus[$menu['sys_tag']], [
                        'app_id' => self::$app_id
                    ]);
                }
                $model->saveAll($save_data);
                $list = $model->order(['sort' => 'asc'])->select();
            }
            Cache::tag('cache')->set('center_menu_' . $model::$app_id, $list);
        }
        return Cache::get('center_menu_' . $model::$app_id);
    }
 
    /**
     * 系统菜单
     */
    public static function getSysMenu()
    {
        return [
            'address' => [
                'sys_tag' => 'address',
                'title' => '收货地址',
                'link_url' => '/pages/user/address/address',
                'image_url' => 'image/menu/address.png'
            ],
            'coupon' => [
                'sys_tag' => 'coupon',
                'title' => '领券中心',
                'link_url' => '/pages/coupon/coupon',
                'image_url' => 'image/menu/coupon.png'
            ],
            'my_coupon' => [
                'sys_tag' => 'my_coupon',
                'title' => '我的优惠券',
                'link_url' => '/pages/user/my-coupon/my-coupon',
                'image_url' => 'image/menu/my_coupon.png'
            ],
            'agent' => [
                'sys_tag' => 'agent',
                'title' => '分销中心',
                'link_url' => '/pages/agent/index/index',
                'image_url' => 'image/menu/agent.png'
            ],
            'team' => [
                'sys_tag' => 'team',
                'title' => '团队分红',
                'link_url' => '/pages2/team/index/index',
                'image_url' => 'image/menu/team.png'
            ],
            'shareholder' => [
                'sys_tag' => 'shareholder',
                'title' => '股东分红',
                'link_url' => '/pages2/shareholder/index/index',
                'image_url' => 'image/menu/shareholder.png'
            ],
            'region' => [
                'sys_tag' => 'region',
                'title' => '区域代理',
                'link_url' => '/pages2/region/index/index',
                'image_url' => 'image/menu/region.png'
            ],
            'bargain' => [
                'sys_tag' => 'bargain',
                'title' => '我的砍价',
                'link_url' => '/pages/user/my-bargain/my-bargain',
                'image_url' => 'image/menu/bargain.png'
            ],
            'shop' => [
                'sys_tag' => 'shop',
                'title' => '入驻店铺',
                'link_url' => '/pages/shop/register',
                'image_url' => 'image/menu/shop.png'
            ],
            'my_shop' => [
                'sys_tag' => 'my_shop',
                'title' => '我的店铺',
                'link_url' => '/pages/user/my_shop/my_shop',
                'image_url' => 'image/menu/my_shop.png'
            ],
            'app_shop' => [
                'sys_tag' => 'app_shop',
                'title' => '我的店铺',
                'link_url' => '/pages/shop/application_status',
                'image_url' => 'image/menu/app_shop.png'
            ],
            'my_attention' => [
                'sys_tag' => 'my_attention',
                'title' => '我的收藏',
                'link_url' => '/pages/user/my_attention/my_attention',
                'image_url' => 'image/menu/my_attention.png'
            ],
            'my_collect' => [
                'sys_tag' => 'my_collect',
                'title' => '我的关注',
                'link_url' => '/pages/user/my_collect/my_collect',
                'image_url' => 'image/menu/my_collect.png'
            ],
            'signin' => [
                'sys_tag' => 'signin',
                'title' => '签到有礼',
                'link_url' => '/pages/plus/signin/signin',
                'image_url' => 'image/menu/signin.png'
            ],
            'lottery' => [
                'sys_tag' => 'lottery',
                'title' => '我的抽奖',
                'link_url' => '/pages/plus/lottery/lottery',
                'image_url' => 'image/menu/lottery.png'
            ],
            'setting' => [
                'sys_tag' => 'setting',
                'title' => '设置',
                'link_url' => '/pages/user/set/set',
                'image_url' => 'image/menu/setting.png'
            ],
        'task' => [
                'sys_tag' => 'task',
                'title' => '任务中心',
                'link_url' => '/pages/plus/task/index',
                'image_url' => 'image/menu/task.png'
            ],
            'delivery' => [
                'sys_tag' => 'delivery',
                'title' => '配送点',
                'link_url' => '/pages2/delivery/index',
                'image_url' => 'image/menu/delivery.png'
            ],
            'deliveryclerk' => [
                'sys_tag' => 'deliveryclerk',
                'title' => '店员配送员',
                'link_url' => '/pages2/deliveryclerk/index',
                'image_url' => 'image/menu/deliveryclerk.png'
            ],
            'commander' => [
                'sys_tag' => 'commander',
                'title' => '团长',
                'link_url' => '/pages2/commander/index',
                'image_url' => 'image/menu/delivery.png'
            ],
            'deliveryman' => [
                'sys_tag' => 'deliveryman',
                'title' => '外卖配送员',
                'link_url' => '/pages2/deliveryman/index',
                'image_url' => 'image/menu/deliveryclerk.png'
            ],
        ];
    }
  
}