C端小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

198 linhas
4.8 KiB

  1. const Http = require("../../../../utils/HttpBasics");
  2. const imgurl = require("../../../../utils/imgurl");
  3. const config = require("../../../../config/config");
  4. const util = require("../../../../utils/util");
  5. let app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. poterbg: imgurl.poterbg.url,
  12. teljpgUrl: imgurl.teljpg.url,
  13. share01: imgurl.share01.url,
  14. actUrl: imgurl.act.url,
  15. wmhome: imgurl.wmhome.url,
  16. page: 1,
  17. imglist: null,
  18. shopVoList: [],
  19. couponList: [], //活动劵列表
  20. qrCodeL: '', //小程序码
  21. currentTab: 0,
  22. isshare: false,
  23. showpost: false,
  24. imgHeight: 0,
  25. id: null,
  26. windowWidth: wx.getSystemInfoSync().windowWidth,
  27. windowHeight: wx.getSystemInfoSync().screenHeight,
  28. totalHeight: 0,
  29. canvasScale: 1.0, // 画布放大的倍数,因为如果保存的是一倍的分享图片的话,分享图会有点虚。所以保存的时候,canvasScale设置为2.0,wxss 里面的left: 500%;打开注释。就可保存两倍的分享图
  30. },
  31. //关闭海报
  32. closePoste: function() {
  33. this.setData({
  34. showpost: false
  35. })
  36. },
  37. /**
  38. * 生命周期函数--监听页面加载
  39. */
  40. onLoad: function(options) {
  41. let that = this;
  42. if (options && options.id) {
  43. this.setData({
  44. id: options.id
  45. });
  46. that.getList(options.id);
  47. that.getCouponList(options.id);
  48. this.setData({
  49. currentTab: 0
  50. })
  51. }
  52. },
  53. /**
  54. * 拨打电话
  55. */
  56. phone: function(e) {
  57. let that = this;
  58. wx.makePhoneCall({
  59. phoneNumber: e.target.dataset.merchantlinkphone
  60. });
  61. },
  62. /**
  63. * 显示分享弹框
  64. */
  65. showshare: function() {
  66. this.setData({
  67. isshare: true,
  68. })
  69. },
  70. /**
  71. * 隐藏分享弹框
  72. */
  73. hidemodal: function() {
  74. this.setData({
  75. isshare: false,
  76. })
  77. },
  78. //滑动切换
  79. swiperTabView: function(e) {
  80. this.setData({
  81. currentTab: e.detail.current
  82. });
  83. },
  84. /**
  85. * 显示分享海报
  86. */
  87. showPoster: function() {
  88. //跳转到海报生成页
  89. wx.navigateTo({
  90. url: `/pages/canvas/index?merchantId=${this.data.id}`
  91. })
  92. },
  93. //点击切换
  94. clickTab: function(e) {
  95. if (this.data.currentTab === e.target.dataset.current) {
  96. return false;
  97. } else {
  98. this.setData({
  99. currentTab: e.target.dataset.current
  100. })
  101. }
  102. },
  103. /**
  104. * 获取商户详情
  105. */
  106. getList: function(id) {
  107. let that = this;
  108. let data;
  109. data = {
  110. pageNum: that.data.page,
  111. pageSize: 15,
  112. id: id
  113. }
  114. Http.get({
  115. url: config.api.merchantList,
  116. data: data
  117. }).then(res => {
  118. let imgList = [];
  119. imgList.push(res.data.list[0].merchantImgUrl)
  120. that.setData({
  121. data: res.data.list[0],
  122. shopVoList: res.data.list[0].shopVoList,
  123. imglist: res.data.list[0].coverPicture == '[]' ? imgList : JSON.parse(res.data.list[0].coverPicture),
  124. })
  125. })
  126. .catch(err => {
  127. wx.showToast({
  128. title: err.errMsg,
  129. icon: 'none',
  130. duration: 2000,
  131. mask: false
  132. });
  133. })
  134. },
  135. /**
  136. * 获取商户活动信息 券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,50.积分券,51.积分停车券 100.消费卡)
  137. * 投放频道:(1.列表, 2.限时抢购, 3. banner图 4. 游戏 5.卡频道 6.砍价频道 7.拼团频道 8专题)
  138. */
  139. getCouponList: function(id) {
  140. let that = this;
  141. let data;
  142. data = {
  143. status: 0,
  144. merchantId: id,
  145. pageNum: that.data.page,
  146. pageSize: 15,
  147. }
  148. Http.get({
  149. url: config.api.listByMerchant,
  150. data: data
  151. }).then(res => {
  152. that.setData({
  153. couponList: res.data.page.list,
  154. qrCode: res.data.qrCode,
  155. })
  156. })
  157. .catch(err => {
  158. wx.showToast({
  159. title: err.errMsg,
  160. icon: 'none',
  161. duration: 2000,
  162. mask: false
  163. });
  164. })
  165. },
  166. /**
  167. * 获取多商铺列表
  168. */
  169. shopList: function(e) {
  170. wx.navigateTo({
  171. url: `/pages/index/merchantList/index?id=${e.currentTarget.dataset.id}`
  172. })
  173. },
  174. onShareAppMessage: function(res) {
  175. let that = this;
  176. let shareObj = {
  177. title: that.data.data.merchantName,
  178. path: `/pages/index/index?id=${that.data.id}&frommd=md`,
  179. success: function(res) {
  180. if (res.errMsg == 'shareAppMessage:ok') {}
  181. },
  182. fail: function(error) {
  183. if (res.errMsg == 'shareAppMessage:fail cancel') {} else if (res.errMsg == 'shareAppMessage:fail') {}
  184. }
  185. };
  186. // 来自页面内的按钮的转发
  187. if (res.from === 'button') {
  188. console.log(res)
  189. var eData = res.target.dataset.id;
  190. console.log(eData)
  191. shareObj.path = `/pages/index/index?id=${eData}&frommd=md`;
  192. }
  193. // 返回shareObj
  194. return shareObj;
  195. }
  196. })