C端小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

132 linhas
3.8 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=${options.avatarUrl}&nickName=${options.nickName}`
  83. });
  84. }
  85. if (that.data.path == 'index') {
  86. wx.reLaunch({
  87. url: "/pages/game/index"
  88. });
  89. } else {
  90. //返回主页
  91. if (that.data.couponChannelId && !that.data.cuserId) {
  92. wx.navigateTo({
  93. url: `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}}`
  94. });
  95. } else if (that.data.couponChannelId && that.data.cuserId) {
  96. /**
  97. * 来自转赠
  98. */
  99. wx.reLaunch({
  100. 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}`
  101. });
  102. } else if (that.data.orderId) {
  103. wx.navigateTo({
  104. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.orderId}&from=${"friend"}`
  105. });
  106. } else {
  107. wx.switchTab({
  108. url: "/pages/main/index"
  109. });
  110. }
  111. }
  112. },
  113. function (error) {
  114. console.log(error)
  115. wx.showToast({
  116. title: "请授权个人信息",
  117. icon: "none"
  118. });
  119. }
  120. )
  121. .catch(err => {
  122. wx.showToast({
  123. title: err.errMsg,
  124. icon: 'none',
  125. duration: 2000,
  126. mask: false
  127. });
  128. })
  129. }
  130. });