<?php

/* ========================================================================
 * $Id: view.php 3850 2020-07-09 00:10:11Z onez $
 * 
 * Email: www@onez.cn
 * QQ: 6200103
 * HomePage: http://www.onez.cn
 * ========================================================================
 * Copyright 2016-2017 佳蓝科技.
 * 
 * ======================================================================== */

!defined('IN_ONEZ') && exit('Access Denied');
# 查看详情
# view
#请求数据
if($MODE=='$post'){
  $action=onez()->gp('action');
  if($action=='data'){
    $id=(int)onez()->gp('id');
    $T=$G['this']->data()->open('products')->one("id='$id'");
    $ac=onez()->gp('ac');
    if($ac=='read'){
      $code=onez()->gp('code');
      if($T['readcode'] && strpos($code,$T['readcode'])===0){
        onez('cache')->cookie('readId',$id,'0');
      }
      return $this->ok('操作成功','reload');
    }
    $C=$G['this']->data()->open('categorys')->one("id='$T[upid]'");
    $A['pagedata']['ready']=true;
    $A['pagedata']['id']=$T['id'];
    $A['pagedata']['token']=$T['key2'];
    $A['pagedata']['thumb']=$T['thumb'];
    $A['pagedata']['name']=$T['name'];
    $A['pagedata']['time']=date('Y-m-d H:i:s',$T['addtime']);
    $A['pagedata']['nickname']=$G['this']->user($T['userid'],'nickname');
    $A['pagedata']['hit']=$T['index1'];
    $item=array();
    $item['index1']=$T['index1']+1;
    $G['this']->data()->open('products')->update($item,"id='$id'");
    $A['pagedata']['price']=$T['money1'];
    if($G['userid']){
      $A['pagedata']['myname']=$G['this']->user($G['userid'],'nickname');
    }else{
      $A['pagedata']['myname']=$this->guest();
    }
    #上一篇
    $T2=$G['this']->data()->open('products')->one("upid='$T[upid]' and id<$id order by id desc");
    if($T2){
      $A['pagedata']['left']=array(
        'name'=>$T2['name'],
        'id'=>$T2['id'],
      );
    }else{
      $A['pagedata']['left']=false;
    }
    #下一篇
    $T2=$G['this']->data()->open('products')->one("upid='$T[upid]' and id>$id order by id");
    if($T2){
      $A['pagedata']['right']=array(
        'name'=>$T2['name'],
        'id'=>$T2['id'],
      );
    }else{
      $A['pagedata']['right']=false;
    }
    
    $A['pagedata']['content']=onez('bs.app.shipments')->content($A,$T);
    onez('bs.app.shipments')->slot('/www/detail',$A);
  }
  return;
}
?>
<template v-if="$pagedata && $pagedata.ready">
<div :class="'page-type-'+pagedata.token">
<div class="box">
  <div class="thumbs">
    <img :src="pagedata.thumb" />
  </div>
  <div class="infos" v-if="pagedata.token=='card'||pagedata.token=='message'">
    <van-cell class="title" :value="pagedata.name" />
    <van-cell class="priceTd">
      <template #default>
        ￥<span class="price">{{pagedata.price}}</span> 元
      </template>
    </van-cell>
    <van-cell>
      <template #default>
        <van-button type="info" @click="buy">购买</van-button>
      </template>
    </van-cell>
  </div>
</div>
<dl class="products">
  <dd class="content">
<div class="shownews" v-if="pagedata.token=='article'">
  <div class="shownews-header" v-if="pagedata.token=='article'">
    <h1>{{pagedata.name}}</h1>
    <div></div>

    <div class="info">
      <span>{{pagedata.time}}</span>
      <span>{{pagedata.nickname}}</span>
      <span><i class="icon wb-eye margin-right-5" aria-hidden="true"></i>{{pagedata.hit}}</span> 
    </div>

  </div>
</div>
<?php 
onez('bs.app.shipments')->slot('/www/detail/content/header');
?>
<template v-for="item in pagedata.content">
  <div v-if="item.type=='html'" v-html="item.html"></div>
  <onez-paybox v-else-if="item.type=='paybox'" :data="pagedata" />
</template>
<?php 
onez('bs.app.shipments')->slot('/www/detail/content/footer');
?>
    <div class="links">
      <div class="left">
        <a :href="'/index/view.php?id='+pagedata.left.id" v-if="pagedata.left">上一篇: {{pagedata.left.name}}</a>
        <a href="javascript:;" v-else>上一篇: 没有了</a>
      </div>
      <div class="right">
        <a :href="'/index/view.php?id='+pagedata.right.id" v-if="pagedata.right">下一篇: {{pagedata.right.name}}</a>
        <a href="javascript:;" v-else>下一篇: 没有了</a>
      </div>
    </div>
  </dd>
</dl>
</div>
</template>