C端小程序
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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