登录页(无感)

parent d200caea
<script setup>
import { getTokenUser } from './api/index';
import { sgyOrderGetStatus } from './api/order';
import testJson from './static/json/test.json';
import { getToken } from './utils/auth';
import { setOrderDic } from './utils/orderDic';
// beforeMount(() => {
// if (!getToken()) signIn();
// });
onLaunch(() => {
if (!getToken()) signIn();
sgyOrderGetStatus().then((res) => {
if (res.code === 0) {
setOrderDic(res.data.store);
}
});
});
onLaunch(() => {});
onShow(() => {
console.log('App Show');
......@@ -23,22 +8,6 @@ onShow(() => {
onHide(() => {
console.log('App Hide');
});
// 登录
const signIn = () => {
xma.xh.getUserProfile({
range: ['ACCOUNT', 'MOBILE', 'CITIZEN'],
async success(info) {
const info2 = JSON.stringify(info);
getTokenUser(info2).then((res) => {
const token = res.data.access_token;
const userInfo = res.data.user_info;
xma.setStorageSync('Authorization', token);
xma.setStorageSync('userInfo', userInfo);
console.log('登录...');
});
},
});
};
</script>
<style>
.multi-line {
......
......@@ -31,13 +31,13 @@ const title = ref('小程序平台');
const { countInfo, addCount } = useCountStore();
const test = ref('');
onMounted(() => {
xma.xh.getUserProfile({
range: ['ACCOUNT', 'MOBILE', 'CITIZEN'],
async success(info) {
const info2 = JSON.stringify(info);
test.value = info2;
},
});
// xma.xh.getUserProfile({
// range: ['ACCOUNT', 'MOBILE', 'CITIZEN'],
// async success(info) {
// const info2 = JSON.stringify(info);
// test.value = info2;
// },
// });
});
const search = (res) => {
......
......@@ -6,6 +6,13 @@
}
},
"pages": [
{
"path": "pages/index/loading",
"style": {
"navigationBarTitleText": "加载",
"navigationStyle":"custom"
}
},
{
"path": "pages/index/index",
"style": {
......
......@@ -155,7 +155,9 @@ import FoodDetails from '../../components/index/FoodDetails.vue';
import ShopCard from '../../components/index/ShopCard.vue';
import Marketing from '../../components/index/Marketing.vue';
import Position from '../../components/index/Position.vue';
import { orderStatus } from '../../utils/signIn';
import {
getTokenUser,
groupBuyList,
groupImgList,
popularityPage,
......@@ -165,9 +167,8 @@ import {
receiveCoupon,
} from '../../api/index';
import { timeConversion } from '../../utils/tool';
const nowTime = ref(new Date().getTime());
// import testJson from '../../static/json/test.json';
// import { getToken } from '../../utils/auth';
const nowTime = ref(new Date().getTime());
const title = ref('小程序平台');
const { countInfo, addCount } = useCountStore();
// 附近美食
......@@ -205,7 +206,8 @@ const coupon = ref([]);
let total;
// 轮播图数据
let lunboData;
onMounted(() => {
onMounted(async () => {
orderStatus();
getClassification();
rotatingBroadcast();
nearbyFood();
......@@ -213,6 +215,7 @@ onMounted(() => {
getMerchantList();
getCouponMainList();
});
function jumpProductDetails(item) {
xma.navigateTo({
url: '/pages/shop/shop?shopId=' + item.shopId,
......
<template>
<view class="loading"></view>
</template>
<script setup>
import {} from 'vue';
import { signIn } from '../../utils/signIn';
import testJson from '../../static/json/test.json';
import { getTokenUser } from '../../api/index';
import { getToken } from '../../utils/auth';
onMounted(async () => {
// await signIn();
if (!getToken()) await signIn2();
xma.reLaunch({ url: '/pages/index/index' });
});
// 登录
const signIn2 = () => {
xma.showLoading({
title: '加载中',
mask: true,
});
return getTokenUser(testJson).then((res) => {
const token = res.data.access_token;
const userInfo = res.data.user_info;
xma.setStorageSync('Authorization', token);
xma.setStorageSync('userInfo', userInfo);
console.log('登录...');
});
};
</script>
<style lang="scss" scoped></style>
import { getTokenUser } from '../api/index';
import { sgyOrderGetStatus } from '../api/order';
import { setOrderDic } from '../utils/orderDic';
// 登录
export const signIn = () => {
xma.showLoading({
title: '加载中',
mask: true,
});
return new Promise((resolve, reject) => {
xma.xh.getUserProfile({
range: ['ACCOUNT', 'MOBILE', 'CITIZEN'],
success(info) {
getTokenUser(info.data).then((res) => {
xma.hideLoading();
const token = res.data.access_token;
const userInfo = res.data.user_info;
xma.setStorageSync('Authorization', token);
xma.setStorageSync('userInfo', userInfo);
resolve();
});
},
});
});
};
export const orderStatus = () => {
sgyOrderGetStatus().then((res) => {
if (res.code === 0) {
setOrderDic(res.data.store);
}
});
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment