selectSite.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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.setStorageSync('userMsg', res.data);
  35. wx.setStorageSync('account_list', [res.data])
  36. wx.setStorageSync('userrole', res.data.usertype == 1 ? '业务员' : '经销商');
  37. require('./modules/login').init();
  38. })
  39. })
  40. }
  41. }
  42. this.setData({
  43. account_list: wx.getStorageSync('account_list')
  44. })
  45. },
  46. toHome(e) {
  47. wx.removeStorageSync('userrole')
  48. wx.setStorageSync('userrole', e.currentTarget.dataset.item.usertype == 1 ? '业务员' : '经销商');
  49. wx.removeStorageSync('userMsg')
  50. wx.setStorageSync('userMsg', e.currentTarget.dataset.item);
  51. require('./modules/login').init();
  52. },
  53. onShow() {
  54. if (wx.getStorageSync('languagecode') != 'ZH') getApp().globalData.Language.setNavBarTitle('选择站点')
  55. this.setData({
  56. account_list: wx.getStorageSync('account_list')
  57. })
  58. }
  59. })