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.

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