怎么将这段代码封装成一个promise函数
目标是确保调用此函数judgelocation后可以使用then确保locationavailable(页变量)的值已经被改变,可以被后续代码使用
wx.getLocation({
type: 'wgs84',
isHighAccuracy: true,
highAccuracyExpireTime: 3000,
success: function (res) {
var latitude = res.latitude
var longitude = res.longitude
var horizontalAccuracy = res.horizontalAccuracy
if ((latitude-horizontalAccuracy*0.00000899<latitudemin)&&(latitude+horizontalAccuracy*0.00000899>latitudemin)&&(longitude-horizontalAccuracy*0.00001141<longitudemin)&&(longitude+horizontalAccuracy*0.00001141>longitudemax)){
locationavailabe: true;
} else {
console.log(phone,res.latitude,res.longtitude,res.horizontalAccuracy);
}
},
resolve(locationavailabe);
})