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.

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