work.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import apps from "./apps";
  2. async function initWorkbench(that) {
  3. let entrance = [{
  4. label: "通用",
  5. icon: "work-tongyong",
  6. appid: "wx197f219a82a89d7b",
  7. list: apps.getapps()
  8. }, {
  9. label: "CRM",
  10. appid: "wx197f219a82a89d7b",
  11. icon: "work-CRM",
  12. list: apps.getcrm()
  13. }];
  14. wx.removeStorageSync('auth')
  15. wx.setStorageSync('auth', apps.authList)
  16. that.setData({
  17. entrance,
  18. auth: JSON.stringify(apps.authList),
  19. userMsg: JSON.stringify(wx.getStorageSync('userMsg')),
  20. site: JSON.stringify(wx.getStorageSync('siteP')),
  21. templetList: JSON.stringify(wx.getStorageSync('templetList'))
  22. })
  23. /* 获取首页banner */
  24. let banner = wx.getStorageSync('banner_list').find(v => v.location == "index_top");
  25. if (banner) that.setData({
  26. bannerList: banner.ads
  27. })
  28. //用于消息跳转对照权限以及路径
  29. wx.setStorageSync('authComparison', entrance.map(v => {
  30. v = v.list.map(s => {
  31. s.appid = v.appid;
  32. return s
  33. })
  34. return v
  35. }).flat())
  36. }
  37. function isHistory() {
  38. let history = getApp().globalData.LaunchOptions;
  39. if (history && !getCurrentPages().some(v => v.__route__ == history.path) && history.path != 'pages/login/phone') {
  40. let url = `/${history.path}?`;
  41. for (const key in history.query) {
  42. url += `${key}=${history.query[key]}&`
  43. }
  44. wx.navigateTo({
  45. url,
  46. success(res) {
  47. wx.showToast({
  48. title: getApp().globalData.Language.getMapText('已恢复页面'),
  49. icon: "none"
  50. });
  51. getApp().globalData.LaunchOptions = null;
  52. }
  53. })
  54. } else {
  55. getApp().globalData.LaunchOptions = null;
  56. }
  57. }
  58. function isRemindChangePassword() {
  59. if (getApp().globalData.remindchangepassword) wx.showModal({
  60. title: getApp().globalData.Language.getMapText('提示'),
  61. content: getApp().globalData.Language.getMapText('当前密码为初始密码,请前往修改密码'),
  62. cancelText: getApp().globalData.Language.getMapText('下次再说'),
  63. confirmText: getApp().globalData.Language.getMapText('前往修改'),
  64. success: ({
  65. confirm
  66. }) => {
  67. getApp().globalData.remindchangepassword = null;
  68. if (confirm) wx.navigateTo({
  69. url: '/pages/tabbar/mine/changePassword/index',
  70. })
  71. },
  72. })
  73. }
  74. module.exports = {
  75. initWorkbench,
  76. isHistory,
  77. isRemindChangePassword
  78. }