index.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. const App = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. // 门店详情
  8. detail: {},
  9. },
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad(options) {
  14. let _this = this;
  15. // 获取门店详情
  16. _this.getShopDetail(options.shop_id);
  17. },
  18. /**
  19. * 获取门店详情
  20. */
  21. getShopDetail(shop_id) {
  22. let _this = this;
  23. App._get('shop/detail', {
  24. shop_id
  25. }, function(result) {
  26. _this.setData(result.data);
  27. });
  28. },
  29. /**
  30. * 拨打电话
  31. */
  32. onMakePhoneCall() {
  33. let _this = this;
  34. wx.makePhoneCall({
  35. phoneNumber: _this.data.detail.phone
  36. });
  37. },
  38. /**
  39. * 查看位置
  40. */
  41. onOpenLocation() {
  42. let _this = this,
  43. detail = _this.data.detail;
  44. wx.openLocation({
  45. name: detail.shop_name,
  46. address: detail.region.province + detail.region.city + detail.region.region + detail.address,
  47. longitude: Number(detail.longitude),
  48. latitude: Number(detail.latitude),
  49. scale: 15
  50. });
  51. },
  52. /**
  53. * 分享当前页面
  54. */
  55. onShareAppMessage() {
  56. const _this = this;
  57. // 构建页面参数
  58. const params = App.getShareUrlParams({
  59. 'shop_id': _this.data.detail.shop_id
  60. });
  61. return {
  62. title: _this.data.detail.article_title,
  63. path: "/pages/shop/detail/index?" + params
  64. };
  65. },
  66. /**
  67. * 分享到朋友圈
  68. * 本接口为 Beta 版本,暂只在 Android 平台支持,详见分享到朋友圈 (Beta)
  69. * https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share-timeline.html
  70. */
  71. onShareTimeline() {
  72. const _this = this;
  73. // 构建页面参数
  74. const params = App.getShareUrlParams({
  75. 'shop_id': _this.data.detail.shop_id
  76. });
  77. return {
  78. title: _this.data.detail.article_title,
  79. path: "/pages/shop/detail/index?" + params
  80. };
  81. },
  82. })