<script type="text/javascript">
wx.config({
debug: false,
appId: '微信ID',
timestamp: '<%=wxconfig.timestamp%>',
nonceStr: '<%=wxconfig.nonceStr%>',
signature: '<%=wxconfig.signature%>',
jsApiList: [
'updateAppMessageShareData', 'updateTimelineShareData', ' onMenuShareWeibo', 'onMenuShareQZone', 'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'playVoice', 'pauseVoice', 'stopVoice', 'onVoicePlayEnd', 'uploadVoice', 'downloadVoice', 'chooseImage', 'previewImage', 'uploadImage', 'downloadImage', 'translateVoice', 'getNetworkType', 'openLocation', 'getLocation', 'hideOptionMenu', 'showOptionMenu', 'hideMenuItems', 'showMenuItems', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem', 'closeWindow', 'scanQRCode', 'chooseWXPay', 'openProductSpecificView', 'addCard', 'chooseCard', 'openCard'
]
});
wx.error(function (res) {
alert("报错:" + res);
});
wx.ready(function () {
wx.checkJsApi({
jsApiList: ['checkJsApi', 'chooseImage', 'updateAppMessageShareData', 'updateTimelineShareData', "scanQRCode", 'onMenuShareAppMessage'], // 需要检测的JS接口列表,所有JS接口列表见附录2,
success: function (res) {
// 以键值对的形式返回,可用的api值true,不可用为false
// 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
$("#xianshi").html(JSON.stringify(res));
}
});
wx.updateAppMessageShareData({
title: '', // 分享标题
desc: '', // 分享描述
link: '', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl: '', // 分享图标
success: function () {
// 设置成功
}
});
wx.updateTimelineShareData({
title: '', // 分享标题
link: '', // 分享链接
imgUrl: '', // 分享图标
success: function () {
// 设置成功
}
});
wx.getLocation({
success: function (res) {
//alert(JSON.stringify(res));
var latitude = res.latitude;
var longitude = res.longitude;
$.ajax({
type: "post",
url: "Ajaxindex.aspx",
data: "longitude=" + longitude + "&latitude=" + latitude,
success: function (msg) {
}
});
},
cancel: function (res) {
alert('用户拒绝授权获取地理位置');
}
});
});
</script>
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Form["longitude"] != null && Request.Form["latitude"] != null)
{
string a = HttpService.Get("https://apis.map.qq.com/ws/geocoder/v1/?location=" + Request.Form["latitude"] + "," + Request.Form["longitude"] + "&key=***********&get_poi=1");
JavaScriptSerializer jss = new JavaScriptSerializer();
json_JS json_JS = new json_JS();
json_JS = jss.Deserialize<json_JS>(a);
User_bll.Update_User("field3='" + Request.Form["longitude"] + "',field4='" + Request.Form["latitude"] + "',field5='" + json_JS.result.address + "',field6='" + json_JS.result.address_component.province + "',field7='" + json_JS.result.address_component.city + "',field8='" + json_JS.result.address_component.district + "',field9='" + json_JS.result.address_component.street + "',field10='" + json_JS.result.address_component.street_number + "'", " and id=" + User.id);
// log4net.ILog logger = WxV3.Helper.LogHelper.GetInstance().Log;
// logger.Info(a);
}
else
{
Response.Write(" 提示:请选择要删除的行 ");
}
Response.End();
}
public class json_JS
{
public dizhi result { get; set; }//
}
public class dizhi
{
public string address { get; set; }//
public xiangxi address_component { get; set; }//
}
public class xiangxi
{
public string province { get; set; }//
public string city { get; set; }//
public string district { get; set; }//
public string street { get; set; }//
public string street_number { get; set; }//
}