Browse Source

添加上传图片api

lulihong 5 years ago
parent
commit
71d2d56305
2 changed files with 60 additions and 11 deletions
  1. 59 11
      html/qygl/js/consulting-doctor.js
  2. 1 0
      html/qygl/js/sign_info.js

+ 59 - 11
html/qygl/js/consulting-doctor.js

@ -50,7 +50,7 @@ var request = GetRequest();
patientcode = request.patientcode;
var patientName = "";
var networkStatus = "";
var consulting = {
    //初始化页面
    getInfo: function(){
@ -95,7 +95,53 @@ var consulting = {
//      var userAgent1 = JSON.parse(window.localStorage.getItem(agentName1));
//      patientName = userAgent1.name;
    },
    bindEvents: bindConsultEvents
    bindEvents: bindConsultEvents,
    getWeixinSign:function(){
    	//从后台那边获取签名等信息
	    var params = {};
	    var url1 = window.location.href;
	    params.pageUrl = url1;
	    $.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({
	                    appId: appId, // 必填,公众号的唯一标识
	                    timestamp: t, // 必填,生成签名的时间戳
	                    nonceStr: noncestr, // 必填,生成签名的随机串
	                    signature: signature,// 必填,签名,见附录1
	                    jsApiList: [
	                        'chooseImage',
	                        'uploadImage',
	                        'startRecord',
	                        'stopRecord',
	                        'onVoiceRecordEnd',
	                        'playVoice',
	                        'pauseVoice',
	                        'stopVoice',
	                        'onVoicePlayEnd',
	                        'uploadVoice',
	                        'getNetworkType'
	                    ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
	                });
	                
	                // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
	                wx.ready(function(){
	                    wx.getNetworkType({
	                        success: function (res) {
	                             networkStatus = res.networkType; // 返回网络类型2g,3g,4g,wifi
	                        }
	                    });
	                });
	            } 
	        }
	    });
    }
};
//请求回调处理
@ -621,15 +667,17 @@ function viewImg(dom) {
//微信上传图片
function chooseImageWx(){
//  dd.showModal();
    wx.chooseImage({
        count: 1, //限制一次只能上传一张图片
        success: function (res) {
            for (var i in res.localIds) {
                images.push(res.localIds[i]);
            }
            uploadImage();
        }
    });
	wx.ready(function(){ 
	    wx.chooseImage({
	        count: 1, //限制一次只能上传一张图片
	        success: function (res) {
	            for (var i in res.localIds) {
	                images.push(res.localIds[i]);
	            }
	            uploadImage();
	        }
	    });
  })
}
function uploadImage(){
    dd.showModal();

+ 1 - 0
html/qygl/js/sign_info.js

@ -91,6 +91,7 @@ function getWxSign(){
}
function getFirstTabValue(){
	consulting.getWeixinSign();
    consulting.getInfo();
    consulting.bindEvents();
}