websoft-uniapp仓库模板
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

293 lines
7.5 KiB

<template>
<view class="page">
<!-- 顶部距离 -->
<view class="header" :style="'margin-top: ' + statusBarHeight + 'px'"></view>
<!-- 用户信息 -->
<ws-admin-card :merchantList="merchantList" :merchantId="merchantId" :data="userInfo" :is-login="isLogin" @openLogin="openLogin" />
<block v-if="hideTools">
<uni-card :border="false" :padding="'18px 8px'">
<uv-skeleton rows="2" :loading="hideTools" :title="false">
</uv-skeleton>
</uni-card>
<uni-card :border="false" :padding="'18px 8px'">
<uv-skeleton rows="9" :loading="hideTools" :title="false">
</uv-skeleton>
</uni-card>
</block>
<block v-else>
<!-- 收藏|关注|足迹|作品 -->
<!-- <ws-user-collect></ws-user-collect> -->
<!-- 我的订单 -->
<ws-user-order :order="order" :is-login="isLogin" @done="openLogin"></ws-user-order>
<!-- 其他功能 -->
<uni-card :border="false" :padding="0">
<!-- 场馆管理可见-->
<block v-if="hasMerchantRole || hasMerchantClerkRole">
<view class="server" style="min-height: 200px;">
<uni-list :border="false">
<block v-for="(item,index) in server" :key="index">
<uni-list-item :thumb="item.icon" link @click="navTo(item)">
<template v-slot:body>
<view class="slot-box">
<text class="slot-text"
:style="{color: item.color ? item.color : '#333333'}">{{ item.title }}</text>
</view>
</template>
</uni-list-item>
</block>
</uni-list>
</view>
</block>
<block v-else>
<!-- 普通会员菜单 -->
<view class="server" style="min-height: 200px;">
<uni-list :border="false">
<block v-for="(item,index) in server" :key="index">
<uni-list-item :thumb="item.icon" link @click="navTo(item)">
<template v-slot:body>
<view class="slot-box">
<text class="slot-text"
:style="{color: item.color ? item.color : '#333333'}">{{ item.title }}</text>
</view>
</template>
</uni-list-item>
</block>
</uni-list>
</view>
</block>
</uni-card>
<view class="debug">
<view>条码类型: {{ scanType }}</view>
<view>条码内容: {{ scanResult }}</view>
</view>
<!-- 登录组件 -->
<ws-login ref="login" :logo="logo" @done="reload" />
<!-- 返回 -->
<view class="logout" @click="goBack">
<view size="20" class="btn">返回</view>
</view>
</block>
</view>
</template>
<script>
import {
useUserStore
} from '@/store/modules/user';
import * as UserApi from '@/api/booking/users';
import * as MpMenuApi from '@/api/cms/mp-menu/index';
import * as MerchantApi from '@/api/shop/merchant';
import {
updateUsers
} from '@/api/shop/users';
import {
openUrl
} from '@/utils/common';
import {
getWxOpenId
} from '@/api/passport/login';
import {
useTenantStore
} from '@/store/modules/tenant';
const tenantStore = useTenantStore();
const userStore = useUserStore();
export default {
data() {
return {
statusBarHeight: 104,
isLogin: false,
userInfo: {},
currMerchant: {},
merchantId: null,
fields: {},
logo: '',
bookingUser: {},
server: [],
order: [],
hideUser: true,
hideTools: true,
// 是否拥有场馆管理员权限
hasMerchantRole: false,
// 是否拥有场馆职员权限
hasMerchantClerkRole: false,
// 是否拥有超级管理员权限
hasSuperAdminRole: false,
scanType: '',
scanResult: ''
}
},
onLoad() {
this.reload()
},
methods: {
async reload(e) {
const app = this
// 获取系统信息
uni.getSystemInfo({
success(data) {
if (data) {
app.statusBarHeight = data.statusBarHeight
}
}
})
// 当前租户信息
const tenantInfo = await tenantStore.fetchTenantInfo();
app.logo = tenantInfo.websiteLogo;
if (tenantInfo.fields) {
tenantInfo.fields.map(d => {
const key = d.name;
app.fields[key] = d.value;
})
}
// 当前登录用户信息
const userInfo = await userStore.fetchUserInfo();
if (Object.keys(userInfo).length > 0) {
app.isLogin = true
app.userInfo = userInfo
uni.setStorageSync('user_id', app.userInfo.userId);
// 判断用户角色
app.hasMerchantRole = userInfo.roles.find(d => d.roleCode == 'merchant');
app.hasMerchantClerkRole = userInfo.roles.find(d => d.roleCode == 'merchantClerk');
app.hasSuperAdminRole = userInfo.roles.find(d => d.roleCode == 'superAdmin');
// 可管理的场馆
MerchantApi.pageMerchant({merchantIds: userInfo.merchants,limit: 50}).then((res) => {
app.merchantList = res.list.map((d,i) => {
if(i == 0){
app.currMerchant = d;
app.merchantId = d.merchantId;
}
return {
text: d.merchantName,
value: d.merchantId
}
})
});
// 获取用户副表信息
UserApi.getByPhone({
phone: userInfo.phone
}).then(data => {
if (data) {
app.hideUser = false
app.userInfo.ouid = data.userId;
app.userInfo = Object.assign({}, app.userInfo, data);
}
})
} else {
app.isLogin = false
app.userInfo = {}
}
// 菜单数据
MpMenuApi.pageMpMenu({ type: 4, limit: 100 })
.then((res) => {
app.order = res.list.filter((d) => d.rows == 0);
app.server = res.list.filter((d) => d.rows == 0);
app.hideTools = false;
})
.catch(() => {
uni.showToast({
title: '请检查您的网络.',
icon: 'none'
});
app.hideTools = false;
});
// #ifdef MP-WEIXIN
uni.login({
success: (res) => {
getWxOpenId({
code: res.code
}).then(response => {
// console.log("response401: ", response);
// console.log('app.userInfo.openid: ', app.userInfo.openid);
if (!app.userInfo.openid) {
updateUsers({
userId: app.userInfo.ouid,
openid: response.openid,
sessionKey: response.session_key,
unionid: response.unionid
})
}
})
}
})
// #endif
},
navTo(item) {
const app = this
if (!this.isLogin) {
this.$refs.login.open('bottom')
return false;
} else {
if(item.path == '/package/admin/order-scan'){
console.log('item.path: ',item.path);
// 允许从相机和相册扫码
uni.scanCode({
success: function (res) {
app.scanType = res.scanType
app.scanResult = res.result
if(res.scanType){
console.log(item.path + '?orderNo=' + res.result);
uni.redirectTo({
url: item.path + '?orderNo=' + res.result
})
}
}
});
return false;
}else{
openUrl(item);
}
}
},
// 弹出登录提示框
openLogin() {
if (!this.isLogin) {
this.$refs.login.open('bottom')
return false;
}
},
goBack(){
return uni.switchTab({
url: '/pages/user/user'
});
}
}
}
</script>
<style>
page {
/* background: url('https://oss.wsdns.cn/20240502/75fc744657544a38a32f83a825688286.png') no-repeat; */
background-size: 100%;
background-repeat: no-repeat;
background-color: #f0f2f5;
width: 750rpx;
overflow-x: hidden;
}
</style>
<style lang="scss">
.logout{
width: 300rpx;
margin: 0 auto;
padding: 10rpx 0 20rpx 0;
.btn {
display: flex;
justify-content: center;
background-color: #fff;
border-radius: 30rpx;
padding: 12rpx 0;
color: $uni-text-color-placeholder;
}
}
</style>