C端小程序
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
2.8 KiB

  1. const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
  2. let config = require("../../config/config.js");
  3. let app = getApp();
  4. const Http = require("../../utils/HttpBasics");
  5. const util = require("../../utils/util");
  6. const imgurl = require("../../utils/imgurl");
  7. Page({
  8. data: {
  9. mouldType: 0,
  10. mouldConfig: {},
  11. navigationBarHeight,
  12. data: {
  13. bgColor:"#fff"
  14. },
  15. wmhome: imgurl.wmhome.url,
  16. couponId: null,
  17. orderId: "",
  18. day: "",
  19. hour: "",
  20. minute: "",
  21. nodes: '',
  22. id:'',
  23. goHomeUrl:""
  24. },
  25. onLoad(options){
  26. this.setData({
  27. mouldType: app.globalData.mouldType,
  28. mouldConfig: app.globalData.mouldConfig,
  29. goHomeUrl: app.globalData.goHomeUrl,
  30. })
  31. console.log(options)
  32. if(options&&options.id){
  33. this.setData({
  34. id:options.id
  35. })
  36. this.topicShow(options.id)
  37. }
  38. },
  39. goback: function () {
  40. let this_ = this
  41. wx.switchTab({
  42. url: this_.data.goHomeUrl,
  43. })
  44. },
  45. topicShow(id){
  46. let that = this;
  47. Http.get({
  48. url: config.api.topicFindById,
  49. data: {
  50. id: id
  51. }
  52. }).then(res => {
  53. console.log(res)
  54. if (res&&res.data) {
  55. that.setData({
  56. data: res.data
  57. });
  58. /**
  59. * 获取屏幕的高度
  60. *
  61. */
  62. let query = wx.createSelectorQuery();
  63. query.select('.coupons').boundingClientRect();
  64. query.selectViewport().scrollOffset();
  65. query.exec((res) => {
  66. let listHeight = res[0].height; // 获取list高度
  67. let windowHeight = wx.getSystemInfoSync().windowHeight;
  68. if (windowHeight >= listHeight){
  69. that.setData({
  70. winHeight:'100%'
  71. })
  72. }
  73. })
  74. }
  75. }).catch(err => {
  76. wx.showToast({
  77. title: err.errMsg,
  78. icon: 'none',
  79. duration: 2000,
  80. mask: false
  81. });
  82. })
  83. },
  84. gotoDetail:function(e){
  85. if (e.currentTarget.dataset.type == 9){
  86. console.log("平团")
  87. wx.navigateTo({
  88. url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${e.currentTarget.dataset.couponchannelid}`,
  89. })
  90. }else{
  91. console.log("优惠卷")
  92. wx.navigateTo({
  93. url: `/pages/coupon/detail/index?couponChannelId=${e.currentTarget.dataset.couponchannelid}&couponId=${e.currentTarget.dataset.couponid}`,
  94. })
  95. }
  96. },
  97. onShareAppMessage: function (options) {
  98. var that = this;
  99. var shareObj = {
  100. title: "专题活动",
  101. path: `/pages/main/index?id=${that.data.id}&type=td`,
  102. success: function (res) {
  103. if (res.errMsg == 'shareAppMessage:ok') { }
  104. },
  105. fail: function (error) {
  106. if (res.errMsg == 'shareAppMessage:fail cancel') { } else if (res.errMsg == 'shareAppMessage:fail') { }
  107. }
  108. };
  109. console.log(shareObj)
  110. // 返回shareObj
  111. return shareObj;
  112. }
  113. });