查看: 568|回复: 0

【独立版】定义自己的短链系统

[复制链接]

748

主题

39

回帖

3907

积分

管理员

总舵主

积分
3907
QQ
发表于 2024-12-30 10:27:52 | 显示全部楼层 |阅读模式
打开站点根目录application/index/controller/Index.php

复制如下代码:
  1. <?php

  2. namespace app\index\controller;

  3. use app\common\controller\Frontend;
  4. use app\admin\model\nianbao\Shortlink;

  5. class Index extends Frontend
  6. {

  7.     protected $noNeedLogin = '*';
  8.     protected $noNeedRight = '*';
  9.     protected $layout = '';

  10.     public function index()
  11.     {
  12.         header("Location:".request()->root(true).'/XasZQxTAdm.php');
  13.     }
  14.    
  15.     /**
  16.      * 短链
  17.      */
  18.     public function shortlink()
  19.     {
  20.         $name = $this->request->param('name');
  21.         $shortlink = Shortlink::get(['querycode'=>$name]);
  22.         if (empty($shortlink)) {
  23.             $this->error('短链不存在');
  24.         }
  25.         // 更新短链访问次数
  26.         $shortlink->allowField(true)->save(['visits'=>$shortlink->visits]);
  27.         header("Location:".$this->request->root(true).'/h5/pages/business/shortlink?id='.$shortlink->id);
  28.     }

  29. }
复制代码
最终效果如下图所示:
微信图片_20241230102645.png
注意红框内的就是需要修改的地方,图里的第一个红框中map应该是nianbao,按照上方代码复制粘贴就行。
道不同,不相为谋!理想要有,万一实现了呢?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注公众号

相关侵权、举报、投诉及建议等,请发 E-mail:2513533699@qq.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.|鲁ICP备19000917号|鲁公网安备37078302000320号

在本版发帖
关注公众号
QQ客服返回顶部