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.

130 rivejä
3.7 KiB

  1. var config = require("../../config/config.js");
  2. var app = getApp();
  3. const Http = require("../../utils/HttpBasics");
  4. Page({
  5. data: {
  6. canIUse: wx.canIUse("button.open-type.getUserInfo"),
  7. path:null,
  8. couponChannelId: null,
  9. cuserId:null,
  10. coverImg:null,
  11. couponOrderId:null,
  12. optionData:null
  13. },
  14. onLoad: function(options) {
  15. var that = this;
  16. if (options.couponChannelId && !options.cuserId||options.orderId) {
  17. that.setData({
  18. couponChannelId: options.couponChannelId,
  19. orderId:options.orderId
  20. })
  21. }
  22. this.setData({
  23. optionData:options
  24. })
  25. /**
  26. * 来自转赠
  27. */
  28. if (options.couponChannelId && options.cuserId){
  29. console.log(1231231231,options)
  30. that.setData({
  31. couponChannelId: options.couponChannelId,
  32. cuserId: options.cuserId,
  33. coverImg: options.coverImg,
  34. userName: options.userName,
  35. avatarUrl: options.avatarUrl,
  36. couponOrderId: options.couponOrderId
  37. })
  38. }
  39. if (options.path == 'index') {
  40. that.path = options.path
  41. }
  42. Http.get({
  43. url: config.api.marketicon,
  44. data: {
  45. appId: config.weapp.AppId
  46. }
  47. }).then(res => {
  48. that.setData({
  49. mallImgUrl: res.data.mallImgUrl
  50. });
  51. wx.setNavigationBarTitle({
  52. title: res.data.mallName
  53. })
  54. })
  55. .catch(err => {
  56. wx.showToast({
  57. title: err.errMsg,
  58. icon: 'none',
  59. duration: 2000,
  60. mask: false
  61. });
  62. })
  63. },
  64. bindGetUserInfo: function (e) {
  65. let that = this;
  66. var iv = e.detail.iv;
  67. var encryptedData = e.detail.encryptedData;
  68. Http.post({
  69. url: config.api.getUserInfo,
  70. data: {
  71. encryptedData: encryptedData,
  72. iv: iv
  73. }
  74. })
  75. .then(
  76. function (res) {
  77. console.log(res)
  78. if (that.data.optionData.orderGroupId){
  79. wx.reLaunch({
  80. url: `/pages/joinFrDpell/index?couponId=${optionData.couponId}&orderGroupId=${optionData.orderGroupId}&couponChannelId=${optionData.couponChannelId}&orderId=${optionData.orderId}`
  81. });
  82. }
  83. if (that.path == 'index') {
  84. wx.reLaunch({
  85. url: "/pages/game/index"
  86. });
  87. } else {
  88. //返回主页
  89. if (that.data.couponChannelId && !that.data.cuserId) {
  90. wx.navigateTo({
  91. url: `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}}`
  92. });
  93. } else if (that.data.couponChannelId && that.data.cuserId) {
  94. /**
  95. * 来自转赠
  96. */
  97. wx.reLaunch({
  98. url: `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}&cuserId=${that.data.cuserId}&coverImg=${that.data.coverImg}&userName=${that.data.userName}&avatarUrl=${that.data.avatarUrl}&couponOrderId=${that.data.couponOrderId}&updateDate=${that.data.updateDate}`
  99. });
  100. } else if (that.data.orderId) {
  101. wx.navigateTo({
  102. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.orderId}&from=${"friend"}`
  103. });
  104. } else {
  105. wx.switchTab({
  106. url: "/pages/main/index"
  107. });
  108. }
  109. }
  110. },
  111. function (error) {
  112. console.log(error)
  113. wx.showToast({
  114. title: "请授权个人信息",
  115. icon: "none"
  116. });
  117. }
  118. )
  119. .catch(err => {
  120. wx.showToast({
  121. title: err.errMsg,
  122. icon: 'none',
  123. duration: 2000,
  124. mask: false
  125. });
  126. })
  127. }
  128. });