work.js 2.7 KB

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