有個別(bie)同學會需要(yao)怎么在下(xia)載(zai)附(fu)件的時(shi)候 跳轉到確認頁(ye),小秋今(jin)天抽空修改下(xia)內置源碼。并將方法做了分享和記錄(lu),當(dang)然是(shi)否更(geng)新到版本當(dang)中,取(qu)決于(yu)需求(qiu)量,由于(yu)目前只(zhi)是(shi)個人需求(qiu),暫時(shi)不做考(kao)慮嵌(qian)入在內置里面(mian)(所(suo)以只(zhi)是(shi)粗(cu)粗(cu)的寫下(xia)代碼,請(qing)老師(shi)勿(wu)見笑),有需要(yao)的朋友自(zi)行修改。
PS:開(kai)啟(qi)前端點擊下載(zai)后,可跳轉確(que)認頁再下載(zai)的目(mu)的功(gong)能。
其二 增加后臺(tai)開關,實現如果不需要(yao)關閉即(ji)可,前端點(dian)擊下(xia)載按(an)鈕(niu)則(ze)恢復系統直(zhi)接下(xia)載模(mo)式無需再進確認(ren)頁!
開(kai)關控(kong)制(zhi)在:功能地圖-頻道模型(xing)-下(xia)載模型(xing)-點編輯(ji)里面
效果圖:

