|
RT 我将外卖案例打包吧weixin.config.xml下的参数配置成我自己的在我自己的微信公众号菜单指向了我部署的外卖案例 然后从微信公众内确实能够进入但是无法正常判断出当前是微信内的运行环境 我把APP在真机进行安装 运行一切正常 这个是什么问题导致的啊
var self = this;
// 获取url上的code参数 - 微信授权code,用于获取微信用户信息
var weixinCode = this.getContext().getRequestParameter("code");
alert(weixinCode)
// 判断运行环境是否在X5移动客户端中,如果在移动客户端中,则当deviceready后取手机设备uuid作为用户唯一标识
// 判断使用app运行
if (justep.Browser.isX5App) {
this._deviceType = "app";
CommonUtils.attachDoubleClickExitApp(function() {
if (self.comp('contents').getActiveIndex() === 0) {
return true;
}
return false;
});
document.addEventListener("deviceready", function() {
self._userID = window.device.uuid;
self._userDefaultName = "新用户(来自X5APP的用户)";
}, false);
} else if (weixinCode !== "") {
this._deviceType = "wx";
// 判断微信环境
if (justep.Browser.isWeChat) {
this.wxApi = new navigator.WxApi("wx3fb4a0dd8ea0730c");
}
Baas.sendRequest({
"url" : "/weixin/weixin",
"action" : "userinfo",
"async" : false,
"params" : {
code : weixinCode
},
"success" : function(weixinUser) {
self._userID = weixinUser.openid;
// 微信名称**********
self._userDefaultName = weixinUser.nickname + "(来自微信的用户)";
self._userDefaultAddress = weixinUser.country + weixinUser.province + weixinUser.city;
self._userPhotoURL = weixinUser.headimgurl;
}
});
}
this.comp('userData').filters.setVar("user", this._userID);
this.comp('orderData').filters.setVar("user", this._userID);
this.initPayData();
// this.queryAddr();
标红的代码应该是判断当前运行环境是否是微信的 但是他不管在app weixin 网页 都是空的 什么原因导致的呢? |
|