优惠券页面登录

parent 37b3f92c
...@@ -121,10 +121,21 @@ ...@@ -121,10 +121,21 @@
<script setup> <script setup>
import { myCouponListApi, userCouponStatisticsApi } from '@/api/ticket'; import { myCouponListApi, userCouponStatisticsApi } from '@/api/ticket';
import { signIn } from '@/utils/signIn';
import Header from '@/pages/order/components/Header/index.vue'; import Header from '@/pages/order/components/Header/index.vue';
import testJson from '@/static/json/test.json';
import { getTokenUser } from '@/api/index';
import { getToken } from '@/utils/auth';
const fileDomain = import.meta.env.VITE_APP_IMG_URL; const fileDomain = import.meta.env.VITE_APP_IMG_URL;
onLoad(async () => {
if (!getToken()) await signIn();
// if (!getToken()) await signIn2();
getStatistics();
getCouponList();
});
// 优惠券状态 0:失效 2:已使用,3-未使用 // 优惠券状态 0:失效 2:已使用,3-未使用
const iconUrl = ref({ const iconUrl = ref({
0: '@/static/ticket/past-icon.png', 0: '@/static/ticket/past-icon.png',
...@@ -173,7 +184,6 @@ const getStatistics = async () => { ...@@ -173,7 +184,6 @@ const getStatistics = async () => {
discountAmount.value = res.data; discountAmount.value = res.data;
} }
}; };
getStatistics();
/** /**
* 获取用户优惠券列表 * 获取用户优惠券列表
...@@ -213,7 +223,21 @@ const getCouponList = async () => { ...@@ -213,7 +223,21 @@ const getCouponList = async () => {
// state.value = 'finished'; // state.value = 'finished';
xma.hideLoading(); xma.hideLoading();
}; };
getCouponList();
// 登录
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('登录...');
});
};
// 下拉刷新 // 下拉刷新
onPullDownRefresh(() => { onPullDownRefresh(() => {
......
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