work.js 2.5 KB

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