抖音小程序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.

94 lines
2.5 KiB

  1. const Http = require("./utils/HttpBasics.js")
  2. const config = require("./config/config.js");
  3. App({
  4. data:{},
  5. globalData:{
  6. token: null,
  7. imgHttps: 'https://formall.oss-accelerate.aliyuncs.com/douyin/drawable-xhdpi/',
  8. platform:null,//手机型号
  9. systemInfo:"",
  10. curHtml:"",
  11. marketName:"",
  12. mouldType:1,
  13. appId:"ttef6599d8705b49b101",
  14. selected:0,
  15. },
  16. onLaunch: function () {
  17. let that = this
  18. try {
  19. var res = tt.getSystemInfoSync();
  20. that.statusBarHeight = res.statusBarHeight
  21. console.log(`手机型号为 ${res.platform}`);
  22. this.globalData.platform = res.platform
  23. } catch (error) {
  24. console.log(`获取系统信息失败`);
  25. }
  26. tt.getSystemInfo({
  27. success(res) {
  28. that.globalData.systemInfo = res
  29. that.logn();
  30. },
  31. fail(res) {
  32. console.log(`getSystemInfo 调用失败`);
  33. },
  34. });
  35. },
  36. statusBarHeight: 0,
  37. logn(){
  38. let that = this;
  39. tt.login({
  40. success:(res=>{
  41. let {code} = res
  42. Http.post({
  43. url:config.api.login,
  44. data:{
  45. code:code,
  46. appId:'ttef6599d8705b49b101',
  47. systemInfo:JSON.stringify(this.globalData.systemInfo)
  48. }
  49. }).then(res=>{
  50. // debugger
  51. if (res.data.mall){
  52. that.globalData.marketName = res.data.mall.name ? res.data.mall.name : ""
  53. }
  54. that.globalData.mouldType = res.data.mouldType ? res.data.mouldType:0;
  55. if (res.data.subMalls) {
  56. const squareList = JSON.parse(res.data.subMalls)
  57. tt.setStorageSync("squareList", squareList)
  58. if (res.data.mall){
  59. tt.setStorageSync("selectedMall", res.data.mall.tenantId)
  60. }
  61. }
  62. Http.setToken(res.data.token);
  63. that.globalData.token = res.data.token
  64. if (that.tokenCallback) {
  65. that.tokenCallback(res.data.token);
  66. }
  67. }).catch(err=>{
  68. console.log(err);
  69. tt.showModal({
  70. title: '提示',
  71. showCancel: false,
  72. content: '登录失败,请重新尝试',
  73. success: (res) => {
  74. if (res.cancel) {
  75. //点击取消,默认隐藏弹框
  76. } else {
  77. //点击确定
  78. tt.reLaunch({
  79. url: '/pages/index/index',
  80. })
  81. }
  82. }
  83. });
  84. })
  85. }),
  86. });
  87. }
  88. })