Files
cmgd-mini-app/pages/mine/index.vue
2026-01-05 12:47:14 +08:00

278 lines
6.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="page-content">
<view class="user-inner" v-if="uid > 0">
<view>
<nut-avatar size="large">用户</nut-avatar>
</view>
<!--<image :src="user_info.image"></image>-->
<view class="user-info-style">
<text class="nickname">{{ userInfo.nickName }}</text>
<text class="user-id">UID{{ userInfo.user_id }}</text>
</view>
</view>
<view class="user-inner" v-else>
<view @click="goToLoginPage()">
<nut-avatar size="large">
<nut-icon name="my" />
</nut-avatar>
</view>
<view @click="goToLoginPage()">
<text>点击登录</text>
</view>
</view>
<view class="content">
<nut-cell-group title="店铺管理">
<nut-grid>
<nut-grid-item text="商城配置" @click="navigateTo('/pages/config/store')">
<nut-icon name="people"></nut-icon>
</nut-grid-item>
<nut-grid-item text="价格调整" @click="navigateTo('/pages/config/price')">
<nut-icon name="refresh"></nut-icon>
</nut-grid-item>
<nut-grid-item text="商品管理" @click="navigateTo('/pages/config/goodsList')">
<nut-icon name="shop"></nut-icon>
</nut-grid-item>
<nut-grid-item text="店铺订单" @click="navigateTo('/pages/config/shopOrder/index?tab=0')">
<nut-icon name="order"></nut-icon>
</nut-grid-item>
<!-- <nut-grid-item text="仓库订单" @click="navigateTo('/pages/order/list/index?tab=3')">
<nut-icon name="order"></nut-icon> -->
<!-- </nut-grid-item> -->
</nut-grid>
</nut-cell-group>
<nut-cell-group title="我的订单" v-if="showMyOrder && !audit">
<nut-grid>
<nut-grid-item text="全部"
@click="navigateTo('/pages/order/index?tab=0')">{{ countInfo.all }}</nut-grid-item>
<nut-grid-item text="待付款"
@click="navigateTo('/pages/order/index?tab=1')">{{ countInfo.payment }}</nut-grid-item>
<nut-grid-item text="待发货"
@click="navigateTo('/pages/order/index?tab=2')">{{ countInfo.delivery }}</nut-grid-item>
<nut-grid-item text="待收货"
@click="navigateTo('/pages/order/index?tab=3')">{{ countInfo.received }}</nut-grid-item>
</nut-grid>
</nut-cell-group>
<!-- <nut-cell-group title="控制台">
<nut-cell title="商城配置" @click="navigateTo('')"></nut-cell>
<nut-cell title="价格调整" @click="navigateTo('/pages/config/index')"></nut-cell>
<nut-cell title="店内机器管理" @click="navigateTo('/pages/config/index')"></nut-cell>
<nut-cell title="订单管理" @click="navigateTo('/pages/config/index')"></nut-cell> -->
<!-- <nut-cell v-if="user_info.super_user_from.includes('parts')" title="配件管理"
@click="navigateTo('/pages/control/parts/index')"></nut-cell> -->
<!-- </nut-cell-group> -->
<!-- <nut-cell-group title="控制台" v-if="user_info.is_super_user">
<nut-cell v-if="user_info.super_user_from.includes('store')" title="手机管理"
@click="navigateTo('/pages/control/goods/index')"></nut-cell> -->
<!-- <nut-cell v-if="user_info.super_user_from.includes('parts')" title="配件管理"
@click="navigateTo('/pages/control/parts/index')"></nut-cell> -->
<!-- </nut-cell-group> -->
<nut-cell-group title="联系我们">
<nut-cell :title="phone" @click="makePhoneCall(phone)"></nut-cell>
</nut-cell-group>
</view>
</view>
</template>
<script setup>
// 导入Vue的响应式函数
import {
reactive,
ref
} from 'vue';
import {
onLoad,
onShow,
} from '@dcloudio/uni-app';
// import TabBar from '@/components/TabBar/TabBar.vue';
// 默认选中第一个tab
// const currentTab = ref(3);
// 导入获取用户信息的API函数
import {
fetchUserInfo
} from '@/api/user';
// 导入页面跳转工具函数
import {
goToLoginPage,
navigateTo
} from '@/utils/helper';
// 导入uni-app生命周期钩子
// 导入获取订单总数的API函数
import {
fetchOrderTotalCount
} from '@/api/order';
import {
fetchGetConfig
} from '@/api/config';
const audit = ref(true);
const showMyOrder = ref(false);
const phone = ref('');
// 用户ID
const uid = ref(0);
/**
* 用户信息响应式对象
*/
const userInfo = reactive({});
/**
* 订单统计信息响应式对象
*/
const countInfo = reactive({
all: 0,
payment: 0,
delivery: 0,
received: 0
});
onLoad(options => {
});
const makePhoneCall = (phoneNumber) => {
console.log(123);
uni.makePhoneCall({
phoneNumber: phoneNumber,
success: () => {
console.log('拨打电话成功');
},
fail: (err) => {
console.error('拨打电话失败:', err);
}
});
}
// 获取配置
const getConfig = () => {
fetchGetConfig().then(res => {
console.log('getConfig=====>', res)
audit.value = res.appConfig.is_audit == 1
phone.value = res.appConfig.shop_phone
})
}
/**
* 页面显示生命周期钩子
* 每次页面显示时都会执行
*/
onShow(() => {
console.log('init');
let userId = uni.getStorageSync('uid');
console.log("userId", userId);
uid.value = userId
// 获取配置
getConfig()
// 如果用户登陆
if (uid.value > 0) {
// 获取用户信息
fetchUserInfo().then(res => {
// if (res.is_bind_phone) {
// navigateTo('/pages/login/phoneAuthorization');
// return
// }
// 将API返回的数据合并到userInfo响应式对象中
Object.assign(userInfo, res);
// 显示订单
showMyOrder.value = true
// 获取订单总数统计
fetchOrderTotalCount().then(res => {
// 将API返回的数据合并到count_info响应式对象中
Object.assign(countInfo, res);
});
});
}
});
</script>
<style scoped lang="scss">
.page-content {
min-height: 100vh;
background-color: #f2f3f5;
}
.user-inner {
background: linear-gradient(30deg, rgba(198, 77, 255, 0.99), rgba(102, 204, 255, 0.99));
height: 150px;
width: calc(100% - 20px);
display: flex;
align-items: center;
padding: 0px 10px;
gap: 15px;
}
.user-info-style {
display: flex;
flex-direction: column;
align-items: flex-start;
}
.nickname {
font-size: 20px;
/* 大字体 */
font-weight: bold;
/* 加粗 */
color: #333;
/* 深色文字 */
margin-bottom: 5px;
/* 与UID的间距 */
}
.user-id {
font-size: 14px;
/* 小字体 */
color: #fff;
/* 浅色文字 */
}
.content {
display: flex;
flex-direction: column;
/* align-items: center; */
// justify-content: center;
background-color: #f2f3f5;
padding: 0px 10px;
// height: calc(100vh - 150px);
}
</style>