登录页(无感)

parent d200caea
<script setup> <script setup>
import { getTokenUser } from './api/index'; onLaunch(() => {});
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);
}
});
});
onShow(() => { onShow(() => {
console.log('App Show'); console.log('App Show');
...@@ -23,22 +8,6 @@ onShow(() => { ...@@ -23,22 +8,6 @@ onShow(() => {
onHide(() => { onHide(() => {
console.log('App Hide'); 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> </script>
<style> <style>
.multi-line { .multi-line {
......
...@@ -31,13 +31,13 @@ const title = ref('小程序平台'); ...@@ -31,13 +31,13 @@ const title = ref('小程序平台');
const { countInfo, addCount } = useCountStore(); const { countInfo, addCount } = useCountStore();
const test = ref(''); const test = ref('');
onMounted(() => { onMounted(() => {
xma.xh.getUserProfile({ // xma.xh.getUserProfile({
range: ['ACCOUNT', 'MOBILE', 'CITIZEN'], // range: ['ACCOUNT', 'MOBILE', 'CITIZEN'],
async success(info) { // async success(info) {
const info2 = JSON.stringify(info); // const info2 = JSON.stringify(info);
test.value = info2; // test.value = info2;
}, // },
}); // });
}); });
const search = (res) => { const search = (res) => {
......
...@@ -6,6 +6,13 @@ ...@@ -6,6 +6,13 @@
} }
}, },
"pages": [ "pages": [
{
"path": "pages/index/loading",
"style": {
"navigationBarTitleText": "加载",
"navigationStyle":"custom"
}
},
{ {
"path": "pages/index/index", "path": "pages/index/index",
"style": { "style": {
......
...@@ -155,7 +155,9 @@ import FoodDetails from '../../components/index/FoodDetails.vue'; ...@@ -155,7 +155,9 @@ import FoodDetails from '../../components/index/FoodDetails.vue';
import ShopCard from '../../components/index/ShopCard.vue'; import ShopCard from '../../components/index/ShopCard.vue';
import Marketing from '../../components/index/Marketing.vue'; import Marketing from '../../components/index/Marketing.vue';
import Position from '../../components/index/Position.vue'; import Position from '../../components/index/Position.vue';
import { orderStatus } from '../../utils/signIn';
import { import {
getTokenUser,
groupBuyList, groupBuyList,
groupImgList, groupImgList,
popularityPage, popularityPage,
...@@ -165,9 +167,8 @@ import { ...@@ -165,9 +167,8 @@ import {
receiveCoupon, receiveCoupon,
} from '../../api/index'; } from '../../api/index';
import { timeConversion } from '../../utils/tool'; import { timeConversion } from '../../utils/tool';
const nowTime = ref(new Date().getTime());
// import testJson from '../../static/json/test.json'; // import testJson from '../../static/json/test.json';
// import { getToken } from '../../utils/auth'; const nowTime = ref(new Date().getTime());
const title = ref('小程序平台'); const title = ref('小程序平台');
const { countInfo, addCount } = useCountStore(); const { countInfo, addCount } = useCountStore();
// 附近美食 // 附近美食
...@@ -205,7 +206,8 @@ const coupon = ref([]); ...@@ -205,7 +206,8 @@ const coupon = ref([]);
let total; let total;
// 轮播图数据 // 轮播图数据
let lunboData; let lunboData;
onMounted(() => { onMounted(async () => {
orderStatus();
getClassification(); getClassification();
rotatingBroadcast(); rotatingBroadcast();
nearbyFood(); nearbyFood();
...@@ -213,6 +215,7 @@ onMounted(() => { ...@@ -213,6 +215,7 @@ onMounted(() => {
getMerchantList(); getMerchantList();
getCouponMainList(); getCouponMainList();
}); });
function jumpProductDetails(item) { function jumpProductDetails(item) {
xma.navigateTo({ xma.navigateTo({
url: '/pages/shop/shop?shopId=' + item.shopId, 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