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.

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