1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- const app = getApp();
- const request = require('./request.js');
- function toLogin() {
- wx.showModal({
- title: '提示',
- content: '您还未登录',
- showCancel: false,
- success: (res) => {
- if (res.confirm) {
- wx.navigateTo({
- url: '/pages/login/login',
- })
- }
- }
- })
- };
- const isLogin = () => {
- return new Promise((resolve, reject) => {
- const openId = wx.getStorageSync('openid');
- if (openId) {
- let options = {
- url: 'resource/miniapp/user/isExist',
- data: {openId},
- method: 'post'
- }
- let res = request.query(options);
- res.then((res2) => {
- if (res2.data.code === 200 && res2.data.data.length !== 0) {
- app.globalData.type
- app.globalData.type = res2.data.data.type;
- resolve(true);
- } else {
- toLogin();
- reject(false);
- }
- }, (error) => {
- console.log(error);
- })
- } else {
- toLogin();
- reject(false);
- }
- })
- };
- module.exports = {
- isLogin
- }
|