work.js 2.9 KB

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