C端小程序
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

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