C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. goHomeUrl: "",
  13. navigationBarHeight,
  14. noMerchant: imgurl.noMerchant.url,
  15. noCoupon: imgurl.noCoupon.url,
  16. poterbg: imgurl.poterbg.url,
  17. teljpgUrl: imgurl.teljpg.url,
  18. fenxiang: imgurl.fenxiang1.url,
  19. actUrl: imgurl.act.url,
  20. wmhome: imgurl.wmhome.url,
  21. page: 1,
  22. imglist: null,
  23. shopVoList: [],
  24. couponList: [], //活动劵列表
  25. qrCodeL: '', //小程序码
  26. currentTab: 0,
  27. isshare: false,
  28. showpost: false,
  29. imgHeight: 0,
  30. id: null,
  31. windowWidth: wx.getSystemInfoSync().windowWidth,
  32. windowHeight: wx.getSystemInfoSync().screenHeight,
  33. totalHeight: 0,
  34. canvasScale: 1.0, // 画布放大的倍数,因为如果保存的是一倍的分享图片的话,分享图会有点虚。所以保存的时候,canvasScale设置为2.0,wxss 里面的left: 500%;打开注释。就可保存两倍的分享图
  35. },
  36. //关闭海报
  37. closePoste: function () {
  38. this.setData({
  39. showpost: false
  40. })
  41. },
  42. goback: function () {
  43. let this_ = this
  44. wx.switchTab({
  45. url: this_.data.goHomeUrl,
  46. })
  47. },
  48. /**
  49. * 生命周期函数--监听页面加载
  50. */
  51. onLoad: function (options) {
  52. console.log(options, 'options');
  53. let that = this;
  54. that.setData({
  55. goHomeUrl: app.globalData.goHomeUrl,
  56. })
  57. if (options && options.id) {
  58. that.setData({
  59. id: options.id
  60. });
  61. that.getList(options.id);
  62. that.getCouponList(options.id);
  63. // that.checkPhoneStatus()
  64. that.setData({
  65. currentTab: 0
  66. })
  67. }
  68. },
  69. /**
  70. * 拨打电话
  71. */
  72. phone: function (e) {
  73. let that = this;
  74. wx.makePhoneCall({
  75. phoneNumber: e.target.dataset.merchantlinkphone
  76. });
  77. },
  78. /**
  79. * 显示分享弹框
  80. */
  81. showshare: function () {
  82. this.setData({
  83. isshare: true,
  84. })
  85. },
  86. /**
  87. * 隐藏分享弹框
  88. */
  89. hidemodal: function () {
  90. this.setData({
  91. isshare: false,
  92. })
  93. },
  94. //滑动切换
  95. swiperTabView: function (e) {
  96. this.setData({
  97. currentTab: e.detail.current
  98. });
  99. },
  100. /**
  101. * 显示分享海报
  102. */
  103. /* showPoster: function() {
  104. //跳转到海报生成页
  105. wx.navigateTo({
  106. url: `/pages/canvas/index?merchantId=${this.data.id}`
  107. })
  108. }, */
  109. showPoster: function () {
  110. //跳转到海报生成页
  111. let that = this;
  112. Http.get({
  113. url: config.api.checkUserStatus,
  114. data: {
  115. token: app.globalData.token
  116. }
  117. }).then(res => {
  118. wx.navigateTo({
  119. url: `/pages/canvas/index?merchantId=${that.data.id}`
  120. })
  121. }).catch(err => {
  122. console.log(err)
  123. if (err.code == 11004) {
  124. // 用户昵称未授权
  125. wx.redirectTo({
  126. url: `/pages/getuserinfo/index?couponChannelId=${that.data.id}&fromflag=poster`
  127. })
  128. }
  129. })
  130. },
  131. //点击切换
  132. clickTab: function (e) {
  133. if (this.data.currentTab === e.target.dataset.current) {
  134. return false;
  135. } else {
  136. this.setData({
  137. currentTab: e.target.dataset.current
  138. })
  139. }
  140. },
  141. /**
  142. * 获取商户详情
  143. */
  144. getList: function (id) {
  145. let that = this;
  146. let data;
  147. data = {
  148. pageNum: that.data.page,
  149. pageSize: 15,
  150. id: id
  151. }
  152. Http.get({
  153. url: config.api.merchantList,
  154. data: data
  155. }).then(res => {
  156. if (res.data.list.length == 0) {
  157. wx.showModal({
  158. title: '提示',
  159. content: '此商户已经停用',
  160. confirmText: "返回",
  161. showCancel: false,
  162. success: function (res) {
  163. if (res.confirm) {
  164. wx.navigateBack({
  165. url: '/index/searchbar',
  166. })
  167. }
  168. }
  169. })
  170. }
  171. let imgList = [];
  172. imgList.push(res.data.list[0].merchantImgUrl)
  173. that.setData({
  174. data: res.data.list[0],
  175. shopVoList: res.data.list[0].shopVoList,
  176. imglist: res.data.list[0].coverPicture == '[]' ? imgList : JSON.parse(res.data.list[0].coverPicture),
  177. })
  178. })
  179. .catch(err => {
  180. wx.showToast({
  181. title: err.errMsg,
  182. icon: 'none',
  183. duration: 2000,
  184. mask: false
  185. });
  186. })
  187. },
  188. /**
  189. * 获取商户活动信息 券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,50.积分券,51.积分停车券 100.消费卡)
  190. * 投放频道:(1.列表, 2.限时抢购, 3. banner图 4. 游戏 5.卡频道 6.砍价频道 7.拼团频道 8专题)
  191. */
  192. getCouponList: function (id) {
  193. let that = this;
  194. let data;
  195. data = {
  196. status: 0,
  197. merchantId: id,
  198. pageNum: that.data.page,
  199. pageSize: 15,
  200. }
  201. Http.post({
  202. url: config.api.listByMerchant,
  203. data: data
  204. }).then(res => {
  205. that.setData({
  206. couponList: res.data.page.list,
  207. })
  208. // if (res.data && res.data.qrCode){
  209. // that.setData({
  210. // qrCode: res.data.qrCode,
  211. // })
  212. // }
  213. })
  214. .catch(err => {
  215. wx.showToast({
  216. title: err.errMsg,
  217. icon: 'none',
  218. duration: 2000,
  219. mask: false
  220. });
  221. })
  222. },
  223. /**
  224. * 获取多商铺列表
  225. */
  226. onShareAppMessage: function (res) {
  227. app.globalData.previewFlag = true
  228. let that = this;
  229. let shareObj = {
  230. title: that.data.data.merchantName,
  231. path: `/pages/index/index?id=${that.data.id}&frommd=md`,
  232. success: function (res) {
  233. if (res.errMsg == 'shareAppMessage:ok') { }
  234. },
  235. fail: function (error) {
  236. if (res.errMsg == 'shareAppMessage:fail cancel') { } else if (res.errMsg == 'shareAppMessage:fail') { }
  237. }
  238. };
  239. // 来自页面内的按钮的转发
  240. if (res.from === 'button') {
  241. console.log(res)
  242. var eData = res.target.dataset.id;
  243. console.log(eData)
  244. shareObj.path = `/pages/index/index?id=${eData}&frommd=md&type=md`;
  245. }
  246. // 返回shareObj
  247. return shareObj;
  248. },
  249. // 检查用户登录状态
  250. checkPhoneStatus() {
  251. let that = this;
  252. Http.get({
  253. url: config.api.checkPhoneStatus,
  254. })
  255. .then(res => {
  256. // just a test
  257. // setTimeout(() => {
  258. // wx.redirectTo({
  259. // url: `/pages/getphoneInfo/index?path=searchbarDetail&id=${that.data.id}`,
  260. // })
  261. // }, 2000);
  262. })
  263. .catch(err => {
  264. if (err.code == 11005) {
  265. // 手机号没有授权,将值传到用户手机号授权的页面
  266. wx.redirectTo({
  267. url: `/pages/getphoneInfo/index?path=searchbarDetail&id=${that.data.id}`,
  268. })
  269. } else {
  270. wx.showToast({
  271. title: err.message,
  272. icon: 'none',
  273. duration: 2500
  274. })
  275. }
  276. })
  277. },
  278. })