var selectType = '', suggestContent = '', teleContent = '', serverId = "",//储存上传后图片地址 $action_btn = $("#action_btn"); var d = dialog({contentType:'load', skin:'bk-popup'}); var dd = dialog({contentType:'load', skin:'bk-popup', content:'提交中...'}); var userAgent = window.localStorage.getItem(agentName); var pagetype=34; $(function(){ checkUserAgent(); //从后台那边获取签名等信息 var params = {}; params.pageUrl = window.location.href; $.ajax(server + "weixin/getSign", { data: params, dataType: "json", type: "post", success: function(res){ if (res.status == 200) { var t = res.data.timestamp; var noncestr = res.data.noncestr; var signature = res.data.signature; wx.config({ // debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: appId, // 必填,公众号的唯一标识 timestamp: t, // 必填,生成签名的时间戳 nonceStr: noncestr, // 必填,生成签名的随机串 signature: signature,// 必填,签名,见附录1 jsApiList: [ 'chooseImage', 'uploadImage' ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 }); } else{ // dialog({ // title:'提示', // skin:"ui-dialog ax-popup pror", // content:"获取微信签名失败", // ok: function (){} // }).showModal(); console.log("获取微信签名失败"); } } }); }) //重写判断用户是否登录 function checkUserAgent(){ var userAgent = window.localStorage.getItem(agentName); if(!userAgent){ var agentOpenid = window.localStorage.getItem(OpenidAgent); if(!agentOpenid){ var Request = new Object(); Request = GetRequest(); var code = Request["code"]; if(code == "" || code == null || code == undefined){ d.close(); dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'授权失败'}).show(); } else{ d.show(); var data = {}; data.code = code; sendPost('weixin/getOpenidByCode', data, 'json', 'post', openidFailed, openidSuccess); } } else{ var jsonstr = $.parseJSON(agentOpenid); var openid = jsonstr.openid; window.location.href = server + "wx/html/home/html/login.html?type=" + pagetype + "&openid=" + openid; } } } function chooseImage(){ wx.chooseImage({ count: 3-getImages().length, success: function (res) { for (var i in res.localIds) { appendFile(res.localIds[i]); } } }); } function uploadImage(){ var images = getImages(); if (images.length == 0) { return; } var i = 0, length = images.length; serverId = ""; function upload() { wx.uploadImage({ localId: images[i], isShowProgressTips: 0, success: function (res) { i++; if(serverId.length == 0){ serverId = res.serverId; } else{ serverId =serverId + "," + res.serverId; } if (i < length) { upload(); } if(i == length){ doSubmit(); } }, fail: function (res) { dd.close(); alert(JSON.stringify(res)); } }); } upload(); } // 添加文件 function appendFile(p) { var amount = getImages().length; if (amount >= 2) { $("#add_img_li").hide(); } if(amount < 3){ var $li = $('