暫無描述

index.html 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <!DOCTYPE html>
  2. <html lang="zh-CN" class="feedback">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  7. <meta name="apple-mobile-web-app-capable" content="yes">
  8. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  9. <title>留言板</title>
  10. <link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
  11. <link rel="stylesheet" type="text/css" href="../css/app.css" />
  12. <link rel="stylesheet" type="text/css" href="../css/mui.picker.min.css" />
  13. <link rel="stylesheet" type="text/css" href="../css/feedback-page.css" />
  14. <link rel="stylesheet" href="../css/webuploader.css" />
  15. <link rel="stylesheet" type="text/css" href="../css/Common.css?v=0619" />
  16. </head>
  17. <body>
  18. <div class="mui-card">
  19. <p class="que_header_content">
  20. 说明:该版块主要向市民征集突出社会治安问题(隐患)、黑恶犯罪线索及对政法各机关工作意见建议,不具警情实时处置和反馈功能。
  21. </p>
  22. </div>
  23. <div class="mui-card">
  24. <div class="mui-card-header">基本信息</div>
  25. <form class="mui-input-group">
  26. <div class="mui-input-row">
  27. <label for="h_userName">姓名:</label>
  28. <input type="text" class="mui-input-clear" id="h_userName" placeholder="请输入姓名">
  29. </div>
  30. <div class="mui-input-row">
  31. <label for="h_phone">电话:</label>
  32. <input type="text" class="mui-input-clear" id="h_phone" placeholder="请输入电话">
  33. </div>
  34. <div id="showCountyPicker">
  35. <div class="mui-input-row">
  36. <label class="label" for="h_county">乡镇或单位:</label>
  37. <input type="text" id="h_county" class="ui-alert type_con" placeholder="请选择乡镇或单位" data-index="">
  38. <a><span class="type_down mui-icon mui-icon-arrowdown mui-pull-right"></span></a>
  39. </div>
  40. </div>
  41. <div class="mui-input-row">
  42. <label for="h_address">地址:</label>
  43. <input type="text" class="mui-input-clear" id="h_address" placeholder="请输入地址">
  44. </div>
  45. <div id="showInfoTypePicker">
  46. <div class="mui-input-row">
  47. <label class="label" for="h_county">信息分类:</label>
  48. <input type="text" id="h_infoType" class="ui-alert type_con" placeholder="请选择信息分类" data-index="">
  49. <a><span class="type_down mui-icon mui-icon-arrowdown mui-pull-right"></span></a>
  50. </div>
  51. </div>
  52. <div class="mui-input-row h_content">
  53. <label for="h_content">反映问题:</label>
  54. <textarea id="h_content" class="mui-input-clear question" placeholder="请详细描述您要反映的问题..."></textarea>
  55. </div>
  56. </form>
  57. </div>
  58. <div class="mui-card">
  59. <div class="mui-card-header">
  60. 附件
  61. <span class="file_tips">(非图片不能预览)</span>
  62. <span id="fileNum">0/6</span>
  63. </div>
  64. <div class="row image-list" id="image-list">
  65. <div id="filePicker"></div>
  66. </div>
  67. </div>
  68. <div class="mui-button-row" id="Btns-box">
  69. <button type="button" data-loading-text="提交中" id="submit" class="mui-btn mui-btn-primary">提交</button>
  70. </div>
  71. <script src="../js/jquery.min.js"></script>
  72. <script src="../js/radialIndicator.min.js"></script>
  73. <script src="../js/zepto.js"></script>
  74. <script src="../js/mui.min.js"></script>
  75. <script src="../js/mui.zoom.js"></script>
  76. <script src="../js/mui.previewimage.js"></script>
  77. <script src="../js/mui.picker.min.js"></script>
  78. <script src="../js/mui.poppicker.js"></script>
  79. <script src="../js/webuploader.min.js"></script>
  80. <script src="../Script/Common/huayi.config.js"></script>
  81. <script src="../Script/Common/huayi.http.js"></script>
  82. <script>
  83. mui.previewImage();
  84. var EnclosureList = []; //保存附件的数组
  85. var uploader; //上传实例
  86. Zepto(function($) {
  87. getCounty(); //获取乡镇或单位地址
  88. getTypeList(); //获取信息分类
  89. uploaderImages(); //上传附件
  90. $('#submit').on('tap', submitHandle);
  91. });
  92. //提交
  93. function submitHandle() {
  94. var telreg = /^\d{3,12}$/;
  95. var that = this;
  96. if(!$.trim($("#h_userName").val())) {
  97. mui.toast("请您输入姓名后再提交");
  98. return;
  99. }
  100. if(!$.trim($("#h_phone").val())) {
  101. mui.toast("请您输入手机号码后再提交");
  102. return;
  103. }
  104. if($.trim($("#h_phone").val())) {
  105. if(!telreg.test($.trim($("#h_phone").val()))) {
  106. mui.toast("请您输入正确手机号码");
  107. return;
  108. }
  109. }
  110. if(!$.trim($("#h_content").val())) {
  111. mui.toast("请您输入反映问题后再提交");
  112. return;
  113. }
  114. $.ajax({
  115. type: "post",
  116. url: huayi.config.callcenter_url + 'WxLogin/AddWorkOrder',
  117. async: true,
  118. beforeSend: function() {
  119. mui(that).button('loading');
  120. },
  121. data: {
  122. openid: helper.cookies.get("openid"), //string 是
  123. cusname: $('#h_userName').val(), //string 是 客户姓名
  124. cusphone: $('#h_phone').val(), // string 是 电话
  125. country: $('#h_county').attr('data-index'), //string 否 乡镇或单位
  126. infotype: $('#h_infoType').val(), //string 否 信息分类
  127. infotypeid: $('#h_infoType').attr('data-index'), //string 否 信息分类
  128. address: $('#h_address').val(), // string 否 住址
  129. content: $('#h_content').val(), // string 是 反映问题
  130. files: EnclosureList && EnclosureList.join(','), // string 否 附件
  131. },
  132. dataType: 'json',
  133. success: function(data) {
  134. mui(that).button('reset');
  135. if(data.state.toLowerCase() == "success") {
  136. mui.alert("提交成功", ' ', function() {
  137. window.location.href = 'WorkList.html';
  138. });
  139. }
  140. },
  141. error: function(textStatus) {
  142. mui(that).button('reset');
  143. mui.toast('网络繁忙,请稍后再试...');
  144. },
  145. complete: function(XMLHttpRequest, textStatus) {
  146. mui(that).button('reset');
  147. if(textStatus == 'timeout') {
  148. var xmlhttp = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHttp");
  149. xmlhttp.abort();
  150. mui.toast('网络超时,请稍后再试...');
  151. }
  152. },
  153. });
  154. }
  155. //获取乡镇或单位
  156. function getCounty() {
  157. $.ajax({
  158. type: "get",
  159. url: huayi.config.callcenter_url + "WxLogin/GetAreaList",
  160. dataType: 'json',
  161. async: true,
  162. data: {
  163. openid: helper.cookies.get("openid"), //string 是
  164. },
  165. success: function(data) {
  166. if(data.state.toLowerCase() == "success") {
  167. var res = data.data;
  168. if(res.length > 0) {
  169. //下拉弹出
  170. (function($, doc) {
  171. $.init();
  172. $.ready(function() {
  173. var t_countyDatas = [{
  174. value: 0,
  175. text: '请选择乡镇或单位'
  176. }];
  177. res.forEach(function(item, index) {
  178. t_countyDatas.push({
  179. value: item.F_DictionaryValueId,
  180. text: item.F_Name
  181. });
  182. });
  183. var countyPicker = new $.PopPicker();
  184. countyPicker.setData(t_countyDatas);
  185. var showCountybtn = doc.getElementById('showCountyPicker');
  186. var countyRes = doc.getElementById('h_county');
  187. showCountybtn.addEventListener('tap', function(event) {
  188. countyPicker.show(function(items) {
  189. countyRes.value = items[0].text;
  190. countyRes.setAttribute("data-index", items[0].value);
  191. });
  192. }, false);
  193. });
  194. })(mui, document);
  195. }
  196. }
  197. }
  198. });
  199. }
  200. //上传附件
  201. function uploaderImages() {
  202. var limitNum = 6; //限制数量
  203. // 优化retina, 在retina下这个值是2
  204. var ratio = window.devicePixelRatio || 1;
  205. // 缩略图大小
  206. var thumbnailWidth = 50 * ratio;
  207. var thumbnailHeight = 50 * ratio;
  208. if(uploader) {
  209. uploader.destroy();
  210. }
  211. uploader = WebUploader.create({
  212. auto: true, // 选完文件后,是否自动上传
  213. swf: '../js/Uploader.swf', // swf文件路径
  214. server: huayi.config.callcenter_url + "WxLogin/UpLoadProcess", // 文件接收服务端
  215. pick: '#filePicker', // 选择文件的按钮。可选
  216. formData: {},
  217. // 只允许选择图片文件。
  218. accept: {
  219. // title: 'Images',
  220. // extensions: 'gif,jpg,jpeg,bmp,png',
  221. // mimeTypes: 'image/*'
  222. },
  223. compress: false, //webuploader默认压缩图片,设置compress:false,可以按照原始比例上传图片
  224. //fileVal: "upFile",//设置文件上传域的name。
  225. threads: limitNum, //上传并发数。允许同时最大上传进程数,为了保证文件上传顺序
  226. fileNumLimit: limitNum,
  227. fileSizeLimit: 120 * 1024 * 1024, // 120 M
  228. fileSingleSizeLimit: 20 * 1024 * 1024 // 20 M
  229. });
  230. uploader.on('fileQueued', function(file) {
  231. var $list = $("#image-list"),
  232. $li = $(
  233. '<div id="' + file.id + '" class="file-item thumbnail">' +
  234. '<div class="image-close">X</div>' +
  235. '<img>' +
  236. '<div class="info">' + file.name + '</div>' +
  237. '</div>'
  238. ),
  239. $img = $li.find('img');
  240. $list.prepend($li);
  241. // 创建缩略图
  242. uploader.makeThumb(file, function(error, src) {
  243. if(error) {
  244. $img.replaceWith('<span class="noThumb mui-icon mui-icon-paperclip"></span>');
  245. return;
  246. }
  247. $img.attr('src', src);
  248. $img.attr('data-preview-src', '');
  249. $img.attr('data-preview-group', "1");
  250. }, thumbnailWidth, thumbnailHeight);
  251. //绑定删除
  252. $('#' + file.id).on('tap', '.image-close', function() {
  253. uploader.removeFile(file);
  254. var $fileLi = $('#' + file.id);
  255. $fileLi.off().find('.image-close').off().end().remove();
  256. var itemFileImgId = $fileLi.attr('data-imgid');
  257. EnclosureList.forEach(function(v, i) {
  258. if(v == itemFileImgId) {
  259. EnclosureList.splice(i, 1);
  260. }
  261. });
  262. $('#fileNum').text(EnclosureList.length + '/' + limitNum);
  263. });
  264. });
  265. // 文件上传过程中创建进度条实时显示。
  266. uploader.on('uploadProgress', function(file, percentage) {
  267. var $li = $('#' + file.id),
  268. $percent = $li.find('.progress span');
  269. // 避免重复创建
  270. if(!$percent.length) {
  271. $percent = $('<div class="progress" style="">' +
  272. '<span class="text">0%</span>' +
  273. '<span class="percentage"></span>' +
  274. '</div>')
  275. .appendTo($li)
  276. .find('span');
  277. }
  278. $percent.eq(0).text(Math.round(percentage * 100) + '%');
  279. $percent.eq(1).css('width', Math.round(percentage * 100) + '%');
  280. $('.hy_loading').remove();
  281. $('body').prepend('<div class="hy_loading" id="hy_loading">' +
  282. '<div class="load_percentage" id="indicatorContainer"></div></div>');
  283. $('#indicatorContainer').radialIndicator({
  284. barColor: '#007aff',
  285. barWidth: 10,
  286. initValue: Math.round(percentage * 100),
  287. roundCorner: true,
  288. percentage: true
  289. });
  290. });
  291. // 文件上传成功,给item添加成功class, 用样式标记上传成功。
  292. uploader.on('uploadSuccess', function(file, res) {
  293. EnclosureList.push(res.data.F_FileId);
  294. $('#' + file.id).attr('data-imgid', res.data.F_FileId);
  295. $('#' + file.id).find('img').attr('src', huayi.config.callcenter_url + res.data.F_FileUrl);
  296. $('#fileNum').text(EnclosureList.length + '/' + limitNum);
  297. $('#' + file.id).addClass('upload-state-done');
  298. $('.hy_loading').remove();
  299. });
  300. // 文件上传失败,显示上传出错。
  301. uploader.on('uploadError', function(file) {
  302. var $li = $('#' + file.id),
  303. $error = $li.find('div.error');
  304. // 避免重复创建
  305. if(!$error.length) {
  306. $error = $('<div class="error"></div>').appendTo($li);
  307. }
  308. $('.hy_loading').remove();
  309. $error.text('上传失败');
  310. });
  311. // 完成上传完了,成功或者失败,先删除进度条。
  312. uploader.on('uploadComplete', function(file) {
  313. $('#' + file.id).find('.progress').remove();
  314. $('.hy_loading').remove();
  315. });
  316. uploader.onError = function(code) {
  317. //console.log('Error:' + code);
  318. switch(code) {
  319. case "Q_EXCEED_NUM_LIMIT":
  320. mui.toast('只能上传六个文件。');
  321. break;
  322. case "Q_TYPE_DENIED":
  323. mui.toast('图片类型不正确。');
  324. break;
  325. case "F_DUPLICATE":
  326. mui.toast('该文件已上传,请选择其它文件。');
  327. break;
  328. case "F_EXCEED_SIZE":
  329. mui.toast('单文件大小不能超过20M。');
  330. break;
  331. case "Q_EXCEED_SIZE_LIMIT":
  332. mui.toast('总文件大小不能超过120M。');
  333. break;
  334. default:
  335. break;
  336. }
  337. };
  338. }
  339. //获取信息分类
  340. function getTypeList() {
  341. $.ajax({
  342. type: "get",
  343. url: huayi.config.callcenter_url + "WxLogin/GetTypeList",
  344. dataType: 'json',
  345. async: true,
  346. data: {
  347. openid: helper.cookies.get("openid"), //string 是
  348. },
  349. success: function(data) {
  350. if(data.state.toLowerCase() == "success") {
  351. var res = data.data;
  352. if(res.length > 0) {
  353. //下拉弹出
  354. (function($, doc) {
  355. $.init();
  356. $.ready(function() {
  357. var t_infoTypeDatas = [{
  358. value: 0,
  359. text: '请选择信息分类'
  360. }];
  361. res.forEach(function(item, index) {
  362. t_infoTypeDatas.push({
  363. value: item.F_DictionaryValueId,
  364. text: item.F_Name
  365. });
  366. });
  367. var infoTypePicker = new $.PopPicker();
  368. infoTypePicker.setData(t_infoTypeDatas);
  369. var showInfoTypebtn = doc.getElementById('showInfoTypePicker');
  370. var infoTypeRes = doc.getElementById('h_infoType');
  371. showInfoTypebtn.addEventListener('tap', function(event) {
  372. infoTypePicker.show(function(items) {
  373. infoTypeRes.value = items[0].text;
  374. infoTypeRes.setAttribute("data-index", items[0].value);
  375. });
  376. }, false);
  377. });
  378. })(mui, document);
  379. }
  380. }
  381. }
  382. });
  383. }
  384. </script>
  385. </body>
  386. </html>