<?php

/* ========================================================================
 * $Id: edit.php 2547 2020-05-13 17:03:01Z onez $
 * 
 * Email: www@onez.cn
 * QQ: 6200103
 * HomePage: http://www.onez.cn
 * ========================================================================
 * Copyright 2016-2017 佳蓝科技.
 * 
 * ======================================================================== */

!defined('IN_ONEZ') && exit('Access Denied');
# edit
#请求数据
if($MODE=='$post'){
  $id=onez()->gp('id');
  $action=onez()->gp('action');
  if($action=='data'){
    $form=$this->load('form');
    if($id){
      $T=$G['this']->data()->open('weixins')->one("userid='$G[userid]' and id='$id'");
      $form->init($T);
    }
    $form->add(array('label'=>'类型','type'=>'select','key'=>'type','hint'=>'','options'=>$G['this']->weixinTypes(),'default'=>'','group'=>''));
    $form->add(array('label'=>'名称','type'=>'text','key'=>'name','hint'=>'','notempty'=>'名称不能为空','default'=>'','group'=>''));
    $form->add(array('label'=>'AppID','type'=>'text','key'=>'weixin_appid','hint'=>'AppID(应用ID)','notempty'=>'AppID(应用ID)不能为空','tip'=>'应用ID'));
    $form->add(array('label'=>'AppSecret','type'=>'text','key'=>'weixin_appsecret','hint'=>'AppSecret(应用密钥)','notempty'=>'AppSecret(应用密钥)不能为空','tip'=>'应用密钥'));
    $form->add(array('label'=>'EncodingAESKey','type'=>'text','key'=>'weixin_aeskey','hint'=>'EncodingAESKey(消息加解密密钥)','notempty'=>'EncodingAESKey(消息加解密密钥)不能为空','tip'=>'消息加解密密钥'));
    $form->add(array('label'=>'MCHID','type'=>'text','key'=>'weixin_mch_id','hint'=>'','notempty'=>''));
    $form->add(array('label'=>'支付密钥','type'=>'text','key'=>'weixin_appkey','hint'=>'','notempty'=>''));
    $form->add(array('label'=>'apiclient_cert','type'=>'form.file','local'=>'1','filetype'=>'file','key'=>'weixin_apiclient_cert','hint'=>'apiclient_cert','notempty'=>''));
    $form->add(array('label'=>'apiclient_key','type'=>'form.file','local'=>'1','filetype'=>'file','key'=>'weixin_apiclient_key','hint'=>'apiclient_key','notempty'=>''));
    
    $form->add(array('label'=>'授权域名','type'=>'text','key'=>'domain','hint'=>'','notempty'=>'','default'=>'','group'=>'','tip'=>'您在微信后台设置的授权域名'));
    $form->add(array('label'=>'备注','type'=>'text','key'=>'summary','hint'=>'','notempty'=>'','default'=>'','group'=>''));
    if($onez=$form->submit()){
      if($id){
        $G['this']->data()->open('weixins')->update($onez,"userid='$G[userid]' and id='$id'");
      }else{
        $onez['userid']=$G['userid'];
        $G['this']->data()->open('weixins')->insert($onez);
      }
      $G['this']->siteUpdate();
      return $this->ok('提交成功','reload2');
    }
    $form->output($A);
  }
  return;
}
$this->add(array(
  'type'=>'pageform',
  'name'=>'表单',
  'data'=>'form',
));
