auth.service.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. const company = getApp().globalData.company
  2. const Parse = getApp().Parse
  3. /** 登录验证*/
  4. function resetlogin() {
  5. return new Promise((resolve, reject) => {
  6. wx.login({
  7. success: function (res) {
  8. if (res.code) {
  9. wx.request({
  10. url: "https://server.fmode.cn/api/wxapp/auth_wxapp",
  11. data: {
  12. c: getApp().globalData.company,
  13. code: res.code,
  14. },
  15. async success(res) {
  16. wx.setStorageSync("userInfo", res.data);
  17. resolve(res)
  18. },
  19. });
  20. }
  21. },
  22. fail: function (err) {
  23. wx.showToast({
  24. title: '服务器繁忙,请稍后重试',
  25. })
  26. }
  27. });
  28. })
  29. }
  30. function logout() {
  31. Parse.User.logOut().then(user => {
  32. wx.showToast({
  33. title: '退出成功',
  34. icon: 'success',
  35. image: '',
  36. duration: 1500,
  37. mask: false,
  38. });
  39. wx.clearStorage()
  40. // wx.removeStorageSync('userLogin')
  41. // wx.removeStorageSync('userInfo')
  42. // wx.removeStorageSync('__plugins__/wx56d559d35ae6e502/userLogin')
  43. // wx.removeStorageSync('__plugins__/wx56d559d35ae6e502/Parse/ncloudmaster/currentInstallationId')
  44. // wx.setStorageSync('userLogin', '');
  45. // wx.setStorageSync('userInfo', '');
  46. // wx.setStorageSync('__plugins__/wx56d559d35ae6e502/userLogin', '');
  47. // wx.setStorageSync('__plugins__/wx56d559d35ae6e502/Parse/ncloudmaster/currentInstallationId', '');
  48. setTimeout(() => {
  49. wx.redirectTo({
  50. url: '/nova-werun/pages/index/index',
  51. });
  52. }, 1000);
  53. });
  54. }
  55. module.exports = {
  56. resetlogin,
  57. logout:logout
  58. }