index.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. const app = getApp()
  2. var util = require("../../utils/util.js")
  3. Page({
  4. data: {
  5. duration: 500,
  6. latitude: undefined,
  7. longitude: undefined,
  8. name: undefined,
  9. address: undefined,
  10. arr: [],
  11. mktarr: [],
  12. mktList: [
  13. "https://api.zhumi.tech/MiniProgram/mkt/mkt1.png",
  14. "https://api.zhumi.tech/MiniProgram/mkt/mkt2.png",
  15. "https://api.zhumi.tech/MiniProgram/mkt/mkt3.png",
  16. "https://api.zhumi.tech/MiniProgram/mkt/mkt4.png",
  17. "https://api.zhumi.tech/MiniProgram/mkt/mkt5.png",
  18. "https://api.zhumi.tech/MiniProgram/mkt/mkt6.png",
  19. "https://api.zhumi.tech/MiniProgram/mkt/mkt7.png"
  20. ],
  21. mktImgage: "https://api.zhumi.tech/MiniProgram/mkt/mkt1.png",
  22. },
  23. onLoad: function(options) {
  24. this.init(options)
  25. },
  26. init(options) {
  27. var that = this
  28. util.getData('/getBanners')
  29. .then(res => {
  30. that.setData({
  31. arr: res
  32. })
  33. })
  34. that.setData({
  35. navH: app.globalData.navHeight
  36. })
  37. util.getData('/getMktInfos',{
  38. mi_branche_code: 110000
  39. }).then(res => {
  40. that.setData({
  41. mktarr: res
  42. })
  43. })
  44. that.setData({
  45. navH: app.globalData.navHeight
  46. })
  47. },
  48. mktImageChange: function(e) {
  49. this.setData({
  50. mktImgage: e.currentTarget.dataset.path
  51. })
  52. },
  53. //点击轮播图
  54. BhrefPm: function(e) {
  55. var index = e.currentTarget.dataset.index;
  56. if (index != null) {
  57. if (e.currentTarget.dataset.type == 1) {
  58. wx.navigateTo({
  59. url: '/pages/promotion/promotionhref?para=' + index
  60. })
  61. }
  62. if (e.currentTarget.dataset.type == 2) {
  63. wx.navigateTo({
  64. url: index
  65. })
  66. }
  67. }
  68. },
  69. onShareAppMessage: function() {
  70. return {
  71. title: '科技强国梦 编程向未来',
  72. path: '/pages/index/index?id=888'
  73. }
  74. },
  75. // map
  76. markertap: function(e) {
  77. wx.getLocation({
  78. type: 'gcj02', //返回可以用于wx.openLocation的经纬度
  79. success: function(res) {
  80. var latitude = e.currentTarget.dataset.latitude
  81. var longitude = e.currentTarget.dataset.longitude
  82. wx.openLocation({ //出发wx.openLocation API
  83. latitude: Number(latitude), //坐标纬度(从地图获取坐标)
  84. longitude: Number(longitude), //坐标经度(从地图获取坐标)
  85. name: e.currentTarget.dataset.name, //打开后显示的地址名称
  86. address: e.currentTarget.dataset.address, //打开后显示的地址汉字
  87. scale: 17
  88. })
  89. }
  90. })
  91. },
  92. })