C端小程序
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

284 líneas
7.0 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. 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. // 2023-5-19,因微信公众平台审核无法通过,此页面不再要求授权手机号
  64. // that.checkPhoneStatus()
  65. that.setData({
  66. currentTab: 0
  67. })
  68. }
  69. },
  70. /**
  71. * 拨打电话
  72. */
  73. phone: function (e) {
  74. let that = this;
  75. wx.makePhoneCall({
  76. phoneNumber: e.target.dataset.merchantlinkphone
  77. });
  78. },
  79. /**
  80. * 显示分享弹框
  81. */
  82. showshare: function () {
  83. this.setData({
  84. isshare: true,
  85. })
  86. },
  87. /**
  88. * 隐藏分享弹框
  89. */
  90. hidemodal: function () {
  91. this.setData({
  92. isshare: false,
  93. })
  94. },
  95. //滑动切换
  96. swiperTabView: function (e) {
  97. this.setData({
  98. currentTab: e.detail.current
  99. });
  100. },
  101. /**
  102. * 显示分享海报
  103. */
  104. /* showPoster: function() {
  105. //跳转到海报生成页
  106. wx.navigateTo({
  107. url: `/pages/canvas/index?merchantId=${this.data.id}`
  108. })
  109. }, */
  110. showPoster: function () {
  111. //跳转到海报生成页
  112. let that = this;
  113. Http.get({
  114. url: config.api.checkUserStatus,
  115. data: {
  116. token: app.globalData.token
  117. }
  118. }).then(res => {
  119. wx.navigateTo({
  120. url: `/pages/canvas/index?merchantId=${that.data.id}`
  121. })
  122. }).catch(err => {
  123. console.log(err)
  124. if (err.code == 11004) {
  125. // 用户昵称未授权
  126. wx.redirectTo({
  127. url: `/pages/getuserinfo/index?couponChannelId=${that.data.id}&fromflag=poster`
  128. })
  129. }
  130. })
  131. },
  132. //点击切换
  133. clickTab: function (e) {
  134. if (this.data.currentTab === e.target.dataset.current) {
  135. return false;
  136. } else {
  137. this.setData({
  138. currentTab: e.target.dataset.current
  139. })
  140. }
  141. },
  142. /**
  143. * 获取商户详情
  144. */
  145. getList: function (id) {
  146. let that = this;
  147. let data;
  148. data = {
  149. pageNum: that.data.page,
  150. pageSize: 15,
  151. id: id
  152. }
  153. Http.get({
  154. url: config.api.merchantList,
  155. data: data
  156. }).then(res => {
  157. if (res.data.list.length == 0) {
  158. wx.showModal({
  159. title: '提示',
  160. content: '此商户已经停用',
  161. confirmText: "返回",
  162. showCancel: false,
  163. success: function (res) {
  164. if (res.confirm) {
  165. wx.navigateBack({
  166. url: '/index/searchbar',
  167. })
  168. }
  169. }
  170. })
  171. }
  172. let imgList = [];
  173. imgList.push(res.data.list[0].merchantImgUrl)
  174. that.setData({
  175. data: res.data.list[0],
  176. shopVoList: res.data.list[0].shopVoList,
  177. imglist: res.data.list[0].coverPicture == '[]' ? imgList : JSON.parse(res.data.list[0].coverPicture),
  178. })
  179. })
  180. .catch(err => {
  181. wx.showToast({
  182. title: err.errMsg,
  183. icon: 'none',
  184. duration: 2000,
  185. mask: false
  186. });
  187. })
  188. },
  189. /**
  190. * 获取商户活动信息 券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,50.积分券,51.积分停车券 100.消费卡)
  191. * 投放频道:(1.列表, 2.限时抢购, 3. banner图 4. 游戏 5.卡频道 6.砍价频道 7.拼团频道 8专题)
  192. */
  193. getCouponList: function (id) {
  194. let that = this;
  195. let data;
  196. data = {
  197. status: 0,
  198. merchantId: id,
  199. pageNum: that.data.page,
  200. pageSize: 15,
  201. }
  202. Http.post({
  203. url: config.api.listByMerchant,
  204. data: data
  205. }).then(res => {
  206. that.setData({
  207. couponList: res.data.page.list,
  208. })
  209. // if (res.data && res.data.qrCode){
  210. // that.setData({
  211. // qrCode: res.data.qrCode,
  212. // })
  213. // }
  214. })
  215. .catch(err => {
  216. wx.showToast({
  217. title: err.errMsg,
  218. icon: 'none',
  219. duration: 2000,
  220. mask: false
  221. });
  222. })
  223. },
  224. /**
  225. * 获取多商铺列表
  226. */
  227. onShareAppMessage: function (res) {
  228. app.globalData.previewFlag = true
  229. let that = this;
  230. let shareObj = {
  231. title: that.data.data.merchantName,
  232. path: `/pages/index/index?id=${that.data.id}&frommd=md`,
  233. success: function (res) {
  234. if (res.errMsg == 'shareAppMessage:ok') { }
  235. },
  236. fail: function (error) {
  237. if (res.errMsg == 'shareAppMessage:fail cancel') { } else if (res.errMsg == 'shareAppMessage:fail') { }
  238. }
  239. };
  240. // 来自页面内的按钮的转发
  241. if (res.from === 'button') {
  242. console.log(res)
  243. var eData = res.target.dataset.id;
  244. console.log(eData)
  245. shareObj.path = `/pages/index/index?id=${eData}&frommd=md&type=md`;
  246. }
  247. // 返回shareObj
  248. return shareObj;
  249. },
  250. // 检查用户登录状态
  251. checkPhoneStatus() {
  252. let that = this;
  253. Http.get({
  254. url: config.api.checkPhoneStatus,
  255. })
  256. .then(res => {
  257. // just a test
  258. // setTimeout(() => {
  259. // wx.redirectTo({
  260. // url: `/pages/getphoneInfo/index?path=searchbarDetail&id=${that.data.id}`,
  261. // })
  262. // }, 2000);
  263. })
  264. .catch(err => {
  265. if (err.code == 11005) {
  266. // 手机号没有授权,将值传到用户手机号授权的页面
  267. wx.redirectTo({
  268. url: `/pages/getphoneInfo/index?path=searchbarDetail&id=${that.data.id}`,
  269. })
  270. } else {
  271. wx.showToast({
  272. title: err.message,
  273. icon: 'none',
  274. duration: 2500
  275. })
  276. }
  277. })
  278. },
  279. })