C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 line
3.7 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. swiperTabView: function (e) {
  45. this.setData({
  46. currentTab: e.detail.current
  47. });
  48. },
  49. //点击切换
  50. clickTab: function (e) {
  51. if (this.data.currentTab === e.target.dataset.current) {
  52. return false;
  53. } else {
  54. this.setData({
  55. currentTab: e.target.dataset.current
  56. })
  57. }
  58. },
  59. /**
  60. * 获取商户详情
  61. */
  62. getList: function (id) {
  63. let that = this;
  64. let data;
  65. data = {
  66. pageNum: that.data.page,
  67. pageSize: 15,
  68. id:id
  69. }
  70. Http.get({
  71. url: config.api.merchantList,
  72. data: data
  73. }).then(res => {
  74. that.setData({
  75. data: res.data.list[0],
  76. shopVoList: res.data.list[0].shopVoList,
  77. imglist: JSON.parse(res.data.list[0].coverPicture) ? JSON.parse(res.data.list[0].coverPicture) : res.data.list[0].merchantImgUrl,
  78. })
  79. })
  80. .catch(err => {
  81. wx.showToast({
  82. title: err.errMsg,
  83. icon: 'none',
  84. duration: 2000,
  85. mask: false
  86. });
  87. })
  88. },
  89. /**
  90. * 获取商户活动信息 券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,50.积分券,51.积分停车券 100.消费卡)
  91. * 投放频道:(1.列表, 2.限时抢购, 3. banner图 4. 游戏 5.卡频道 6.砍价频道 7.拼团频道 8专题)
  92. */
  93. getCouponList: function (id) {
  94. let that = this;
  95. let data;
  96. data = {
  97. status:0,
  98. merchantId:id,
  99. pageNum: that.data.page,
  100. pageSize: 15,
  101. }
  102. Http.get({
  103. url: config.api.merchantCouponList,
  104. data: data
  105. }).then(res => {
  106. that.setData({
  107. couponList: res.data,
  108. })
  109. })
  110. .catch(err => {
  111. wx.showToast({
  112. title: err.errMsg,
  113. icon: 'none',
  114. duration: 2000,
  115. mask: false
  116. });
  117. })
  118. },
  119. /**
  120. * 获取多商铺列表
  121. */
  122. shopList:function(e){
  123. wx.navigateTo({
  124. url: `/pages/index/merchantList/index?id=${e.currentTarget.dataset.id}`
  125. })
  126. },
  127. /**
  128. * 生命周期函数--监听页面隐藏
  129. */
  130. onHide: function () {
  131. },
  132. onShareAppMessage: function (options) {
  133. var that = this;
  134. var shareObj = {
  135. title: that.data.data.title,
  136. path: `/pages/index/index?couponChannelId=${that.data.couponChannelId}`,
  137. success: function (res) {
  138. if (res.errMsg == 'shareAppMessage:ok') { }
  139. },
  140. fail: function (error) {
  141. if (res.errMsg == 'shareAppMessage:fail cancel') { } else if (res.errMsg == 'shareAppMessage:fail') { }
  142. }
  143. };
  144. // 来自页面内的按钮的转发
  145. if (options.from == 'button') {
  146. var eData = options.target.dataset.id;
  147. shareObj.path = `/pages/index/index?couponChannelId=${eData}`;
  148. }
  149. // 返回shareObj
  150. return shareObj;
  151. },
  152. /**
  153. * 页面相关事件处理函数--监听用户下拉动作
  154. */
  155. onPullDownRefresh: function () {
  156. },
  157. })