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.

183 lines
4.1 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. actUrl: imgurl.act.url,
  13. page: 1,
  14. imglist:null,
  15. shopVoList:[],
  16. couponList:[],//活动劵列表
  17. data:{
  18. currentTab: 0,
  19. isshare:false
  20. },
  21. id:null
  22. },
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad: function (options) {
  27. let that=this;
  28. if (options && options.id){
  29. this.setData({
  30. id: options.id
  31. });
  32. that.getList(options.id);
  33. that.getCouponList(options.id);
  34. this.setData({
  35. currentTab: 0
  36. })
  37. }
  38. },
  39. /**
  40. * 拨打电话
  41. */
  42. phone: function (e) {
  43. let that = this;
  44. wx.makePhoneCall({
  45. phoneNumber: e.target.dataset.merchantlinkphone
  46. });
  47. },
  48. /**
  49. * 显示分享弹框
  50. */
  51. showshare:function(){
  52. this.setData({
  53. isshare:true,
  54. })
  55. },
  56. /**
  57. * 隐藏分享弹框
  58. */
  59. hidemodal:function(){
  60. this.setData({
  61. isshare: false,
  62. })
  63. },
  64. //滑动切换
  65. swiperTabView: function (e) {
  66. this.setData({
  67. currentTab: e.detail.current
  68. });
  69. },
  70. //点击切换
  71. clickTab: function (e) {
  72. if (this.data.currentTab === e.target.dataset.current) {
  73. return false;
  74. } else {
  75. this.setData({
  76. currentTab: e.target.dataset.current
  77. })
  78. }
  79. },
  80. /**
  81. * 获取商户详情
  82. */
  83. getList: function (id) {
  84. let that = this;
  85. let data;
  86. data = {
  87. pageNum: that.data.page,
  88. pageSize: 15,
  89. id:id
  90. }
  91. Http.get({
  92. url: config.api.merchantList,
  93. data: data
  94. }).then(res => {
  95. that.setData({
  96. data: res.data.list[0],
  97. shopVoList: res.data.list[0].shopVoList,
  98. imglist: JSON.parse(res.data.list[0].coverPicture) ? JSON.parse(res.data.list[0].coverPicture) : res.data.list[0].merchantImgUrl,
  99. })
  100. })
  101. .catch(err => {
  102. wx.showToast({
  103. title: err.errMsg,
  104. icon: 'none',
  105. duration: 2000,
  106. mask: false
  107. });
  108. })
  109. },
  110. /**
  111. * 获取商户活动信息 券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,50.积分券,51.积分停车券 100.消费卡)
  112. * 投放频道:(1.列表, 2.限时抢购, 3. banner图 4. 游戏 5.卡频道 6.砍价频道 7.拼团频道 8专题)
  113. */
  114. getCouponList: function (id) {
  115. let that = this;
  116. let data;
  117. data = {
  118. status:0,
  119. merchantId:id,
  120. pageNum: that.data.page,
  121. pageSize: 15,
  122. }
  123. Http.get({
  124. url: config.api.merchantCouponList,
  125. data: data
  126. }).then(res => {
  127. that.setData({
  128. couponList: res.data,
  129. })
  130. })
  131. .catch(err => {
  132. wx.showToast({
  133. title: err.errMsg,
  134. icon: 'none',
  135. duration: 2000,
  136. mask: false
  137. });
  138. })
  139. },
  140. /**
  141. * 获取多商铺列表
  142. */
  143. shopList:function(e){
  144. wx.navigateTo({
  145. url: `/pages/index/merchantList/index?id=${e.currentTarget.dataset.id}`
  146. })
  147. },
  148. /**
  149. * 生命周期函数--监听页面隐藏
  150. */
  151. onHide: function () {
  152. },
  153. onShareAppMessage: function (res) {
  154. debugger
  155. var that = this;
  156. var shareObj = {
  157. title: that.data.data.title,
  158. path: `/pages/index/index?couponChannelId=${that.data.couponChannelId}`,
  159. success: function (res) {
  160. if (res.errMsg == 'shareAppMessage:ok') { }
  161. },
  162. fail: function (error) {
  163. if (res.errMsg == 'shareAppMessage:fail cancel') { } else if (res.errMsg == 'shareAppMessage:fail') { }
  164. }
  165. };
  166. // 来自页面内的按钮的转发
  167. if (res.from === 'button') {
  168. var eData = res.target.dataset.id;
  169. shareObj.path = `/pages/index/index?couponChannelId=${eData}`;
  170. }
  171. // 返回shareObj
  172. return shareObj;
  173. },
  174. /**
  175. * 页面相关事件处理函数--监听用户下拉动作
  176. */
  177. onPullDownRefresh: function () {
  178. },
  179. })