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.

95 Zeilen
2.1 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. })
  55. .then(
  56. function(res) {
  57. console.log(res)
  58. if(that.path=='index'){
  59. wx.reLaunch({
  60. url: "/pages/game/index"
  61. });
  62. }
  63. else{
  64. //返回主页
  65. if (that.data.couponChannelId && that.data.couponId){
  66. wx.redirectTo({
  67. url: `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}&couponId=${that.data.couponId}`
  68. });
  69. }else{
  70. wx.switchTab({
  71. url: "/pages/index/index"
  72. });
  73. }
  74. }
  75. },
  76. function(error) {
  77. console.log(error)
  78. wx.showToast({
  79. title: "请授权个人信息",
  80. icon: "none"
  81. });
  82. }
  83. )
  84. .catch(err => {
  85. wx.showToast({
  86. title: err.errMsg,
  87. icon: 'none',
  88. duration: 2000,
  89. mask: false
  90. });
  91. })
  92. }
  93. });