足迹插件 调用当前会员浏览记录 / 清除当前会员浏览记录

审核中 讯睿功能 未结 已结 置顶 精帖
删除 置顶 取消置顶 加精 取消加精
66 0
yswl
yswl VIP3 2021-09-04 11:37:43
悬赏:60金币 编辑此贴

html

{if $member} <!--是否登录-->
<div class="pdr2 mt_25 bgwhite bdrls">
 <h3 class="pdr1tit flex_center disflex flex_lmr footprint_id">浏览历史<a href="javascript:;" onclick="footprint_remove()">清除</a></h3>
 <div class="pdr2w" id="pdr2w">
 <!--查询当前会员足迹-->
 {php $query=urlencode('SELECT a.*,b.cid,b.uid FROM @#1_store as a left JOIN @#1_store_footprint as b on a.id = b.cid WHERE a.id=b.cid and b.uid='.$member.id);}
  {sql sql='$query' page=1 pagesize=3}
  {php $thumb = dr_get_files($t.thumb);}
   <a href="{$t.url}" class="pdr2a disblock">
    <div class="pdr2aimg"><img class="disblock w100" src="{dr_get_file($thumb[0][file])}"/></div>
    <p>{$t.title}</p>
    <span>¥ {number_format($t.price, 2)}</span>
   </a>     
  {/sql}
 </div>
</div>
<!--获取当前会员id-->
<input type="hidden" id="footprint_id" value="{$member.id}" >
{/if}


ajax

<!--清除浏览-->
<script type="text/javascript">
 function footprint_remove(){
  var footprint_id = $('#footprint_id').val();
  $.post("/index.php?s=footprint&app=store&c=home&m=footprintdel",{footprintid:footprint_id},function(msg){
   layer.msg("清除成功!");
   $('#pdr2w').html('');
  });
 }
</script>


php 控制器路径

\dayrui\App\Footprint\Controllers\Home.php

php

//删除足迹记录

public function footprintdel(){
    //获取前端传入的会员id
    $fpid = \Phpcmf\Service::L('input')->post('footprintid');
    //执行删除
    \Phpcmf\Service::M()->db->table($this->tablename.'_footprint')->where('uid='.$fpid)->delete();
}