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.

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