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.

211 lines
5.2 KiB

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