work.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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.setStorageSync('auth', apps.authList)
  44. that.setData({
  45. entrance,
  46. auth: JSON.stringify(apps.authList),
  47. userMsg: JSON.stringify(wx.getStorageSync('userMsg')),
  48. site: JSON.stringify(wx.getStorageSync('siteP'))
  49. })
  50. /* 获取首页banner */
  51. let banner = wx.getStorageSync('banner_list').find(v => v.location == "index_top");
  52. if (banner) that.setData({
  53. bannerList: banner.ads
  54. })
  55. //用于消息跳转对照权限以及路径
  56. wx.setStorageSync('authComparison', entrance.map(v => {
  57. v = v.list.map(s => {
  58. s.appid = v.appid;
  59. return s
  60. })
  61. return v
  62. }).flat())
  63. }
  64. function isHistory() {
  65. let history = getApp().globalData.LaunchOptions;
  66. if (history && !getCurrentPages().some(v => v.__route__ == history.path) && history.path != 'pages/login/phone') {
  67. let url = `/${history.path}?`;
  68. for (const key in history.query) {
  69. url += `${key}=${history.query[key]}&`
  70. }
  71. wx.navigateTo({
  72. url,
  73. success(res) {
  74. wx.showToast({
  75. title: '已恢复页面',
  76. icon: "none"
  77. });
  78. getApp().globalData.LaunchOptions = null;
  79. }
  80. })
  81. } else {
  82. getApp().globalData.LaunchOptions = null;
  83. }
  84. }
  85. function isRemindChangePassword() {
  86. if (getApp().globalData.remindchangepassword) wx.showModal({
  87. title: "提示",
  88. content: "当前密码为初始密码,请前往修改密码",
  89. confirmText: '前往修改',
  90. cancelText: "下次再说",
  91. success: ({
  92. confirm
  93. }) => {
  94. getApp().globalData.remindchangepassword = null;
  95. if (confirm) wx.navigateTo({
  96. url: '/pages/tabbar/mine/changePassword/index',
  97. })
  98. },
  99. })
  100. }
  101. module.exports = {
  102. initWorkbench,
  103. isHistory,
  104. isRemindChangePassword
  105. }