微擎前台页面一边我们会使用createMobileUrl类方法生成手机端页面,即{php echo $this->createMobileUrl('buyquan',array('op'=>'jfbuy'))}
protected function createMobileUrl($do, $query = array(), $noredirect = true) {
global $_W;
$query['do'] = $do;
$query['m'] = strtolower($this->modulename);
return murl('entry', $query, $noredirect);
}通过查看createMobileUrl类实现方法我们知道实现的是本模块的do方法,无法指定模块生成,但我们可以提供murl生成指定模块名的,
$url = murl('site/entry/rank', ['m'=>'yoby_test','op'=>'del'], 1,1);生成如下地址 : ./index.php?i=5&c=site&a=entry&do=rank&m=yoby_test&op=del,true不带微信拼接字符,第二个true表示添加域名
function murl($segment, $params = array(), $noredirect = true, $addhost = false) {
global $_W;
list($controller, $action, $do) = explode('/', $segment);
if (!empty($addhost)) {
$url = $_W['siteroot'] . 'app/';
} else {
$url = './';
}
$str = '';
if(uni_is_multi_acid()) {
$str .= "&j={$_W['acid']}";
}
if (!empty($_W['account']) && $_W['account']['type'] == ACCOUNT_TYPE_WEBAPP_NORMAL) {
$str .= '&a=webapp';
}
if (!empty($_W['account']) && $_W['account']['type'] == ACCOUNT_TYPE_PHONEAPP_NORMAL) {
$str .= '&a=phoneapp';
}
$url .= "index.php?i={$_W['uniacid']}{$str}&";
if (!empty($controller)) {
$url .= "c={$controller}&";
}
if (!empty($action)) {
$url .= "a={$action}&";
}
if (!empty($do)) {
$url .= "do={$do}&";
}
if (!empty($params)) {
$queryString = http_build_query($params, '', '&');
$url .= $queryString;
if ($noredirect === false) {
$url .= '&wxref=mp.weixin.qq.com#wechat_redirect';
}
}
return $url;
}实际模版使用
{php echo murl('entry', array('m' => 'paycenter', 'do' => 'pay', 'id' => $id), true, true);}
如果本文对你有帮助,欢迎打赏本站

支付宝扫码打赏
微信扫码打赏
