| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329 |
- <!DOCTYPE html>
- <html lang="zh-CN" class="feedback">
- <head>
- <meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
- <meta http-equiv="X-UA-Compatible" content="ie=edge" />
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black">
- <title>工单创建</title>
- <link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
- <link rel="stylesheet" type="text/css" href="../css/app.css" />
- <link rel="stylesheet" type="text/css" href="../css/mui.picker.min.css" />
- <link rel="stylesheet" type="text/css" href="../css/feedback-page.css" />
- <link rel="stylesheet" href="../css/webuploader.css" />
- <link rel="stylesheet" type="text/css" href="../css/Common.css" />
- </head>
- <body>
- <div class="mui-card">
- <div class="mui-card-header">基本信息</div>
- <form class="mui-input-group">
- <div class="mui-input-row">
- <label for="h_userName">姓名:</label>
- <input type="text" class="mui-input-clear" id="h_userName" placeholder="请输入姓名">
- </div>
- <div class="mui-input-row">
- <label for="h_phone">电话:</label>
- <input type="text" class="mui-input-clear" id="h_phone" placeholder="请输入电话">
- </div>
- <div id="showCountyPicker">
- <div class="mui-input-row">
- <label class="label" for="h_county">乡镇:</label>
- <input type="text" id="h_county" class="ui-alert type_con" placeholder="请选择乡镇" data-index="">
- <a><span class="type_down mui-icon mui-icon-arrowdown mui-pull-right"></span></a>
- </div>
- </div>
- <div class="mui-input-row">
- <label for="h_address">地址:</label>
- <input type="text" class="mui-input-clear" id="h_address" placeholder="请输入地址">
- </div>
- <div class="mui-input-row h_content">
- <label for="h_content">反映问题:</label>
- <textarea id="h_content" class="mui-input-clear question" placeholder="请详细描述您要反映的问题..."></textarea>
- </div>
- </form>
- </div>
- <div class="mui-card">
- <div class="mui-card-header">
- 附件
- <span id="fileNum">0/6</span>
- </div>
- <div class="row image-list" id="image-list">
- <div id="filePicker"></div>
- </div>
- </div>
- <div class="mui-button-row" id="Btns-box">
- <button type="button" data-loading-text="提交中" id="submit" class="mui-btn mui-btn-primary" onclick="return false;">提交</button>
- </div>
- <script src="../js/jquery.min.js"></script>
- <script src="../js/zepto.js"></script>
- <script src="../js/mui.min.js"></script>
- <script src="../js/mui.zoom.js"></script>
- <script src="../js/mui.previewimage.js"></script>
- <script src="../js/mui.picker.min.js"></script>
- <script src="../js/mui.poppicker.js"></script>
- <script src="../js/webuploader.min.js"></script>
- <script src="../Script/Common/huayi.config.js"></script>
- <script src="../Script/Common/huayi.http.js"></script>
- <script>
- mui.previewImage();
- var EnclosureList = []; //保存附件的数组
- var uploader; //上传实例
- Zepto(function($) {
- getCounty(); //获取乡镇地址
- uploaderImages();//上传附件
- $('#submit').on('tap', submitHandle);
- });
- //提交
- function submitHandle() {
- var telreg = /^\d{3,12}$/;
- var that = this;
- if(!$.trim($("#h_userName").val())) {
- mui.toast("请您输入姓名后再提交");
- return;
- }
- if(!$.trim($("#h_phone").val())) {
- mui.toast("请您输入手机号码后再提交");
- return;
- }
- if($.trim($("#h_phone").val())) {
- if(!telreg.test($.trim($("#h_phone").val()))) {
- mui.toast("请您输入正确手机号码");
- return;
- }
- }
- if(!$.trim($("#h_content").val())) {
- mui.toast("请您输入反映问题后再提交");
- return;
- }
- $.ajax({
- type: "post",
- url: huayi.config.callcenter_url + 'WxLogin/AddWorkOrder',
- async: true,
- beforeSend: function() {
- mui(that).button('loading');
- },
- data: {
- openid: helper.cookies.get("openid"),//string 是
- cusname: $('#h_userName').val(), //string 是 客户姓名
- cusphone: $('#h_phone').val(), // string 是 电话
- country: $('#h_county').attr('data-index'), //string 否 乡镇
- address: $('#h_address').val(), // string 否 住址
- content: $('#h_content').val(), // string 是 反映问题
- files: EnclosureList && EnclosureList.join(','), // string 否 附件
- },
- dataType: 'json',
- success: function(data) {
- mui(that).button('reset');
- if(data.state.toLowerCase() == "success") {
- mui.alert("提交成功", ' ', function() {
- window.location.href = 'WorkList.html';
- });
- }
- },
- error: function(textStatus) {
- mui(that).button('reset');
- mui.toast('网络繁忙,请稍后再试...');
- },
- complete: function(XMLHttpRequest, textStatus) {
- mui(that).button('reset');
- if(textStatus == 'timeout') {
- var xmlhttp = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHttp");
- xmlhttp.abort();
- mui.toast('网络超时,请稍后再试...');
- }
- },
- });
- }
- //获取乡镇
- function getCounty() {
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + "WxLogin/GetAreaList",
- dataType: 'json',
- async: true,
- data: {
- openid: helper.cookies.get("openid"),//string 是
- },
- success: function(data) {
- if(data.state.toLowerCase() == "success") {
- var res = data.data;
- if(res.length > 0) {
- //下拉弹出
- (function($, doc) {
- $.init();
- $.ready(function() {
- var t_countyDatas = [];
- res.forEach(function(item, index) {
- t_countyDatas.push({
- value: item.F_DictionaryValueId,
- text: item.F_Name
- });
- });
- var countyPicker = new $.PopPicker();
- countyPicker.setData(t_countyDatas);
- var showCountybtn = doc.getElementById('showCountyPicker');
- var countyRes = doc.getElementById('h_county');
- showCountybtn.addEventListener('tap', function(event) {
- countyPicker.show(function(items) {
- countyRes.value = items[0].text;
- countyRes.setAttribute("data-index", items[0].value);
- });
- }, false);
- });
- })(mui, document);
- }
- }
- }
- });
- }
- //上传附件
- function uploaderImages() {
- var limitNum = 6; //限制数量
- // 优化retina, 在retina下这个值是2
- var ratio = window.devicePixelRatio || 1;
- // 缩略图大小
- var thumbnailWidth = 50 * ratio;
- var thumbnailHeight = 50 * ratio;
- if(uploader) {
- uploader.destroy();
- }
- uploader = WebUploader.create({
- auto: true, // 选完文件后,是否自动上传
- swf: '../js/Uploader.swf', // swf文件路径
- server: huayi.config.callcenter_url + "WxLogin/UpLoadProcess", // 文件接收服务端
- pick: '#filePicker', // 选择文件的按钮。可选
- formData: {},
- // 只允许选择图片文件。
- accept: {
- // title: 'Images',
- // extensions: 'gif,jpg,jpeg,bmp,png',
- // mimeTypes: 'image/*'
- },
- compress: false, //webuploader默认压缩图片,设置compress:false,可以按照原始比例上传图片
- //fileVal: "upFile",//设置文件上传域的name。
- threads: limitNum, //上传并发数。允许同时最大上传进程数,为了保证文件上传顺序
- fileNumLimit: limitNum,
- fileSizeLimit: 300 * 1024 * 1024, // 300 M
- fileSingleSizeLimit: 50 * 1024 * 1024 // 50 M
- });
- uploader.on('fileQueued', function(file) {
- var $list = $("#image-list"),
- $li = $(
- '<div id="' + file.id + '" class="file-item thumbnail">' +
- '<div class="image-close">X</div>' +
- '<img>' +
- '<div class="info">' + file.name + '</div>' +
- '</div>'
- ),
- $img = $li.find('img');
- $list.prepend($li);
- // 创建缩略图
- uploader.makeThumb(file, function(error, src) {
- if(error) {
- $img.replaceWith('<span class="noThumb mui-icon mui-icon-paperclip"></span>');
- return;
- }
- $img.attr('src', src);
- $img.attr('data-preview-src', '');
- $img.attr('data-preview-group', "1");
- }, thumbnailWidth, thumbnailHeight);
- //绑定删除
- $('#' + file.id).on('tap', '.image-close', function() {
- uploader.removeFile(file);
- var $fileLi = $('#' + file.id);
- $fileLi.off().find('.image-close').off().end().remove();
- var itemFileImgId = $fileLi.attr('data-imgid');
- EnclosureList.forEach(function(v, i) {
- if(v == itemFileImgId) {
- EnclosureList.splice(i, 1);
- }
- });
- $('#fileNum').text(EnclosureList.length + '/' + limitNum);
- });
- });
- // 文件上传过程中创建进度条实时显示。
- uploader.on('uploadProgress', function(file, percentage) {
- var $li = $('#' + file.id),
- $percent = $li.find('.progress span');
- // 避免重复创建
- if(!$percent.length) {
- $percent = $('<div class="progress" style="">' +
- '<span class="text">0%</span>' +
- '<span class="percentage"></span>' +
- '</div>')
- .appendTo($li)
- .find('span');
- }
- $percent.eq(0).text(Math.round(percentage * 100) + '%');
- $percent.eq(1).css('width', Math.round(percentage * 100) + '%');
- });
- // 文件上传成功,给item添加成功class, 用样式标记上传成功。
- uploader.on('uploadSuccess', function(file, res) {
- EnclosureList.push(res.data);
- $('#' + file.id).attr('data-imgid', res.data);
- $('#fileNum').text(EnclosureList.length + '/' + limitNum);
- $('#' + file.id).addClass('upload-state-done');
- });
- // 文件上传失败,显示上传出错。
- uploader.on('uploadError', function(file) {
- var $li = $('#' + file.id),
- $error = $li.find('div.error');
- // 避免重复创建
- if(!$error.length) {
- $error = $('<div class="error"></div>').appendTo($li);
- }
- $error.text('上传失败');
- });
- // 完成上传完了,成功或者失败,先删除进度条。
- uploader.on('uploadComplete', function(file) {
- $('#' + file.id).find('.progress').remove();
- });
- uploader.onError = function(code) {
- //console.log('Error:' + code);
- switch(code) {
- case "Q_EXCEED_NUM_LIMIT":
- mui.toast('只能上传六个文件。');
- break;
- case "Q_TYPE_DENIED":
- mui.toast('图片类型不正确。');
- break;
- case "F_DUPLICATE":
- mui.toast('该文件已上传,请选择其它文件。');
- break;
- case "F_EXCEED_SIZE":
- mui.toast('文件大小不能超过5M。');
- break;
- default:
- break;
- }
- };
- }
- </script>
- </body>
- </html>
|