人人商城

display.html 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. {php load()->func('tpl')}
  2. {php echo tpl_ueditor('');}
  3. <div class="alert alert-info" style="margin-top:-20px">
  4. <i class="fa fa-info-circle"></i>
  5. 图文可添加多组回复,如果添加了多组回复,系统将随机选择一条回复给粉丝
  6. </div>
  7. <input type="hidden" name="replies" value="">
  8. <div class="panel panel-default clearfix">
  9. <div class="panel-heading">回复内容</div>
  10. <div class="panel-body">
  11. <div class="row clearfix reply">
  12. <div class="col-xs-6 col-sm-3 col-md-3">
  13. <div class="panel-group" ng-repeat="items in context.groups">
  14. <div class="panel panel-default" ng-repeat="item in items">
  15. <div class="panel-body" ng-if="$index == 0">
  16. <div class="img">
  17. <i class="default">封面图片</i>
  18. <img src="" ng-src="{{item.thumb}}">
  19. <span class="text-left">{{item.title}}</span>
  20. <div class="mask">
  21. <a href="javascript:;" ng-click="context.exportFromCms(item, items)"><i class="fa fa-book"></i>导入文章</a>
  22. <a href="javascript:;" ng-click="context.editItem(item, items)"><i class="fa fa-edit"></i>编辑</a>
  23. <a href="javascript:;" ng-click="context.removeItem(item, items)"><i class="fa fa-times"></i>删除</a>
  24. </div>
  25. </div>
  26. </div>
  27. <div class="panel-body" ng-if="$index != 0">
  28. <div class="text">
  29. <h4>{{item.title}}</h4>
  30. </div>
  31. <div class="img">
  32. <img src="" ng-src="{{item.thumb}}">
  33. <i class="default">缩略图</i>
  34. </div>
  35. <div class="mask">
  36. <a href="javascript:;" ng-click="context.exportFromCms(item, items)"><i class="fa fa-book"></i> 导入文章</a>
  37. <a href="javascript:;" ng-click="context.editItem(item, items)"><i class="fa fa-edit"></i> 编辑</a>
  38. <a href="javascript:;" ng-click="context.removeItem(item, items)"><i class="fa fa-times"></i> 删除</a>
  39. </div>
  40. </div>
  41. </div>
  42. <div class="panel panel-default" ng-show="items.length < 8">
  43. <div class="panel-body" style="padding-right:15px">
  44. <div class="add" ng-click="items.length >= 8 ? '' : context.addItem(items);"><span><i class="fa fa-plus"></i> 添加</span></div>
  45. </div>
  46. </div>
  47. <div class="no">{{$index + 1}}</div>
  48. <div class="del" ng-click="context.removeGroup(items);"><i class="fa fa-times"></i></div>
  49. </div>
  50. <div class="btn btn-primary" ng-click="context.addGroup()" style="margin-bottom: 20px">添加一组回复</div>
  51. </div>
  52. <div class="col-xs-6 col-sm-9 col-md-9 aside" id="edit-container">
  53. <div style="margin-bottom: 20px"></div>
  54. <div class="card">
  55. <div class="arrow-left"></div>
  56. <div class="inner">
  57. <div class="panel panel-default">
  58. <div class="panel-body">
  59. <div class="form-group">
  60. <label class="col-xs-12 col-sm-3 col-md-2 control-label">标题</label>
  61. <div class="col-sm-9 col-xs-12">
  62. <input type="text" class="form-control" placeholder="添加图文消息的标题" ng-model="context.activeItem.title"/>
  63. <input type="hidden" ng-model="context.activeItem.id" />
  64. </div>
  65. </div>
  66. <div class="form-group">
  67. <label class="col-xs-12 col-sm-3 col-md-2 control-label">作者</label>
  68. <div class="col-sm-9 col-xs-12">
  69. <input type="text" class="form-control" placeholder="添加图文消息的作者" ng-model="context.activeItem.author"/>
  70. </div>
  71. </div>
  72. <div class="form-group" ng-show="!context.activeItem.isFirst">
  73. <label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
  74. <div class="col-sm-9 col-xs-12">
  75. <input type="text" class="form-control" placeholder="添加排序" ng-model="context.activeItem.displayorder"/>
  76. <span class="help-block">排序只能在提交后显示。按照从大到小的顺序对图文排序</span>
  77. </div>
  78. </div>
  79. <div class="form-group">
  80. <label class="col-xs-12 col-sm-3 col-md-2 control-label">封面</label>
  81. <div class="col-sm-9 col-xs-12">
  82. <div class="col-xs-3 img" ng-if="context.activeItem.thumb == ''">
  83. <span ng-click="context.changeItem(context.activeItem)"><i class="fa fa-plus-circle green"></i>&nbsp;添加图片</span>
  84. </div>
  85. <div class="col-xs-3 img" ng-if="context.activeItem.thumb != ''">
  86. <h3 ng-click="context.changeItem(context.activeItem)">重新上传</h3>
  87. <img ng-src="{{ context.activeItem.thumb }}">
  88. </div>
  89. </div>
  90. </div>
  91. <div class="form-group">
  92. <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
  93. <div class="col-sm-9 col-xs-12">
  94. <label>
  95. 封面(大图片建议尺寸:360像素 * 200像素)
  96. </label>
  97. </div>
  98. </div>
  99. <div class="form-group">
  100. <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
  101. <div class="col-sm-9 col-xs-12">
  102. <label class="checkbox-inline">
  103. <input type="checkbox" value="1" ng-model="context.activeItem.incontent" ng-checked="context.activeItem.incontent"/> 封面图片显示在正文中
  104. </label>
  105. </div>
  106. </div>
  107. <div class="form-group">
  108. <label class="col-xs-12 col-sm-3 col-md-2 control-label">描述</label>
  109. <div class="col-sm-9 col-xs-12">
  110. <textarea class="form-control" placeholder="添加图文消息的简短描述" ng-model="context.activeItem.description"></textarea>
  111. </div>
  112. </div>
  113. <div class="form-group">
  114. <div class="col-sm-offset-4 col-md-offset-3 col-lg-offset-2 col-xs-12 col-sm-8 col-md-9 col-lg-10">
  115. <label class="checkbox-inline">
  116. <input type="checkbox" value="1" ng-model="context.activeItem.detail" ng-checked="context.activeItem.detail" ng-init="context.activeItem.detail = context.activeItem.content!=''"/> 是否编辑图文详情
  117. </label>
  118. <span class="help-block">编辑详情可以展示这条图文的详细内容, 可以选择不编辑详情, 那么这条图文将直接链接至下方的原文地址中.</span>
  119. </div>
  120. </div>
  121. <div class="form-group" ng-show="context.activeItem.detail">
  122. <label class="col-xs-12 col-sm-3 col-md-2 control-label">详情</label>
  123. <div class="col-sm-9 col-xs-12">
  124. <div ng-my-editor ng-my-value="context.activeItem.content"></div>
  125. </div>
  126. </div>
  127. <div class="form-group">
  128. <label class="col-xs-12 col-sm-3 col-md-2 control-label">来源</label>
  129. <div class="col-sm-9 col-xs-12">
  130. <div class="input-group">
  131. <input type="text" class="form-control" placeholder="图文消息的来源地址" ng-model="context.activeItem.url"/>
  132. <span class="input-group-btn">
  133. <button class="btn btn-default" type="button" ng-click="context.selectLink()"><i class="fa fa-external-link"></i> 系统链接</button>
  134. </span>
  135. </div>
  136. </div>
  137. </div>
  138. </div>
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. </div>
  146. <script>
  147. window.initReplyController = function($scope, $http) {
  148. $scope.context = {};
  149. $scope.context.groups = {php echo json_encode($replies)};
  150. if(!$.isArray($scope.context.groups)) {
  151. $scope.context.groups = [];
  152. }
  153. if($scope.context.groups.length == 0) {
  154. $scope.context.groups.push(
  155. [{
  156. id: '',
  157. parent_id: -1,
  158. title: '',
  159. author: '',
  160. thumb: '',
  161. displayorder: '0',
  162. incontent: true,
  163. description: '',
  164. detail: true,
  165. content: '',
  166. url: ''
  167. }]
  168. );
  169. }
  170. //当前编辑的回复项目的索引
  171. $scope.context.activeGroupIndex = 0;
  172. $scope.context.activeIndex = 0;
  173. //当前编辑的回复项目
  174. $scope.context.activeItem = $scope.context.groups[$scope.context.activeGroupIndex][$scope.context.activeIndex];
  175. $scope.context.activeItem.incontent = $scope.context.activeItem.incontent == 1;
  176. $scope.context.addGroup = function(){
  177. $scope.context.groups.push(
  178. [{
  179. id: '',
  180. parent_id: -1,
  181. title: '',
  182. author: '',
  183. thumb: '',
  184. displayorder: '0',
  185. incontent: true,
  186. description: '',
  187. detail: true,
  188. content: '',
  189. url: ''
  190. }]
  191. );
  192. $scope.context.activeGroupIndex = $scope.context.groups.length - 1;
  193. $scope.context.triggerActiveItem(0);
  194. };
  195. $scope.context.removeGroup = function(items){
  196. if($scope.context.groups.length == 1) {
  197. util.message('至少有一组回复内容');
  198. return false;
  199. }
  200. $scope.context.groups = _.without($scope.context.groups, items);
  201. $scope.context.activeGroupIndex = 0;
  202. $scope.context.triggerActiveItem(0);
  203. $scope.$digest();
  204. }
  205. $scope.context.editItem = function(item, items){
  206. $scope.context.triggerActiveGroup(items);
  207. var index = $.inArray(item, $scope.context.groups[$scope.context.activeGroupIndex]);
  208. if(index == -1) return false;
  209. $scope.context.triggerActiveItem(index);
  210. };
  211. $scope.context.triggerActiveGroup = function(items) {
  212. var index = $.inArray(items, $scope.context.groups);
  213. if(index == -1) return false;
  214. $scope.context.activeGroupIndex = index;
  215. }
  216. $scope.context.triggerActiveItem = function(index) {
  217. var gindex = $scope.context.activeGroupIndex;
  218. var top = 0;
  219. for(i = 0; i < gindex; i++) {
  220. if($scope.context.groups[i].length == 8) {
  221. top = top + 7*105 + 210;
  222. } else {
  223. top = top + 210 + $scope.context.groups[i].length * 105;
  224. }
  225. }
  226. top += index * 105 + 80;
  227. $('#edit-container').css('marginTop', top);
  228. $("html,body").animate({scrollTop:top + 500},500);
  229. $scope.context.activeIndex = index;
  230. $scope.context.activeItem = $scope.context.groups[$scope.context.activeGroupIndex][$scope.context.activeIndex];
  231. $scope.context.activeItem.incontent = $scope.context.activeItem.incontent == 1;
  232. $scope.context.activeItem.detail = $scope.context.activeItem.content != '';
  233. $scope.context.activeItem.isFirst = false;
  234. if(!index) {
  235. $scope.context.activeItem.isFirst = true;
  236. }
  237. };
  238. $scope.context.changeItem = function(item) {
  239. require(['fileUploader'], function(uploader){
  240. uploader.init(function(imgs){
  241. var index = $.inArray(item, $scope.context.groups[$scope.context.activeGroupIndex]);
  242. if(index > -1){
  243. $scope.context.groups[$scope.context.activeGroupIndex][index].thumb = imgs.url;
  244. $scope.$apply()
  245. }
  246. }, {'direct' : true, 'multiple' : false, fileSizeLimit : {php echo intval($_W['setting']['upload']['image']['limit']) * 1024}});
  247. });
  248. };
  249. $scope.context.selectLink = function(){
  250. util.linkBrowser(function(href){
  251. $scope.context.activeItem.url = href;
  252. $scope.$digest();
  253. });
  254. };
  255. $scope.context.addItem = function(items){
  256. $scope.context.triggerActiveGroup(items);
  257. $scope.context.groups[$scope.context.activeGroupIndex].push({
  258. id: '',
  259. parent_id: -1,
  260. title: '',
  261. author: '',
  262. thumb: '',
  263. displayorder: '0',
  264. incontent: true,
  265. description: '',
  266. detail: true,
  267. content: '',
  268. url: ''
  269. });
  270. var index = $scope.context.groups[$scope.context.activeGroupIndex].length - 1;
  271. $scope.context.triggerActiveItem(index);
  272. };
  273. $scope.context.removeItem = function(item, items){
  274. $scope.context.triggerActiveGroup(items);
  275. require(['underscore'], function(_){
  276. $scope.context.groups[$scope.context.activeGroupIndex] = _.without($scope.context.groups[$scope.context.activeGroupIndex], item);
  277. $scope.context.triggerActiveItem(0);
  278. $scope.$digest();
  279. });
  280. };
  281. //导入文章
  282. $scope.context.exportFromCms = function(item, items) {
  283. $scope.context.triggerActiveGroup(items);
  284. var index = $.inArray(item, $scope.context.groups[$scope.context.activeGroupIndex]);
  285. if(index == -1) return false
  286. $scope.context.triggerActiveItem(index);
  287. $scope.context.searchCms();
  288. }
  289. $scope.context.searchCms = function(page) {
  290. var html = {};
  291. html['header'] = '<ul role="tablist" class="nav nav-pills" style="font-size:14px; margin-top:-20px;">'+
  292. ' <li role="presentation" class="active" id="li_goodslist"><a data-toggle="tab" role="tab" aria-controls="articlelist" href="#articlelist">文章列表</a></li>'+
  293. '</ul>';
  294. html['content'] =
  295. '<div class="tab-content">'+
  296. '<div id="articlelist" class="tab-pane active" role="tabpanel">' +
  297. ' <table class="table table-hover">' +
  298. ' <thead class="navbar-inner">' +
  299. ' <tr>' +
  300. ' <th style="width:40%;">标题</th>' +
  301. ' <th style="width:30%">创建时间</th>' +
  302. ' <th style="width:30%; text-align:right">' +
  303. ' <div class="input-group input-group-sm">' +
  304. ' <input type="text" class="form-control">' +
  305. ' <span class="input-group-btn">' +
  306. ' <button class="btn btn-default" type="button"><i class="fa fa-search"></i></button>' +
  307. ' </span>' +
  308. ' </div>' +
  309. ' </th>' +
  310. ' </tr>' +
  311. ' </thead>' +
  312. ' <tbody></tbody>'+
  313. ' </table>'+
  314. ' <div id="pager" style="text-align:center;"></div>'+
  315. '</div>'+
  316. '</div>';
  317. html['footer'] = '';
  318. html['articleitem'] =
  319. '<%_.each(list, function(item) {%> \n' +
  320. '<tr>\n' +
  321. ' <td><a href="#" data-cover-attachment-url="<%=item.attachment%>" title="<%=item.title%>"><%=item.title%></a></td>\n' +
  322. ' <td><%=item.createtime%></td>\n' +
  323. ' <td class="text-right">\n' +
  324. ' <button class="btn btn-default js-btn-select" js-id="<%=item.id%>">选取</button>\n' +
  325. ' </td>\n' +
  326. '</tr>\n' +
  327. '<%});%>\n';
  328. if (!$('#link-search-cms')[0]) {
  329. $scope.modalobj = util.dialog(html['header'], html['content'], html['footer'] ,{'containerName' : 'link-search-cms'});
  330. $scope.modalobj.find('.modal-body').css({'height':'680px','overflow-y':'auto' });
  331. $scope.modalobj.modal('show');
  332. $scope.modalobj.on('hidden.bs.modal', function(){$scope.modalobj.remove();});
  333. $('#link-search-cms').data('modal', $scope.modalobj);
  334. } else {
  335. $scope.modalobj = $('#link-search-cms').data('modal');
  336. }
  337. page = page || 1;
  338. $http.get('./index.php?c=utility&a=link&do=articlelist' + '&page=' + page).success(function(result, status, headers, config){
  339. if (result.message.list) {
  340. $scope.modalobj.find('#articlelist').data('articles', result.message.list);
  341. $scope.modalobj.find('#articlelist tbody').html(_.template(html['articleitem'])(result.message));
  342. $scope.modalobj.find('#pager').html(result.message.pager);
  343. $scope.modalobj.find('#pager .pagination li[class!=\'active\'] a').click(function(){
  344. $scope.context.searchCms($(this).attr('page'));
  345. return false;
  346. });
  347. $scope.modalobj.find('.js-btn-select').click(function(){
  348. $scope.context.addCms($(this).attr('js-id'));
  349. $scope.$apply();
  350. $scope.modalobj.modal('hide');
  351. });
  352. }
  353. });
  354. };
  355. $scope.context.addCms = function(id) {
  356. var article =$scope.modalobj.find('#articlelist').data('articles')[id];
  357. $scope.context.activeItem.title = article.title;
  358. $scope.context.activeItem.thumb = article.thumb_url;
  359. $scope.context.activeItem.author = article.author;
  360. $scope.context.activeItem.incontent = article.incontent == 1;
  361. $scope.context.activeItem.description = article.description;
  362. $scope.context.activeItem.content = article.content;
  363. $scope.context.activeItem.url = article.linkurl;
  364. $scope.context.activeItem.detail = article.content != '';
  365. };
  366. };
  367. window.validateReplyForm = function(form, $, _, util, $scope) {
  368. if($scope.context.groups.length == 0) {
  369. util.message('没有回复内容', '', 'error');
  370. return false;
  371. }
  372. var error = {empty: false, message: ''};
  373. angular.forEach($scope.context.groups, function(v, k){
  374. var item = $scope.context.groups[k];
  375. angular.forEach(item, function(v1){
  376. if($.trim(v1.title) == '') {
  377. this.empty = true;
  378. }
  379. if($.trim(v1.thumb) == '') {
  380. this.message = '标题为 "' + v1.title + '" 的回复条目没有上传封面图片<br>';
  381. }
  382. }, error);
  383. }, error);
  384. if(error.empty) {
  385. util.message('存在没有设置 "标题" 的回复条目');
  386. return false;
  387. }
  388. if(error.message) {
  389. util.message(error.message, '', 'error');
  390. return false;
  391. }
  392. var val = angular.toJson($scope.context.groups);
  393. $(':hidden[name=replies]').val(val);
  394. return true;
  395. };
  396. </script>