首(shou)先打(da)開:\application\home\controller\View.php
找到488行上面這段:【 public function downfile() 函(han)數里】
if ($users['level_value'] < $file_level['level_value']) {
$msg = '文件為【' . $file_level['level_name'] . '】可(ke)下載,您(nin)當(dang)前為【' . $users['level_name'] . '】,請先升(sheng)級!';
$this->error($msg, null, ['url' => url('user/Level/level_centre')]);
exit;
}
/*--end*/
}
}
}
下面將
// 下載次(ci)數限制
!empty($result['arc_level_id']) && $this->down_num_access($result['aid']);
//判斷外部鏈接的拓(tuo)展(zhan)名是否(fou)是圖片或者txt
if (is_http_url($result['file_url'])){
$url_arr = explode('.',$result['file_url']);
$count = count($url_arr);
$ext = $url_arr[$count - 1];
$image_ext_arr = explode(',', config('global.image_ext'));
$image_ext_arr = array_merge($image_ext_arr, ['txt']);
if (in_array($ext, $image_ext_arr)){
//保存(cun)到本(ben)地
$result['file_url'] = remote_file_to_local($result['file_url']);
$result['is_remote'] = 0;
$result['remote_to_local'] = 1;
}
}
替換以下代碼::
//小秋
if (!empty($channelData['is_download_cofirm'])){
// 下載次數限制
!empty($result['arc_level_id']) && $this->down_num_access($result['aid']);
//判斷外部鏈接的拓(tuo)展名是(shi)否是(shi)圖片(pian)或者txt
if (is_http_url($result['file_url'])){
$url_arr = explode('.',$result['file_url']);
$count = count($url_arr);
$ext = $url_arr[$count - 1];
$image_ext_arr = explode(',', config('global.image_ext'));
$image_ext_arr = array_merge($image_ext_arr, ['txt']);
if (in_array($ext, $image_ext_arr)){
//保存到本(ben)地
$result['file_url'] = remote_file_to_local($result['file_url']);
$result['is_remote'] = 0;
$result['remote_to_local'] = 1;
}
}
// 記錄下(xia)載(zai)次數
$this->download_log($result['file_id'], $result['aid']);
$uhash_mch = mchStrCode($uhash);
// 跳(tiao)轉到(dao)確認(ren)頁面
$confirm_url = url('home/View/download_confirm', ['file_id' => $file_id, 'uhash' => $uhash_mch]);
if (IS_AJAX) {
$this->success('請確認下載……', $confirm_url);
} else {
$this->redirect($confirm_url);
exit;
}
}else{
// 下載(zai)次(ci)數限制
!empty($result['arc_level_id']) && $this->down_num_access($result['aid']);
//判斷外部鏈接的拓展名是(shi)否(fou)是(shi)圖片或(huo)者txt
if (is_http_url($result['file_url'])){
$url_arr = explode('.',$result['file_url']);
$count = count($url_arr);
$ext = $url_arr[$count - 1];
$image_ext_arr = explode(',', config('global.image_ext'));
$image_ext_arr = array_merge($image_ext_arr, ['txt']);
if (in_array($ext, $image_ext_arr)){
//保(bao)存到本地
$result['file_url'] = remote_file_to_local($result['file_url']);
$result['is_remote'] = 0;
$result['remote_to_local'] = 1;
}
}
繼續找到 :
/**
* 本地附件下載
*/
public function download_file()
上面添加(jia)一個(ge)
}
符號即可 【public function downfile()函(han)數的結尾】。
完整的public function downfile()代碼如下:
/**
* 下載(zai)文(wen)件
*/
public function downfile()
{
$file_id = input('param.id/d', 0);
$uhash = input('param.uhash/s', '');
if (empty($file_id) || empty($uhash)) {
$this->error('下載(zai)地址(zhi)出錯!');
exit;
}
clearstatcache();
// 查(cha)詢信息
$map = array(
'a.file_id' => $file_id,
'a.uhash' => $uhash,
);
$result = Db::name('download_file')
->alias('a')
->field('a.*,b.arc_level_id,b.restric_type,b.users_price,b.no_vip_pay')
->join('__ARCHIVES__ b', 'a.aid = b.aid', 'LEFT')
->where($map)
->find();
$file_url_gbk = iconv("utf-8", "gb2312//IGNORE", $result['file_url']);
$file_url_gbk = preg_replace('#^(/[/\w\-]+)?(/public/upload/soft/|/uploads/soft/)#i', '$2', $file_url_gbk);
if (empty($result) || (!is_http_url($result['file_url']) && !file_exists('.' . $file_url_gbk))) {
$this->error('下(xia)載文(wen)件不存(cun)在!');
exit;
}
//安裝(zhuang)下載模(mo)型付費插件 走(zou)新(xin)邏輯 大黃(huang)
$channelData = Db::name('channeltype')->where(['nid'=>'download','status'=>1])->value('data');
if (!empty($channelData)) $channelData = json_decode($channelData,true);
if (!empty($channelData['is_download_pay'])){
if ($result['restric_type'] > 0) {
$UsersData = session('users');
if (empty($UsersData['users_id'])) {
$this->error('請登錄后(hou)下載(zai)!', null, ['is_login' => 0, 'url' => url('user/Users/login')]);
exit;
}
}
if ($result['restric_type'] == 1) {// 付費
$order = Db::name('download_order')->where(['users_id' => $UsersData['users_id'], 'order_status' => 1, 'product_id' => $result['aid']])->find();
if (empty($order)) {
$msg = '文件購買后可下載,請先(xian)購買!';
$this->error($msg, null, ['url' => url('user/Download/buy'), 'need_buy' => 1, 'aid' => $result['aid']]);
exit;
}
} elseif ($result['restric_type'] == 2) {//會(hui)員專享
// 查詢會(hui)員(yuan)信息
$users = Db::name('users')
->alias('a')
->field('a.users_id,b.level_value,b.level_name')
->join('__USERS_LEVEL__ b', 'a.level = b.level_id', 'LEFT')
->where(['a.users_id' => $UsersData['users_id']])
->find();
// 查詢下載(zai)所(suo)需等級(ji)值
$file_level = Db::name('archives')
->alias('a')
->field('b.level_value,b.level_name')
->join('__USERS_LEVEL__ b', 'a.arc_level_id = b.level_id', 'LEFT')
->where(['a.aid' => $result['aid']])
->find();
if ($users['level_value'] < $file_level['level_value']) {//未達到會員級別
if ($result['no_vip_pay'] == 1){ //會員專享 開啟 非會員付費下載
$order = Db::name('download_order')->where(['users_id' => $UsersData['users_id'], 'order_status' => 1, 'product_id' => $result['aid']])->find();
if (empty($order)) {
$msg = '文件為(wei)【' . $file_level['level_name'] . '】免費下載,您當前為(wei)【' . $users['level_name'] . '】,可付(fu)費購買!';
$this->error($msg, null, ['url' => url('user/Download/buy'), 'need_buy' => 1, 'aid' => $result['aid']]);
exit;
}
}else{
$msg = '文(wen)件為(wei)【' . $file_level['level_name'] . '】可下載,您當前為(wei)【' . $users['level_name'] . '】,請(qing)先(xian)升級(ji)!';
$this->error($msg, null, ['url' => url('user/Level/level_centre')]);
exit;
}
}
} elseif ($result['restric_type'] == 3) {//會員付費
// 查(cha)詢會員信息(xi)
$users = Db::name('users')
->alias('a')
->field('a.users_id,b.level_value,b.level_name')
->join('__USERS_LEVEL__ b', 'a.level = b.level_id', 'LEFT')
->where(['a.users_id' => $UsersData['users_id']])
->find();
// 查詢(xun)下載所(suo)需等級值
$file_level = Db::name('archives')
->alias('a')
->field('b.level_value,b.level_name')
->join('__USERS_LEVEL__ b', 'a.arc_level_id = b.level_id', 'LEFT')
->where(['a.aid' => $result['aid']])
->find();
if ($users['level_value'] < $file_level['level_value']) {
$msg = '文件為【' . $file_level['level_name'] . '】購買(mai)可下載,您當前為【' . $users['level_name'] . '】,請(qing)先升(sheng)級后購買(mai)!';
$this->error($msg, null, ['url' => url('user/Level/level_centre')]);
exit;
}
$order = Db::name('download_order')->where(['users_id' => $UsersData['users_id'], 'order_status' => 1, 'product_id' => $result['aid']])->find();
if (empty($order)) {
$msg = '文件為【' . $file_level['level_name'] . '】購買(mai)(mai)可(ke)下載(zai),您當前為【' . $users['level_name'] . '】,請先購買(mai)(mai)!';
$this->error($msg, null, ['url' => url('user/Level/level_centre'), 'need_buy' => 1, 'aid' => $result['aid']]);
exit;
}
}
}else{
// 判斷會員信息
if (0 < intval($result['arc_level_id'])) {
//走下(xia)載模型會員限制下(xia)載舊版邏輯(ji)
$UsersData = session('users');
if (empty($UsersData['users_id'])) {
$this->error('請登錄后(hou)下(xia)載!', null, ['is_login' => 0, 'url' => url('user/Users/login')]);
exit;
} else {
/*判(pan)斷會(hui)員是否可下(xia)載該文件--2019-06-21 陳(chen)風任添加*/
// 查詢(xun)會員信息(xi)
$users = Db::name('users')
->alias('a')
->field('a.users_id,b.level_value,b.level_name')
->join('__USERS_LEVEL__ b', 'a.level = b.level_id', 'LEFT')
->where(['a.users_id' => $UsersData['users_id']])
->find();
// 查詢(xun)下載所(suo)需(xu)等(deng)級值
$file_level = Db::name('archives')
->alias('a')
->field('b.level_value,b.level_name')
->join('__USERS_LEVEL__ b', 'a.arc_level_id = b.level_id', 'LEFT')
->where(['a.aid' => $result['aid']])
->find();
if ($users['level_value'] < $file_level['level_value']) {
$msg = '文件為【' . $file_level['level_name'] . '】可下載,您當前為【' . $users['level_name'] . '】,請先升級!';
$this->error($msg, null, ['url' => url('user/Level/level_centre')]);
exit;
}
/*--end*/
}
}
}
//小秋
if (!empty($channelData['is_download_cofirm'])){
// 下載次數限制(zhi)
!empty($result['arc_level_id']) && $this->down_num_access($result['aid']);
//判(pan)斷外(wai)部(bu)鏈接的拓(tuo)展名(ming)是否是圖片或者txt
if (is_http_url($result['file_url'])){
$url_arr = explode('.',$result['file_url']);
$count = count($url_arr);
$ext = $url_arr[$count - 1];
$image_ext_arr = explode(',', config('global.image_ext'));
$image_ext_arr = array_merge($image_ext_arr, ['txt']);
if (in_array($ext, $image_ext_arr)){
//保存(cun)到(dao)本地(di)
$result['file_url'] = remote_file_to_local($result['file_url']);
$result['is_remote'] = 0;
$result['remote_to_local'] = 1;
}
}
// 記錄下載次數
$this->download_log($result['file_id'], $result['aid']);
$uhash_mch = mchStrCode($uhash);
// 跳轉到確(que)認頁面
$confirm_url = url('home/View/download_confirm', ['file_id' => $file_id, 'uhash' => $uhash_mch]);
if (IS_AJAX) {
$this->success('請確認下載(zai)……', $confirm_url);
} else {
$this->redirect($confirm_url);
exit;
}
}else{
// 下載次數限制
!empty($result['arc_level_id']) && $this->down_num_access($result['aid']);
//判斷外(wai)部(bu)鏈(lian)接(jie)的(de)拓展名(ming)是否(fou)是圖片或者txt
if (is_http_url($result['file_url'])){
$url_arr = explode('.',$result['file_url']);
$count = count($url_arr);
$ext = $url_arr[$count - 1];
$image_ext_arr = explode(',', config('global.image_ext'));
$image_ext_arr = array_merge($image_ext_arr, ['txt']);
if (in_array($ext, $image_ext_arr)){
//保存到本地
$result['file_url'] = remote_file_to_local($result['file_url']);
$result['is_remote'] = 0;
$result['remote_to_local'] = 1;
}
}
// 外部下載鏈(lian)接
if (is_http_url($result['file_url']) || !empty($result['is_remote'])) {
if ($result['uhash'] != md5($result['file_url'])) {
$this->error('下載地(di)址出錯!');
}
// 記錄下載(zai)次數(限制會員級別(bie)下載(zai)的文件才記錄下載(zai)次數)
// if (0 < intval($result['arc_level_id'])) {
// $this->download_log($result['file_id'], $result['aid']);
// }
//20220816修改為不限級別都更新(xin)次數
$this->download_log($result['file_id'], $result['aid']);
$result['file_url'] = htmlspecialchars_decode($result['file_url']);
$result['file_url'] = handle_subdir_pic($result['file_url'], 'soft');
if (IS_AJAX) {
$this->success('正(zheng)在跳轉中……', $result['file_url'], $result);
} else {
$this->redirect($result['file_url']);
exit;
}
}
// 本(ben)站(zhan)鏈接
else
{
//如(ru)果是遠(yuan)程轉換(huan)到本地的(de)不做(zuo)這個判斷
if (md5_file('.' . $file_url_gbk) != $result['md5file'] && empty($result['remote_to_local'])) {
$this->error('下(xia)載文件包已(yi)損壞!');
}
// 記錄(lu)下(xia)載(zai)次數(shu)(shu)(限制會員(yuan)級別下(xia)載(zai)的文件(jian)才記錄(lu)下(xia)載(zai)次數(shu)(shu))
// if (0 < intval($result['arc_level_id'])) {
// $this->download_log($result['file_id'], $result['aid']);
// }
// 記錄下載次數(shu)
$this->download_log($result['file_id'], $result['aid']);
$uhash_mch = mchStrCode($uhash);
$url = $this->root_dir . "/index.php?m=home&c=View&a=download_file&file_id={$file_id}&uhash={$uhash_mch}";
cookie($file_id.$uhash_mch, 1);
if (IS_AJAX) {
$this->success('開始下載中(zhong)……', $url);
} else {
$url = $this->request->domain() . $url;
$this->redirect($url);
exit;
}
}
}
}
第二步:
繼續找到:
/**
* 本地附件下載(zai)
*/
public function download_file()
這(zhe)代碼上面添加以(yi)下代碼:
/**
* 確認下(xia)載頁面
*/
public function download_confirm()
{
$file_id = input('param.file_id/d', 0);
$uhash_mch = input('param.uhash/s', '');
if (empty($file_id) || empty($uhash_mch)) {
$this->error('下載地址出錯!');
exit;
}
// 查詢文(wen)件信息
$result = Db::name('download_file')
->alias('a')
->field('a.*,b.arc_level_id,b.restric_type,b.users_price,b.no_vip_pay')
->join('__ARCHIVES__ b', 'a.aid = b.aid', 'LEFT')
->where(['a.file_id' => $file_id, 'a.uhash' => mchStrCode($uhash_mch, 'DECODE')])
->find();
if (empty($result)) {
$this->error('下載文件不存在(zai)!');
exit;
}
// 顯示確認頁面(mian)
$this->assign('file_info', $result);
return $this->fetch('system/download_confirm');
}
/**
* 執(zhi)行(xing)下載(zai)
*/
public function do_download()
{
// 獲取(qu)文件 ID 和哈希值
$file_id = input('param.file_id/d', 0);
$uhash_mch = input('param.uhash/s', '');
// 檢查文件 ID 和哈希值(zhi)是否為空
if (empty($file_id) || empty($uhash_mch)) {
$this->error('下載(zai)地址出錯!');
exit;
}
// 查詢文件信息(xi)
$result = Db::name('download_file')
->alias('a')
->field('a.*,b.arc_level_id,b.restric_type,b.users_price,b.no_vip_pay')
->join('__ARCHIVES__ b', 'a.aid = b.aid', 'LEFT')
->where(['a.file_id' => $file_id, 'a.uhash' => mchStrCode($uhash_mch, 'DECODE')])
->find();
// 檢查查詢結(jie)果是否為空
if (empty($result)) {
$this->error('下載文件不存在!');
exit;
}
// 將文(wen)件 URL 轉換為 GB2312 編碼(ma)并處理(li)路徑(jing)
$file_url_gbk = iconv("utf-8", "gb2312//IGNORE", $result['file_url']);
$file_url_gbk = preg_replace('#^(/[/\w\-]+)?(/public/upload/soft/|/uploads/soft/)#i', '$2', $file_url_gbk);
// 處理外部下載鏈接
if (is_http_url($result['file_url']) || !empty($result['is_remote'])) {
// 檢(jian)查哈希值是(shi)否(fou)匹配
if ($result['uhash'] != md5($result['file_url'])) {
$this->error('下(xia)載(zai)地址出錯(cuo)!');
exit;
}
// 記錄下(xia)載次數(shu)
$this->download_log($result['file_id'], $result['aid']);
// 解(jie)碼并處理(li)文件(jian) URL
$result['file_url'] = htmlspecialchars_decode($result['file_url']);
$result['file_url'] = handle_subdir_pic($result['file_url'], 'soft');
// 根(gen)據請求類型(xing)進行處理
if (IS_AJAX) {
$this->success('正(zheng)在跳轉中(zhong)……', $result['file_url'], $result);
} else {
$this->redirect($result['file_url']);
exit;
}
} else {
// 檢查文件是否損壞(非遠程轉(zhuan)換(huan)到本(ben)地的情況)
if (md5_file('.' . $file_url_gbk) != $result['md5file'] && empty($result['remote_to_local'])) {
$this->error('下載文件(jian)包已損壞!');
exit;
}
// 記錄(lu)下載次(ci)數(shu)
$this->download_log($result['file_id'], $result['aid']);
// 生(sheng)成下載鏈接(jie)
$url = $this->root_dir . "/index.php?m=home&c=View&a=download_file&file_id={$file_id}&uhash={$uhash_mch}";
// 設置 cookie
cookie($file_id.$uhash_mch, 1);
// 根據請求類型進行(xing)處理
if (IS_AJAX) {
$this->success('開始下載中……', $url);
} else {
$url = $this->request->domain() . $url;
$this->redirect($url);
exit;
}
}
}
本頁PHP完成
第三步:
打開\application\admin\controller
Channeltype.php文件;
找到以下代碼:
if ($post['nid'] == 'download'){
Db::name('arctype')->where([
'channeltype' => $post['id'],
])->update([
'is_release' => !empty($post['is_release']) ? $post['is_release'] : 0,
'update_time' => getTime(),
]);
if (!empty($post['data']['is_download_pay'])){
//開啟下載付費兼容舊(jiu)數據 舊(jiu)數據開始了(le)會員限制的restric_type改為(wei)2
Db::name('archives')->where(['channel'=>$post['id'],'restric_type'=>0])->where('arc_level_id','>',0)->update(['restric_type'=>2,'update_time'=>getTime()]);
}
大概在284行左右。
在下面添加以(yi)下代碼:
// 設置下載確認相關的配置參(can)數
if (isset($post['is_download_cofirm'])) {
$paramData = [
'is_download_cofirm' => intval($post['is_download_cofirm'])
];
tpSetting('download_cofirm', $paramData);
}
再次打(da)開:\application\admin\template\channeltype
edit.htm文(wen)件(jian):
找到:
{eq name="$field.nid" value="download"}
<dl class="row">
<dt class="tit">
<label>開啟下載(zai)付費(fei)</label>
</dt>
<dd class="opt">
<label class="curpoin"><input id="is_download_pay1" name="data[is_download_pay]" value="1" type="radio" on-click="article_pay(this,'download');" {if condition="!empty($field.data.is_download_pay)"} checked="checked"{/if}>是</label>
<label class="curpoin"><input id="is_download_pay0" name="data[is_download_pay]" value="0" type="radio" on-click="article_pay(this,'download');" {if condition="empty($field.data.is_download_pay)"} checked="checked"{/if}>否</label>
<a href="javascript:void(0);" class="{if condition='empty($field.data.is_download_pay)'}none{/if}" id="a_downloadpay" on-click="click_to_eyou_1575506523('//www.thetomatinaafterparty.com/plus/view.php?aid=28561&origin_eycms=1','downloadpay 下載模型(xing)付費標(biao)(biao)簽')" style="font-size: 12px;padding-top: 3px;position: absolute;margin-left: 10px;">標(biao)(biao)簽教程</a>
<p class="notic"></p>
</dd>
</dl>
{/eq}
大概186行:
添加以下代碼:
{eq name="$field.nid" value="download"}
<dl class="row">
<dt class="tit">
<label>開啟下(xia)載確認(ren)頁(ye)</label>
</dt>
<dd class="opt">
<label class="curpoin"><input id="is_download_cofirm1" name="data[is_download_cofirm]" value="1" type="radio" on-click="download_cofirm(this,'download');" {if condition="!empty($field.data.is_download_cofirm)"} checked="checked"{/if}>是</label>
<label class="curpoin"><input id="is_download_cofirm0" name="data[is_download_cofirm]" value="0" type="radio" on-click="download_cofirm(this,'download');" {if condition="empty($field.data.is_download_cofirm)"} checked="checked"{/if}>否</label>
<p class="notic"></p>
</dd>
</dl>
{/eq}
繼續查找 JS部分
找到下面代碼
<script type="text/javascript">
function article_pay(obj,nid)
{
var value = $(obj).val();
if (1 == value) {
$('#a_'+nid+'pay').removeClass('none');
if ('article' == nid) {
var php_servicemeal = {$php_servicemeal|default=0};
var system_is_article_pay = {$system_is_article_pay|default=0};
if (php_servicemeal < 2 && system_is_article_pay == 0) {
$('input[name="data[is_article_pay]"]').eq(1).prop('checked', true);
var alert1 = layer.alert('付(fu)'+'費'+'功'+'能'+'只(zhi)'+'限'+'于'+'專'+'業'+'授'+'權'+'域'+'名'+'!', {
icon: 4,
shade: layer_shade,
title:false,
btn: ['購買授權(quan)']
}, function(){
window.open('//www.thetomatinaafterparty.com/buy');
layer.close(alert1);
});
return false;
}
var a = '<a href="javascript:void(0);" on-click="openPage(this);" data-url="//www.thetomatinaafterparty.com/index.php?m=home&c=View&a=index&aid=11810&origin_eycms=1" data-title="articlepay 文章模(mo)型付費閱讀標(biao)簽(qian)">標(biao)簽(qian)教程</a>';
layer.alert('開啟文章付費需添加相關標簽,請(qing)查看'+ a +'修改(gai)', {
shade: layer_shade,
move: false,
title: '提示(shi)',
btnAlign:'r',
closeBtn: 3,
success: function () {
$(".layui-layer-content").css('text-align', 'left');
}
});
} else if ('download' == nid) {
var a = '<a href="javascript:void(0);" on-click="openPage(this);" data-url="//www.thetomatinaafterparty.com/index.php?m=home&c=View&a=index&aid=28561&origin_eycms=1" data-title="downloadpay 下(xia)載(zai)模型付費標(biao)簽">標(biao)簽教程</a>';
layer.alert('開啟下載付費需添(tian)加相關標簽,請(qing)查看'+ a +'修改', {
shade: layer_shade,
move: false,
title: '提示',
btnAlign:'r',
closeBtn: 3,
success: function () {
$(".layui-layer-content").css('text-align', 'left');
}
});
}
} else {
$('#a_'+nid+'pay').addClass('none');
}
}
下面添加以下代碼:
function download_cofirm(obj, nid) {
var value = $(obj).val();
if (1 == value) {
$('#a_' + nid + 'cofirm').removeClass('none');
if ('download' == nid) {
}
} else {
$('#a_' + nid + 'cofirm').addClass('none');
}
}
做(zuo)到(dao)這里核心部分(fen)就已(yi)經完成。
剩(sheng)下的(de)是(shi)模板文(wen)件和代(dai)碼添加:
新(xin)建download_confirm.htm模板文件(jian) 放在(zai):\template\pc\system目錄里面
代碼如下:
<style>
.downlf {
width: 400px; /* 假設寬度為 400px,你可以根據實際情況調整 */
margin: 0 auto; /* 上(shang)下 margin 為 0,左右 margin 為 auto 實現水平居中 */
}
</style>
<div class="downlf">
<h1>確認下(xia)載</h1>
<p>文件名(ming)稱:{$file_info.file_name}</p>
<p>文件大小(xiao):{$file_info.file_size}</p>
<p>文(wen)件描述:{$file_info.file_des}</p>
<form action="{:url('home/View/do_download')}" method="post">
<input type="hidden" name="file_id" value="{$file_info.file_id}">
<input type="hidden" name="uhash" value="{:input('param.uhash/s')}">
<button type="submit">確認下(xia)載</button>
</form>
樣式這里將不在介紹 自(zi)己套用自(zi)己現有的模(mo)板即可!
舉例:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>確認下載 - {$fife_infoarc_title}</title>
<link rel="stylesheet" href="/static/css/common.css">
<style>
.confirm-box {max-width: 800px; margin: 50px auto; padding: 20px; border: 1px solid #eee; border-radius: 8px;}
.file-info {margin: 20px 0; padding: 15px; background: #f9f9f9; border-radius: 4px;}
.info-item {margin: 10px 0;}
.btn-group {margin-top: 30px;}
.btn {display: inline-block; padding: 10px 20px; text-decoration: none; border-radius: 4px;}
.btn-confirm {background: #007bff; color: #fff; margin-right: 15px;}
.btn-cancel {background: #6c757d; color: #fff;}
.notice {margin-top: 20px; padding: 10px; background: #fff3cd; border-left: 4px solid #ffc107;}
</style>
</head>
<body>
<div>
<h2>確認下載(zai)文(wen)件</h2>
<div>
<div class="info-item"><strong>文件名(ming)稱:</strong>{$file_info.title}</div>
<div class="info-item"><strong>附件(jian)名稱(cheng):</strong>{$file_info.file_name}</div>
<div class="info-item"><strong>文(wen)件大(da)小(xiao):</strong>{$file_info.file_size}kb</div>
<div class="info-item"><strong>文(wen)件(jian)格式:</strong>{$file_info.file_ext|strtoupper}</div>
<div class="info-item"><strong>發布(bu)時間(jian):</strong>{$file_info.add_time|MyDate='Y-m-d H:i:s',###}</div>
<div class="info-item"><strong>文(wen)件描述:</strong>{$file_info.description|default='無描述'}</div>
</div>
<div>
<p>?? 下載須(xu)知(zhi):</p>
<p>1. 請確認該文件符合您的需求,下載后將計(ji)入下載次數</p>
<p>2. 若文件(jian)格式(shi)為壓縮包,建議下載(zai)后驗證文件(jian)完整性</p>
<p>3. 如需幫助(zhu),請聯系客服熱線:400-xxx-xxxx</p>
</div>
<div>
下載第一種
<a href="{$file_info.file_url}" class="btn btn-confirm">確認下載</a>
<a href="javascript:history.back()" class="btn btn-cancel">返回上一頁</a>
</div>
</div>
下載第二種
<form action="{:url('home/View/do_download')}" method="post">
<input type="hidden" name="file_id" value="{$file_info.file_id}">
<input type="hidden" name="uhash" value="{:input('param.uhash/s')}">
<button type="submit">確認下載(zai)</button>
</form>
</body>
</html>
標簽說明:
與下載標簽字典一樣,只不過標簽ID頭要以:file_info 為準【ID="file_info】"。
例子:文件名稱:{$file_info.file_name} 【非(fei)field】
