C端小程序
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

146 satır
3.4 KiB

  1. const Http = require("../../../../utils/HttpBasics");
  2. const imgurl = require("../../../../utils/imgurl");
  3. const config = require("../../../../config/config");
  4. let app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. teljpgUrl: imgurl.teljpg.url,
  11. share01: imgurl.share01.url,
  12. page: 1,
  13. imglist: null,
  14. shopVoList: [],
  15. couponList: [], //活动劵列表
  16. data: {
  17. currentTab: 0
  18. },
  19. id: null
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad: function(options) {
  25. let that = this;
  26. if (options && options.id) {
  27. this.setData({
  28. id: options.id
  29. });
  30. that.getList(options.id);
  31. that.getCouponList(options.id);
  32. }
  33. },
  34. /**
  35. * 拨打电话
  36. */
  37. phone: function(e) {
  38. let that = this;
  39. wx.makePhoneCall({
  40. phoneNumber: e.target.dataset.merchantlinkphone
  41. });
  42. },
  43. /**
  44. * 获取商户详情
  45. */
  46. getList: function(id) {
  47. let that = this;
  48. let data;
  49. data = {
  50. pageNum: that.data.page,
  51. pageSize: 15,
  52. id: id
  53. }
  54. Http.get({
  55. url: config.api.merchantList,
  56. data: data
  57. }).then(res => {
  58. that.setData({
  59. data: res.data.list[0],
  60. shopVoList: res.data.list[0].shopVoList,
  61. imglist: JSON.parse(res.data.list[0].coverPicture) ? JSON.parse(res.data.list[0].coverPicture) : res.data.list[0].merchantImgUrl,
  62. })
  63. })
  64. .catch(err => {
  65. wx.showToast({
  66. title: err.errMsg,
  67. icon: 'none',
  68. duration: 2000,
  69. mask: false
  70. });
  71. })
  72. },
  73. /**
  74. * 获取商户活动信息 券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,50.积分券,51.积分停车券 100.消费卡)
  75. * 投放频道:(1.列表, 2.限时抢购, 3. banner图 4. 游戏 5.卡频道 6.砍价频道 7.拼团频道 8专题)
  76. */
  77. getCouponList: function(id) {
  78. let that = this;
  79. let data;
  80. data = {
  81. status: 0,
  82. merchantId: id,
  83. pageNum: that.data.page,
  84. pageSize: 15,
  85. }
  86. Http.get({
  87. url: config.api.merchantCouponList,
  88. data: data
  89. }).then(res => {
  90. that.setData({
  91. couponList: res.data.list,
  92. })
  93. })
  94. .catch(err => {
  95. wx.showToast({
  96. title: err.errMsg,
  97. icon: 'none',
  98. duration: 2000,
  99. mask: false
  100. });
  101. })
  102. },
  103. /**
  104. * 获取多商铺列表
  105. */
  106. shopList: function(e) {
  107. wx.navigateTo({
  108. url: `/pages/index/merchantList/index?id=${e.currentTarget.dataset.id}`
  109. })
  110. },
  111. /**
  112. * 生命周期函数--监听页面隐藏
  113. */
  114. onHide: function() {
  115. },
  116. onShareAppMessage: function(options) {
  117. var that = this;
  118. var shareObj = {
  119. title: that.data.data.title,
  120. path: `/pages/index/index?couponChannelId=${that.data.couponChannelId}`,
  121. success: function(res) {
  122. if (res.errMsg == 'shareAppMessage:ok') {}
  123. },
  124. fail: function(error) {
  125. if (res.errMsg == 'shareAppMessage:fail cancel') {} else if (res.errMsg == 'shareAppMessage:fail') {}
  126. }
  127. };
  128. // 来自页面内的按钮的转发
  129. if (options.from == 'button') {
  130. var eData = options.target.dataset.id;
  131. shareObj.path = `/pages/index/index?couponChannelId=${eData}`;
  132. }
  133. // 返回shareObj
  134. return shareObj;
  135. },
  136. /**
  137. * 页面相关事件处理函数--监听用户下拉动作
  138. */
  139. onPullDownRefresh: function() {
  140. },
  141. })