work.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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: "营销工具",
  10. icon: "work-yingxiaogongju",
  11. appid: "wx197f219a82a89d7b",
  12. list: apps.gettool()
  13. }, {
  14. label: "CRM",
  15. appid: "wx197f219a82a89d7b",
  16. icon: "work-CRM",
  17. list: apps.getcrm()
  18. }, {
  19. label: "E-订单",
  20. appid: "wxc1b6ae925ac1d06a",
  21. icon: "work-E-dingdan",
  22. list: apps.getedd()
  23. }, {
  24. label: "E-服务",
  25. appid: "wxc1b6ae925ac1d06a",
  26. icon: "work-E-fuwu",
  27. list: apps.geteservice()
  28. }];
  29. if (wx.getStorageSync('languagecode') != 'ZH') {
  30. const language = getApp().globalData.Language;
  31. await language.getLanguages(wx.getStorageSync('languagecode'))
  32. entrance = entrance.map(v => {
  33. try {
  34. v.label = language.getMapText(v.label)
  35. v.list = v.list.map(item => {
  36. item.name = language.getMapText(item.name)
  37. return item
  38. })
  39. } catch (error) {}
  40. return v
  41. })
  42. }
  43. wx.removeStorageSync('auth')
  44. wx.setStorageSync('auth', apps.authList)
  45. that.setData({
  46. entrance,
  47. auth: JSON.stringify(apps.authList),
  48. userMsg: JSON.stringify(wx.getStorageSync('userMsg')),
  49. site: JSON.stringify(wx.getStorageSync('siteP')),
  50. templetList: JSON.stringify(wx.getStorageSync('templetList'))
  51. })
  52. /* 获取首页banner */
  53. let banner = wx.getStorageSync('banner_list').find(v => v.location == "index_top");
  54. if (banner) that.setData({
  55. bannerList: banner.ads
  56. })
  57. //用于消息跳转对照权限以及路径
  58. wx.setStorageSync('authComparison', entrance.map(v => {
  59. v = v.list.map(s => {
  60. s.appid = v.appid;
  61. return s
  62. })
  63. return v
  64. }).flat())
  65. }
  66. function isHistory() {
  67. let history = getApp().globalData.LaunchOptions;
  68. if (history && !getCurrentPages().some(v => v.__route__ == history.path) && history.path != 'pages/login/phone') {
  69. let url = `/${history.path}?`;
  70. for (const key in history.query) {
  71. url += `${key}=${history.query[key]}&`
  72. }
  73. wx.navigateTo({
  74. url,
  75. success(res) {
  76. wx.showToast({
  77. title: '已恢复页面',
  78. icon: "none"
  79. });
  80. getApp().globalData.LaunchOptions = null;
  81. }
  82. })
  83. } else {
  84. getApp().globalData.LaunchOptions = null;
  85. }
  86. }
  87. function isRemindChangePassword() {
  88. if (getApp().globalData.remindchangepassword) wx.showModal({
  89. title: "提示",
  90. content: "当前密码为初始密码,请前往修改密码",
  91. confirmText: '前往修改',
  92. cancelText: "下次再说",
  93. success: ({
  94. confirm
  95. }) => {
  96. getApp().globalData.remindchangepassword = null;
  97. if (confirm) wx.navigateTo({
  98. url: '/pages/tabbar/mine/changePassword/index',
  99. })
  100. },
  101. })
  102. }
  103. module.exports = {
  104. initWorkbench,
  105. isHistory,
  106. isRemindChangePassword
  107. }