框架更新

This commit is contained in:
2024-08-02 23:22:38 +08:00
parent 0cda1968e8
commit ff46808425
214 changed files with 6171 additions and 15881 deletions
+495 -515
View File
File diff suppressed because it is too large Load Diff
+451 -387
View File
@@ -1,407 +1,471 @@
<template>
<view class="waterfall">
<!-- 商城导航图标 -->
<block v-if="navigation.length > 0">
<div class="user-oreder web-cell">
<block v-for="(item,index) in goodsCategoryList" :key="index">
<div class="web-cell-content web-text-center" @click="onCategory(item)">
<image :src="item.image" style="width: 30px; height: 30px;" mode="widthFix"></image>
<text>{{ item.title }}</text>
</div>
</block>
</div>
</block>
<block v-else>
<uni-card :border="false" :padding="'12px 4px'">
<view class="web-cell" style="justify-content: center; align-items: center;">
<uv-skeleton rows="0" avatar :loading="hideTools" :title="false">
</uv-skeleton>
<uv-skeleton rows="0" avatar :loading="hideTools" :title="false">
</uv-skeleton>
<uv-skeleton rows="0" avatar :loading="hideTools" :title="false">
</uv-skeleton>
<uv-skeleton rows="0" avatar :loading="hideTools" :title="false">
</uv-skeleton>
</view>
</uni-card>
</block>
<block v-if="!hideTools">
<view class="waterfall">
<uv-waterfall ref="waterfall" v-model="goodsList" :add-time="10" :left-gap="leftGap"
:right-gap="rightGap" :column-gap="columnGap" @changeList="changeList">
<!-- 第一列数据 -->
<template v-slot:list1>
<!-- 为了磨平部分平台的BUG,必须套一层view -->
<view>
<view v-for="(item, index) in list1" :key="item.id" class="waterfall-item">
<view class="waterfall-item__image" :style="[imageStyle(item)]" @click="navTo(item)">
<image :src="item.image ? JSON.parse(item.image)[0] : []" mode="widthFix"
:style="{width:item.width+'px'}"></image>
</view>
<view class="waterfall-item__ft">
<view class="waterfall-item__ft__title" @click="navTo(item)">
<text class="value">{{item.goodsName}}</text>
</view>
<view class="waterfall-item__ft__desc uv-line-2">
<text class="web-text-danger">¥{{ item.price }}</text>
</view>
</view>
</view>
</view>
</template>
<!-- 第二列数据 -->
<template v-slot:list2>
<!-- 为了磨平部分平台的BUG,必须套一层view -->
<view>
<view v-for="(item, index) in list2" :key="item.id" class="waterfall-item">
<view class="waterfall-item__image" :style="[imageStyle(item)]" @click="navTo(item)">
<image :src="item.image ? JSON.parse(item.image)[0] : []" mode="widthFix"
:style="{width:item.width+'px'}"></image>
</view>
<view class="waterfall-item__ft">
<view class="waterfall-item__ft__title" @click="navTo(item)">
<text class="value">{{item.goodsName}}</text>
</view>
<view class="waterfall-item__ft__desc uv-line-2">
<text class="web-text-danger">¥{{ item.price }}</text>
</view>
</view>
</view>
</view>
</template>
</uv-waterfall>
</view>
</block>
<block v-else>
<view class="skeleton" style="display: flex;">
<uni-card :border="false" :padding="'18px 6px'">
<uv-skeleton rows="0" avatar avatarShape="square" avatarSize="100" :loading="hideTools"
:title="false">
</uv-skeleton>
<uv-gap height="16"></uv-gap>
<uv-skeleton rows="2" :loading="hideTools" :title="false">
</uv-skeleton>
</uni-card>
<uni-card :border="false" :padding="'18px 6px'">
<uv-skeleton rows="0" avatar avatarShape="square" avatarSize="100" :loading="hideTools"
:title="false">
</uv-skeleton>
<uv-gap height="16"></uv-gap>
<uv-skeleton rows="2" :loading="hideTools" :title="false">
</uv-skeleton>
</uni-card>
</view>
<view class="skeleton" style="display: flex;">
<uni-card :border="false" :padding="'18px 6px'">
<uv-skeleton rows="0" avatar avatarShape="square" avatarSize="100" :loading="hideTools"
:title="false">
</uv-skeleton>
<uv-gap height="16"></uv-gap>
<uv-skeleton rows="2" :loading="hideTools" :title="false">
</uv-skeleton>
</uni-card>
<uni-card :border="false" :padding="'18px 6px'">
<uv-skeleton rows="0" avatar avatarShape="square" avatarSize="100" :loading="hideTools"
:title="false">
</uv-skeleton>
<uv-gap height="16"></uv-gap>
<uv-skeleton rows="2" :loading="hideTools" :title="false">
</uv-skeleton>
</uni-card>
</view>
</block>
</view>
<layout class="container" @done="onLayout">
<!-- 幻灯片广告 -->
<block v-if="shopInfo.files">
<view class="uv-demo-block" style="width: 750rpx; margin: auto">
<uv-swiper :list="JSON.parse(shopInfo.files)" bgColor="transparent" indicatorMode="dot" indicator circular
:autoplay="false"
radius="0" height="200" @click="onSlide"></uv-swiper>
</view>
</block>
<!-- search-->
<view class="search" style="padding: 0 10rpx; background-color: #FFFFFF">
<uni-search-bar radius="5" placeholder="搜索商品" clearButton="auto" cancelButton="none" @confirm="search"/>
</view>
<!-- <uv-gap height="8"></uv-gap>-->
<uv-vtabs
:chain="chain"
:list="list"
keyName="title"
:height="height"
:barItemActiveStyle="{color: '#ff0000'}"
:barItemActiveLineStyle="{background: '#ff0000'}"
hdHeight="100rpx"
@change="change">
<template v-for="(item,index) in children" :key="index">
<uv-vtabs-item :index="index">
<view class="item">
<text class="ele-text-secondary" style="color: #808080">{{ item.title }}</text>
</view>
<view class="item"
v-for="(item,index2) in item.goods"
:key="index2">
<view class="flex">
<uv-image :src="item.image" width="80" height="80" radius="6"
@click="navTo(`/package/goods/detail?id=${item.goodsId}`)"/>
<view class="goods-info ml-2" style="flex: 1">
<view class="flex flex-col justify-between" style="height: 80px">
<view class="goods-bar">
<view class="goods-name">{{ item.goodsName }}</view>
<view class="goods-desc web-text-secondary">{{ item.comments }}</view>
</view>
<view class="flex justify-between goods-price-bar">
<view class="goods-price">¥{{ item.price }}</view>
<block v-if="item.specs === 1">
<uv-button type="error" class="goods-btn" size="mini" @click="openSpecForm(item)"
:customStyle="{backgroundColor: '#ff0000', color: '#ffffff'}">选规格
</uv-button>
</block>
<block v-else>
<uv-number-box v-model="item.totalNums"
step="1"
:min="0"
:showMinus="item.totalNums > 0"
@change="addNum(item)"
>
<template v-slot:minus>
<view class="minus">
<uv-icon
name="minus"
size="12">
</uv-icon>
</view>
</template>
<template v-slot:input>
<text
style="width: 18px;text-align: center;"
class="input"
>
{{ item.totalNums }}
</text>
</template>
<template v-slot:plus>
<view class="plus">
<uv-icon
name="plus"
color="#FFFFFF"
size="12"
>
</uv-icon>
</view>
</template>
</uv-number-box>
</block>
</view>
</view>
</view>
</view>
</view>
<view
class="gap"
v-if="index<list.length-1">
<uv-gap bg-color="#f1f1f1" height="4"></uv-gap>
</view>
</uv-vtabs-item>
</template>
</uv-vtabs>
<!-- 支付密码弹窗 -->
<uni-popup ref="specForm" type="center" border-radius="10px 10px 0 0">
<uni-card :title="goods.goodsName" :border="false" :is-shadow="false" :padding="0">
<view class="spec-card" style="width: 660rpx;">
<block v-if="goods.specValue">
<uv-cell-group :customStyle="{ backgroundColor: '#ffffff' }" :border="false">
<block v-for="(item, index) in JSON.parse(goods.specValue)" :key="index">
<uv-cell :title="item.value" :cellStyle="{ padding: '10px 0' }" :label="item.address">
<template v-slot:label>
<view class="tags flex mt-10">
<view class="tag mr-15" v-for="value in item.detail">
<uv-tags :text="value" v-if="onPlain(value)" plain border-color="#eeeeee" color="#808080"
@click="onTag(value,index)"></uv-tags>
<uv-tags :text="value" v-else plain color="#ff0000" border-color="#ff0000"
@click="onTag(value,index)"></uv-tags>
</view>
</view>
</template>
</uv-cell>
</block>
<uv-cell :cellStyle="{ padding: '40px 0' }">
</uv-cell>
<uv-cell :cellStyle="{ padding: '10px 0', backgroundColor: '#f3f3f3' }">
<template v-slot:label>
<view class="web-text-secondary">
已选规格:{{ skuText }}
</view>
</template>
</uv-cell>
</uv-cell-group>
<view class="flex m-20 justify-between items-center">
<view class="total-price web-text-heading">
总计
<text class="text-red-500" style="font-weight: 500; font-size: 36rpx">¥12.99</text>
</view>
<view class="add-cart">
<uv-button type="warning" class="add-address" iconSize="16" :customStyle="{ borderRadius: '6px', padding: '5px 20px',
backgroundColor: '#ff0000', color: '#ffffff', fontWeight: 'bold' }" text="加入购物车"
@click="addCart"></uv-button>
</view>
</view>
</block>
</view>
</uni-card>
</uni-popup>
<!-- 登录组件 -->
<ws-login ref="login" @done="reload"/>
</layout>
</template>
<script>
import * as GoodsApi from '@/api/shop/goods';
import * as GoodsCategoryApi from '@/api/shop/goodsCategory';
import {
guid
} from '@/uni_modules/uv-ui-tools/libs/function/index.js'
import {
useTenantStore
} from '@/store/modules/tenant';
import Layout from "@/components/layout.vue";
import {listCategoryParentIdTree, listCategoryTree} from '@/api/shop/goodsCategory';
import UvAvatar from "@/uni_modules/uv-avatar/components/uv-avatar/uv-avatar.vue";
import UvImage from "@/uni_modules/uv-image/components/uv-image/uv-image.vue";
import UvButton from "@/uni_modules/uv-button/components/uv-button/uv-button.vue";
import {useMpStore} from "@/store/modules/mp";
import UvGap from "@/uni_modules/uv-gap/components/uv-gap/uv-gap.vue";
import * as CartApi from "@/api/shop/cart";
const mpStore = useMpStore();
const tenantStore = useTenantStore();
export default {
components: {UvGap, UvButton, UvImage, UvAvatar, Layout},
data() {
return {
shopInfo: {},
goods: {},
cart: {},
isLogin: false,
// 配置信息
config: {},
mpMenus: [],
list: [],
children: [],
chain: false,
showSpecForm: false,
sku: [],
skuText: '',
disabled: false,
// 支付密码是否正确
isPayPasswordCorrect: false,
disabledPayPayPassword: false,
payPassword: '',
totalPrice: 0,
cartNum: 0
}
},
computed: {
height() {
return uni.getSystemInfoSync().windowHeight - uni.upx2px(108);
}
},
onLoad() {
this.listCart();
},
onReady() {
// 模拟接口请求数据
uni.showLoading({
title: '加载中'
})
this.reload();
// setTimeout(() => {
// // this.list = getList;
// this.reload()
// }, 500)
},
methods: {
async reload() {
const app = this;
// 获取小程序信息包
const info = await mpStore.fetchMpInfo();
// 配置信息
app.config = info.config
// 登录状态
if (uni.getStorageSync('user_id') && uni.getStorageSync('access_token')) {
app.isLogin = true;
}
export default {
data() {
return {
goodsList: [], // 瀑布流全部数据
list1: [], // 瀑布流第一列数据
list2: [], // 瀑布流第二列数据
goodsCategoryList: [], // 商品分类
leftGap: 10,
rightGap: 10,
columnGap: 10,
// 小程序导航图标
navigation: [],
// 骨架屏
hideTools: true,
// 商品分类
categoryId: undefined
}
},
computed: {
imageStyle(item) {
return item => {
const v = uni.upx2px(750) - this.leftGap - this.rightGap - this.columnGap;
const w = v / 2;
const rate = w / item.w;
const h = rate * item.h;
return {
width: w + 'px',
height: h + 'px'
}
}
}
},
async onLoad() {
// const {
// data
// } = await this.getData();
// this.list = data;
// 查询店铺分类
listCategoryTree({type: 0}).then(data => {
app.list = data;
if (data.length > 0) {
const parentId = data[0].categoryId
listCategoryParentIdTree(parentId).then(children => {
app.children = children;
})
}
// 获取服务租户信息包
const info = await tenantStore.fetchTenantInfo();
}).finally(err => {
uni.hideLoading();
})
},
listCart() {
CartApi.listCart({type: 0, isNew: false}).then(data => {
if (data) {
this.cart = data
uni.setTabBarBadge({
index: 2,
text: `${data.totalNums}`
})
}
})
},
navTo(url) {
uni.navigateTo({url})
},
change(index) {
const app = this
this.children = this.list[index].children;
const parentId = this.list[index].categoryId
listCategoryParentIdTree(parentId).then(children => {
app.children = children;
})
console.log('选项改变:', index)
},
openSpecForm(goods) {
if (!this.isLogin) {
this.$refs.login.open('bottom');
return false;
}
this.goods = goods;
this.$refs.specForm.open('center');
},
addNum(item) {
const app = this
if (!app.isLogin) {
app.$refs.login.open('bottom');
return false;
}
CartApi.addCart({
...item,
spec: this.skuText,
cartNum: 1
}).then(() => {
app.listCart()
}).catch(res => {
uni.showToast({
title: res.message,
icon: 'none'
})
})
},
onPlain(text) {
const index = this.sku.findIndex(d => d === text)
return index < 0;
},
onTag(text, index) {
const app = this
console.log(text, index)
const json = JSON.parse(this.goods.specValue)
const parent = this.sku.findIndex(d => d === text)
console.log(parent);
if (parent < 0) {
app.sku.push(text)
app.skuText = app.sku.join('、')
}
},
addCart() {
const app = this
this.disabled = true;
CartApi.addCart({
...app.goods,
spec: app.skuText,
cartNum: 1
}).then(data => {
app.reload()
})
this.$refs.specForm.close();
},
onSlide() {
// 解析小程序导航图标
if (info.mpMenus) {
const arr1 = info.mpMenus.filter(d => (d.type == 3))
console.log('info.mpMenus: ', arr1);
if (arr1) {
this.navigation = arr1
}
}
// 请求数据
this.reload()
},
methods: {
async reload() {
const app = this
// 获取服务租户信息包
const info = await tenantStore.fetchTenantInfo();
// 登录状态
if (uni.getStorageSync('user_id') && uni.getStorageSync('access_token')) {
app.isLogin = true;
}
// 解析小程序导航图标
if (info.mpMenus) {
const arr1 = info.mpMenus.filter(d => (d.type == 3))
console.log('info.mpMenus: ', arr1);
if (arr1) {
app.navigation = arr1
}
}
// 请求数据
Promise.all([app.pageGoods(),app.getGoodsCategory()])
.then((res) => {
app.goodsList = res[0];
app.goodsCategoryList = res[1];
app.hideTools = false
})
},
pageGoods() {
const app = this
const { categoryId } = this
return new Promise((resolve, reject) => {
GoodsApi.pageGoods({parentId: categoryId})
.then(result => {
resolve(result.list)
})
.catch(reject)
})
},
getGoodsCategory(){
const app = this
return new Promise((resolve, reject) => {
GoodsCategoryApi.pageGoodsCategory({parentId: 0})
.then(result => {
resolve(result.list)
})
.catch(reject)
})
},
navTo(item) {
uni.navigateTo({
url: '/package/goods/detail?id=' + item.goodsId
})
},
onCategory(item){
this.categoryId = item.categoryId
this.goodsList = []
this.list1 = []
this.list2 = []
this.reload()
},
// 这点非常重要:e.name在这里返回是list1或list2,要手动将数据追加到相应列
changeList(e) {
console.log('e: ', e);
this[e.name].push(e.value);
},
// 模拟的后端数据
getData() {
return new Promise((resolve) => {
const imgs = [{
url: 'https://via.placeholder.com/100x110.png/3c9cff/fff',
width: 100,
height: 110
},
{
url: 'https://via.placeholder.com/200x220.png/f9ae3d/fff',
width: 200,
height: 220
},
{
url: 'https://via.placeholder.com/300x340.png/5ac725/fff',
width: 300,
height: 340
},
{
url: 'https://via.placeholder.com/400x400.png/f56c6c/fff',
width: 400,
height: 400
},
{
url: 'https://via.placeholder.com/500x510.png/909399/fff',
width: 500,
height: 510
},
{
url: 'https://via.placeholder.com/600x606.png/3c9cff/fff',
width: 600,
height: 606
},
{
url: 'https://via.placeholder.com/310x422.png/f1a532/fff',
width: 310,
height: 422
},
{
url: 'https://via.placeholder.com/320x430.png/3c9cff/fff',
width: 320,
height: 430
},
{
url: 'https://via.placeholder.com/330x424.png/f9ae3d/fff',
width: 330,
height: 424
},
{
url: 'https://via.placeholder.com/340x435.png/5ac725/fff',
width: 340,
height: 435
},
{
url: 'https://via.placeholder.com/350x440.png/f56c6c/fff',
width: 350,
height: 440
},
{
url: 'https://via.placeholder.com/380x470.png/909399/fff',
width: 380,
height: 470
}
];
let list = [];
const doFn = (i) => {
const randomIndex = Math.floor(Math.random() * 10);
return {
id: guid(),
allowEdit: i == 0,
image: imgs[randomIndex].url,
w: imgs[randomIndex].width,
h: imgs[randomIndex].height,
title: i % 2 == 0 ? `(${this.list.length + i + 1})体验uv-ui框架` :
`(${this.list.length + i +1})uv-ui支持多平台`,
desc: i % 2 == 0 ? `(${this.list.length + i + 1})欢迎使用uv-ui,uni-app生态专用的UI框架` :
`(${this.list.length + i})开发者编写一套代码, 可发布到iOS、Android、H5、以及各种小程序`
}
};
// 模拟异步
setTimeout(() => {
for (let i = 0; i < 20; i++) {
list.push(doFn(i));
}
resolve({
data: list
});
}, 200)
})
}
}
}
},
save() {
// 跳转页面
uni.navigateTo({
url: '/package/goods/checkout?goodsId=' + this.goods.goodsId
})
},
onLayout(data) {
if (data) {
// 页面图标链接
this.mpMenus = data.mpMenus;
}
}
}
}
</script>
<style>
page {
/* background: url('https://oss.wsdns.cn/20240505/eaa18a0271fa42aa8395bd5eb874808a.png') no-repeat; */
background-size: 100%;
background-repeat: no-repeat;
background-color: #f0f2f5;
width: 750rpx;
overflow-x: hidden;
}
</style>
<style scoped lang="scss">
$show-lines: 1;
@import '@/uni_modules/uv-ui-tools/libs/css/variable.scss';
.container {
position: relative;
}
.waterfall-item {
overflow: hidden;
margin-top: 10px;
border-radius: 6px;
.header {
padding: 30rpx;
font-size: 30rpx;
color: #333;
}
&__image {
background-color: #fff;
}
}
.item {
padding: 10rpx 20rpx;
.waterfall-item__ft {
padding: 20rpx;
background: #fff;
&-title {
.text {
font-weight: 700;
font-size: 32rpx;
color: #111;
}
}
&__title {
margin-bottom: 10rpx;
line-height: 48rpx;
font-weight: 700;
&-content {
padding: 20rpx 0;
.value {
font-size: 32rpx;
color: #303133;
}
}
.text {
line-height: 48rpx;
font-size: 30rpx;
color: #111;
/* #ifndef APP-NVUE */
word-break: break-all;
/* #endif */
}
}
}
&__desc .value {
font-size: 28rpx;
color: #606266;
}
.checkout-car {
width: 700rpx;
left: 25rpx;
z-index: 9999;
position: fixed;
bottom: 30rpx;
display: flex;
justify-content: space-between;
background-color: #000000;
border-radius: 100px;
align-items: center;
&__btn {
padding: 10px 0;
}
}
.car-selected {
color: #ccc;
display: flex;
align-items: center;
padding: 0 20rpx;
}
.user-oreder {
width: 720rpx;
margin: 20rpx auto 8rpx auto;
padding: 28rpx 0;
border-radius: 16rpx;
background: #fff;
.car-total {
display: flex;
color: #ebcf00;
align-items: center;
padding-left: 40rpx;
.web-cell-content {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.save-btn {
}
}
}
.web-text-center {
text-align: center;
}
}
</style>
.gap {
padding: 0 30rpx;
}
.goods-desc {
font-size: 24rpx;
}
.goods-price {
color: #ff0000;
font-weight: 500;
font-size: 30rpx;
}
.shop-bar {
width: 680rpx;
height: 160rpx;
overflow: hidden;
margin: auto;
position: absolute;
top: 189rpx;
left: 35rpx;
background-color: #FFFFFF;
border-radius: 12rpx 12rpx 0 0;
.shop-info {
height: 160rpx;
.shop-name-box {
.shop-name {
font-size: 46rpx;
font-weight: 400;
}
}
}
//.shop-bar{
// background-color: #FFFFFF;
// width: 600rpx;
// height: 160rpx;
// margin: auto;
// position: absolute;
// top: 0rpx;
//}
}
.minus {
width: 20px;
height: 20px;
border: 1px solid #E6E6E6 !important;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
}
.input {
padding: 0 10px;
}
.plus {
width: 20px;
height: 20px;
background-color: #FF0000;
border-radius: 50%;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
}
</style>
+197 -177
View File
@@ -1,140 +1,155 @@
<template>
<view class="page">
<!-- 顶部距离 -->
<view class="header" :style="'margin-top: ' + statusBarHeight + 'px'"></view>
<!-- 用户信息 -->
<ws-user-card :data="userInfo" :users="users" :is-login="isLogin" @openLogin="openLogin" @done="reload" />
<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-my-asset :data="users" :is-login="isLogin" @done="openLogin"></ws-my-asset>
<!-- 我的订单 -->
<!-- <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>
<!-- <ws-personal :form="users" ref="personal" @done="reload" />-->
<!-- 登录组件 -->
<ws-login ref="login" :logo="logo" @done="reload" />
<!-- 退出按钮 -->
<ws-logout v-if="isLogin" @done="reload"></ws-logout>
</block>
</view>
<layout class="page" @done="onLayout">
<!-- 顶部距离 -->
<view class="header" :style="'margin-top: ' + statusBarHeight + 'px'"></view>
<!-- 用户信息 -->
<ws-user-card :data="userInfo" :users="users" :is-login="isLogin" @openLogin="openLogin" @done="reload"/>
<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-my-asset :data="users" :is-login="isLogin" @done="openLogin"></ws-my-asset>
<!-- 我的订单 -->
<!-- <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 mpMenus" :key="index">
<block v-if="index === '1981'" v-for="(v,i) in item">
<uni-list-item :thumb="v.avatar" link @click="navTo(item)">
<template v-slot:body>
<view class="slot-box">
<text class="slot-text" :style="{ color: v.color ? v.color : '#333333' }">{{
v.title
}}
</text>
</view>
</template>
</uni-list-item>
</block>
</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 mpMenus" :key="index">
<block v-if="index === '1981'" v-for="(v,i) in item">
<uni-list-item :thumb="item.avatar" link @click="navTo(item)">
<template v-slot:body>
<view class="slot-box">
<text class="slot-text" :style="{ color: item.color ? item.color : '#333333' }">{{
v.title
}}
</text>
</view>
</template>
</uni-list-item>
</block>
</block>
</uni-list>
</view>
</block>
</uni-card>
<!-- <ws-personal :form="users" ref="personal" @done="reload" />-->
<!-- 登录组件 -->
<ws-login ref="login" :logo="logo" @done="reload"/>
<!-- 退出按钮 -->
<ws-logout v-if="isLogin" @done="reload"></ws-logout>
</block>
</layout>
</template>
<script>
import { useUserStore } from '@/store/modules/user';
import {useUserStore} from '@/store/modules/user';
import * as UserApi from '@/api/booking/users';
import * as MpMenuApi from '@/api/cms/mp-menu/index';
import * as UserCardApi from '@/api/booking/userCard';
import { updateUsers } from '@/api/shop/users';
import { openUrl } from '@/utils/common';
import { getWxOpenId } from '@/api/passport/login';
import {updateUsers} from '@/api/shop/users';
import {openUrl} from '@/utils/common';
import {getWxOpenId} from '@/api/passport/login';
import Layout from "@/components/layout.vue";
import { useTenantStore } from '@/store/modules/tenant';
import {useTenantStore} from '@/store/modules/tenant';
const tenantStore = useTenantStore();
const userStore = useUserStore();
export default {
data() {
return {
statusBarHeight: 104,
isLogin: false,
userInfo: {},
fields: {},
logo: '',
bookingUser: {},
merchantList: [],
server: [],
order: [],
components: {Layout},
data() {
return {
statusBarHeight: 104,
isLogin: false,
userInfo: {},
fields: {},
logo: '',
bookingUser: {},
merchantList: [],
server: [],
mpMenus: [],
ads: [],
order: [],
users: {},
hideTools: true,
// 是否拥有场馆管理员权限
hasMerchantRole: false,
// 是否拥有场馆职员权限
hasMerchantClerkRole: false,
// 是否拥有超级管理员权限
hasSuperAdminRole: false
};
},
onLoad() {
this.reload();
},
methods: {
async reload(e) {
const app = this;
// 获取系统信息
uni.getSystemInfo({
success(data) {
if (data) {
app.statusBarHeight = data.statusBarHeight + 50;
}
}
});
// 当前租户信息
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;
});
}
hideTools: true,
// 是否拥有场馆管理员权限
hasMerchantRole: false,
// 是否拥有场馆职员权限
hasMerchantClerkRole: false,
// 是否拥有超级管理员权限
hasSuperAdminRole: false
};
},
onLoad() {
this.reload();
},
methods: {
async reload(e) {
const app = this;
// 获取系统信息
uni.getSystemInfo({
success(data) {
if (data) {
app.statusBarHeight = data.statusBarHeight + 50;
}
}
});
// 当前租户信息
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);
// 当前登录用户信息
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');
// 判断用户角色
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');
// 获取用户副表信息
UserApi.getByPhone({
@@ -142,16 +157,16 @@ export default {
}).then((data) => {
if (data) {
app.users = data;
uni.setStorageSync('uid',data.id);
uni.setStorageSync('uid', data.id);
app.userInfo = Object.assign({}, app.userInfo, data);
if(!data.openId){
if (!data.openId) {
data.openId = app.userInfo.openid
updateUsers(data);
}
}
});
if(!uni.getStorageSync('openid')){
if (!uni.getStorageSync('openid')) {
// 更新openid
// #ifdef MP-WEIXIN
uni.login({
@@ -159,7 +174,7 @@ export default {
getWxOpenId({
code: res.code
}).then((response) => {
uni.setStorageSync('openid',response.openid);
uni.setStorageSync('openid', response.openid);
updateUsers({
id: uni.getStorageSync('uid'),
openId: response.openid,
@@ -172,64 +187,69 @@ export default {
// #endif
}
} else {
app.isLogin = false;
app.userInfo = {};
}
// 菜单数据
MpMenuApi.pageMpMenu({ type: 0, limit: 100 })
.then((res) => {
app.order = res.list.filter((d) => d.rows == 0);
app.server = res.list.filter((d) => d.rows == 1);
// console.log('app.hasMerchantRole: ',app.hasMerchantRole);
// console.log('app.hasMerchantClerkRole: ',app.hasMerchantClerkRole);
// console.log('app.hasSuperAdminRole: ',app.hasSuperAdminRole);
if(!app.hasMerchantRole && !app.hasMerchantClerkRole){
// console.log('11111: ',11111);
app.server = res.list.filter((d) => d.rows == 1 && d.adminShow == 0);
}
app.hideTools = false;
})
.catch(() => {
uni.showToast({
title: '请检查您的网络.',
icon: 'none'
});
app.hideTools = false;
});
} else {
app.isLogin = false;
app.userInfo = {};
}
// 菜单数据
MpMenuApi.pageMpMenu({type: 0, limit: 100})
.then((res) => {
app.order = res.list.filter((d) => d.rows == 0);
app.server = res.list.filter((d) => d.rows == 1);
// console.log('app.hasMerchantRole: ',app.hasMerchantRole);
// console.log('app.hasMerchantClerkRole: ',app.hasMerchantClerkRole);
// console.log('app.hasSuperAdminRole: ',app.hasSuperAdminRole);
if (!app.hasMerchantRole && !app.hasMerchantClerkRole) {
// console.log('11111: ',11111);
app.server = res.list.filter((d) => d.rows == 1 && d.adminShow == 0);
}
app.hideTools = false;
})
.catch(() => {
uni.showToast({
title: '请检查您的网络.',
icon: 'none'
});
app.hideTools = false;
});
UserCardApi.pageUserCard({payStatus:1, userId: uni.getStorageSync('user_id')}).then(res => {
console.log('res8888889: ',res);
app.userInfo.cards = res.count
app.userInfo.coupon = 1;
})
},
navTo(item) {
if (!this.isLogin) {
this.$refs.login.open('bottom');
return false;
} else {
openUrl(item);
}
},
// 弹出登录提示框
openLogin() {
if (!this.isLogin) {
this.$refs.login.open('bottom');
return false;
}
}
}
UserCardApi.pageUserCard({payStatus: 1, userId: uni.getStorageSync('user_id')}).then(res => {
console.log('res8888889: ', res);
app.userInfo.cards = res.count
app.userInfo.coupon = 1;
})
},
navTo(item) {
if (!this.isLogin) {
this.$refs.login.open('bottom');
return false;
} else {
openUrl(item);
}
},
onLayout({mpMenus, ads}) {
this.mpMenus = mpMenus;
this.ads = ads;
this.hideTools = false;
},
// 弹出登录提示框
openLogin() {
if (!this.isLogin) {
this.$refs.login.open('bottom');
return false;
}
}
}
};
</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;
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"></style>