123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- const app = require('../../utils/util.js');
- var util = require('../../utils/md5.js')
- var QQMapWX = require('../../libs/qqmap-wx-jssdk.min.js');
- Page({
- data: {
- time: '',
- lng: '', // 经度
- lat: '', // 纬度
- visitLocation: '',
- info: '', //老人锕
- },
- oldClick(e) {
- let fid = e.currentTarget.dataset.infos.fid;
- let name = e.currentTarget.dataset.infos.name;
- const app = getApp()
- app.globalData.id = fid
- app.globalData.name = name
- wx.switchTab({
- url: `/pages/collectInfo/collectInfo`,
- success: function (e) {
- var page = getCurrentPages().pop();
- if (page == undefined || page == null) return;
- page.onLoad();
- }
- })
- },
- time() {
- var timestamp = Date.parse(new Date());
- var date = new Date(timestamp);
- //获取年份
- var Y = date.getFullYear();
- //获取月份
- var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
- //获取当日日期
- var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
- this.setData({
- time: Y + '-' + M + '-' + D
- })
- },
- //获取位置
- getSelfLocation: function (varSendOrgId) {
- // 实例化API核心类
- var qqmapsdk = new QQMapWX({
- key: 'B5DBZ-NGIHP-SQMD4-LHMG3-NJ72Z-7KFOV' //申请的开发者秘钥key
- });
- var that = this; //用户授权过可以直接获取位置
- wx.getLocation({
- //type: 'wgs84',
- type: 'gcj02',
- success: function (res) {
- console.log(res, "0000000");
- var latitude = res.latitude;
- var longitude = res.longitude;
- that.setData({
- lng: longitude, //经度
- lat: latitude, //纬度
- });
- // 调用sdk接口
- qqmapsdk.reverseGeocoder({
- location: {
- latitude: res.latitude,
- longitude: res.longitude
- },
- success: function (res) {
- //获取当前地址成功
- console.log(res, "为是都是都是");
- that.setData({
- visitLocation: res.result.address
- })
- },
- fail: function (res) {
- console.log('获取当前地址失败');
- }
- });
- },
- fail: function (res) {
- }
- });
- },
- // 获取老人详情
- oldsInfo(id) {
- wx.request({
- url: app.globalData.publicUrl + '/info/one',
- method: "GET",
- header: {
- appletsId: wx.getStorageSync('openId')
- },
- data: {
- id: id
- },
- success: (res) => {
- console.log(res, "777777");
- if (res.data.code == 0) {
- this.setData({
- info: res.data.data
- })
- } else {
- wx.showModal({
- showCancel: false,
- content: '查询失败,当前二维码过期或失效',
- success() {
- wx.switchTab({
- url: '/pages/index/index',
- })
- }
- })
- }
- }
- })
- },
- onLoad: function (opotions) {
- this.time();
- this.getSelfLocation();
- this.oldsInfo(opotions.id);
- },
- })
|