94 lines
2.0 KiB
JavaScript
94 lines
2.0 KiB
JavaScript
// app.js
|
|
const { createApp } = Vue;
|
|
|
|
const { ElButton, ElMessage, ElInput, ElCard, ElRow, ElForm, ElFormItem, ElDivider, ElLoading } = ElementPlus;
|
|
const app = createApp({
|
|
data() {
|
|
return {
|
|
userlogo: null,
|
|
UserInfo: null,
|
|
page: null,
|
|
purchases: null,
|
|
cart: null,
|
|
ld: true,
|
|
}
|
|
},
|
|
async mounted() {
|
|
// 生命周期钩子 - 挂载后
|
|
console.log('应用已挂载');
|
|
this.getinfo();
|
|
|
|
},
|
|
methods: {
|
|
go(link) {
|
|
|
|
|
|
Message.info('跳转中...');
|
|
window.location.href = link;
|
|
},
|
|
viewcart() {
|
|
this.ldo();
|
|
axios.get('/Main/GetGoods/')
|
|
.then(response => {
|
|
this.ldx();
|
|
this.cart = response.data;
|
|
this.cart_fid = Object.keys(this.cart)[0];
|
|
})
|
|
},
|
|
ldo() {
|
|
this.ld = true;
|
|
},
|
|
ldx() {
|
|
this.ld = false;
|
|
},
|
|
getinfo() {
|
|
this.ldo();
|
|
axios.get('/Main/GetInfo/')
|
|
.then(response => {
|
|
|
|
this.ldx();
|
|
Message.closeAll();
|
|
if (response.data.code === 200) {
|
|
this.UserInfo = response.data.msg;
|
|
|
|
this.page = "home";
|
|
if (response.data.msg.qq != null) {
|
|
this.userlogo = "https://q1.qlogo.cn/g?b=qq&nk="+response.data.msg.qq+"&s=640";
|
|
}
|
|
} else {
|
|
|
|
Message.warning('请先登陆');
|
|
// 1 秒后跳转到指定页面
|
|
setTimeout(function() {
|
|
window.location.href = "/Main/Login";
|
|
}, 2000); // 1000 毫秒 = 1 秒
|
|
|
|
}
|
|
})
|
|
},
|
|
getpurchases() {
|
|
|
|
this.ldo();
|
|
axios.get('/Main/GetProducts/')
|
|
|
|
.then(response => {
|
|
|
|
this.ldx();
|
|
if (response.data.code === 200) {
|
|
this.purchases = response.data.msg;
|
|
} else {
|
|
|
|
|
|
Message.warning('获取业务失败');
|
|
}
|
|
})
|
|
|
|
},
|
|
|
|
}
|
|
});
|
|
|
|
// 挂载到DOM元素
|
|
app.use(ElementPlus);
|
|
app.mount('#app');
|