{template 'common/header'}
<div class="account-list-add-step" id="js-miniapp-create" ng-controller="CreateMiniappCtrl" ng-cloak>
	<ol class="breadcrumb we7-breadcrumb">
		<a href="{php echo url('account/manage', array('account_type' => $type))}"><i class="wi wi-back-circle"></i></a>
		<li><a href="{php echo url('account/manage')}">平台列表</a></li>
		<li>新建{{presetTypeInfo.title}}</li>
	</ol>
	<ul class="we7-step">
		<li ng-class="createStep == 1 ? 'active': ''"><span class="content">1 设置{{presetTypeInfo.title}}信息</span></li>
		<li ng-class="createStep == 2 ? 'active': ''"><span class="content">2 生成版本</span></li>
	</ul>
	<form method="post" ng-submit="package()">
		<input name="token" type="hidden" value="{$_W['token']}">
		<div class="panel panel-app">
			<div class="panel-body">
				<div class="wxapp-content tab-content" style="width: 100%;">
					<div id="select" ng-show="createStep == 1">
						<div class="form-defalut we7-form">
							{if empty($uniacid)}
							<div class="form-group">
								<label for="" class="control-label col-sm-2">{{presetTypeInfo.title}}名称</label>
								<div class="form-controls col-sm-10">
									<input type="text" name="name" ng-model="miniapp.name" class="form-control wxapp-name" placeholder="{$account_all_type[$type]['title']}名称">
								</div>
							</div>
							<div class="form-group">
								<label for="" class="control-label col-sm-2">{{presetTypeInfo.title}}描述</label>
								<div class="form-controls col-sm-10">
									<input type="text" name="description" ng-model="miniapp.description" class="form-control wxapp-name" placeholder="版本描述">
								</div>
							</div>
							<div class="form-group">
								<label for="" class="control-label col-sm-2">AppId</label>
								<div class="form-controls col-sm-10">
									<input type="text" name="key" value="" ng-model="miniapp.appid" class="form-control wxapp-name" placeholder="AppId">
								</div>
							</div>
							<div class="form-group" ng-if="presetTypeInfo.type_sign == 'baiduapp' || presetTypeInfo.type_sign == 'toutiaoapp'">
								<label for="" class="control-label col-sm-2">AppKey</label>
								<div class="form-controls col-sm-10">
									<input type="text" name="key" value="" ng-model="miniapp.key" class="form-control wxapp-name" placeholder="AppKey">
								</div>
							</div>
							<div class="form-group" ng-if="presetTypeInfo.type_sign == 'baiduapp' || presetTypeInfo.type_sign == 'toutiaoapp'">
								<label for="" class="control-label col-sm-2">AppSecret</label>
								<div class="form-controls col-sm-10">
									<input type="text" name="key" value="" ng-model="miniapp.secret" class="form-control wxapp-name" placeholder="AppSecret">
								</div>
							</div>
							{else}
							<div class="form-group">
								<label for="" class="control-label col-sm-2">版本描述</label>
								<div class="form-controls col-sm-10">
									<input type="text" name="description" ng-model="miniapp.description" class="form-control wxapp-name" placeholder="版本描述">
								</div>
							</div>
							{/if}
							<div class="form-group">
								<label for="" class="control-label col-sm-2">版本号</label>
								<div class="form-controls col-sm-10">
									<input type="text" name="version" ng-model="miniapp.version" class="form-control wxapp-name" placeholder="版本号，只能是数字、点，数字最多两位，例如 1.01 / 1.0.1">
								</div>
							</div>
							<div class="form-group" ng-hide="newversion">
								<label for="" class="control-label col-sm-2">头像</label>
								<div class="form-controls col-sm-8">
									<div class="input-more we7-input-img" ng-class="{'active': miniapp.headimg}">
										<img ng-src="{{miniapp.headimg}}" width="150px" ng-if="miniapp.headimg" ng-style="{'height': 'auto'}">
										<a href="javascript:;" class="input-addon" ng-click="uploadMultiImage('headimg')" ng-hide="miniapp.headimg"><span>+</span></a>
										<input type="text" name="headimg" ng-model="miniapp.headimg" ng-style="{'display' : 'none'}">
										<div class="cover-dark">
											<a href="javascript:;" class="cut" ng-click="uploadMultiImage('headimg')">更换</a>
											<a href="javascript:;" class="del" ng-click="delMultiImage('headimg')"><i class="fa fa-times text-danger"></i></a>
										</div>
									</div>
									<span class="help-block"></span>
								</div>
							</div>
							<div class="form-group" ng-hide="newversion">
								<label for="" class="control-label col-sm-2">二维码</label>
								<div class="form-controls col-sm-8">
									<div class="input-more we7-input-img" ng-class="{'active': miniapp.qrcode}">
										<img ng-src="{{miniapp.qrcode}}" width="150px" ng-if="miniapp.qrcode" ng-style="{'height': 'auto'}">
										<a href="javascript:;" class="input-addon" ng-click="uploadMultiImage('qrcode')" ng-hide="miniapp.qrcode"><span>+</span></a>
										<input type="text" name="qrcode" ng-model="miniapp.qrcode" ng-style="{'display' : 'none'}">
										<div class="cover-dark">
											<a href="javascript:;" class="cut" ng-click="uploadMultiImage('qrcode')">更换</a>
											<a href="javascript:;" class="del" ng-click="delMultiImage('qrcode')"><i class="fa fa-times text-danger"></i></a>
										</div>
									</div>
									<span class="help-block"></span>
								</div>
							</div>
							<div class="form-group">
								<input type="hidden" name="modules" value="">
								<label class="control-label col-sm-2">添加应用</label>
								<div class="form-controls col-sm-10">
									<ul class="app-list" ng-click="resourceModule()">
										<div class="app-info" ng-show="miniapp.choose_module.title">
											<img ng-src="{{miniapp.choose_module.icon}}" />
											<p>{{miniapp.choose_module.title}}</p>
										</div>
										<li class="select select-more"></li>
									</ul>
								</div>
							</div>
						</div>
					</div>
					<div id="finish" ng-show="createStep == 2">
						<div class="form we7-form wxapp-finish">
							<div class="form-group" ng-hide="newversion">
								<label for="" class="control-label col-sm-2">{{presetTypeInfo.title}}名称</label>
								<div class="form-controls col-sm-10">
									<p class="form-control-static" ng-bind="miniapp.name"></p>
								</div>
							</div>
							<div class="form-group">
								<label for="" class="control-label col-sm-2">描述</label>
								<div class="form-controls col-sm-10">
									<p class="form-control-static" ng-bind="miniapp.description"></p>
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-sm-2">版本号</label>
								<div class="form-controls col-sm-10">
									<p class="form-control-static">{{miniapp.version}}</p>
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-sm-2">打包应用</label>
								<div class="form-controls col-sm-10">
									<ul class="app-list">
										<li class="select">
											<div class="app-info">
												<img ng-src="{{miniapp.choose_module.icon}}" />
												<p>{{miniapp.choose_module.title}}</p>
											</div>
										</li>
									</ul>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<nav class="navbar navbar-wxapp-bottom navbar-fixed-bottom" role="navigation">
			<div class="container">
				<div class="pager">
					<a type="button" class="btn btn-primary" ng-show="createStep != 1" ng-click="prevStep()">上一步</a>
					<a type="button" class="btn btn-primary" ng-show="createStep != 2" ng-click="nextStep()">下一步</a>
					<button type="submit" name="submit" value="yes" class="btn btn-danger" ng-show="createStep == 2" ng-disabled="submitDisabled">生成版本</button>
				</div>
			</div>
		</nav>
	</form>
</div>
<script>
require(['fileUploader','underscore'], function(uploader){
	var miniapp = {'name' : '{$wxapp_info['name']}'};
	angular.module('wxApp').value('config', {
		'type' : "{$type}",
		'preset_type_info' : {php echo json_encode($account_all_type[$type])},
		'miniapp' : miniapp,
		'uniacid' : "{$uniacid}",
		'version_id' : "{$version_id}",
        'postUrl': "{php echo url('miniapp/post/save_post', array('version_id' => $version_id))}",
		'token' : "{$_W['token']}",
		'mtype' : "{$mtype}",
	});

	angular.bootstrap($('#js-miniapp-create'), ['wxApp']);
});
</script>
</html>