1
0

imageAtlas.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>添加分类</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  9. <link rel="stylesheet" href="../../static/css/font-awesome.min.css">
  10. <link rel="stylesheet" href="../../static/css/weadmin.css">
  11. <link rel="stylesheet" href="../../static/css/style.css">
  12. <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
  13. <!--[if lt IE 9]>
  14. <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  15. <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  16. <![endif]-->
  17. <style>
  18. html{
  19. overflow-y: auto;
  20. }
  21. .layui-form-label{
  22. width: 100px;
  23. }
  24. .layui-input-block{
  25. margin-left: 138px;
  26. }
  27. .w-e-toolbar{
  28. padding: 0 !important;
  29. }
  30. .w-e-toolbar .w-e-menu{
  31. padding: 5px 4px !important;
  32. }
  33. .operation i{
  34. margin: 0 3px;
  35. }
  36. </style>
  37. </head>
  38. <body>
  39. <div class="weadmin-body" style="padding: 20px 0">
  40. <form class="layui-form">
  41. <div class="layui-form-item">
  42. <label class="layui-form-label">
  43. 图集标题:
  44. </label>
  45. <div class="layui-input-block steta_grouds">
  46. <input type="text" placeholder="请输入图集标题" class="layui-input textName" lay-verify="required" oninput="pureTextTitles(this.value)">
  47. </div>
  48. </div>
  49. <div class="layui-form-item">
  50. <label class="layui-form-label">图集:</label>
  51. <div class="layui-input-block">
  52. <div class="imageAtlas_items">
  53. </div>
  54. <button type="button" class="layui-btn" id="upload1">
  55. <i class="layui-icon">&#xe67c;</i>上传图片
  56. </button>
  57. </div>
  58. </div>
  59. <div class="layui-form-item" style="text-align: center;padding-top: 50px">
  60. <button class="layui-btn" lay-submit lay-filter="imageAtlasBtn">提交</button>
  61. </div>
  62. </form>
  63. <span class="text" style="display: none"></span>
  64. </div>
  65. <script src="../../lib/layui/layui.js" charset="utf-8"></script>
  66. <script src="../../static/js/config.js"></script>
  67. <script>
  68. layui.use(['form','layer','jquery','upload'], function(){
  69. var form = layui.form,
  70. $ = layui.jquery,
  71. upload= layui.upload,
  72. layer = layui.layer;
  73. form.render();
  74. window.pureTextTitles = function (title) {
  75. parent.onFocus();
  76. parent.pureTextTitle(title)
  77. };
  78. if (sessionStorage.getItem('QRcodeIDs') !=""){
  79. QRcodeImageAtle(sessionStorage.getItem('QRcodeIDs'))
  80. }
  81. var index,num = 0,bums = 0,delateImageatlas = [];
  82. var uploadInst = upload.render({
  83. elem: '#upload1'
  84. ,url: urlF+'api/swagger/api/common/v1/uploadFile'
  85. ,before: function(obj){
  86. index = layer.load(2);
  87. obj.preview(function(index, file, result){
  88. });
  89. }
  90. ,done: function(res){
  91. //上传成功
  92. layer.close(index);
  93. if(res.code == 200){
  94. var muns = bums++ +1;
  95. parent.onFocus();
  96. parent.uploadImageAtlas(res.data.fullURL,muns);
  97. var str = `
  98. <div class="imageAtlas_tiem" index-data="${muns}" img-name="${res.data.fileName}" img-url="${res.data.fullURL}">
  99. <img src="${res.data.fullURL}" alt="" class="image2">
  100. <div class="imageText">
  101. <input type="text" placeholder="输入图片标题" class="imageTitle" lay-verify="required">
  102. <input type="text" placeholder="输入图片链接" class="imageLinking">
  103. </div>
  104. <span class="operation">
  105. <i class="fa fa-long-arrow-up moveUp"></i>
  106. <i class="fa fa-long-arrow-down moveDown"></i>
  107. <i class="fa fa-trash-o deleteLink"></i>
  108. </span>
  109. </div>`;
  110. $('.imageAtlas_items').append(str);
  111. return layer.msg('上传成功');
  112. }
  113. //如果上传失败
  114. layer.msg('上传失败');
  115. }
  116. ,error: function(){
  117. layer.msg('请检查网络!');
  118. }
  119. });
  120. $('body').on('click','.deleteLink',function () {
  121. var imageAtlas = {id:'',deleteFlag:false,imageName:"",imageUrl:'',parentId:"",title:"",imageTitle:'',imageLinking:''};
  122. $(this).parent().parent().remove();
  123. var index_data = $(this).parent().parent().attr('index-data');
  124. $(this).parent().parent().attr("img-name","");
  125. $(this).parent().parent().attr("img-url","");
  126. parent.onFocus();
  127. parent.deleteImageAtlas(index_data);
  128. if ($(this).parent().parent().attr('image-id') != "") {
  129. imageAtlas.id =$(this).parent().parent();
  130. imageAtlas.imageLinking = $(this).parent().parent().find('.imageLinking').val();
  131. imageAtlas.imageTitle = $(this).parent().parent().find('.imageTitle').val();
  132. imageAtlas.title = $('.textName').val();
  133. imageAtlas.parentId = sessionStorage.getItem("QRcodeIDs");
  134. imageAtlas.imageName = $(this).parent().parent().attr('img-name');
  135. imageAtlas.imageUrl = $(this).parent().parent().attr('img-url');
  136. imageAtlas.id = $(this).parent().parent().attr('image-id');
  137. imageAtlas.deleteFlag = true;
  138. delateImageatlas.push(imageAtlas);
  139. console.log(delateImageatlas,'delateImageatlas')
  140. }
  141. });
  142. // 上移
  143. $("body") .on("click",".moveUp",function () {
  144. var index = $(this).parent().parent();
  145. if(index.index() != 0){
  146. index.prev().before(index);
  147. }else {
  148. layer.msg('已经移至最高点', {icon: 8});
  149. }
  150. });
  151. // 下移
  152. $("body") .on("click",".moveDown",function () {
  153. var index = $(this).parent().parent();
  154. if(index.index() != $(".imageAtlas_tiem").length-1){
  155. index.next().after(index);
  156. }else {
  157. layer.msg('已经移至最低点', {icon: 8});
  158. }
  159. });
  160. // form.verify({
  161. // linkverify: function(value, item){
  162. // if(!new RegExp("(https|http)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]").test(value)){
  163. // return '请输入合法的链接地址';
  164. // }
  165. // }
  166. // });
  167. form.on('submit(imageAtlasBtn)', function(){
  168. if (sessionStorage.getItem('QRcodeIDs') == "false") {
  169. var imageAtlasArray = [] , imageAtlas_tiem = $('.imageAtlas_tiem'),num = 0;
  170. var imageAtlas = {imageName:"",imageUrl:'',pageId:sessionStorage.getItem("QRcodeDetaileID"),title:$('.textName').val(),imageTitle:'',imageLinking:''};
  171. imageAtlas_tiem.each(function () {
  172. imageAtlas = {};
  173. imageAtlas.imageLinking = $(this).find('.imageLinking').val();
  174. imageAtlas.imageTitle = $(this).find('.imageTitle').val();
  175. imageAtlas.title = $('.textName').val();
  176. imageAtlas.pageId = sessionStorage.getItem("QRcodeDetaileID");
  177. imageAtlas.imageName = $(this).attr('img-name');
  178. imageAtlas.imageUrl = $(this).attr('img-url');
  179. imageAtlasArray.push(imageAtlas)
  180. });
  181. $.ajax({
  182. url:urlF+'api/page/v1/addPicture',
  183. type:'post',
  184. data:JSON.stringify(imageAtlasArray),
  185. contentType:'application/json;charset=utf-8',
  186. dataType:'json',
  187. success:function (res) {
  188. if (res.code === '200'){
  189. parent.pageRelationIdFun(res.data);
  190. parent.QRcodeIndexas();
  191. layer.msg('图集新增成功');
  192. }else {
  193. layer.msg('图集新增失败,请检查信息');
  194. }
  195. },
  196. error:function () {
  197. layer.msg('网络错误,请检查网络');
  198. }
  199. });
  200. }else {
  201. var imageAtlasArray = [] , imageAtlas_tiem = $('.imageAtlas_tiem');
  202. var imageAtlas = {id:'',deleteFlag:false,imageName:"",imageUrl:'',parentId:"",title:"",imageTitle:'',imageLinking:''};
  203. if (delateImageatlas != []) {
  204. for (var j = 0; j < delateImageatlas.length; j++) {
  205. imageAtlasArray.push(delateImageatlas[j])
  206. }
  207. }
  208. imageAtlas_tiem.each(function () {
  209. imageAtlas = {};
  210. imageAtlas.imageLinking = $(this).find('.imageLinking').val();
  211. imageAtlas.imageTitle = $(this).find('.imageTitle').val();
  212. imageAtlas.title = $('.textName').val();
  213. imageAtlas.parentId = sessionStorage.getItem("QRcodeIDs");
  214. imageAtlas.imageName = $(this).attr('img-name');
  215. imageAtlas.imageUrl = $(this).attr('img-url');
  216. imageAtlas.id = $(this).attr('image-id');
  217. imageAtlas.deleteFlag = false;
  218. imageAtlasArray.push(imageAtlas)
  219. });
  220. $.ajax({
  221. url:urlF+'api/page/v1/updatePicture',
  222. type:'post',
  223. data:JSON.stringify(imageAtlasArray),
  224. contentType:'application/json;charset=utf-8',
  225. dataType:'json',
  226. success:function (res) {
  227. if (res.code === '200'){
  228. parent.onFocus();
  229. parent.pageRelationIdFun(res.data);
  230. layer.msg('图集修改成功');
  231. }else {
  232. layer.msg('图集修改失败,请检查信息');
  233. }
  234. },
  235. error:function () {
  236. layer.msg('网络错误,请检查网络');
  237. }
  238. });
  239. }
  240. return false;
  241. });
  242. // 数据回显
  243. function QRcodeImageAtle(id) {
  244. $.ajax({
  245. url: urlF+'api/page/v1/getPageEdit/'+sessionStorage.getItem('QRcodeDetaileID'),
  246. type: 'get',
  247. dataType: 'json',
  248. success: function (res) {
  249. for (var i = 0; i < res.data.pageItemList.length; i++) {
  250. if (res.data.pageItemList[i].pageRelation.businessType == "PICTURE" && res.data.pageItemList[i].pageRelation.businessId == id) {
  251. $('.textName').val(res.data.pageItemList[i].pictureList[0].title);
  252. for (var j = 0; j < res.data.pageItemList[i].pictureList.length; j++) {
  253. bums = j;
  254. console.log(bums,'bums');
  255. var str = `
  256. <div class="imageAtlas_tiem" index-data="${j}" img-name="${res.data.pageItemList[i].pictureList[j].imageName}" img-url="${res.data.pageItemList[i].pictureList[j].imageUrl}" image-id="${res.data.pageItemList[i].pictureList[j].id}">
  257. <img src="${res.data.pageItemList[i].pictureList[j].imageUrl}" alt="" class="image2">
  258. <div class="imageText">
  259. <input type="text" placeholder="输入图片标题" lay-verify="required" class="imageTitle" value="${res.data.pageItemList[i].pictureList[j].imageTitle}">
  260. <input type="text" placeholder="输入图片链接" value="${res.data.pageItemList[i].pictureList[j].imageLinking}" class="imageLinking">
  261. </div>
  262. <span class="operation">
  263. <i class="fa fa-long-arrow-up moveUp"></i>
  264. <i class="fa fa-long-arrow-down moveDown"></i>
  265. <i class="fa fa-trash-o deleteLink"></i>
  266. </span>
  267. </div>`;
  268. $('.imageAtlas_items').append(str);
  269. }
  270. }
  271. }
  272. },
  273. error:function () {
  274. layer.msg('请检查网络', {icon: 2});
  275. }
  276. });
  277. }
  278. });
  279. </script>
  280. </body>
  281. </html>