storedetail.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. var app = getApp();
  2. var util = require("../../utils/util.js");
  3. let wxParse = require("../../wxParse/wxParse.js");
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. obj: {},
  10. appAssetsUrl2: app.appAssetsUrl2,
  11. content: "",
  12. covers: [
  13. {
  14. id: 1,
  15. latitude: "",
  16. longitude: "",
  17. },
  18. ],
  19. latitude: null,
  20. longitude: null,
  21. imglist: [],
  22. current: 0,
  23. lon: null,
  24. lat: null
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. // this.setData({
  31. // expertId: options.expertId,
  32. // meetId: options.meetId,
  33. // })
  34. this.getStore(options.lon, options.lat);
  35. this.getDetail(options.id);
  36. },
  37. ok() {
  38. wx.switchTab({
  39. url: "/pages/home/index/index",
  40. });
  41. },
  42. changeSwiper(e) {
  43. let { current, source } = e.detail;
  44. if (source === "autoplay" || source === "touch") {
  45. this.setData({
  46. current: current,
  47. });
  48. }
  49. // this.setData({
  50. // current: e.detail.current
  51. // })
  52. },
  53. getStore(lon, lat) {
  54. let that = this
  55. app._get(
  56. "store/storeRecommendation",
  57. {
  58. lon: lon,
  59. lat: lat,
  60. },
  61. function (res) {
  62. if (res.code == 0 && res.data) {
  63. let val = res.data.calculateNew / 1000;
  64. let formatVal = parseInt(val*10)
  65. that.setData({
  66. // shopObj: res.data,
  67. calculateNew: formatVal/10,
  68. });
  69. }
  70. }
  71. );
  72. },
  73. getDetail(id) {
  74. let that = this;
  75. app._get("store/info/" + id, {}, function (res) {
  76. let val = res.store.calculateNew / 1000;
  77. let [latitude, longitude] = [
  78. res.store.coordinate.split(",")[1],
  79. res.store.coordinate.split(",")[0],
  80. ];
  81. if (res.code == 0) {
  82. that.setData({
  83. obj: res.store,
  84. "obj.calculateNew": val.toFixed(1),
  85. imglist: res.store.storePhoto.split(","),
  86. latitude,
  87. longitude,
  88. covers: [
  89. {
  90. id: 1,
  91. latitude: latitude,
  92. longitude: longitude,
  93. },
  94. ],
  95. });
  96. wxParse.wxParse("content", "html", res.store.introduce, that, 0);
  97. }
  98. });
  99. },
  100. // 查看地图
  101. goLocal() {
  102. let that = this;
  103. let [latitude, longitude] = [
  104. this.data.obj.coordinate.split(",")[0],
  105. this.data.obj.coordinate.split(",")[1],
  106. ];
  107. // console.log(Number(latitude),Number(longitude))
  108. wx.openLocation({
  109. latitude: Number(longitude),
  110. longitude: Number(latitude),
  111. name: that.data.obj.name,
  112. address: that.data.obj.address,
  113. success: function () {
  114. // console.log("success");
  115. },
  116. });
  117. },
  118. callPhone() {
  119. let that = this;
  120. wx.makePhoneCall({
  121. phoneNumber: that.data.obj.phone,
  122. });
  123. },
  124. /**
  125. * 生命周期函数--监听页面初次渲染完成
  126. */
  127. onReady: function () {},
  128. /**
  129. * 生命周期函数--监听页面显示
  130. */
  131. onShow: function () {},
  132. /**
  133. * 生命周期函数--监听页面隐藏
  134. */
  135. onHide: function () {},
  136. /**
  137. * 页面相关事件处理函数--监听用户下拉动作
  138. */
  139. onPullDownRefresh: function () {},
  140. /**
  141. * 页面上拉触底事件的处理函数
  142. */
  143. onReachBottom: function () {},
  144. showShareMenu: function () {
  145. wx.showShareMenu();
  146. },
  147. hideShareMenu() {
  148. wx.hideShareMenu();
  149. },
  150. });