0.微信小程序资料填写及申请
1.域名填写
2.腾讯地图key申请
https://lbs.qq.com/dev/console/key/manage
3.demo实际效果,可以V扫码观看,引流的好案例
4.源码部分代码
var t, a = require("../tpls/package.js"), e = (getApp(), new a.Package()), i = require("../../utils/qqmap-wx-jssdk.min.js");
t = new i({
key: "HJWBZ-7GRKK-R7SJZ-ARZML-WCJT3-1116"
});
var n = null;
Page({
data: {
markers: [],
scale: 8,
marriageList: [],
page: 1,
setPage: 1,
show: 0,
linkData: [],
phoneAd: 1,
mapAd: 1,
bindWho: ""
},
goToCity: function() {
var t = this.data.city;
wx.navigateTo({
url: "../switchcity/switchcity?city=" + t
});
},
closetip: function() {
this.setData({
show: 1
});
},
markertap: function(t) {
var a = t.markerId, e = this.data.markers;
this.setData({
longitude: e[a].longitude,
latitude: e[a].latitude,
scale: 20
});
},
bindcallouttap: function(t) {
var a = t.markerId, e = this.data.markers;
wx.openLocation({
latitude: Number(e[a].latitude),
longitude: Number(e[a].longitude),
name: e[a].name,
address: e[a].title
});
},
jump: function(t) {
var a = e.getDataSet(t, "appid");
wx.navigateToMiniProgram({
appId: a,
extraData: {},
envVersion: "",
success: function(t) {
console.log("跳转成功");
}
});
},
telPhone: function(t) {
wx.showLoading();
var a = e.getDataSet(t, "phone");
this.setData({
phone: a,
bindWho: "phone"
}), 1 == this.data.phoneAd ? ( wx.hideLoading(),
this.setData({
phoneAd: 0
})) : (wx.hideLoading(), wx.makePhoneCall({
phoneNumber: a
}));
},
openLocation: function(t) {
wx.showLoading();
var a = this.data.marriageList, i = e.getDataSet(t, "index");
this.setData({
index: i,
bindWho: "map"
}), 1 == this.data.mapAd ? ( wx.hideLoading(), this.setData({
mapAd: 0
})) : (wx.hideLoading(), wx.openLocation({
latitude: Number(a[i].latitude),
longitude: Number(a[i].longitude),
name: a[i].name,
address: a[i].address
}));
},
onLoad: function(t) {
this._loadData();
},
_loadData: function() {
var t = this;
console.log(333333)
t._getUserLocation(function(a) {
// console.log(a), a && (
console.log(111111111)
t._getVehicleData();
t._getVehicleMap();
console.log(22222222)
// wx.createInterstitialAd && ((n = wx.createInterstitialAd({
// adUnitId: "adunit-e59752a650a496c4"
// })).onLoad(function() {
// console.log("onLoad event emit");
// }), n.onError(function(a) {
// t._judgeAd();
// }), n.onClose(function(a) {
// t._judgeAd();
// }))
// );
});
},
_judgeAd: function() {
var t = this;
wx.showLoading();
var a = t.data.bindWho, e = t.data.phoneAd, i = t.data.mapAd;
if ("phone" == a && 0 == e && (wx.hideLoading(), wx.makePhoneCall({
phoneNumber: t.data.phone
})), "map" == a && 0 == i) {
var n = t.data.marriageList, o = t.data.index;
wx.hideLoading(), wx.openLocation({
latitude: Number(n[o].latitude),
longitude: Number(n[o].longitude),
name: n[o].name,
address: n[o].address
});
}
wx.hideLoading();
},
_getUserLocation: function(t) {
var a = this;
wx.getSetting({
success: function(i) {
console.log(i)
void 0 != i.authSetting["scope.userLocation"] && 1 != i.authSetting["scope.userLocation"] ? wx.showModal({
title: "请求授权当前位置",
content: "需要获取您的地理位置,请确认授权",
success: function(i) {
console.log(i)
i.cancel ? wx.showToast({
title: "拒绝授权",
icon: "none",
duration: 1e3
}) : i.confirm && wx.openSetting({
success: function(i) {
console.log(i)
console.log(1e3)
1 == i.authSetting["scope.userLocation"] ? (e.showToast("授权成功", "success"), setTimeout(function() {
a._goAddress(t);
}, 1e3)) : (e.showToast("授权失败"), t && t(!1));
}
});
},fail:function(e){
console.log(e)
}
}) : (i.authSetting["scope.userLocation"], a._goAddress(t));
}
});
},
_goAddress: function(a) {
var e = this;
wx.getLocation({
type: "wgs84",
success: function(i) {
var n = i.latitude, o = i.longitude;
t.reverseGeocoder({
location: {
latitude: n,
longitude: o
},
success: function(t) {
var i = t.result.ad_info.province, s = t.result.ad_info.city;
e.setData({
province: i,
city: s,
latitude: n,
longitude: o
}), wx.setStorageSync("city", s), a && a(!0);
}
});
}
});
},
_getVehicleData: function(t) {
var a = this, i = {};
i.city = a.data.city, i.lng = a.data.longitude, i.lat = a.data.latitude, i.page = a.data.page,
e.getVehicleList(i, function(e) {
var i = a.data.marriageList;
a.setData({
marriageList: i.concat(e.data),
show: 0
}), t && t(!0);
});
},
_getVehicleMap: function() {
var t = this, a = {};
a.city = t.data.city, e.getVehicleMap(a, function(a) {
t.setData({
markers: a.makers,
sum: a.sum
});
});
},
onReady: function() {},
onShow: function() {
var a = this;
2 == a.data.setPage && t.geocoder({
address: a.data.city,
success: function(t) {
0 == t.status && (a.setData({
longitude: t.result.location.lng,
latitude: t.result.location.lat,
marriageList: [],
page: 1,
setPage: 1,
scale: 8
}), a._getVehicleData(), a._getVehicleMap());
}
}), e.getBasic(function(t) {
var i = {};
i.appid = "wx07e9c864ea30371a", i.label = t.gao_label, e.getLinkData(i, function(e) {
a.setData({
swit: t.swit,
linkData: e,
phoneAd: 1,
mapAd: 1
});
});
});
},
onHide: function() {},
onUnload: function() {},
onPullDownRefresh: function() {
wx.stopPullDownRefresh();
},
onReachBottom: function() {
var t = this;
t.data.marriageList.length >= 5 * t.data.page && (wx.showLoading({
title: "加载中"
}), t.setData({
page: 1 * t.data.page + 1
}), t._getVehicleData(function(t) {
wx.hideLoading();
}));
},
onShareAppMessage: function(t) {
var a = {
title: "婚姻登记处查询",
path: "",
imageUrl: "/images/share.png",
success: function(t) {
"shareAppMessage:ok" == t.errMsg && console.log("分享成功");
}
};
return "button" == t.from && console.log("点击分享"), a;
}
});