| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 | 
							- var jweixin = require('./jweixin.js');
 
- var serverUrl = "http://wy2.jiliyilian.com/api/h5/";
 
- export default {
 
-     //判断是否在微信中
 
-     isWechat: function() {
 
-         var ua = window.navigator.userAgent.toLowerCase();
 
-         if (ua.match(/micromessenger/i) == 'micromessenger') {
 
-             // console.log('是微信客户端')
 
-             return true;
 
-         } else {
 
-             // console.log('不是微信客户端')
 
-             return false;
 
-         }
 
-     },
 
-     initJssdk:function(callback){
 
- 		var surl = encodeURIComponent(window.location.href); // 当前地址
 
- 		uni.request({
 
- 		    url: serverUrl + 'Oauth/jssdk',
 
- 			data: {url:surl},
 
- 			method: 'POST',
 
- 			header: {
 
- 				'content-type': 'application/x-www-form-urlencoded'
 
- 			},
 
- 		    success: function (res) {
 
- 		        console.log(res)
 
- 		        if(res.data.code == 0) {					
 
- 					jweixin.config({
 
- 					    debug: res.data.data.debug,
 
- 					    appId: res.data.data.appId,
 
- 					    timestamp: res.data.data.timestamp,
 
- 					    nonceStr: res.data.data.nonceStr,
 
- 					    signature: res.data.data.signature,
 
- 					    jsApiList: res.data.data.jsApiList,
 
- 					});
 
- 					//配置完成后,再执行分享等功能
 
- 					if (callback) {
 
- 					    callback(res.data);
 
- 					}
 
- 		        }
 
- 		    },
 
- 			fail: function (err) {
 
- 				console.log(err);
 
- 			}
 
- 		})
 
-     },
 
- 	// 获取微信对象
 
- 	getWx: function(callback) {
 
- 	    if (!this.isWechat()) {
 
- 	        console.log('不是微信客户端')
 
- 	        return;
 
- 	    }
 
- 	
 
- 	    this.initJssdk(function(res) {
 
- 	        jweixin.ready(function() {
 
- 	            callback(jweixin);
 
- 	        });
 
- 	    });
 
- 	},
 
-     //在需要定位页面调用
 
-     location: function(callback) {
 
-         if (!this.isWechat()) {
 
-             console.log('不是微信客户端')
 
-             return;
 
-         }
 
-         this.initJssdk(function(res) {
 
-             jweixin.ready(function() {
 
-                 console.info('定位ready')
 
-                 jweixin.getLocation({
 
-                     type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
 
-                     success: function (res) {
 
-                         console.log(res);
 
-                         callback(res)
 
-                     },
 
-                     fail:function(res){
 
-                         console.log(res)
 
-                     },
 
-                 });
 
-             });
 
-         });
 
-     },
 
- 	
 
- }
 
 
  |