<?php

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

!defined('IN_ONEZ') && exit('Access Denied');
#请求数据
if($MODE=='$post'){
  $action=onez()->gp('action');
  if($action=='data'){
    $ac=onez()->gp('ac');
    if($ac=='logout'){
      onez('cache')->cookie($G['this']->cname,'del',0);
      return $this->ok('操作成功','reload');
    }
    
    $A['appData']=array();
    
    $menus=array();
    $menus[]=array(
      'name'=>'商品',
      'href'=>'/index.php',
      'path'=>'/index',
    );
    $menus[]=array(
      'name'=>'订单查询',
      'href'=>'/orders/search.php',
    );
    $menus[]=array(
      'name'=>'帮助中心',
      'href'=>'/helps.php',
    );
    $menus[]=array(
      'name'=>'友情链接',
      'href'=>'/links.php',
    );
    $A['appData']['menus']=$menus;
    $A['appData']['userid']=(int)$G['userid'];
    $A['appData']['user']=$G['user'];
    $A['appData']['sitename']=$G['this']->setting('sitename');
    $A['appData']['footer']=$G['this']->setting('copyright');
    !$A['appData']['sitename'] && $A['appData']['sitename']=$G['title'];
  }
  return;
}
?>
<template v-if="$appData && $appData.menus">
<header>
  <div class="page-box">
    <a href="#/index.php" class="sitename">{{appData.sitename}}</a>
    <ul class="menus">
      <li v-for="item in $appData.menus" :class="onez.curPage(item)?'active':''">
        <a :href="item.href">{{item.name}}</a>
      </li>
<?php 
onez('bs.app.shipments')->slot('/www/menus');
?>
    </ul>
    <div class="rightBox">
      <template v-if="$appData.userid==0">
        <van-button type="info" @click="toLogin">登录</van-button>
      </template>
      <template v-else>
        <span class="userinfo">
          <img :src="appData.user.avatar" class="avatar">
          <span class="nickname">{{appData.user.nickname}}</span>
          ,你好！
        </span>
        <van-button type="info" @click="toAdmin">管理中心</van-button>
        <van-button plain type="info" @click="logout">退出</van-button>
      </template>
    </div>
  </div>
</header>
<div class="page-box">
  <component :is="tpl" :data="$appData"></component>
</div>
<footer>
  <div class="page-box" v-html="appData.footer">
    
  </div>
</footer>
<van-action-sheet v-model="showAction" :round="false" cancel-text="取消" :actions="actions" @select="onSelect" />
<van-number-keyboard safe-area-inset-bottom />
</template>