work.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import apps from "./apps";
  2. async function initWorkbench(that) {
  3. let entrance = [{
  4. appid: "wx24e33714c6edf9da",
  5. list: apps.getapps()
  6. }];
  7. wx.removeStorageSync('auth')
  8. wx.setStorageSync('auth', apps.authList)
  9. that.setData({
  10. entrance,
  11. auth: JSON.stringify(apps.authList),
  12. userMsg: JSON.stringify(wx.getStorageSync('userMsg')),
  13. site: JSON.stringify(wx.getStorageSync('siteP')),
  14. templetList: JSON.stringify(wx.getStorageSync('templetList'))
  15. })
  16. /* 获取首页banner */
  17. let banner = wx.getStorageSync('banner_list').find(v => v.location == "index_top");
  18. if (banner) that.setData({
  19. bannerList: banner.ads
  20. })
  21. //用于消息跳转对照权限以及路径
  22. wx.setStorageSync('authComparison', entrance.map(v => {
  23. v = v.list.map(s => {
  24. s.appid = v.appid;
  25. return s
  26. })
  27. return v
  28. }).flat())
  29. }
  30. function isHistory() {
  31. let history = getApp().globalData.LaunchOptions;
  32. if (history && !getCurrentPages().some(v => v.__route__ == history.path) && history.path != 'pages/login/phone') {
  33. let url = `/${history.path}?`;
  34. for (const key in history.query) {
  35. url += `${key}=${history.query[key]}&`
  36. }
  37. wx.navigateTo({
  38. url,
  39. success(res) {
  40. wx.showToast({
  41. title: getApp().globalData.Language.getMapText('已恢复页面'),
  42. icon: "none"
  43. });
  44. getApp().globalData.LaunchOptions = null;
  45. }
  46. })
  47. } else {
  48. getApp().globalData.LaunchOptions = null;
  49. }
  50. }
  51. function isRemindChangePassword() {
  52. if (getApp().globalData.remindchangepassword) wx.showModal({
  53. title: getApp().globalData.Language.getMapText('提示'),
  54. content: getApp().globalData.Language.getMapText('当前密码为初始密码,请前往修改密码'),
  55. cancelText: getApp().globalData.Language.getMapText('下次再说'),
  56. confirmText: getApp().globalData.Language.getMapText('前往修改'),
  57. success: ({
  58. confirm
  59. }) => {
  60. getApp().globalData.remindchangepassword = null;
  61. if (confirm) wx.navigateTo({
  62. url: '/pages/tabbar/mine/changePassword/index',
  63. })
  64. },
  65. })
  66. }
  67. module.exports = {
  68. initWorkbench,
  69. isHistory,
  70. isRemindChangePassword
  71. }