work.js 3.0 KB

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