123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- /**
- * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
- * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
- * @author pillar<ltmn@qq.com>
- * 应用扩展
- */
- namespace app\ais\controller;
- use app\ais\model\AisAdwords;
- use app\common\facade\WechatProgram;
- use think\facade\Request;
- class Adwords extends Common{
- public function initialize() {
- parent::initialize();
- $this->assign('pathMaps', [['name'=>'广告管理','url'=>'javascript:;']]);
- }
- /**
- * 列表
- */
- public function index($group){
- $condition = [];
- $condition['group'] = $group;
- $condition['member_miniapp_id'] = $this->member_miniapp_id;
- $view['lists'] = AisAdwords::where($condition)->order('sort desc,id desc')->paginate(20);
- $view['pathMaps'] = [['name'=>'广告管理','url'=>url("adwords/index",['group' => $group])]];
- $view['group'] = $group;
- return view('index',$view);
- }
-
- //编辑
- public function edit(){
- if(request()->isAjax()){
- $data = [
- 'id' => Request::param('id/d',0),
- 'group' => Request::param('group/s'),
- 'open_type' => Request::param('open_type/s','','htmlspecialchars'),
- 'title' => Request::param('title/s'),
- 'link' => Request::param('link/s'),
- 'picture' => Request::param('picture/s'),
- 'member_miniapp_id' => $this->member_miniapp_id,
- ];
- $validate = $this->validate($data,'adwords.edit');
- if(true !== $validate){
- return json(['code'=>0,'msg'=>$validate]);
- }
- $result = AisAdwords::edit($data);
- if($result){
- return json(['code'=>200,'url'=>url('adwords/index',['group' => $data['group']]),'msg'=>'操作成功']);
- }else{
- return json(['code'=>0,'msg'=>'操作失败']);
- }
- }else{
- $view['info'] = AisAdwords::where($this->mini_program)->where(['id' => Request::param('id/d', 0)])->find();
- if($this->member_miniapp->miniapp->is_openapp == 0){
- $list = WechatProgram::isTypes($this->member_miniapp_id)->code->getPage();
- }else{
- $list = ['errcode' => 1];
- }
- $view['list'] = $list;
- $view['group'] = Request::param('group');
- return view()->assign($view);
- }
- }
- //删除
- public function delete(int $id){
- $result = AisAdwords::where($this->mini_program)->where(['id' => $id])->delete();
- if($result){
- return enjson(200);
- }else{
- return enjson(0,'删除失败');
- }
- }
-
- /**
- * 排序
- */
- public function sort(){
- if(request()->isAjax()){
- $data = [
- 'sort' => $this->request->param('sort/d'),
- 'id' => $this->request->param('id/d'),
- ];
- $validate = $this->validate($data,'Category.sort');
- if(true !== $validate){
- return json(['code'=>0,'msg'=>$validate]);
- }
- $result = AisAdwords::update(['sort'=>$data['sort']],['member_miniapp_id' => $this->member_miniapp_id,'id' =>$data['id']]);
- if($result){
- return enjson(200);
- }else{
- return enjson(0);
- }
- }
- }
- }
|