love.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. const app = require('../../utils/util.js');
  2. var util = require('../../utils/md5.js')
  3. var QQMapWX = require('../../libs/qqmap-wx-jssdk.min.js');
  4. Page({
  5. data: {
  6. time: '',
  7. lng: '', // 经度
  8. lat: '', // 纬度
  9. visitLocation: '',
  10. info: '', //老人锕
  11. },
  12. oldClick(e) {
  13. let fid = e.currentTarget.dataset.infos.fid;
  14. let name = e.currentTarget.dataset.infos.name;
  15. const app = getApp()
  16. app.globalData.id = fid
  17. app.globalData.name = name
  18. wx.switchTab({
  19. url: `/pages/collectInfo/collectInfo`,
  20. success: function (e) {
  21. var page = getCurrentPages().pop();
  22. if (page == undefined || page == null) return;
  23. page.onLoad();
  24. }
  25. })
  26. },
  27. time() {
  28. var timestamp = Date.parse(new Date());
  29. var date = new Date(timestamp);
  30. //获取年份  
  31. var Y = date.getFullYear();
  32. //获取月份  
  33. var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
  34. //获取当日日期 
  35. var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
  36. this.setData({
  37. time: Y + '-' + M + '-' + D
  38. })
  39. },
  40. //获取位置
  41. getSelfLocation: function (varSendOrgId) {
  42. // 实例化API核心类
  43. var qqmapsdk = new QQMapWX({
  44. key: 'B5DBZ-NGIHP-SQMD4-LHMG3-NJ72Z-7KFOV' //申请的开发者秘钥key
  45. });
  46. var that = this; //用户授权过可以直接获取位置
  47. wx.getLocation({
  48. //type: 'wgs84',
  49. type: 'gcj02',
  50. success: function (res) {
  51. console.log(res, "0000000");
  52. var latitude = res.latitude;
  53. var longitude = res.longitude;
  54. that.setData({
  55. lng: longitude, //经度
  56. lat: latitude, //纬度
  57. });
  58. // 调用sdk接口
  59. qqmapsdk.reverseGeocoder({
  60. location: {
  61. latitude: res.latitude,
  62. longitude: res.longitude
  63. },
  64. success: function (res) {
  65. //获取当前地址成功
  66. console.log(res, "为是都是都是");
  67. that.setData({
  68. visitLocation: res.result.address
  69. })
  70. },
  71. fail: function (res) {
  72. console.log('获取当前地址失败');
  73. }
  74. });
  75. },
  76. fail: function (res) {
  77. }
  78. });
  79. },
  80. // 获取老人详情
  81. oldsInfo(id) {
  82. wx.request({
  83. url: app.globalData.publicUrl + '/info/one',
  84. method: "GET",
  85. header: {
  86. appletsId: wx.getStorageSync('openId')
  87. },
  88. data: {
  89. id: id
  90. },
  91. success: (res) => {
  92. console.log(res, "777777");
  93. if (res.data.code == 0) {
  94. this.setData({
  95. info: res.data.data
  96. })
  97. } else {
  98. wx.showModal({
  99. showCancel: false,
  100. content: '查询失败,当前二维码过期或失效',
  101. success() {
  102. wx.switchTab({
  103. url: '/pages/index/index',
  104. })
  105. }
  106. })
  107. }
  108. }
  109. })
  110. },
  111. onLoad: function (opotions) {
  112. this.time();
  113. this.getSelfLocation();
  114. this.oldsInfo(opotions.id);
  115. },
  116. })