storedetail.js 3.8 KB

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