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.

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