C端小程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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