{template 'common/header'}
<div class="alert we7-page-alert">
	<p><i class="wi wi-info-sign"></i>本{$_W['account']['type_name']}可操作的模块中，仅显示可进行同步的模块；</p>
	<p><i class="wi wi-info-sign"></i>可以非{$_W['account']['type_name']}的其他应用的会员、数据等信息同步至{$_W['account']['type_name']}应用当中；</p>
	<p><i class="wi wi-info-sign"></i>一个模块，同步了小程序则不可再同步PC，同步了PC则不可再同步小程序；</p>
	<p><i class="wi wi-info-sign"></i>若小程序A应用已同步{$_W['account']['type_name']}，则{$_W['account']['type_name']}同步小程序应用时，无法选择小程序A且小程序A不会显示在同步列表中，即两者不可相互同步,PC同理。</p>
</div>
<div id="js-app-module-link-uniacid" ng-controller="appModuleLinkUniacidCtrl" ng-cloak>
	<table class="table we7-table table-hover vertical-middle">
		<col width="180px" />
		<col width="140px"/>
		<col width="140px" />
		<tr>
			<th class="text-left">模块</th>
			<th class="text-left">同步应用</th>
			<th class="text-right">操作</th>
		</tr>
		<tr ng-repeat="module in modules" ng-if="modules">
			<td class="text-left">
				<img ng-src="{{module.logo}}" style="width:50px;height:50px;">
				{{module.title}}
			</td>
			<td class="text-left" ng-if="module.link_uniacid_info">
				<img ng-src="{{module.link_uniacid_info.logo}}" style="width:50px;height:50px;">
				<span>{{module.link_uniacid_info.name}}</span>
			</td>
			<td class="text-left" ng-if="!module.link_uniacid_info && !module.other_link">
				<span>暂无</span>
			</td>
			<td class="text-left" ng-if="!module.link_uniacid_info && module.other_link">
				<div ng-repeat="item in module.other_link">
					已被 {{item.type_name}} <span class="color-default" ng-bind="item.name"></span> 同步
				</div>
			</td>
			<td>
				<div class="link-group" ng-if="module.link_uniacid_info">
					<a href="javascript:;" ng-click="initModule(module.name)">修改</a>
					<a href="javascript:;" ng-click="module_unlink_uniacid(module.name)">删除</a>
				</div>
				<div class="link-group" ng-if="!module.link_uniacid_info && !module.other_link">
					<a href="javascript:;" ng-click="initModule(module.name)">添加</a>
				</div>
				<div class="link-group" ng-if="!module.link_uniacid_info && module.other_link">
					<a href="javascript:;">---</a>
				</div>
			</td>
		</tr>
		<tr ng-if="!modules">
			<td colspan="3">
				暂无同步模块
			</td>
		</tr>
	</table>

	<div class="modal fade modal-app" tabindex="-1" id="show-account" role="dialog" >
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header clearfix">
					<h4 class="text-over"> 选择账号 </h4>
					<div class="type"></div>
					<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				</div>
				<div class="modal-body">
					<div class="search-box">
						<span class="we7-margin-right">账号类型:</span>
						<select class="we7-select we7-margin-right"
								ng-model="activeTypeSign"
								ng-change="changeType(activeTypeSign)">
							<option value="{{key}}"
									ng-repeat="(key, item) in we7TypeDefault"
							>{{item.name}}</option>
						</select>
						<div class="search-form">
							<div class="input-group">
								<input class="form-control" type="text" ng-model="searchKeyword" autocomplete="false" >
								<span class="input-group-btn"><button class="btn btn-default"><i class="fa fa-search"></i></button></span>
							</div>
						</div>
					</div>
					<div class="modal-app-list" ng-show="loadData">
						<span class="help-block text-center"><img src="./resource/images/loading.gif" alt="" width="45px"></span>
					</div>
					<div class="modal-app-list" ng-show="!loadData">
						<div class="modal-item" ng-class="{'active': account.checked == 1}" ng-repeat="account in linkAccounts" ng-if="linkAccounts" ng-show="!searchKeyword || searchKeyword && account.name.indexOf(searchKeyword) > -1">
							<div class="logo" ng-click="selectLinkAccount(account)">
								<img ng-src="{{account.logo}}" class="account-logo" alt="">
								<div class="mark">
									<i class="wi wi-right"></i>
								</div>
							</div>
							<div class="name text-over" ng-click="selectLinkAccount(account, $event)">
								<i class="{{we7TypeDefault[account.type_sign]['icon']}}"></i>{{account.name}}
							</div>
						</div>
						<div class="we7-empty-block" ng-if="linkAccounts | we7IsEmpty">没有可以关联的账号</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-primary" ng-click="moduleLinkUniacid()">确定</button>
					<button type="button" class="btn btn-default"  data-dismiss="modal">取消</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	angular.module('profileApp').value('config', {
		'modules': {php echo !empty($modules) ? json_encode($modules) : 'null'},
		'token': "{php echo $_W['token']}",
		'typeSign': "{php echo $_W['account']['type_sign']}",
		'links' : {
			'search_link_account': "{php echo url('profile/module-link-uniacid/search_link_account')}",
			'module_link_uniacid': "{php echo url('profile/module-link-uniacid')}",
			'module_unlink_uniacid':"{php echo url('profile/module-link-uniacid/module_unlink_uniacid')}"
		},
	});
	angular.bootstrap($('#js-app-module-link-uniacid'), ['profileApp']);
</script>
{template 'common/footer'}