add
This commit is contained in:
parent
ee738e9f80
commit
b69e51fe9f
4
App.vue
4
App.vue
@ -85,6 +85,10 @@
|
|||||||
index: 1,
|
index: 1,
|
||||||
visible: false
|
visible: false
|
||||||
})
|
})
|
||||||
|
uni.setTabBarItem({
|
||||||
|
index: 4,
|
||||||
|
visible: false
|
||||||
|
})
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
uni.setTabBarItem({
|
uni.setTabBarItem({
|
||||||
index: 2,
|
index: 2,
|
||||||
|
@ -42,5 +42,14 @@ export const applysApi = (data) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const merchatTypeApi = (data) => {
|
export const merchatTypeApi = (data) => {
|
||||||
return request.get('shop/index/merchat_type', data);
|
return request.get('shop/index/merchat_type', data, {
|
||||||
|
tokenName: 1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getSTokenApi = (data) => {
|
||||||
|
uni.setStorageSync('LOGIN_STATUS_STOKEN', 'asdfdsfsdfsdfds')
|
||||||
|
return request.get('shop/index/get_token', data, {
|
||||||
|
tokenName: 1
|
||||||
|
});
|
||||||
}
|
}
|
@ -10,9 +10,10 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
//token
|
//token
|
||||||
LOGIN_STATUS: 'LOGIN_STATUS_TOKEN',
|
LOGIN_STATUS: 'LOGIN_STATUS_TOKEN',
|
||||||
UUID:'UUID',
|
LOGIN_STATUS_S: 'LOGIN_STATUS_STOKEN',
|
||||||
|
UUID: 'UUID',
|
||||||
// uid
|
// uid
|
||||||
UID:'UID',
|
UID: 'UID',
|
||||||
//<2F>û<EFBFBD>
|
//<2F>û<EFBFBD>
|
||||||
USER_INFO: 'USER_INFO',
|
USER_INFO: 'USER_INFO',
|
||||||
//token<65><6E><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
//token<65><6E><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||||
@ -39,4 +40,4 @@ module.exports = {
|
|||||||
CACHE_LONGITUDE: 'LONGITUDE',
|
CACHE_LONGITUDE: 'LONGITUDE',
|
||||||
//缓存纬度
|
//缓存纬度
|
||||||
CACHE_LATITUDE: 'LATITUDE',
|
CACHE_LATITUDE: 'LATITUDE',
|
||||||
}
|
}
|
@ -18,6 +18,7 @@ import auth from './wechat';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
LOGIN_STATUS,
|
LOGIN_STATUS,
|
||||||
|
LOGIN_STATUS_S,
|
||||||
USER_INFO,
|
USER_INFO,
|
||||||
EXPIRES_TIME,
|
EXPIRES_TIME,
|
||||||
STATE_R_KEY
|
STATE_R_KEY
|
||||||
@ -48,10 +49,10 @@ export function toLogin(push, pathLogin) {
|
|||||||
// #endif
|
// #endif
|
||||||
if (!pathLogin)
|
if (!pathLogin)
|
||||||
pathLogin = '/page/users/login/login_copy'
|
pathLogin = '/page/users/login/login_copy'
|
||||||
Cache.set('login_back_url', path);
|
Cache.set('login_back_url', path);
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
if (isWeixin()) {
|
if (isWeixin()) {
|
||||||
auth.oAuth();
|
auth.oAuth();
|
||||||
// if (Cache.get('WECHAT_APPID')) {
|
// if (Cache.get('WECHAT_APPID')) {
|
||||||
// uni.navigateTo({
|
// uni.navigateTo({
|
||||||
// url: '/pages/users/wechat_login/index',
|
// url: '/pages/users/wechat_login/index',
|
||||||
@ -89,6 +90,7 @@ export function checkLogin() {
|
|||||||
let newTime = Math.round(new Date() / 1000);
|
let newTime = Math.round(new Date() / 1000);
|
||||||
if (expiresTime < newTime || !token) {
|
if (expiresTime < newTime || !token) {
|
||||||
Cache.clear(LOGIN_STATUS);
|
Cache.clear(LOGIN_STATUS);
|
||||||
|
Cache.clear(LOGIN_STATUS_S);
|
||||||
Cache.clear(EXPIRES_TIME);
|
Cache.clear(EXPIRES_TIME);
|
||||||
Cache.clear(USER_INFO);
|
Cache.clear(USER_INFO);
|
||||||
Cache.clear(STATE_R_KEY);
|
Cache.clear(STATE_R_KEY);
|
||||||
|
187
libs/routine.js
187
libs/routine.js
@ -8,96 +8,109 @@
|
|||||||
// | Author: CRMEB Team <admin@crmeb.com>
|
// | Author: CRMEB Team <admin@crmeb.com>
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
import store from '../store';
|
import store from '../store';
|
||||||
import { checkLogin } from './login';
|
import {
|
||||||
import { login } from '../api/public';
|
checkLogin
|
||||||
|
} from './login';
|
||||||
|
import {
|
||||||
|
login
|
||||||
|
} from '../api/public';
|
||||||
import Cache from '../utils/cache';
|
import Cache from '../utils/cache';
|
||||||
import { STATE_R_KEY, USER_INFO, EXPIRES_TIME, LOGIN_STATUS} from './../config/cache';
|
import {
|
||||||
|
STATE_R_KEY,
|
||||||
|
USER_INFO,
|
||||||
|
EXPIRES_TIME,
|
||||||
|
LOGIN_STATUS,
|
||||||
|
LOGIN_STATUS_S
|
||||||
|
} from './../config/cache';
|
||||||
|
|
||||||
class Routine
|
class Routine {
|
||||||
{
|
|
||||||
|
constructor() {
|
||||||
constructor()
|
this.scopeUserInfo = 'scope.userInfo';
|
||||||
{
|
|
||||||
this.scopeUserInfo = 'scope.userInfo';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUserCode(){
|
async getUserCode() {
|
||||||
let isAuth = await this.isAuth(), code = '' ;
|
let isAuth = await this.isAuth(),
|
||||||
if(isAuth)
|
code = '';
|
||||||
|
if (isAuth)
|
||||||
code = await this.getCode();
|
code = await this.getCode();
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户信息
|
* 获取用户信息
|
||||||
*/
|
*/
|
||||||
getUserInfo(){
|
getUserInfo() {
|
||||||
let that = this , code = this.getUserCode();
|
let that = this,
|
||||||
return new Promise( (resolve,reject) => {
|
code = this.getUserCode();
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
uni.getUserInfo({
|
uni.getUserInfo({
|
||||||
lang: 'zh_CN',
|
lang: 'zh_CN',
|
||||||
success(user) {
|
success(user) {
|
||||||
if(code) user.code = code;
|
if (code) user.code = code;
|
||||||
resolve({userInfo:user,islogin:false});
|
resolve({
|
||||||
|
userInfo: user,
|
||||||
|
islogin: false
|
||||||
|
});
|
||||||
},
|
},
|
||||||
fail(res){
|
fail(res) {
|
||||||
reject(res);
|
reject(res);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户信息
|
* 获取用户信息
|
||||||
*/
|
*/
|
||||||
authorize()
|
authorize() {
|
||||||
{
|
|
||||||
let c2543fff3bfa6f144c2f06a7de6cd10c0b650cae = this;
|
let c2543fff3bfa6f144c2f06a7de6cd10c0b650cae = this;
|
||||||
return new Promise((resolve,reject)=>{
|
return new Promise((resolve, reject) => {
|
||||||
if(checkLogin())
|
if (checkLogin())
|
||||||
return resolve({
|
return resolve({
|
||||||
userInfo:Cache.get(USER_INFO,true),
|
userInfo: Cache.get(USER_INFO, true),
|
||||||
islogin:true,
|
islogin: true,
|
||||||
});
|
});
|
||||||
uni.authorize({
|
uni.authorize({
|
||||||
scope: c2543fff3bfa6f144c2f06a7de6cd10c0b650cae.scopeUserInfo,
|
scope: c2543fff3bfa6f144c2f06a7de6cd10c0b650cae.scopeUserInfo,
|
||||||
success() {
|
success() {
|
||||||
resolve({islogin:false});
|
resolve({
|
||||||
},
|
islogin: false
|
||||||
fail(res){
|
});
|
||||||
|
},
|
||||||
|
fail(res) {
|
||||||
reject(res);
|
reject(res);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async getCode(){
|
async getCode() {
|
||||||
let backUrlCRshlcICwGdGY = await this.getProvider();
|
let backUrlCRshlcICwGdGY = await this.getProvider();
|
||||||
return new Promise((resolve,reject)=>{
|
return new Promise((resolve, reject) => {
|
||||||
if(Cache.has(STATE_R_KEY)){
|
if (Cache.has(STATE_R_KEY)) {
|
||||||
return resolve(Cache.get(STATE_R_KEY));
|
return resolve(Cache.get(STATE_R_KEY));
|
||||||
}
|
}
|
||||||
uni.login({
|
uni.login({
|
||||||
provider:backUrlCRshlcICwGdGY,
|
provider: backUrlCRshlcICwGdGY,
|
||||||
success(res) {
|
success(res) {
|
||||||
if (res.code) Cache.set(STATE_R_KEY, res.code ,10);
|
if (res.code) Cache.set(STATE_R_KEY, res.code, 10);
|
||||||
return resolve(res.code);
|
return resolve(res.code);
|
||||||
},
|
},
|
||||||
fail(){
|
fail() {
|
||||||
return reject(null);
|
return reject(null);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取服务供应商
|
* 获取服务供应商
|
||||||
*/
|
*/
|
||||||
getProvider()
|
getProvider() {
|
||||||
{
|
return new Promise((resolve, reject) => {
|
||||||
return new Promise((resolve,reject)=>{
|
|
||||||
uni.getProvider({
|
uni.getProvider({
|
||||||
service:'oauth',
|
service: 'oauth',
|
||||||
success(res) {
|
success(res) {
|
||||||
resolve(res.provider);
|
resolve(res.provider);
|
||||||
},
|
},
|
||||||
@ -107,13 +120,13 @@ class Routine
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否授权
|
* 是否授权
|
||||||
*/
|
*/
|
||||||
isAuth(){
|
isAuth() {
|
||||||
let that = this;
|
let that = this;
|
||||||
return new Promise((resolve,reject)=>{
|
return new Promise((resolve, reject) => {
|
||||||
uni.getSetting({
|
uni.getSetting({
|
||||||
success(res) {
|
success(res) {
|
||||||
if (!res.authSetting[that.scopeUserInfo]) {
|
if (!res.authSetting[that.scopeUserInfo]) {
|
||||||
@ -122,8 +135,8 @@ class Routine
|
|||||||
resolve(true);
|
resolve(true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail(){
|
fail() {
|
||||||
resolve(false);
|
resolve(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -147,48 +160,50 @@ class Routine
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 小程序比较版本信息
|
* 小程序比较版本信息
|
||||||
* @param v1 当前版本
|
* @param v1 当前版本
|
||||||
* @param v2 进行比较的版本
|
* @param v2 进行比较的版本
|
||||||
* @return boolen
|
* @return boolen
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
compareVersion(v1, v2) {
|
compareVersion(v1, v2) {
|
||||||
v1 = v1.split('.')
|
v1 = v1.split('.')
|
||||||
v2 = v2.split('.')
|
v2 = v2.split('.')
|
||||||
const len = Math.max(v1.length, v2.length)
|
const len = Math.max(v1.length, v2.length)
|
||||||
|
|
||||||
while (v1.length < len) {
|
while (v1.length < len) {
|
||||||
v1.push('0')
|
v1.push('0')
|
||||||
}
|
|
||||||
while (v2.length < len) {
|
|
||||||
v2.push('0')
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < len; i++) {
|
|
||||||
const num1 = parseInt(v1[i])
|
|
||||||
const num2 = parseInt(v2[i])
|
|
||||||
|
|
||||||
if (num1 > num2) {
|
|
||||||
return 1
|
|
||||||
} else if (num1 < num2) {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
authUserInfo(data)
|
while (v2.length < len) {
|
||||||
{
|
v2.push('0')
|
||||||
return new Promise((resolve, reject)=>{
|
}
|
||||||
login(data).then(res=>{
|
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
const num1 = parseInt(v1[i])
|
||||||
|
const num2 = parseInt(v2[i])
|
||||||
|
|
||||||
|
if (num1 > num2) {
|
||||||
|
return 1
|
||||||
|
} else if (num1 < num2) {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
authUserInfo(data) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
login(data).then(res => {
|
||||||
let time = res.data.expires_time - Cache.time();
|
let time = res.data.expires_time - Cache.time();
|
||||||
store.commit('UPDATE_USERINFO', res.data.user);
|
store.commit('UPDATE_USERINFO', res.data.user);
|
||||||
store.commit('LOGIN', {token:res.data.token, time:time});
|
store.commit('LOGIN', {
|
||||||
|
token: res.data.token,
|
||||||
|
time: time
|
||||||
|
});
|
||||||
store.commit('SETUID', res.data.user.uid);
|
store.commit('SETUID', res.data.user.uid);
|
||||||
Cache.set(EXPIRES_TIME,res.data.expires_time,time);
|
Cache.set(EXPIRES_TIME, res.data.expires_time, time);
|
||||||
Cache.set(USER_INFO,res.data.userInfo,time);
|
Cache.set(USER_INFO, res.data.userInfo, time);
|
||||||
return resolve(res);
|
return resolve(res);
|
||||||
}).catch(res=>{
|
}).catch(res => {
|
||||||
return reject(res);
|
return reject(res);
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
10
pages.json
10
pages.json
@ -126,7 +126,7 @@
|
|||||||
"path": "pages/order_addcart/order_addcart",
|
"path": "pages/order_addcart/order_addcart",
|
||||||
"style": {
|
"style": {
|
||||||
"enablePullDownRefresh": true,
|
"enablePullDownRefresh": true,
|
||||||
"navigationBarTitleText": "报价",
|
"navigationBarTitleText": "购物车",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
@ -1657,6 +1657,7 @@
|
|||||||
"selectedIconPath": "static/tabbar_icon/b-a.png",
|
"selectedIconPath": "static/tabbar_icon/b-a.png",
|
||||||
"text": "批发"
|
"text": "批发"
|
||||||
},
|
},
|
||||||
|
|
||||||
// {
|
// {
|
||||||
// "pagePath": "pages/plant_grass/index",
|
// "pagePath": "pages/plant_grass/index",
|
||||||
// "iconPath": "static/tabbar_icon/b.png",
|
// "iconPath": "static/tabbar_icon/b.png",
|
||||||
@ -1673,8 +1674,15 @@
|
|||||||
"pagePath": "pages/order_addcart/order_addcart",
|
"pagePath": "pages/order_addcart/order_addcart",
|
||||||
"iconPath": "static/tabbar_icon/d.png",
|
"iconPath": "static/tabbar_icon/d.png",
|
||||||
"selectedIconPath": "static/tabbar_icon/d-a.png",
|
"selectedIconPath": "static/tabbar_icon/d-a.png",
|
||||||
|
"text": "购物车"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pagePath": "pages/quote/list",
|
||||||
|
"iconPath": "static/tabbar_icon/d.png",
|
||||||
|
"selectedIconPath": "static/tabbar_icon/d-a.png",
|
||||||
"text": "报价"
|
"text": "报价"
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"pagePath": "pages/user/index",
|
"pagePath": "pages/user/index",
|
||||||
"iconPath": "static/tabbar_icon/e.png",
|
"iconPath": "static/tabbar_icon/e.png",
|
||||||
|
@ -252,7 +252,8 @@
|
|||||||
} from '@/api/store.js';
|
} from '@/api/store.js';
|
||||||
import {
|
import {
|
||||||
merchatTypeApi,
|
merchatTypeApi,
|
||||||
applysApi
|
applysApi,
|
||||||
|
UserWithdrawApi
|
||||||
} from "@/api/supplier.js"
|
} from "@/api/supplier.js"
|
||||||
|
|
||||||
// import Verify from '@/components/verify/verify.vue';
|
// import Verify from '@/components/verify/verify.vue';
|
||||||
@ -586,6 +587,7 @@
|
|||||||
uni.stopPullDownRefresh()
|
uni.stopPullDownRefresh()
|
||||||
},
|
},
|
||||||
onLoad(option) {
|
onLoad(option) {
|
||||||
|
UserWithdrawApi()
|
||||||
this.shoplist('mer_services_agree')
|
this.shoplist('mer_services_agree')
|
||||||
this.formData.phone = this.$store.state.app.userInfo.account
|
this.formData.phone = this.$store.state.app.userInfo.account
|
||||||
// merClassifly().then(res => {
|
// merClassifly().then(res => {
|
||||||
|
@ -399,6 +399,9 @@
|
|||||||
import {
|
import {
|
||||||
showTab
|
showTab
|
||||||
} from "@/utils/showTab.js";
|
} from "@/utils/showTab.js";
|
||||||
|
import {
|
||||||
|
getSTokenApi
|
||||||
|
} from "@/api/supplier.js"
|
||||||
export default {
|
export default {
|
||||||
computed: configMap({
|
computed: configMap({
|
||||||
hide_mer_status: 0,
|
hide_mer_status: 0,
|
||||||
@ -647,6 +650,11 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
onShow() {
|
onShow() {
|
||||||
|
getSTokenApi().then(res => {
|
||||||
|
if (res.token) {
|
||||||
|
uni.setStorageSync('LOGIN_STATUS_STOKEN', 'asdfdsfsdfsdfds')
|
||||||
|
}
|
||||||
|
})
|
||||||
if (uni.getStorageSync('newStore')) this.openDiver();
|
if (uni.getStorageSync('newStore')) this.openDiver();
|
||||||
let that = this;
|
let that = this;
|
||||||
that.isIntegral = uni.getStorageSync('isIntegral')
|
that.isIntegral = uni.getStorageSync('isIntegral')
|
||||||
|
@ -302,6 +302,9 @@
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
import dayjs from "@/plugin/dayjs/dayjs.min.js";
|
import dayjs from "@/plugin/dayjs/dayjs.min.js";
|
||||||
import sendVerifyCode from "@/mixins/SendVerifyCode";
|
import sendVerifyCode from "@/mixins/SendVerifyCode";
|
||||||
|
import {
|
||||||
|
getSTokenApi
|
||||||
|
} from "@/api/supplier.js"
|
||||||
import {
|
import {
|
||||||
loginH5,
|
loginH5,
|
||||||
loginMobile,
|
loginMobile,
|
||||||
@ -321,6 +324,7 @@
|
|||||||
wechatAppAuth,
|
wechatAppAuth,
|
||||||
appleAppAuth
|
appleAppAuth
|
||||||
} from '@/api/api.js'
|
} from '@/api/api.js'
|
||||||
|
|
||||||
// #endif
|
// #endif
|
||||||
import attrs, {
|
import attrs, {
|
||||||
required,
|
required,
|
||||||
@ -480,7 +484,7 @@
|
|||||||
});
|
});
|
||||||
that.$store.commit("SETUID", data.user.uid);
|
that.$store.commit("SETUID", data.user.uid);
|
||||||
that.$store.commit('UPDATE_USERINFO', data.user);
|
that.$store.commit('UPDATE_USERINFO', data.user);
|
||||||
|
getSTokenApi()
|
||||||
let method
|
let method
|
||||||
let indexPat = ['/pages/index/index', '/pages/order_addcart/order_addcart',
|
let indexPat = ['/pages/index/index', '/pages/order_addcart/order_addcart',
|
||||||
'/pages/goods_cate/goods_cate',
|
'/pages/goods_cate/goods_cate',
|
||||||
@ -600,7 +604,7 @@
|
|||||||
});
|
});
|
||||||
that.$store.commit("SETUID", data.result.user.uid);
|
that.$store.commit("SETUID", data.result.user.uid);
|
||||||
that.$store.commit('UPDATE_USERINFO', data.result.user);
|
that.$store.commit('UPDATE_USERINFO', data.result.user);
|
||||||
|
getSTokenApi()
|
||||||
let method
|
let method
|
||||||
let indexPat = ['/pages/index/index', '/pages/order_addcart/order_addcart',
|
let indexPat = ['/pages/index/index', '/pages/order_addcart/order_addcart',
|
||||||
'/pages/goods_cate/goods_cate',
|
'/pages/goods_cate/goods_cate',
|
||||||
@ -692,6 +696,7 @@
|
|||||||
'token': data.result.token,
|
'token': data.result.token,
|
||||||
'time': data.result.exp
|
'time': data.result.exp
|
||||||
});
|
});
|
||||||
|
getSTokenApi()
|
||||||
that.$store.commit("SETUID", data.result.user.uid);
|
that.$store.commit("SETUID", data.result.user.uid);
|
||||||
that.$store.commit('UPDATE_USERINFO', data.result.user);
|
that.$store.commit('UPDATE_USERINFO', data.result.user);
|
||||||
let method
|
let method
|
||||||
@ -750,6 +755,7 @@
|
|||||||
'token': data.result.token,
|
'token': data.result.token,
|
||||||
'time': data.result.exp
|
'time': data.result.exp
|
||||||
});
|
});
|
||||||
|
getSTokenApi()
|
||||||
that.$store.commit("SETUID", data.result.user.uid);
|
that.$store.commit("SETUID", data.result.user.uid);
|
||||||
that.$store.commit('UPDATE_USERINFO', data.result.user);
|
that.$store.commit('UPDATE_USERINFO', data.result.user);
|
||||||
let method
|
let method
|
||||||
@ -847,6 +853,7 @@
|
|||||||
'token': data.token,
|
'token': data.token,
|
||||||
'time': data.exp
|
'time': data.exp
|
||||||
});
|
});
|
||||||
|
getSTokenApi()
|
||||||
that.$store.commit("SETUID", data.user.uid);
|
that.$store.commit("SETUID", data.user.uid);
|
||||||
that.$store.commit('UPDATE_USERINFO', data.user);
|
that.$store.commit('UPDATE_USERINFO', data.user);
|
||||||
|
|
||||||
@ -924,6 +931,7 @@
|
|||||||
'token': res.data.token,
|
'token': res.data.token,
|
||||||
'time': res.data.exp
|
'time': res.data.exp
|
||||||
});
|
});
|
||||||
|
getSTokenApi()
|
||||||
that.$store.commit("SETUID", res.data.user.uid);
|
that.$store.commit("SETUID", res.data.user.uid);
|
||||||
that.$store.commit('UPDATE_USERINFO', res.data.user);
|
that.$store.commit('UPDATE_USERINFO', res.data.user);
|
||||||
const backUrl = that.$Cache.get('login_back_url_weixin') || that.$Cache.get(BACK_URL) ||
|
const backUrl = that.$Cache.get('login_back_url_weixin') || that.$Cache.get(BACK_URL) ||
|
||||||
@ -1007,6 +1015,7 @@
|
|||||||
'token': res.data.token,
|
'token': res.data.token,
|
||||||
'time': res.data.exp
|
'time': res.data.exp
|
||||||
});
|
});
|
||||||
|
getSTokenApi()
|
||||||
that.$store.commit("SETUID", res.data.user.uid);
|
that.$store.commit("SETUID", res.data.user.uid);
|
||||||
that.$store.commit('UPDATE_USERINFO', res.data.user);
|
that.$store.commit('UPDATE_USERINFO', res.data.user);
|
||||||
const backUrl = that.$Cache.get('login_back_url_weixin') || that.$Cache.get(BACK_URL) ||
|
const backUrl = that.$Cache.get('login_back_url_weixin') || that.$Cache.get(BACK_URL) ||
|
||||||
@ -1092,6 +1101,7 @@
|
|||||||
'token': res.data.token,
|
'token': res.data.token,
|
||||||
'time': res.data.exp
|
'time': res.data.exp
|
||||||
});
|
});
|
||||||
|
getSTokenApi()
|
||||||
that.$store.commit("SETUID", res.data.user.uid);
|
that.$store.commit("SETUID", res.data.user.uid);
|
||||||
that.$store.commit('UPDATE_USERINFO', res.data.user);
|
that.$store.commit('UPDATE_USERINFO', res.data.user);
|
||||||
const backUrl = that.$Cache.get('login_back_url_weixin') || that.$Cache.get(BACK_URL) ||
|
const backUrl = that.$Cache.get('login_back_url_weixin') || that.$Cache.get(BACK_URL) ||
|
||||||
@ -1238,7 +1248,6 @@
|
|||||||
|
|
||||||
// 账号密码验证通过后的逻辑
|
// 账号密码验证通过后的逻辑
|
||||||
submitSuccess(data) {
|
submitSuccess(data) {
|
||||||
console.log(data, 'hanshu')
|
|
||||||
let that = this
|
let that = this
|
||||||
this.checkOpenId(data.user)
|
this.checkOpenId(data.user)
|
||||||
const backUrl = that.$Cache.get('login_back_url_weixin') || that.$Cache.get(BACK_URL) ||
|
const backUrl = that.$Cache.get('login_back_url_weixin') || that.$Cache.get(BACK_URL) ||
|
||||||
@ -1247,6 +1256,7 @@
|
|||||||
'token': data.token,
|
'token': data.token,
|
||||||
'time': data.exp
|
'time': data.exp
|
||||||
});
|
});
|
||||||
|
getSTokenApi()
|
||||||
that.$store.commit("SETUID", data.user.uid);
|
that.$store.commit("SETUID", data.user.uid);
|
||||||
that.$store.commit('UPDATE_USERINFO', data.user);
|
that.$store.commit('UPDATE_USERINFO', data.user);
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import {
|
|||||||
} from "../../api/user.js";
|
} from "../../api/user.js";
|
||||||
import {
|
import {
|
||||||
LOGIN_STATUS,
|
LOGIN_STATUS,
|
||||||
|
LOGIN_STATUS_S,
|
||||||
UID,
|
UID,
|
||||||
USER_INFO
|
USER_INFO
|
||||||
} from '../../config/cache';
|
} from '../../config/cache';
|
||||||
@ -28,6 +29,7 @@ import {
|
|||||||
const state = {
|
const state = {
|
||||||
location: Cache.get('LOCATION_DATA', true) || {},
|
location: Cache.get('LOCATION_DATA', true) || {},
|
||||||
token: Cache.get(LOGIN_STATUS) || null,
|
token: Cache.get(LOGIN_STATUS) || null,
|
||||||
|
s_token: uni.getStorageSync(LOGIN_STATUS_S) || null,
|
||||||
uuid: uni.getStorageSync('uuid') || "",
|
uuid: uni.getStorageSync('uuid') || "",
|
||||||
backgroundColor: "#fff",
|
backgroundColor: "#fff",
|
||||||
userInfo: (typeof Cache.get('USER_INFO') == 'string' ? JSON.parse(Cache.get('USER_INFO')) : Cache.get(
|
userInfo: (typeof Cache.get('USER_INFO') == 'string' ? JSON.parse(Cache.get('USER_INFO')) : Cache.get(
|
||||||
@ -72,6 +74,7 @@ const mutations = {
|
|||||||
state.token = null;
|
state.token = null;
|
||||||
state.uid = null
|
state.uid = null
|
||||||
Cache.clear(LOGIN_STATUS);
|
Cache.clear(LOGIN_STATUS);
|
||||||
|
Cache.clear(LOGIN_STATUS_S);
|
||||||
Cache.clear(UID);
|
Cache.clear(UID);
|
||||||
},
|
},
|
||||||
BACKGROUND_COLOR(state, color) {
|
BACKGROUND_COLOR(state, color) {
|
||||||
|
@ -77,7 +77,7 @@ function baseRequest(url, method, data, {
|
|||||||
enLoad = false //终止上一个接口相同类型正在请求的接口, 防止快速切换tab时页面抖动
|
enLoad = false //终止上一个接口相同类型正在请求的接口, 防止快速切换tab时页面抖动
|
||||||
}) {
|
}) {
|
||||||
let Url = HTTP_REQUEST_URL,
|
let Url = HTTP_REQUEST_URL,
|
||||||
header = HEADER;
|
header = uni.$u.deepClone(HEADER);
|
||||||
if (!noAuth) {
|
if (!noAuth) {
|
||||||
//登录过期自动登录
|
//登录过期自动登录
|
||||||
if (!store.state.app.token && !checkLogin()) {
|
if (!store.state.app.token && !checkLogin()) {
|
||||||
|
@ -18,8 +18,6 @@ import {
|
|||||||
import store from '../store';
|
import store from '../store';
|
||||||
import pako from '../plugin/pako/pako.es5.min.js'
|
import pako from '../plugin/pako/pako.es5.min.js'
|
||||||
|
|
||||||
// let TOKENNAME = 'Token'
|
|
||||||
|
|
||||||
function toLogin() {
|
function toLogin() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -70,10 +68,11 @@ var HTTP_list = new Map();
|
|||||||
function baseRequest(url, method, data, {
|
function baseRequest(url, method, data, {
|
||||||
noAuth = false,
|
noAuth = false,
|
||||||
noVerify = false,
|
noVerify = false,
|
||||||
|
tokenName = 0, //判断token名称,值的Boolean值为true时为X-token,一般为token
|
||||||
enLoad = false //终止上一个接口相同类型正在请求的接口, 防止快速切换tab时页面抖动
|
enLoad = false //终止上一个接口相同类型正在请求的接口, 防止快速切换tab时页面抖动
|
||||||
}) {
|
}) {
|
||||||
let Url = HTTP_REQUEST_URL_TWO,
|
let Url = HTTP_REQUEST_URL_TWO,
|
||||||
header = HEADER;
|
header = uni.$u.deepClone(HEADER);
|
||||||
let URL = Url + '/api/' + url
|
let URL = Url + '/api/' + url
|
||||||
if (enLoad) {
|
if (enLoad) {
|
||||||
let http = HTTP_list.get(URL);
|
let http = HTTP_list.get(URL);
|
||||||
@ -82,7 +81,12 @@ function baseRequest(url, method, data, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
HTTP_list.delete(URL);
|
HTTP_list.delete(URL);
|
||||||
if (store.state.app.token) header[TOKENNAME] = 'Bearer ' + store.state.app.token;
|
|
||||||
|
if (tokenName) {
|
||||||
|
if (store.state.app.token) header[TOKENNAME] = 'Bearer' + store.state.app.token;
|
||||||
|
} else {
|
||||||
|
if (store.state.app.s_token) header['Token'] = store.state.app.s_token;
|
||||||
|
}
|
||||||
if (store.state.app.uuid) header['uuid'] = store.state.app.uuid
|
if (store.state.app.uuid) header['uuid'] = store.state.app.uuid
|
||||||
return new Promise((reslove, reject) => {
|
return new Promise((reslove, reject) => {
|
||||||
let http = uni.request({
|
let http = uni.request({
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
// 控制tabbar是否显示
|
// 控制tabbar是否显示
|
||||||
import store from "@/store/index.js"
|
import store from "@/store/index.js"
|
||||||
|
|
||||||
export const showTab = (data)=>{
|
const setTab = (index, visible) => {
|
||||||
let user = data || store.state.app.userInfo;
|
uni.setTabBarItem({
|
||||||
if(user.mer_info&&user.mer_info.mer_settlement_agree_status){
|
index,
|
||||||
uni.setTabBarItem({
|
visible,
|
||||||
index: 1,
|
fail: (e) => {
|
||||||
visible: true,
|
console.log(e);
|
||||||
fail:(e)=>{
|
}
|
||||||
console.log(e);
|
})
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}else {
|
export const showTab = (data) => {
|
||||||
uni.setTabBarItem({
|
setTab(4, Boolean(store.state.app.s_token))
|
||||||
index: 1,
|
|
||||||
visible: false,
|
let user = data || store.state.app.userInfo;
|
||||||
fail:(e)=>{
|
if (user.mer_info && user.mer_info.mer_settlement_agree_status) {
|
||||||
console.log(e);
|
setTab(1, true)
|
||||||
}
|
} else {
|
||||||
})
|
setTab(1, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user