C端小程序
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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