selectSite.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. let _Http = getApp().globalData.http
  2. Page({
  3. data: {
  4. account_list: []
  5. },
  6. onLoad(options) {
  7. for (var key in options) {
  8. if (key.length > 30 && key.includes("_")) {
  9. let value = key.split("_")
  10. wx.setNavigationBarTitle({
  11. title: 'loading...',
  12. })
  13. _Http.appName = value[1];
  14. const languages = value[2] ? value[2].toUpperCase() : 'ZH';
  15. getApp().globalData.Language.getLanguages(languages).then(s => {
  16. _Http.base({
  17. "id": 2024092514364201,
  18. accesstoken: value[0]
  19. }).then(res => {
  20. console.log('通过token获取登录数据', res);
  21. if (res.code != 1) {
  22. wx.showToast({
  23. title: res.msg,
  24. icon: "none",
  25. mask: true
  26. })
  27. setTimeout(() => {
  28. wx.redirectTo({
  29. url: '/pages/login/phone',
  30. })
  31. }, 500);
  32. return
  33. }
  34. wx.removeStorageSync('userMsg');
  35. wx.removeStorageSync('account_list');
  36. wx.setStorageSync('userMsg', res.data);
  37. wx.setStorageSync('account_list', [res.data])
  38. require('./modules/login').init();
  39. })
  40. })
  41. }
  42. }
  43. this.setData({
  44. account_list: wx.getStorageSync('account_list')
  45. })
  46. },
  47. toHome(e) {
  48. wx.removeStorageSync('userMsg')
  49. wx.setStorageSync('userMsg', e.currentTarget.dataset.item);
  50. require('./modules/login').init();
  51. },
  52. onShow() {
  53. getApp().globalData.Language.setNavBarTitle('选择站点')
  54. this.setData({
  55. account_list: wx.getStorageSync('account_list')
  56. })
  57. }
  58. })