人人商城

theme.html 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. {template 'common/header-gw'}
  2. <style>
  3. .template .item{position:relative;display:block;float:left;border:1px #ddd solid;border-radius:5px;background-color:#fff;padding:5px;width:190px;margin:0 10px 10px 0;}
  4. .template .title{margin:5px auto;line-height:2em;}
  5. .template .title .theme-title {overflow:hidden; height:30px;}
  6. .template .item img{width:178px;height:270px;}
  7. .template .item.active img{width:178px;height:270px;border:3px #009cd6 solid;padding:1px;}
  8. .template .fa{}
  9. .template .fa.fa-times{display:inline-block;position:absolute;bottom:33px;right:6px;color:#FFF;background:#009CD6;padding:5px;font-size:14px;border-radius:0 0 6px 0;text-decoration:none}
  10. .update-bg{width:178px; height:270px; background:#000; position:absolute; z-index:1; opacity:0.5; top:38px;}
  11. .update-div{width:178px; height:270px; position:absolute; z-index:2; top:38px; text-align:center;}
  12. .update-btn{position:relative; top:85px; display:inline-block; width: 60px; height:60px; text-align:center; line-height:60px; text-decoration:none; border-width:1px; border-style:solid; cursor:pointer;}
  13. .template-form{position:absolute; z-index:2; bottom:38px; right:10px;}
  14. .template-upgrade-info {display: none;}
  15. .template-upgrade-info img {width: 100%;}
  16. </style>
  17. {template 'extension/theme-tabs'}
  18. <div class="clearfix template">
  19. {if $do == 'installed'}
  20. <h5 class="page-header">已安装的微站模板</h5>
  21. <nav role="navigation" class="navbar navbar-default">
  22. <div class="container-fluid">
  23. <div class="navbar-header">
  24. <a href="javascript:;" class="navbar-brand">微站模板类型</a>
  25. </div>
  26. <ul class="nav navbar-nav nav-btns">
  27. <li {if $_GPC['type'] == 'all' || empty($_GPC['type'])} class="active" {/if}>
  28. <a href="{php echo url('extension/theme/installed', array('type' => 'all'));}">全部</a>
  29. </li>
  30. {loop $temtypes $type}
  31. <li {if $_GPC['type'] == $type['name']} class="active" {/if}>
  32. <a href="{php echo url('extension/theme/installed', array('type' => $type['name']));}">{$type['title']}</a>
  33. </li>
  34. {/loop}
  35. </ul>
  36. </div>
  37. </nav>
  38. <div id="batch-contain" style="clear:both;height:50px;line-height:50px;margin-top:-20px;display:none">
  39. <a href="{php echo url('extension/theme/upgrade', array('check' => 1, 'batch' => 1));}" class="btn btn-primary">一键更新模板</a>
  40. </div>
  41. {loop $templates $item}
  42. <div class="item">
  43. <div class="title">
  44. <div class="theme-title">{$item['title']} ({$item['name']})</div>
  45. <img src="../app/themes/{$item['name']}/preview.jpg" class="img-rounded" />
  46. <span class="upgrade-label" theme="{$item['name']}" version="{$item['version']}"></span>
  47. <span class="hide-form" id="{$item['name']}" style="display:none"></span>
  48. </div>
  49. <div class="btn-group btn-group-justified">
  50. <a title="卸载" onclick="return confirm('确定卸载此模板吗?')" href="{php echo url('extension/theme/uninstall', array('id' => $item['id']))}" class="btn btn-default btn-xs">卸载</a>
  51. </div>
  52. </div>
  53. {/loop}
  54. <div class="modal fade" id="upgrade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  55. <div class="modal-dialog modal-lg">
  56. <div class="modal-content">
  57. <div class="modal-header">
  58. <button type="button" class="close" data-dismiss="modal">
  59. <span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
  60. </button>
  61. <h4 class="modal-title" id="myModalLabel">模板分支版本信息</h4>
  62. </div>
  63. <div class="modal-body" id="errorinfo"></div>
  64. <div class="modal-body" id="moduleinfo">
  65. <div class="form-group">
  66. 模板名称:<span id="js-module-name"></span>
  67. </div>
  68. <div class="panel panel-default">
  69. <div class="panel-heading">
  70. 模板分支信息
  71. </div>
  72. <div class="panel-body" id="js-module-branch">
  73. </div>
  74. </div>
  75. <div class="alert alert-info">
  76. <span><i class="fa fa-info-circle"></i></span>
  77. 应用分支按照等级顺序排列。<br/>
  78. <span><i class="fa fa-info-circle"></i></span>
  79. 已购买的模板分支可以免费升级到该分支的最新版本。<br/>
  80. <span><i class="fa fa-info-circle"></i></span>
  81. 如果要升级到其它分支最新版本,需要花费对应分支价格数量的交易币。
  82. </div>
  83. </div>
  84. <div class="modal-footer">
  85. <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. <script type="text/javascript">
  91. var upgrade = [];
  92. $.post('{php echo url("extension/theme/check");}', {foo: 'upgrade'},function(themes){
  93. try {
  94. $('.upgrade-label').each(function() {
  95. var n = $(this).attr('theme');
  96. var v = $(this).attr('version');
  97. if (typeof themes[n] != 'undefined') {
  98. $('.hide-form[id="' + n + '"]').html('<span class="label label-warning template-form">来自云平台安装</span>').show();
  99. if (themes[n].site_branch != null) {
  100. var branches = themes[n].branches;
  101. var site_branch_sort = parseInt(themes[n].site_branch.displayorder);
  102. for (var index in branches) {
  103. if ( (parseInt(branches[index].displayorder) > site_branch_sort)
  104. || ( (parseInt(branches[index].displayorder) >= site_branch_sort) && ( parseFloat(branches[index].version) > parseFloat(v) ) ) ) {
  105. var tips = '来自微擎云服务更新';
  106. $(this).html('<div class="img-rounded update-bg"></div><div class="update-div"><a href="javascript:;" class="btn-danger img-circle update-btn" title="来自微擎云服务更新" onclick=\'setThemeInfo("' + n + '", "' + v +'");\' );>更新</a></div>');
  107. break;
  108. }
  109. }
  110. }
  111. } else if ($.inArray(n, themes.pirate_apps) > -1) {
  112. $('.hide-form[id="' + n + '"]').html('<span class="label label-danger template-form">来自非法渠道</span>').show();
  113. } else {
  114. $('.hide-form[id="' + n + '"]').html('<span class="label label-success template-form">来自本地安装</span>').show();
  115. }
  116. });
  117. } catch(err) {}
  118. }, 'json');
  119. var setThemeInfo = function(theme, version) {
  120. var trade_link = "{php echo url('extension/theme/upgrade');}" + '&templateid=' + theme;
  121. var current_version = version;
  122. $.post('{php echo url("extension/theme/upgrade");}', {theme : theme, templateid : theme}, function(response) {
  123. if (typeof response.message.version != 'object') {
  124. $('#moduleinfo').hide();
  125. $('#errorinfo').show();
  126. $('#upgrade').modal('show');
  127. $('#errorinfo').html('<div class="alert alert-danger">' + response.message + '</div>');
  128. $('#confirm').attr('href', 'javascript:;').text('无法更新').removeClass('btn-success').addClass('btn-danger');
  129. } else {
  130. var theme_branches = response.message.branches;
  131. var current_branch = response.message.version.branch_id;
  132. var current_branch_sort = parseInt(theme_branches[current_branch].displayorder);
  133. var branch_info = '';
  134. for (var branch in theme_branches) {
  135. branch_info +=
  136. '<div class="input-group help-block col-sm-12">' +
  137. '<div class="col-sm-3">' +
  138. '<h4>分支名称:' + theme_branches[branch].name + '</h4>' +
  139. '</div>' +
  140. '<div class="col-sm-3">' +
  141. '<h4>升级价格:' + theme_branches[branch].upgrade_price + '</h4>' +
  142. '</div>' +
  143. '<div class="col-sm-2">' +
  144. '<button type="button" class="btn btn-default js-upgrade-info">升级说明</button>' +
  145. '</div>' +
  146. '<div class="col-sm-4">';
  147. if (theme_branches[branch].id != current_branch) {
  148. if ( parseInt(theme_branches[branch].displayorder) > current_branch_sort) {
  149. branch_info += '<a href="' + trade_link + '&branch=' + theme_branches[branch].id + '" class="btn btn-warning js-module-trade" data-price="' + theme_branches[branch].upgrade_price + '">付费升级到【' + theme_branches[branch].name + '】</a></div></div>';
  150. } else {
  151. branch_info += '<a href="javascript:;" class="btn btn-default">已是最新版,无需升级</a></div></div>';
  152. }
  153. } else {
  154. if ( parseFloat(theme_branches[branch].version.version) > parseFloat(current_version) ) {
  155. branch_info += '<a href="' + trade_link + '&branch=' + theme_branches[branch].id + '" class="btn btn-success js-module-trade" data-price="0">免费升级到【' + theme_branches[branch].name + '】最新版本</a></div></div>';
  156. } else {
  157. branch_info += '<a href="javascript:;" class="btn btn-default">已是最新版,无需升级</a></div></div>';
  158. }
  159. }
  160. branch_info += '<div class="input-group help-block col-sm-12 template-upgrade-info">' +
  161. '<div class="col-sm-12">' + theme_branches[branch].version.description + '</div>' +
  162. '</div>';
  163. }
  164. $('#js-module-name').text(response.message.title);
  165. $('#js-module-branch').html(branch_info);
  166. $('#moduleinfo').show();
  167. $('#errorinfo').hide();
  168. $('#upgrade').modal('show');
  169. $('.js-upgrade-info').on('click', function() {
  170. $(this).parent().parent().next().toggle();
  171. });
  172. $('.js-module-trade').on('click', function() {
  173. return confirm('提示:升级到此版本需要花费 ' + $(this).data('price') + ' 个交易币,确认操作?');
  174. });
  175. }
  176. }, 'json');
  177. }
  178. </script>
  179. {/if}
  180. {if $do == 'prepared'}
  181. <h5 class="page-header">已购买的微站模板</h5>
  182. <div class="form clearfix" ng-controller="listInstallThemes">
  183. <div class="item" id="templates-{{m.name}}" ng-repeat="m in templates">
  184. <div class="title">
  185. <div class="theme-title">{{m.title}} ({{m.name}})</div>
  186. <img src="{{m.logo}}" class="img-rounded" />
  187. </div>
  188. <div class="btn-group btn-group-justified">
  189. <a href="{php echo url('extension/theme/install')}templateid={{m.name}}" class="btn btn-default btn-xs">安装</a>
  190. </div>
  191. </div>
  192. </div>
  193. {if $uninstallTemplates}
  194. <div class="form">
  195. <h5 class="page-header">未安装的微站模板(本地模板)</h5>
  196. </div>
  197. <div class="alert alert-info form-horizontal" style="display:none" id="install-info">
  198. <dl class="dl-horizontal">
  199. <dt>整体进度</dt>
  200. <dd id="pragress"></dd>
  201. <dt>正在安装的模板</dt>
  202. <dd id="m_name"></dd>
  203. </dl>
  204. <dl class="dl-horizontal" style="display:none">
  205. <dt>安装失败的模板</dt>
  206. <dd>
  207. <p class="text-danger" id="fail" style="margin:0;"></p>
  208. </dd>
  209. </dl>
  210. </div>
  211. {loop $uninstallTemplates $item}
  212. <div class="item" id="templates-{$item['name']}">
  213. <div class="title">
  214. <div class="theme-title">{$item['title']} ({$item['name']})</div>
  215. <img src="../app/themes/{$item['name']}/preview.jpg" class="img-rounded" />
  216. </div>
  217. <div class="btn-group btn-group-justified">
  218. <a href="{php echo url('extension/theme/install', array('templateid' => $item['name']))}" class="btn btn-default btn-xs">安装</a>
  219. </div>
  220. </div>
  221. {/loop}
  222. <div style="clear:both;height:50px;line-height:50px">
  223. <span class="btn btn-primary" id="batch-install">一键安装所有本地模板</span>
  224. </div>
  225. {else}
  226. <div class="form">
  227. <h5 class="page-header">未安装的微站模板(本地模板)</h5>
  228. <div class="alert alert-danger">
  229. 目前没有未安装的本地模板
  230. </div>
  231. </div>
  232. {/if}
  233. <script type="text/javascript">
  234. angular.module('app', []).controller('listInstallThemes', function($scope, $http) {
  235. $.post('{php echo url('extension/theme/check');}', {foo: 'install'},function(dat){
  236. try {
  237. var ret = $.parseJSON(dat);
  238. if(!$.isArray(ret)) {
  239. return;
  240. }
  241. $.each(ret, function(){
  242. $('div.item[templates-name=' + this.name + ']').remove();
  243. });
  244. $scope.$apply(function(){
  245. $scope.templates = ret;
  246. });
  247. } catch(err) {}
  248. });
  249. });
  250. angular.bootstrap(document, ['app']);
  251. //处理批量安装模块
  252. var templates = {$prepare_templates};
  253. var templates_title = {$prepare_templates_title};
  254. var total = templates.length;
  255. var i = 1;
  256. var fail = [];
  257. var success = [];
  258. var insta = function(){
  259. var m_name = templates.pop();
  260. if(!m_name) {
  261. util.message('本次成功安装' + success.length + '个模板.<br>安装失败' + fail.length + '个模板', "{php echo url('extension/theme/installed')}", 'info');
  262. return;
  263. }
  264. var pragress = i + '/' + total;
  265. $('#m_name').html(templates_title[m_name]);
  266. $('#pragress').html(pragress);
  267. $.post("{php echo url('extension/theme/batch-install')}", {'templateid' : m_name}, function(data){
  268. if(data == 'success') {
  269. i++;
  270. $('#templates-' + m_name).slideUp();
  271. success.push(templates_title[m_name]);
  272. setTimeout(function(){insta()}, 2000);
  273. } else {
  274. i++;
  275. fail.push(templates_title[m_name]);
  276. $('#fail').html(fail.join('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;')).parent().parent().show();
  277. setTimeout(function(){insta()}, 2000);
  278. }
  279. });
  280. }
  281. $('#batch-install').click(function(){
  282. $('#install-info').show();
  283. insta();
  284. });
  285. </script>
  286. {/if}
  287. </div>
  288. {template 'common/footer-gw'}