This commit is contained in:
HongRun Liu
2026-05-26 15:52:30 +08:00
commit b0744c8ab6
849 changed files with 130587 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
# 版本号
SHOPRO_VERSION=v2.4.1
# 后端接口 - 正式环境(通过 process.env.NODE_ENV 非 development)
#SHOPRO_BASE_URL=http://8.136.55.200:48090
# 后端接口 - 测试环境(通过 process.env.NODE_ENV = development)
# 霍慧超
#SHOPRO_DEV_BASE_URL=http://192.168.101.7:48092
# 陈力
# SHOPRO_DEV_BASE_URL=http://192.168.101.57:48092
# 张吉生
#SHOPRO_DEV_BASE_URL=http://192.168.101.58:48090
# 服务器
SHOPRO_DEV_BASE_URL=http://www.qflyqzy.net:48090
#SHOPRO_DEV_BASE_URL=https://www.qflyqzy.net/yg-api
# 本地
#SHOPRO_DEV_BASE_URL=http://8.136.55.200:48090
### SHOPRO_DEV_BASE_URL=http://10.171.1.188:48090
### SHOPRO_DEV_BASE_URL = http://yunai.natapp1.cc
# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务
SHOPRO_UPLOAD_TYPE=server
# 后端接口前缀(一般不建议调整)
SHOPRO_API_PATH=/app-api
# 后端 websocket 接口前缀
SHOPRO_WEBSOCKET_PATH=/infra/ws
# 开发环境运行端口
SHOPRO_DEV_PORT=3000
# 客户端静态资源地址 空=默认使用服务端指定的CDN资源地址前缀 | local=本地 | http(s)://xxx.xxx=自定义静态资源地址前缀
SHOPRO_STATIC_URL=https://file.sheepjs.com
### SHOPRO_STATIC_URL = https://file.sheepjs.com
# 前端 H5 访问域名
SHOPRO_H5_URL=http://8.136.55.200:3000
# 是否开启直播 1 开启直播 | 0 关闭直播
SHOPRO_MPLIVE_ON=0
# 租户ID 默认 1
SHOPRO_TENANT_ID=1
+12
View File
@@ -0,0 +1,12 @@
unpackage/*
node_modules/*
.idea/*
deploy.sh
.hbuilderx/
.vscode/
**/.DS_Store
yarn.lock
package-lock.json
*.keystore
pnpm-lock.yaml
.history
+6
View File
@@ -0,0 +1,6 @@
/unpackage/*
/node_modules/**
/uni_modules/**
/public/*
**/*.svg
**/*.sh
+10
View File
@@ -0,0 +1,10 @@
{
"printWidth": 100,
"semi": true,
"vueIndentScriptAndStyle": true,
"singleQuote": true,
"trailingComma": "all",
"proseWrap": "never",
"htmlWhitespaceSensitivity": "strict",
"endOfLine": "auto"
}
+267
View File
@@ -0,0 +1,267 @@
<script setup>
import {
ref,
onMounted,
onBeforeMount,
onBeforeUnmount,
onBeforeUpdate
} from 'vue';
import {
onLoad,
onLaunch,
onShow,
onError
} from '@dcloudio/uni-app';
import {
ShoproInit
} from './sheep';
import {
gethotupdatelist
} from '@/sheep/api/index/index';
let globalData = ref({
statusBarHeight: 0, // 状态导航栏高度
navHeight: 0, // 总体高度
navigationBarHeight: 0, // 导航栏高度(标题栏高度)
windowHeight: 0,
});
let filePath = ref();
const wgtUp = async () => {
// console.log(plus.runtime);
let res = await gethotupdatelist();
if (res.code !== 0) return;
filePath.value = res.data.filePath;
let localVersion = uni.getSystemInfoSync().appWgtVersion;
if (res.data.versionNumber != localVersion) {
if (res.data.type == 'min') {
if (res.data.isForceUpdate) {
// 强制更新
downloadFile();
} else {
uni.showModal({
title: '提示',
content: '发现新的版本,是否更新?',
confirmColor: '#FA7E31',
success: (res) => {
if (res.confirm) {
downloadFile();
} else if (res.cancel) {
if (res.data.isForceUpdate) {
plus.runtime.quit(); //退出应用
}
}
},
});
}
} else {
uni.showModal({
title: '提示',
content: '发现新的版本,请到立即更新到最新版本',
confirmText: '立即更新',
cancelText: res.data.isForceUpdate ? '关闭' : '取消',
confirmColor: '#FA7E31',
success: (res) => {
if (res.confirm) {
updateApp(filePath.value);
} else if (res.cancel) {
if (res.data.isForceUpdate) {
plus.runtime.quit(); //退出应用
}
}
},
});
}
}
};
const updateApp = (url) => {
uni.showLoading({
title: '下载中',
});
uni.downloadFile({
url: url, //下载地址
success: (res) => {
console.log(res, '下载成功');
if (res.statusCode === 200) {
console.log('下载成功');
uni.hideLoading();
uni.showToast({
title: '下载成功',
icon: 'success',
});
uni.saveFile({
tempFilePath: res.tempFilePath,
success: function(res) {
uni.openDocument({
filePath: res.savedFilePath,
success: function(res) {
console.log(res, '打开安装包');
},
});
},
fail: (err) => {
console.log(err, '打开安装包-失败');
},
});
}
},
fail(e) {
uni.hideLoading();
uni.showToast({
title: '下载失败,请检查网络',
icon: 'none',
});
console.log(e);
},
});
};
const socket = () => {
let url = 'ws://192.168.101.229:48080/aishop/ws';
let socketTask = uni.connectSocket({
url: url,
success(res) {
console.log('连接成功', res);
},
fail() {},
});
socketTask.onOpen((res) => {
console.log('WebSocket 连接已打开');
});
socketTask.onMessage((res) => {
console.log('收到服务器消息', res);
});
socketTask.onClose((res) => {
console.log('WebSocket 已关闭!');
});
socketTask.onError((res) => {
console.log('WebSocket 错误!', res);
});
};
onMounted(() => {
// #ifdef APP-PLUS
// plus.nativeUI.setUIStyle('dark');
// #endif
// #ifdef H5
// 以下是H5端的代码
// document.body.classList.remove('dark', 'light', 'auto');
// document.body.classList.add('dark');
// #endif
// 初始化全局数据
globalData.value = {
...globalData.value,
...uni.getStorageSync('globalData'),
};
globalData.value.statusBarHeight = uni.getSystemInfoSync()?.statusBarHeight;
globalData.value.windowHeight = uni.getSystemInfoSync()?.windowHeight;
// 热更新
// #ifdef APP-PLUS
wgtUp();
// #endif
// socket()
});
const downloadFile = () => {
let url = filePath.value;
uni.downloadFile({
url: url,
success: (downloadResult) => {
uni.showToast({
title: '更新中....',
icon: 'none',
});
if (downloadResult) {
if (downloadResult.statusCode === 200) {
plus.runtime.install(
downloadResult.tempFilePath, {
force: true,
},
function() {
uni.showModal({
title: '成功提示',
content: '热更新成功,请重启应用',
confirmColor: '#FA7E31',
showCancel: false,
success: function(res) {
if (res.confirm) {
plus.runtime.restart(); //自动重启软件
}
},
});
},
function(e) {
uni.showModal({
title: '失败提示',
content: e,
showCancel: false,
confirmColor: '#FA7E31',
});
},
);
}
}
},
});
};
onLaunch(() => {
// 隐藏原生导航栏 使用自定义底部导航
// uni.hideTabBar({
// fail: () => {},
// });
// globalData.value.statusBarHeight = uni.getSystemInfoSync()?.statusBarHeight;
// globalData.value.windowHeight = uni.getSystemInfoSync()?.windowHeight;
// 获取微信胶囊的位置信息 width,height,top,right,left,bottom
let custom = {
top: 0,
height: 0,
};
// #ifdef MP-WEIXIN
custom = wx.getMenuButtonBoundingClientRect();
// #endif
// 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
globalData.value.navigationBarHeight =
custom.height + (custom.top - uni.getSystemInfoSync()?.statusBarHeight) * 2;
globalData.value.navHeight =
globalData.value.navigationBarHeight + uni.getSystemInfoSync()?.statusBarHeight;
uni.setStorageSync('globalData', globalData.value);
// 加载Shopro底层依赖
ShoproInit();
});
onShow(() => {
// #ifdef APP-PLUS
// 获取urlSchemes参数
const args = plus.runtime.arguments;
if (args) {}
// 获取剪贴板
uni.getClipboardData({
success: (res) => {},
});
// #endif
});
uni.onTabBarMidButtonTap(() => {
uni.navigateTo({
url: '/pages/home/seed',
});
});
</script>
<style lang="scss">
@import '@/sheep/scss/index.scss';
.uni-tabbar-border {
background-color: transparent !important;
/* 移除背景色 */
height: 0 !important;
/* 隐藏边框元素 */
border: none !important;
/* 确保无边框 */
}
.uni-app--showtopwindow uni-page-head {
display: none;
}
</style>
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 lidongtony
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+13
View File
@@ -0,0 +1,13 @@
{
"prompt" : "template",
"title" : "用户协议和隐私政策",
"message" : "欢迎使用本应用,我们非常重视您的个人信息和隐私保护。在使用服务之前,请仔细阅读<a href='http://www.qflyqzy.net:5010/h5/#/user_agreement'>《用户协议》</a>和<a href='http://www.qflyqzy.net:5010/h5/#/privacy_agreement'>《隐私政策》</a>。我们将按照您同意的条款使用您的个人信息,以便为您提供服务。",
"buttonAccept" : "同意并接受",
"buttonRefuse" : "退出应用",
"styles" : {
"backgroundColor" : "#ffffff",
"buttonAccept" : {
"color" : "#FA7E31"
}
}
}
+152
View File
@@ -0,0 +1,152 @@
<template>
<uni-popup ref="privacyPopup" type="center" :isMaskClick="false">
<view class="privacy-modal">
<view class="privacy-header">
<!-- <view class="badge">S</view> -->
<view class="privacy-title">隐私政策</view>
</view>
<scroll-view class="privacy-content" scroll-y="true">
<view class="privacy-text">
欢迎使用本应用,我们非常重视您的个人信息和隐私保护。在使用服务之前,请仔细阅读
<text class="privacy-link" @click="goAgreement(1)">《隐私政策》</text>
和
<text class="privacy-link" @click="goAgreement(2)">《用户协议》</text>
。我们将按照您同意的条款使用您的个人信息,以便为您提供服务。
<text class="privacy-subtext">
如您同意此政策,请点击“同意”开始使用我们的产品和服务;如您不同意,我们将无法为您提供完整服务。
</text>
</view>
</scroll-view>
<view class="privacy-actions">
<view class="submit-btn" @click="agree"> 同意 </view>
<!-- <button class="btn confirm" @click="agree">同意</button> -->
<view class="cancel" @click="exitApp">不同意</view>
</view>
</view>
</uni-popup>
</template>
<script setup>
import { ref, onMounted, onUnmounted } from 'vue';
const privacyPopup = ref();
const agree = () => {
uni.setStorageSync('privacy_agreed', 1);
uni.showTabBar();
privacyPopup.value && privacyPopup.value.close();
};
const exitApp = () => {
// #ifdef APP-PLUS
uni.showTabBar();
plus.runtime.quit();
// #endif
// #ifndef APP-PLUS
uni.showTabBar();
uni.reLaunch({
url: '/pages/index/index'
});
// #endif
};
const goAgreement = (type) => {
uni.navigateTo({
url: '/pages/home/agreement?type=' + type,
});
};
onMounted(() => {
const agreed = !!uni.getStorageSync('privacy_agreed');
if (!agreed) {
uni.hideTabBar();
setTimeout(() => {
privacyPopup.value && privacyPopup.value.open();
}, 50);
}
});
onUnmounted(() => {
uni.showTabBar();
});
</script>
<style scoped lang="scss">
.privacy-modal {
// width: 620rpx;
// max-height: 70vh;
background: #ffffff;
border-radius: 22rpx;
overflow: hidden;
margin: 0 80rpx;
}
.privacy-header {
padding-top: 36rpx;
align-items: center;
}
.badge {
width: 96rpx;
height: 96rpx;
margin: 0 auto;
border-radius: 48rpx;
background: linear-gradient(180deg, #e9f1ff 0%, #cfe0ff 100%);
color: #366EEE;
font-size: 42rpx;
font-weight: 700;
text-align: center;
line-height: 96rpx;
}
.privacy-title {
text-align: center;
font-size: 34rpx;
font-weight: 700;
padding: 18rpx 24rpx 6rpx;
color: #333;
}
.privacy-content {
// max-height: 48vh;
// margin: 8rpx 28rpx 0;
}
.privacy-text {
font-size: 26rpx;
line-height: 42rpx;
color: #666;
margin: 0 40rpx 12rpx;
}
.privacy-subtext {
font-size: 24rpx;
line-height: 40rpx;
color: #888;
}
.privacy-link {
color: #366EEE;
// text-decoration: underline;
}
.privacy-actions {
margin: 28rpx 40rpx;
.btn {
height: 88rpx;
border-radius: 12rpx;
font-size: 30rpx;
}
}
// .submit-btn{
// height: 88rpx;
// border-radius: 12rpx;
// text-align: center;
// line-height: 88rpx;
// color: #fff;
// background: linear-gradient(90deg,#FFA65B 0%, #366EEE 100%);
// }
.cancel {
color: #666;
font-size: 26rpx;
margin: 30rpx 0;
}
</style>
+388
View File
@@ -0,0 +1,388 @@
<template>
<view class="flex-row card" @click="goDetail(props.data)">
<view
class="image m-r-16 shrink"
:class="{ w_180: props.source === 3, h_180: props.source === 3 }"
>
<image :src="props.data.picUrl" mode="scaleToFill" />
</view>
<view class="flex1 flex-column ju-between">
<view>
<view class="lineTwo size28 f500 m-b-14">
{{ props.source === 3 || props.source === 1 ? props.data.spuName : props.data.name }}
</view>
<view class="flex-center m-t-14 m-b-14" v-if="props.source === 0">
<view class="flex1 m-r-28 progressCard card1">
<view class="progress"></view>
<view
class="progress1"
:style="{
width:
Math.ceil(
(props.data.sales / (props.data.stocks + props.data.sales)) * 100,
).toFixed(0) + '%',
}"
></view>
<view class="progressText size20 line28"
>{{
Math.ceil(
(props.data.sales / (props.data.stocks + props.data.sales)) * 100,
).toFixed(0)
}}%</view
>
</view>
<view class="stockText size24">存量:{{ props.data.stocks }}</view>
</view>
<view
class="flex-center ju-flex-start"
v-if="props.source === 0"
:style="{ opacity: show ? 0 : 1 }"
>
<view class="size24 m-r-10">
距离<span class="c15">本场{{ timeText }}</span
>仅剩
</view>
<uni-countdown
color="#FFFFFF"
background-color="#FF393A"
border-color="#FF393A"
:show-day="false"
:hour="hour"
:minute="minute"
:second="second"
@timeup="timeup"
></uni-countdown>
</view>
</view>
<view class="flex-center ju-flex-start">
<view class="ai-button3 w_110 line38 h_38 radius8 m-t-8 m-b-14 m-r-20" v-if="props.source === 1">
{{ formatOrderStatus(props.data) }}
</view>
<view class="ai-button3 w_92 line38 h_38 radius8 m-t-8 m-b-14" v-if="props.source === 1"
:class="{'c12 border12':!props.data?.items1[0]?.saleStatus}">
{{ props.data?.items1[0]?.saleStatus ? '已上架' : '已下架' }}
</view>
</view>
<view>
<view class="m-b-12 size24 h_52" v-for="(item, i) in props.data.skuArr" :key="i">
<view
class="flex1 flex-center ju-between h_52 bg18 radius8 p-l-8 p-r-16"
v-if="item?.properties"
>
<view class="lineOne c19">
{{ item?.properties.length > 1 ? item?.propertyText : item?.properties[0].valueName }}
</view>
<view class="flex-center">
<view class="c19">x{{ item.count }}</view>
<view class="size28 m-l-12 weight900"
>¥<span class="">{{
fen2yuan(item.discountedPrice ? item.discountedPrice : item.price)
}}</span>
</view>
</view>
</view>
</view>
</view>
<view class="flex-row ju-between">
<view class="flex-row al-flex-end">
<view class="c13 size28 weight900"
>¥
<span class="size38" v-if="props.source == 1">{{ fen2yuan(props.data.price) }}</span>
<span class="size38" v-else-if="props.source == 3">{{
fen2yuan(
props.data.discountedTotalPrice
? props.data.discountedTotalPrice
: props.data.totalPrice,
)
}}</span>
<span class="size38" v-else>
{{
fen2yuan(props.data.discountedPrice ? props.data.discountedPrice : props.data.price)
}}
</span>
</view>
<!-- <view class="through c12 m-l-8 size20" v-if="!props.source"
>¥{{
fen2yuan(
props.data.discountedPrice
? props.data.price
: props.data.totalPrice,
)
}}</view
> -->
<view class="through c12 m-l-8 size20" v-if="props.source == 3"
>¥{{
fen2yuan(props.data.discountedTotalPrice ? props.data.price : props.data.totalPrice)
}}</view
>
</view>
<view v-if="props.source === 0 && timeText !== '开始'">
<uni-badge :text="props.data.cartCount" absolute="rightTop" :offset="[8, 3]">
<view class="ai-button1 w_144" style="color: #fff" @click.stop="addCar">选规格</view>
</uni-badge>
</view>
</view>
<view v-if="props.source === 1" class="flex-center ju-flex-end m-t-12">
<view
class="ai-button3 w_144 m-r-10"
@click.stop="delayShipment(props.data)"
v-if="props.data.status === 10"
>延迟发货</view
>
<view
class="ai-button3 w_144 m-r-10"
@click.stop="nowShipment(props.data)"
v-if="props.data.status === 50"
>立即发货
</view>
<view class="ai-button3 w_144" @click.stop="goInfo">查看订单</view>
<view class="ai-button1 w_144 m-l-16" v-if="props.data.status === 20" @click.stop="confirm"
>确认收货</view
>
<view class="ai-button1 w_144 m-l-16" v-if="props.data.status === 0" @click.stop="goPay"
>去支付</view
>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { fen2yuan } from '@/sheep/hooks/useGoods';
import { ref, onMounted, getCurrentInstance, defineProps, watch } from 'vue';
import { formatOrderStatus } from '@/sheep/hooks/useGoods';
import * as api from '@/sheep/api/ai/index';
const { proxy } = getCurrentInstance() as any;
const props = defineProps({
data: {
type: Object,
default() {
return {};
},
},
source: {
//0选品广场 1我的店铺 3订单
type: Number,
default: 0,
},
idName: {
type: String,
default: 'id',
},
});
let timeText = ref('结束');
let hour = ref(0);
let minute = ref(0);
let second = ref(0);
let show = ref(false);
const timeup = () => {
show.value = true;
timeChange();
};
const timeChange = () => {
show.value = false;
let data = props.data;
let endTime = data.endTime;
let startTime = data.startTime;
// 当前时间戳
let currentTime = Date.now();
let time = null;
if (currentTime < startTime) {
timeText.value = '开始';
time = startTime - currentTime;
} else if (currentTime > startTime && currentTime < endTime) {
timeText.value = '结束';
time = endTime - currentTime;
} else {
show.value = true;
timeText.value = '已结束';
}
if (time) {
hour.value = Math.floor(time / 1000 / 60 / 60);
minute.value = Math.floor(time / 1000 / 60) % 60;
second.value = Math.floor(time / 1000) % 60;
}
};
watch(
() => props.data,
() => {
timeChange();
},
{
immediate: true,
deep: true,
},
);
//延迟发货
function delayShipment(e) {
uni.showModal({
title: '延迟发货',
content: '请您确认是否暂时不需要发货,确认后该产品将为您安排延迟发货',
confirmColor: '#FA7E31',
success: function (res) {
if (res.confirm) {
api
.aiDelayedShipment({
id: e.orderId,
status: 50,
})
.then((res) => {
if (res.code === 0) {
proxy.$emit('shipment');
}
});
} else if (res.cancel) {
}
},
});
}
//立即发货
function nowShipment(e) {
uni.showModal({
title: '立即发货',
content: '请您确认是否需要立即发货,确认后将尽快为您安排发货',
confirmColor: '#FA7E31',
success: function (res) {
if (res.confirm) {
api
.aiPendingShipment({
id: e.orderId,
status: 10,
})
.then((res) => {
if (res.code === 0) {
proxy.$emit('shipment');
}
});
}
},
});
}
function getPrice(source, data) {
// console.log(source, data);
if (source === 3) {
return props.data.totalPrice;
} else if (source === 1) {
return props.data.payPrice;
} else {
return props.data.price;
}
}
const addCar = () => {
proxy.$emit('addCar', props.data);
};
const goInfo = () => {
let id = props.data.orderId;
// if (props.source === 1) {
// id = props.data.spu.id;
// }
proxy.utils.go('/pages/AI/orderInfo', {
id: id,
});
};
// 确认收货
const confirm = () => {
api
.confirmReceive({
id: props.data.orderId,
})
.then(() => {
proxy.$emit('update');
});
};
// 去支付
const goPay = () => {
proxy.utils.go('/pages/AI/cashierDesk', {
id: props.data.orderId,
payOrderId: props.data.spuId,
});
};
function goDetail(e) {
if (props.source == 3) return;
proxy.utils.go('/pages/AI/comDetails', {
id: e[props.idName],
shopId: e.shoppingPlazaId || e.roundTimeId,
});
}
</script>
<style scoped lang="scss">
.card {
background: #ffefe5;
border-radius: 12rpx;
padding: 24rpx 20rpx;
box-sizing: border-box;
}
.image {
width: 248rpx;
height: 248rpx;
border-radius: 8rpx;
overflow: hidden;
image {
width: 100%;
height: 100%;
}
}
.stockText {
color: #000;
}
.progressCard {
position: relative;
height: 28rpx;
overflow: hidden;
.progress,
.progress1 {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 28rpx;
background-color: #7a7995;
opacity: 0.3;
border-radius: 40rpx;
}
.progressText {
position: absolute;
top: 0;
left: 14rpx;
}
.progress {
}
.progress1 {
width: 0%;
background: linear-gradient(90deg, #f7772e 0%, #ee0a24 98%),
linear-gradient(96deg, #f7772e 10%, #ee0a24 126%), #fa7e31;
}
}
:deep(.uni-badge) {
z-index: 1;
}
:deep(.uni-countdown__number) {
font-size: 20rpx !important;
width: 32rpx !important;
height: 32rpx !important;
line-height: 32rpx !important;
}
:deep(.uni-countdown__splitor) {
color: #ff393a !important;
}
.card {
border-radius: 16rpx;
overflow: hidden;
}
</style>
+60
View File
@@ -0,0 +1,60 @@
<template>
<l-echart ref="chartRef"></l-echart>
</template>
<script setup lang="ts">
import { onMounted, ref, onBeforeUnmount, nextTick, watch } from 'vue';
import * as echarts from 'echarts';
const chartRef = ref(null)
const myChart = ref(null)
const props = defineProps({
options: {
type: Object,
default: () => ({})
},
});
// 初始化图表
const initChart = async () => {
if (!chartRef.value) return
// 初始化echart
myChart.value = await chartRef.value.init(echarts)
// 默认获取容器尺寸
myChart.value.resize();
// 设置true清空echart缓存
myChart.value?.setOption(props.options, true);
}
// 监听图表数据时候变化,重新渲染图表
watch(
() => props.options,
() => {
nextTick(() => {
initChart();
});
},
{ deep: true }
);
// 页面挂载,开始绘制图表
onMounted(() => {
nextTick(() => {
initChart();
})
})
// 组件销毁时销毁图表实例
onBeforeUnmount(() => {
if (myChart.value) {
echarts.dispose(myChart.value);
}
});
</script>
+392
View File
@@ -0,0 +1,392 @@
<!-- 收货地址的新增/编辑 -->
<template>
<view class="cardEdit" style="position: relative">
<view>
<view class="title" :class="props.theme == 2 ? 'c0' : ''">添加收货地址</view>
</view>
<view class="close" @click="onColse">
<image :src="$url + 'home/closee.svg'" mode="scaleToFill" />
</view>
<view>
<view class="flex-center w100 h_108 border-top p-x-28" v-for="(v, i) in arr" :key="i"
:class="{'ju-between': v.type == 'switch'}">
<view class="m-r-20 w_180" style="text-align: left;">{{ v.name }}</view>
<view @click="regionClick(v)" class="flex1 flex-center" :class="{'ju-flex-end': v.type == 'switch'}">
<uni-easyinput :type="v.typeName || 'text'" class="flex1 h100"
v-if="v.type == 'input'" v-model="state.model[v.value]"
:placeholder="v.placeholder" :inputBorder="false"
placeholderStyle="color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal"
:maxlength="v.max" :disabled="v.disabled"/>
<view v-if="v.type == 'select'" :style="{color: state.model[v.value]?'#333333':'#BBBBBB'}" style="font-size:30rpx;font-weight:400;line-height:normal;text-align: left;width: 100%">{{state.model[v.value] || v.placeholder}}</view>
<su-switch v-if="v.type == 'switch'" style="transform: scale(0.8)"
v-model="state.model.defaultStatus" />
<uni-icons v-if="v.value == 'areaName'" type="right" :color="props.theme == 2 ? '#ffffff' : ''" />
</view>
</view>
</view>
<view class="border-top p-x-28 c35" style="text-align: left;">{{messText}}</view>
<view class="btn p-x-28">
<button class="add-btn" :class="props.theme == 2 ? 'ai-button2' : ''" @tap="onSave">保存</button>
</view>
<!-- 省市区弹窗 -->
<su-region-picker :show="state.showRegion" @cancel="state.showRegion = false" @confirm="onRegionConfirm" />
</view>
</template>
<script setup>
import {
ref,
reactive,
unref
} from 'vue';
import sheep from '@/sheep';
import {
onLoad
} from '@dcloudio/uni-app';
import _ from 'lodash-es';
import {
mobile
} from '@/sheep/validate/form';
import AreaApi from '@/sheep/api/system/area';
import AddressApi from '@/sheep/api/member/address';
let emit = defineEmits(['close']);
let messText = ref('')
let props = defineProps({
theme: {
type: Number,
default: 2,
},
});
let arr = ref([{
name: '收货人',
value: 'name',
type: 'input',
typeName: 'text',
placeholder: '请输入收货人姓名',
},
{
name: '手机号',
value: 'mobile',
type: 'input',
max: 11,
typeName: 'number',
placeholder: '请输入手机号',
},
{
name: '省市区',
value: 'areaName',
type: 'select',
placeholder: '请选择省市区',
disabled: true
},
{
name: '详细地址',
value: 'detailAddress',
type: 'input',
typeName: 'text',
placeholder: '请输入详细地址',
},
{
name: '默认地址',
value: 'defaultStatus',
type: 'switch',
},
]);
const addressFormRef = ref(null);
const state = reactive({
showRegion: false,
model: {
name: '',
mobile: '',
detailAddress: '',
defaultStatus: false,
areaName: '',
},
rules: {},
});
const rules = {
name: {
rules: [{
required: true,
errorMessage: '请输入收货人姓名',
}, ],
},
mobile: {
rules: [{
required: true,
errorMessage: '请输入手机号',
}, ],
},
areaName: {
rules: [{
required: true,
errorMessage: '请选择您的位置',
}, ],
},
detailAddress: {
rules: [{
required: true,
errorMessage: '请输入详细地址',
}, ],
},
};
// 确认选择地区
const onRegionConfirm = (e) => {
state.model.areaName = `${e.province_name} ${e.city_name} ${e.district_name} ${e.street_name}`;
state.model.areaId = e.street_id;
state.showRegion = false;
};
// 获得地区数据
const getAreaData = () => {
if (_.isEmpty(uni.getStorageSync('areaData'))) {
AreaApi.getAreaTree().then((res) => {
if (res.code === 0) {
uni.setStorageSync('areaData', res.data);
}
});
}
};
// 保存收货地址
const onSave = async () => {
// 参数校验
for (const key in rules) {
if (!state.model[key]) {
// messText.value = rules[key].rules[0].errorMessage
uni.showToast({
title: rules[key].rules[0].errorMessage,
icon: 'none',
});
return;
}
}
if (!/^1(3|4|5|7|8|9|6)\d{9}$/.test(state.model.mobile)) {
uni.showToast({
title: '请填写正确的手机号',
icon: 'none',
});
// messText.value = '请填写正确的手机号'
return;
}
// messText.value = ""
// 提交请求
const formData = {
...state.model,
};
const {
code
} =
state.model.id > 0 ?
await AddressApi.updateAddress(formData) :
await AddressApi.createAddress(formData);
if (code === 0) {
emit('close');
}
};
// 删除收货地址
const onDelete = () => {
uni.showModal({
title: '提示',
content: '确认删除此收货地址吗?',
confirmColor: '#FA7E31',
success: async function(res) {
if (!res.confirm) {
return;
}
const {
code
} = await AddressApi.deleteAddress(state.model.id);
if (code === 0) {
sheep.$router.back();
}
},
});
};
const onEdit = async (id) => {
let {
code,
data
} = await AddressApi.getAddress(id);
if (code !== 0) {
return;
}
state.model = data;
};
onLoad(async (options) => {
// 获得地区数据
getAreaData();
// 情况一:基于 id 获得收件地址
if (options.id) {
let {
code,
data
} = await AddressApi.getAddress(options.id);
if (code !== 0) {
return;
}
state.model = data;
}
// 情况二:微信导入
if (options.data) {
let data = JSON.parse(options.data);
const areaData = uni.getStorageSync('areaData');
const findAreaByName = (areas, name) => areas.find((item) => item.name === name);
let provinceObj = findAreaByName(areaData, data.province_name);
let cityObj = provinceObj ? findAreaByName(provinceObj.children, data.city_name) : undefined;
let districtObj = cityObj ? findAreaByName(cityObj.children, data.district_name) : undefined;
let areaId = (districtObj || cityObj || provinceObj).id;
state.model = {
...state.model,
areaId,
areaName: [data.province_name, data.city_name, data.district_name]
.filter(Boolean)
.join(' '),
defaultStatus: false,
detailAddress: data.address,
mobile: data.mobile,
name: data.consignee,
};
}
});
const onColse = () => {
emit('close');
};
defineExpose({
onEdit,
});
const regionClick = (e) => {
console.log('111')
if (e.value == 'areaName') {
state.showRegion = true;
}
};
</script>
<style lang="scss" scoped>
.cardEdit {
// width: 90%;
}
:deep() {
.uni-forms-item__label .label-text {
font-size: 28rpx !important;
color: #333333;
line-height: normal !important;
}
.uni-easyinput__content-input {
font-size: 28rpx !important;
color: #333333;
line-height: normal !important;
padding-left: 0 !important;
}
.uni-easyinput__content-textarea {
font-size: 28rpx !important;
color: #333333;
line-height: normal !important;
margin-top: 8rpx !important;
}
.uni-icons {
font-size: 40rpx !important;
}
.is-textarea-icon {
margin-top: 22rpx;
}
.is-disabled {
color: #333333;
}
}
:deep(.form2) {
.border-top {
border-top: 1rpx solid #4c505b;
}
}
.default-box {
width: 100%;
box-sizing: border-box;
height: 100rpx;
.default-box-title {
font-size: 28rpx;
color: #333333;
line-height: normal;
}
}
.footer-box {
.save-btn {
width: 710rpx;
height: 80rpx;
border-radius: 40rpx;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
color: $white;
}
.cancel-btn {
width: 710rpx;
height: 80rpx;
border-radius: 40rpx;
background: #F2F4F7;
}
}
:deep(.uni-forms-item--border) {
padding: 0;
border-top: 1px solid #4c505b;
}
.btn {
padding: 32rpx 0rpx;
box-align: border-box;
}
.add-btn {
background: linear-gradient(131deg, #f7772e 0%, #ee0a24 100%);
border-radius: 8rpx;
font-size: 32rpx;
// font-weight: 500;
line-height: 82rpx;
color: $white;
position: relative;
}
.title {
line-height: 92rpx;
color: #3d3d3d;
font-size: 32rpx;
}
.close {
width: 56rpx;
height: 56rpx;
position: absolute;
right: -14rpx;
top: -18rpx;
image {
width: 100%;
height: 100%;
}
}
:deep(.uni-forms-item__error) {
text-align: left;
}
:deep(.is-disabled){
background-color: #ffffff !important;
}
</style>
+45
View File
@@ -0,0 +1,45 @@
<template>
<uni-list>
<uni-list-item
:title="v.title"
:rightText="v.rightText"
:disabled="v.disabled"
v-for="(v, i) in arr"
:link="v.link"
:to="v.to"
:key="i"
>
<template v-slot:footer>
<slot :name="`footer-${v.id}`"></slot>
</template>
</uni-list-item>
</uni-list>
</template>
<script setup>
import { ref, reactive, toRaw, watch, onMounted, onUnmounted, getCurrentInstance } from 'vue';
const props = defineProps({
arr: {
type: Array,
default() {
return [];
},
},
});
</script>
<style lang="scss">
:deep(.uni-list--border) {
display: none;
}
:deep(.uni-list-item__extra-text) {
font-size: 28rpx;
color: #666666;
}
:deep(.uni-list--border-top) {
display: none;
}
:deep(.uni-list--border-bottom) {
display: none;
}
</style>
+105
View File
@@ -0,0 +1,105 @@
<template>
<view class="cardTitle p-x-20 cardBg" :style="{ height: statusBarHeight + 44 + 'px' }">
<view :style="{ height: statusBarHeight + 'px' }"></view>
<view class="flex-center ju-between h_88">
<view class="cardLeft" v-if="props.showLeftButton">
<view @tap="onClickLeft">
<uni-icons type="left" :color="textColor" />
</view>
</view>
<view class="title size36 flex1 center" :style="[{ color: textColor }]">{{
props.title
}}</view>
<view> </view>
</view>
</view>
</template>
<script setup lang="ts">
import { getCurrentInstance, defineProps, defineEmits, ref } from 'vue';
import { onPageScroll } from '@dcloudio/uni-app';
import sheep from '@/sheep';
const { proxy } = getCurrentInstance() as any;
let props = defineProps({
title: {
type: String,
default: '',
},
bg: {
type: String,
default: '#ffffff',
},
scrollbg: {
type: String,
default: '#ffffff',
},
scrollTop: {
type: Number,
default: 20,
},
showLeftButton: {
type: Boolean,
default: true,
},
color: {
type: String,
default: '#333333',
},
scrollColor: {
type: String,
default: '#ffffff',
},
goLeft: {
type: Boolean,
default: true,
},
url: {
type: String,
default: '/pages/index/index',
},
back: {
type: Number,
default: 1,
},
});
let statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
const hasHistory = sheep.$router.hasHistory();
const emits = defineEmits(['navback', 'clickLeft']);
const onClickLeft = () => {
if (props.goLeft) {
if (hasHistory) {
uni.navigateBack({ delta: props.back });
} else {
sheep.$router.go(props.url);
}
} else {
emits('clickLeft');
}
};
// 监听滚动事件
let scrollTop = ref(0);
let backgroundColor = ref(props.bg);
let textColor = ref(props.color);
</script>
<style scoped lang="scss">
.cardTitle {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 1;
}
.cardBg {
// 背景图片顶部显示, 超出部分隐藏, 宽等于100%
background-color: #ffffff;
}
:deep(.uniui-left) {
font-size: 44rpx !important;
}
.cardLeft {
position: absolute;
bottom: 44rpx;
left: 20rpx;
transform: translateY(50%);
}
</style>
+114
View File
@@ -0,0 +1,114 @@
<template>
<view class="cardTitle p-x-20" :style="{ background: backgroundColor }">
<view :style="{height: statusBarHeight + 'px'}"></view>
<view class="flex-center ju-between h_88">
<view class="cardLeft" v-if="props.showLeftButton">
<view @tap="onClickLeft">
<uni-icons type="left" :color="textColor" />
</view>
</view>
<view class="title size36 flex1 center" :style="[{ color: textColor }]">{{ props.title }}</view>
</view>
</view>
</template>
<script setup lang="ts">
import { getCurrentInstance, defineProps, defineEmits, ref } from 'vue';
import {onPageScroll} from '@dcloudio/uni-app';
import sheep from '@/sheep';
const { proxy } = getCurrentInstance() as any;
let props = defineProps({
title: {
type: String,
default: '',
},
bg: {
type: String,
default: '',
},
scrollbg: {
type: String,
default: '#ffffff',
},
scrollTop: {
type: Number,
default: 20
},
showLeftButton: {
type: Boolean,
default: true,
},
color: {
type: String,
default: '#333333',
},
scrollColor:{
type: String,
default: '#333333'
},
goLeft: {
type: Boolean,
default: true,
},
url: {
type: String,
default: '/pages/index/index',
},
back:{
type: Number,
default: 1
},
index:{
type: Number,
default: 0
}
});
let statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
const hasHistory = sheep.$router.hasHistory();
const emits = defineEmits(['navback', 'clickLeft']);
const onClickLeft = () => {
if (props.goLeft && props.showLeftButton) {
if (hasHistory) {
uni.navigateBack({ delta: props.back })
} else {
sheep.$router.go(props.url);
}
} else {
emits('clickLeft');
}
};
// 监听滚动事件
let scrollTop = ref(0)
let backgroundColor = ref(props.bg)
let textColor = ref(props.color)
onPageScroll(e=>{
scrollTop.value = e.scrollTop
if(e.scrollTop > props.scrollTop){
backgroundColor.value = props.scrollbg
textColor.value = props.scrollColor
}else{
backgroundColor.value = props.bg
textColor.value = props.color
}
})
</script>
<style scoped lang="scss">
.cardTitle {
position: fixed;
top:0;
left:0;
width: 100%;
z-index: 98;
}
:deep(.uniui-left){
font-size: 44rpx !important;
}
.cardLeft{
position: absolute;
bottom: 44rpx;
left: 20rpx;
transform: translateY(50%);
}
</style>
@@ -0,0 +1,126 @@
<template>
<view class="cardTitle p-x-20">
<view :style="{height: statusBarHeight + 'px'}"></view>
<view class="flex-center ju-between h_88">
<view class="cardLeft" v-if="props.showLeftButton">
<view @tap="onClickLeft">
<uni-icons type="left" :color="textColor" />
</view>
</view>
<view class="title size36 flex1 center" :style="[{ color: textColor }]">{{ props.title }}</view>
</view>
</view>
</template>
<script setup lang="ts">
import { getCurrentInstance, defineProps, defineEmits, ref } from 'vue';
import { onPageScroll } from '@dcloudio/uni-app';
import sheep from '@/sheep';
const { proxy } = getCurrentInstance() as any;
let props = defineProps({
title: {
type: String,
default: '',
},
bg: {
type: String,
default: '',
},
scrollbg: {
type: String,
default: '#ffffff',
},
scrollTop: {
type: Number,
default: 20
},
showLeftButton: {
type: Boolean,
default: true,
},
color: {
type: String,
default: '#333333',
},
scrollColor: {
type: String,
default: '#333333'
},
goLeft: {
type: Boolean,
default: true,
},
url: {
type: String,
default: '/pages/index/index',
},
back: {
type: Number,
default: 1
},
index: {
type: Number,
default: 0
}
});
let statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
const hasHistory = sheep.$router.hasHistory();
const emits = defineEmits(['navback', 'clickLeft']);
const onClickLeft = () => {
if (props.goLeft && props.showLeftButton) {
if (hasHistory) {
uni.navigateBack({ delta: props.back })
} else {
sheep.$router.go(props.url);
}
} else {
emits('clickLeft');
}
};
// 监听滚动事件
let scrollTop = ref(0)
let backgroundColor = ref(props.bg)
let textColor = ref(props.color)
onPageScroll(e => {
scrollTop.value = e.scrollTop
if (e.scrollTop > props.scrollTop) {
backgroundColor.value = props.scrollbg
textColor.value = props.scrollColor
} else {
backgroundColor.value = props.bg
textColor.value = props.color
}
})
</script>
<style scoped lang="scss">
.one {
width: 100%;
height: 708rpx;
background-image: linear-gradient(to top, #F2F4F7 0%, rgba(251, 129, 55, 0.459) 36%);
position: fixed;
top: 0;
left: 0;
// z-index: -1;
}
.cardTitle {
position: fixed;
top: 0;
left: 0;
width: 100%;
// z-index: 98;
}
:deep(.uniui-left) {
font-size: 44rpx !important;
}
.cardLeft {
position: absolute;
bottom: 44rpx;
left: 20rpx;
transform: translateY(50%);
}
</style>
+213
View File
@@ -0,0 +1,213 @@
<template>
<view class="flex-center" :class="{
'ju-flex-end': props.type == 2,
'ju-between': props.type != 2,
}">
<view class="more size24" v-if="props.type != 2"></view>
<view class="flex-center ju-flex-end">
<view v-for="(item, index) in btns" :key="index">
<view v-if="item.value.split(',').indexOf(String(props?.data?.status)) !== -1" class="btn size28 f500"
@click.stop="btnClick(item.id)"
:style="{ color: item.color, background: item.background, border: item.border }"
:class="{btn1: props.type == 2}">
{{ item.name }}
</view>
</view>
</view>
</view>
</template>
<script setup>
import {
ref,
getCurrentInstance,
defineProps,
defineEmits
} from 'vue';
import sheep from '@/sheep';
import OrderApi from '@/sheep/api/trade/order';
const {
proxy
} = getCurrentInstance();
let emit = defineEmits(['downData']);
const props = defineProps({
data: {
type: Object,
default () {
return {};
},
},
type: {
type: String,
default: '0', //0列表2订单详情
},
});
let btns = ref([{
id: 1,
name: '取消订单',
value: '0',
},
{
id: 2,
name: '去付款',
value: '0',
color: '#EE0A24',
background: 'rgba(238,10,36,0.2)',
border: 'none'
},
// { //在订单详情退货
// id: 3,
// name: '申请售后',
// value: '10,20',
// },
{
id: 4,
name: '确认收货',
value: '20,60',
color: '#EE0A24',
background: 'rgba(238,10,36,0.2)',
border: 'none'
},
// {
// id: 5,
// name: '再次购买',
// value: '30,50,40',
// color: '#FA9C31',
// },
{
id: 6,
name: '取消售后',
value: '60',
},
]);
const btnClick = (index) => {
let timestamp = new Date().getTime();
let payExpireTime = props.data.payExpireTime
if (timestamp > payExpireTime && props.data.status == 0 && index == 2) {
uni.showToast({
title: '订单已过期',
icon: 'none'
});
return;
}
let id = props.data?.id;
switch (index) {
case 1:
cancelOrder();
break;
case 2:
payOrder(id);
break;
case 3:
applyAfterSale();
break;
case 4:
confirmReceive();
break;
case 5:
buyAgain();
break;
case 6:
cancelAfterSale();
break;
}
};
// 取消订单
const cancelOrder = () => {
let orderId = props.data?.id;
uni.showModal({
title: '提示',
content: '确定要取消订单吗?',
confirmColor: '#FA7E31',
success: async function(res) {
if (!res.confirm) {
return;
}
upData();
const {
code
} = await OrderApi.cancelOrder(orderId);
if (code === 0) {
uni.showToast({
title: '订单已取消',
icon: 'none'
});
upData();
}
},
});
};
// 去付款
const payOrder = (id) => {
sheep.$router.go('/pages/pay/index', {
id: props.data.payOrderId,
});
};
// 申请售后
const applyAfterSale = () => {
sheep.$router.go('/pages/order/aftersale/apply', props.data);
};
// 确认收货
const confirmReceive = () => {
let change = false
if (props.data?.items.length) {
props.data.items.forEach(item => {
if (item.afterSaleStatus == 10) {
change = true
return
}
})
}
if (change) {
uni.showToast({
title: '有售后中的商品,请先处理完售后',
icon: 'none'
})
return
}
uni.showModal({
title: '提示',
content: '确认收货吗?',
confirmColor: '#FA7E31',
success: async function(res) {
if (!res.confirm) {
return;
}
// 正常的确认收货流程
const {
code
} = await OrderApi.receiveOrder(props.data?.id);
if (code === 0) {
upData();
}
},
});
};
// 再次购买
const buyAgain = () => {};
// 取消售后
const cancelAfterSale = () => {};
const upData = () => {
emit('downData');
};
</script>
<style scoped lang="scss">
.more {}
.btn {
line-height: 54rpx;
padding: 0 24rpx;
box-sizing: border-box;
border: 2rpx solid #999999;
border-radius: 94px 94px 94px 94px;
margin-left: 12rpx;
color: #999999;
}
.btn1 {
line-height: 74rpx;
padding: 0 30rpx;
}
</style>
@@ -0,0 +1,140 @@
<template>
<view v-show="props.i === props.index" class="h100">
<mescroll-uni
@init="mescrollInit"
top="0"
:down="downOption"
@down="downCallback"
:up="upOption"
@up="upCallback"
@emptyclick="emptyClick"
:height="props.height"
>
<slot></slot>
</mescroll-uni>
</view>
</template>
<script setup>
import { ref, watch, getCurrentInstance } from 'vue';
import useMescroll from '@/uni_modules/mescroll-uni/hooks/useMescroll.js';
const { proxy } = getCurrentInstance();
const props = defineProps({
i: {
// 每个tab页的专属下标
type: Number,
default() {
return 0;
},
},
index: {
// 当前tab的下标
type: Number,
default() {
return 0;
},
},
tabs: {
// 为了请求数据,演示用,可根据自己的项目判断是否要传
type: Array,
default() {
return [];
},
},
pageSize: {
type: Number,
default: 10,
},
height: {
type: String,
default: '100%',
},
});
watch(
() => props.i,
() => {
},
{
immediate: true,
deep: true,
},
);
const { mescrollInit, downCallback, getMescroll } = useMescroll(); // 调用mescroll的hook
const isAutoInit = props.i === props.index; // 自动加载当前tab的数据
const downOption = {
auto: isAutoInit, // 自动加载当前tab的数据
bottomOffset: 20, // 当手指touchmove位置在距离body底部20upx范围内的时候结束上拉刷新,避免Webview嵌套导致touchend事件不执行
};
const upOption = {
auto: true, // 是否在初始化完毕之后自动执行下拉刷新的回调; 默认true
noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
empty: {
tip: '~ 空空如也 ~', // 提示
},
page: {
num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
size: props.pageSize, // 每页数据的数量
},
};
const isInit = ref(isAutoInit); // 当前tab是否已初始化
// 监听下标的变化
watch(
() => props.index,
(val) => {
if (props.i === val && !isInit.value) mescrollTrigger();
},
);
// 主动触发下拉加载
const mescrollTrigger = () => {
isInit.value = true; // 标记为true
const mescroll = getMescroll();
if (mescroll) {
if (mescroll.optDown.use) {
mescroll.triggerDownScroll();
} else {
mescroll.triggerUpScroll();
}
}
};
//点击空布局按钮的回调
const emptyClick = () => {
uni.showToast({
title: '点击了按钮,具体逻辑自行实现',
});
};
const upCallback = (mescroll) => {
setTimeout(() => {
proxy.$emit('upCallback', {
...mescroll,
dataObj: {
status: props.tabs.length ? props.tabs[props.i].value : null,
i: props.i,
index: props.index,
},
});
}, 500);
};
/**
* 根据状态更新 Mescroll 组件的状态
*
* @param state 布尔值,表示 Mescroll 组件的状态,默认为 true
* @param num 数字,表示数据长度,默认为 0
*/
const getState = (state = true, num = 0) => {
const mescroll = getMescroll();
if (state) {
mescroll.endSuccess(num);
} else {
mescroll.endErr();
}
};
defineExpose({ getMescroll, getState, mescrollTrigger }); // 使父组件可以通过ref调用到getMescroll方法 (必须)
</script>
<style lang="scss" scoped></style>
+144
View File
@@ -0,0 +1,144 @@
<template>
<view v-show="props.i === props.index" class="h100">
<mescroll-uni @init="mescrollInit" top="0" :down="downOption" @down="downCallback" :up="upOption"
@up="upCallback" @emptyclick="emptyClick" :height="props.height">
<slot></slot>
</mescroll-uni>
</view>
</template>
<script setup>
import {
ref,
watch,
getCurrentInstance
} from 'vue';
import useMescroll from '@/uni_modules/mescroll-uni/hooks/useMescroll.js';
const {
proxy
} = getCurrentInstance();
const props = defineProps({
i: {
// 每个tab页的专属下标
type: Number,
default () {
return 0;
},
},
index: {
// 当前tab的下标
type: Number,
default () {
return 0;
},
},
tabs: {
// 为了请求数据,演示用,可根据自己的项目判断是否要传
type: Array,
default () {
return [];
},
},
pageSize: {
type: Number,
default: 10,
},
height: {
type: String,
default: '100%',
},
});
watch(
() => props.i,
() => {}, {
immediate: true,
deep: true,
},
);
const {
mescrollInit,
downCallback,
getMescroll
} = useMescroll(); // 调用mescroll的hook
const isAutoInit = props.i === props.index; // 自动加载当前tab的数据
const downOption = {
auto: isAutoInit, // 自动加载当前tab的数据
bottomOffset: 20, // 当手指touchmove位置在距离body底部20upx范围内的时候结束上拉刷新,避免Webview嵌套导致touchend事件不执行
};
const upOption = {
auto: true, // 是否在初始化完毕之后自动执行下拉刷新的回调; 默认true
noMoreSize: 1, // 总数量小于该值也展示“无更多”,设为0确保少于10条时也显示结束
empty: {
tip: '~ 空空如也 ~', // 提示
},
page: {
num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
size: props.pageSize, // 每页数据的数量
},
};
const isInit = ref(isAutoInit); // 当前tab是否已初始化
// 监听下标的变化
watch(
() => props.index,
(val) => {
if (props.i === val && !isInit.value) mescrollTrigger();
},
);
// 主动触发下拉加载
const mescrollTrigger = () => {
isInit.value = true; // 标记为true
const mescroll = getMescroll();
if (mescroll) {
if (mescroll.optDown.use) {
mescroll.triggerDownScroll();
} else {
mescroll.triggerUpScroll();
}
}
};
//点击空布局按钮的回调
const emptyClick = () => {
uni.showToast({
title: '点击了按钮,具体逻辑自行实现',
});
};
const upCallback = (mescroll) => {
setTimeout(() => {
proxy.$emit('upCallback', {
...mescroll,
dataObj: {
status: props.tabs.length ? props.tabs[props.i].value : null,
i: props.i,
index: props.index,
},
});
}, 500);
};
/**
* 根据状态更新 Mescroll 组件的状态
*
* @param state 布尔值,表示 Mescroll 组件的状态,默认为 true
* @param num 数字,表示数据长度,默认为 0
*/
const getState = (state = true, num = 0) => {
const mescroll = getMescroll();
if (state) {
mescroll.endSuccess(num);
} else {
mescroll.endErr();
}
};
defineExpose({
getMescroll,
getState,
mescrollTrigger
}); // 使父组件可以通过ref调用到getMescroll方法 (必须)
</script>
<style lang="scss" scoped></style>
+140
View File
@@ -0,0 +1,140 @@
<template>
<view v-show="props.i === props.index" class="h100">
<mescroll-body
@init="mescrollInit"
top="0"
:down="downOption"
@down="downCallback"
:up="upOption"
@up="upCallback"
@emptyclick="emptyClick"
:height="props.height"
>
<slot></slot>
</mescroll-body>
</view>
</template>
<script setup>
import { ref, watch, getCurrentInstance } from 'vue';
import useMescroll from '@/uni_modules/mescroll-uni/hooks/useMescroll.js';
const { proxy } = getCurrentInstance();
const props = defineProps({
i: {
// 每个tab页的专属下标
type: Number,
default() {
return 0;
},
},
index: {
// 当前tab的下标
type: Number,
default() {
return 0;
},
},
tabs: {
// 为了请求数据,演示用,可根据自己的项目判断是否要传
type: Array,
default() {
return [];
},
},
pageSize: {
type: Number,
default: 10,
},
height: {
type: String,
default: '100%',
},
});
watch(
() => props.i,
() => {
},
{
immediate: true,
deep: true,
},
);
const { mescrollInit, downCallback, getMescroll } = useMescroll(); // 调用mescroll的hook
const isAutoInit = props.i === props.index; // 自动加载当前tab的数据
const downOption = {
auto: isAutoInit, // 自动加载当前tab的数据
bottomOffset: 20, // 当手指touchmove位置在距离body底部20upx范围内的时候结束上拉刷新,避免Webview嵌套导致touchend事件不执行
};
const upOption = {
auto: true, // 是否在初始化完毕之后自动执行下拉刷新的回调; 默认true
noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
empty: {
tip: '~ 空空如也 ~', // 提示
},
page: {
num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
size: props.pageSize, // 每页数据的数量
},
};
const isInit = ref(isAutoInit); // 当前tab是否已初始化
// 监听下标的变化
watch(
() => props.index,
(val) => {
if (props.i === val && !isInit.value) mescrollTrigger();
},
);
// 主动触发下拉加载
const mescrollTrigger = () => {
isInit.value = true; // 标记为true
const mescroll = getMescroll();
if (mescroll) {
if (mescroll.optDown.use) {
mescroll.triggerDownScroll();
} else {
mescroll.triggerUpScroll();
}
}
};
//点击空布局按钮的回调
const emptyClick = () => {
uni.showToast({
title: '点击了按钮,具体逻辑自行实现',
});
};
const upCallback = (mescroll) => {
setTimeout(() => {
proxy.$emit('upCallback', {
...mescroll,
dataObj: {
status: props.tabs.length ? props.tabs[props.i].value : null,
i: props.i,
index: props.index,
},
});
}, 500);
};
/**
* 根据状态更新 Mescroll 组件的状态
*
* @param state 布尔值,表示 Mescroll 组件的状态,默认为 true
* @param num 数字,表示数据长度,默认为 0
*/
const getState = (state = true, num = 0) => {
const mescroll = getMescroll();
if (state) {
mescroll.endSuccess(num);
} else {
mescroll.endErr();
}
};
defineExpose({ getMescroll, getState, mescrollTrigger }); // 使父组件可以通过ref调用到getMescroll方法 (必须)
</script>
<style lang="scss" scoped></style>
+119
View File
@@ -0,0 +1,119 @@
<template>
<view class="card_pages flex1 flex-column h100">
<view v-if="props.type == 1" class="flex1 flex-column">
<slot name="nav"></slot>
<view class="flex1">
<!-- props.oneShow -->
<view v-for="(tab, i) in props.navList" :key="tab.id || i">
<card_mescroll
v-if="props.oneShow?props.currentTab == i:true"
:ref="(el) => mescrollItems[i] && (mescrollItems[i].value = el)"
:i="i"
:index="props.currentTab"
:tabs="props.navList"
@upCallback="upCallback"
:pageSize="props.pageSize"
:height="props.height"
>
<slot name="content"></slot>
</card_mescroll>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref, reactive, watch, onMounted, onUnmounted, getCurrentInstance } from 'vue';
import card_mescroll from './card_mescroll.vue';
import card_mescroll1 from './card_mescroll1.vue';
import { onPageScroll, onReachBottom, onShow } from '@dcloudio/uni-app';
import useMescrollMore from '@/uni_modules/mescroll-uni/hooks/useMescrollMore.js';
const { proxy } = getCurrentInstance();
const props = defineProps({
type: {
type: Number,
default: 1,
},
navList: {
//菜单列表
type: Array,
default: () => [],
},
currentTab: {
//当前选中的菜单
type: Number,
default: 0,
},
pageSize: {
type: Number,
default: 10,
},
height: {
type: String,
default: '100%',
},
oneShow: {
//滚动的时候根据全局滚动测算
type: Boolean,
default: false,
},
});
let mescrollRef = ref(null);
watch(
() => {
props.currentTab;
},
(val) => {
if (props.oneShow && mescrollRef.value) {
mescrollRef.value.mescrollTrigger();
}
},
{
immediate: true,
deep: true,
},
);
// 动态生成与 tabs 同步的 refs 数组,供 useMescrollMore 使用
const mescrollItems = props.navList.map(() => ref(null));
const { getMescroll, scrollToLastY } = useMescrollMore(
mescrollItems,
onPageScroll,
onReachBottom,
);
// 下拉刷新回调
const downCallback = () => {
if (props.oneShow && mescrollRef.value) {
mescrollRef.value.mescrollTrigger();
return;
}
if (mescrollItems.length && mescrollItems[props.currentTab]) {
mescrollItems[props.currentTab].value.mescrollTrigger();
}
};
// 上拉加载回调
const upCallback = (mescroll) => {
//获取数据
proxy.$emit('upCallback', mescroll);
};
const getState = (state = true, num = 0) => {
// console.log(mescrollItems[props.currentTab].value)
if (props.oneShow && mescrollRef.value) {
return mescrollRef.value.getState(state, num);
}
if (mescrollItems.length && mescrollItems[props.currentTab]) {
return mescrollItems[props.currentTab].value.getState(state, num);
}
};
defineExpose({
getMescroll,
scrollToLastY,
getState,
downCallback,
});
</script>
<style lang="scss" scoped></style>
+334
View File
@@ -0,0 +1,334 @@
<template>
<view>
<view class="card_payment flex-center ju-between bg16 h_128 p-l-34 p-r-40">
<view class="flex-center ju-flex-start flex1" @click="showPopup">
<uni-badge :text="num" absolute="rightTop" :offset="[13, 6]">
<view class="w_80 h_80 m-r-24">
<image class="w100 h100" :src="$url + 'ai/index/2.svg'" mode="scaleToFill" />
</view>
</uni-badge>
<view class="flex1">总计: <span class="c13 size24 m-r-5">¥</span><span
class="c13 size34">{{ $fen2yuan(price) }}</span></view>
</view>
<view class="ai-button1 h_80 line80 w_200" @click="go"> 去结算 </view>
</view>
<uni-popup ref="popupRef" type="bottom" border-radius="10px 10px 0 0">
<view class="p-x-32 p-y-40 bg17">
<view class="flex-center ju-between p-b-44">
<view>已加购商品</view>
<view @click="hidePopup">
<uni-icons type="closeempty" color="#999999" size="20" />
</view>
</view>
<view class="popupCon">
<view class="flex-row m-b-24" v-for="(v, i) in cartList" :key="i">
<view class="w_130 h_130 shrink m-r-16">
<image class="w100 h100 radius8" :src="v.picUrl" mode="scaleToFill" />
</view>
<view class="flex-column ju-between flex1">
<view class="m-b-14">
<view class="size28 lineTwo">{{ v?.name }}</view>
</view>
<view class="w100">
<view class="flex-center m-b-12" v-for="(item, index) in v.skuArr" :key="index"
@click="openSelectSku(v, item)">
<view class="flex1 flex-center ju-between h_52 bg18 radius8 p-l-8 p-r-16">
<view class="lineOne c19" v-if="item?.properties">
{{item?.properties.length > 1? item?.propertyText: item?.properties[0].valueName}}
</view>
<view class="flex-center">
<view class="c19">x{{ item?.count }}</view>
<view class="m-l-12 weight900">¥{{ $fen2yuan(item?.discountedPrice?item?.discountedPrice:item?.price) }}</view>
<uni-icons class="m-l-10" type="right" color="#999999" size="16" />
</view>
</view>
<view class="m-l-16" @click.stop="deleteCart(v, item)">
<uni-icons type="closeempty" size="27" color="#999999"></uni-icons>
</view>
</view>
<view class="p-x-8 p-y-10 radius8 bg18 c20" style="display: inline-block">
<span class="m-r-12" @click="openSelectSku(v)">再选一款</span>
<uni-icons type="plusempty" color="#D4D8E1" size="13" />
</view>
</view>
<view class="c13 size36 m-t-8 weight900">
<span class="size28">¥</span>{{ $fen2yuan(v.discountedPrice?v.discountedPrice:v.price) }}
</view>
</view>
</view>
</view>
<view class="popupBottom flex-center ju-between h_128">
<view class="flex-center ju-flex-start flex1">
<uni-badge :text="num" absolute="rightTop" :offset="[13, 6]">
<view class="w_80 h_80 m-r-24">
<image class="w100 h100" :src="$url + 'ai/index/2.svg'" mode="scaleToFill" />
</view>
</uni-badge>
<view class="flex1">
总计: <span class="c13 size24 m-r-5">¥</span>
<span class="c13 size34">{{ $fen2yuan(price) }}</span>
</view>
</view>
<view class="ai-button1 h_80 line80 w_200" @click="go"> 去结算 </view>
</view>
</view>
</uni-popup>
<s-select-aiSku v-if="showSelectSku" :goodsInfo="goodsInfo" :activeSku="activeSku" :selectSku="selectSku"
:show="showSelectSku" :activeInfo="activeInfo" @addCart="onAddCart" @change="onSkuChange"
@close="aiSkuClose" :minSalesCountShow="props.minSalesCountShow"/>
</view>
</template>
<script setup lang="ts">
import { ref, getCurrentInstance, onMounted, defineProps, watch } from 'vue';
import CartApi from '@/sheep/api/trade/cart.js';
import * as SpuApi from '@/sheep/api/ai/index';
import { onShow } from '@dcloudio/uni-app';
const { proxy } = getCurrentInstance() as any;
const props = defineProps({
source: {
// orderInfo商品详情
type: String,
default: 'index',
},
actionStatus: {
// 活动开始状态
type: String,
default: 'index',
},
addShow: {
type: Boolean,
default: false,
},
minSalesCountShow: {
type: Boolean,
default: false
}
});
const cartList = ref([]);
let price = ref(0);
let num = ref(0);
let addShow1 = ref(false)
watch(() => props.addShow, () => {
addShow1.value = props.addShow
}, {
immediate: true,
deep: true
})
const getCartList = (val : any = true) => {
num.value = 0;
price.value = 0;
SpuApi.getShopCartList({}).then((res) => {
let list = res.data || [];
if (list.length) {
list.forEach((e) => {
e.skuArr = JSON.parse(e.specification);
e.skuArr.forEach((item) => {
num.value += item.count;
item.propertyText = '';
if (item.properties) {
item.properties.forEach((e1) => {
item.propertyText += e1.valueName + " ";
});
}
});
price.value += e.discountedPrice;
});
addShow1.value = true
} else {
if (!val) {
addShow1.value = false
}
}
cartList.value = list;
proxy.$emit('updatePrice', addShow1.value);
});
};
onShow(() => {
getCartList();
});
let popupRef = ref(null);
const showPopup = () => {
if (!popupRef.value) return;
popupRef.value.open('bottom');
};
const hidePopup = () => {
popupRef.value.close();
};
onMounted(() => { });
//#region 选择规格弹窗
let showSelectSku = ref(false);
let goodsInfo = ref({});
// 加入购物车
const onAddCart = (data) => {
let obj = {
spuId: '',
specification: '',
shoppingPlazaId: '', //选品广场id
id: '',
};
let url = SpuApi.addShopCart;
if (addShow.value) {
// 新增
delete obj.id;
obj.spuId = addObj.value.id;
obj.shoppingPlazaId = addObj.value.shoppingPlazaId;
let arr = [];
arr.push(data);
obj.specification = JSON.stringify(arr);
url(obj).then((res) => {
if (res.code === 0) {
aiSkuClose();
getCartList();
}
});
} else {
// 编辑
let info = activeInfo.value;
console.log(info)
console.log(activeSku.value)
let index = -1;
if (activeSku.value.id) {
// index = info.skuArr.findIndex((e) => activeSku.value.id == data.id);
info.skuArr.forEach((e, i) => {
if (e.id == activeSku.value.id) {
index = i
}
})
} else {
index = info.skuArr.findIndex((e) => e.id == data.id);
}
if (index != -1) {
info.skuArr[index] = data;
} else {
info.skuArr.push(data);
}
infoChange(info);
}
};
const onSkuChange = (data) => { };
let activeSku = ref({}); // 选中的sku
let selectSku = ref([]); // 选中的sku列表
let activeInfo = ref({}); // 当前商品信息
// 打开规格选择弹窗
const openSelectSku = async (v : any = {}, item = {}) => {
let res = await SpuApi.getSpuDetail(v.spuId, v.shoppingPlazaId);
if (res.code === 0) {
goodsInfo.value = res.data;
activeSku.value = item;
selectSku.value = v?.skuArr || [];
activeInfo.value = v;
showSelectSku.value = true;
}
};
// 关闭规格选择弹窗
const aiSkuClose = () => {
showSelectSku.value = false;
goodsInfo.value = {};
activeSku.value = {};
selectSku.value = [];
activeInfo.value = {};
addObj.value = {};
addShow.value = false;
};
//#endregion
const deleteCart = (v, item) => {
if (v.skuArr.length == 1) {
// 删除接口
SpuApi.deleteShopCart({ id: v.id }).then((res) => {
if (res.code === 0) {
getCartList(false);
proxy.$emit('updataList');
}
});
} else {
// 修改接口
let index = v.skuArr.findIndex((e) => e.id == item.id);
v.skuArr.splice(index, 1);
infoChange(v);
}
};
// 修改属性
const infoChange = (data) => {
let obj = {
spuId: data.spuId,
specification: JSON.stringify(data.skuArr),
shoppingPlazaId: data.shoppingPlazaId, //选品广场id
id: data.id,
};
let url = SpuApi.updateShopCart;
url(obj).then((res) => {
if (res.code === 0) {
aiSkuClose();
getCartList();
}
});
};
let addObj = ref({});
let addShow = ref(false);
const addCar = async (data) => {
addObj.value = data;
let obj = cartList.value.find(
(e) => e.shoppingPlazaId == data.shoppingPlazaId && e.spuId == data.id,
);
if (obj?.id) {
openSelectSku(obj);
return;
}
addShow.value = true;
let res = await SpuApi.getSpuDetail(data.id, data.shoppingPlazaId);
if (res.code === 0) {
goodsInfo.value = res.data;
showSelectSku.value = true;
}
};
defineExpose({
addCar,
getCartList,
});
const go = () => {
// if (props.actionStatus === '开始') {
// uni.showToast({
// title: '活动未开始',
// icon: 'none'
// });
// return;
// }
if (price.value > 0) {
// proxy.utils.go('/pages/AI/placeOrder');
uni.redirectTo({
url: '/pages/AI/placeOrder',
});
} else {
if (props.source == 'orderInfo') {
proxy.$emit('addCar');
return;
}
proxy.utils.toast('请选择商品');
}
};
</script>
<style scoped lang="scss">
.card_payment {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
box-shadow: 0px 0px 18px 0px rgba(0, 0, 0, 0.04);
z-index: 2;
}
.popupCon {
height: 506rpx;
overflow-y: auto;
}
.popupBottom {
box-shadow: 0px 0px 18px 0px rgba(0, 0, 0, 0.04);
}
</style>
+80
View File
@@ -0,0 +1,80 @@
<template>
<view class="flex-center ju-between w100 search">
<view class="flex-center flex1 search_input">
<image
style="width: 32rpx; height: 32rpx"
src="/static/icon/search1.png"
mode="scaleToFill"
/>
<input
class="flex1 input"
type="text"
placeholder="搜索想要的商品"
confirm-type="搜索"
placeholder-class="search_placeholder"
v-model="searchText"
@confirm="search"
/>
<view class="search_btn" @click="search">搜索</view>
</view>
</view>
</template>
<script setup>
import { ref, watch } from 'vue';
const emit = defineEmits(['search']);
const props = defineProps({
modelValue: {
type: String,
default: '',
},
});
let searchText = ref('');
watch(
() => props.modelValue,
() => {
searchText.value = props.modelValue;
},
{ immediate: true, deep: true },
);
// let globalData = uni.getStorageSync('globalData');
const search = () => {
emit('search', searchText.value);
};
</script>
<style lang="scss" scoped>
.search {
width: 100%;
box-sizing: border-box;
// background-color: #fff;
.search_input {
border: 4rpx solid #fa9c31;
height: 72rpx;
border-radius: 64rpx;
padding-left: 28rpx;
padding-right: 6rpx;
input {
width: 100%;
margin-left: 16rpx;
height: 100%;
}
.search_btn {
line-height: 64rpx;
width: 108rpx;
text-align: center;
background: linear-gradient(270deg, #fa7931 0%, #fa9c31 100%);
border-radius: 64rpx;
color: #fff;
font-size: 30rpx;
}
}
}
.shopIcon {
width: 80rpx;
}
.search_placeholder {
font-size: 28rpx !important;
height: 100%;
display: flex;
align-items: center;
}
</style>
+47
View File
@@ -0,0 +1,47 @@
<template>
<view class="card_tabber">
</view>
</template>
<script setup>
import {ref} from 'vue'
const tabber = ref({
items: [
{
text: '首页',
url: '/pages/index/index',
iconUrl: proxy.$url+'index/1.svg',
activeIconUrl: proxy.$url+'index/1_1.svg',
},
{
text: '分类',
url: '/pages/index/category',
iconUrl: proxy.$url+'index/2.svg',
activeIconUrl: proxy.$url+'index/2_1.svg',
},
{
text: '',
url: '/pages/home/seed',
iconUrl: proxy.$url+'index/6.svg',
activeIconUrl: proxy.$url+'index/6.svg',
},
{
text: '购物车',
url: '/pages/cart/cart',
iconUrl: proxy.$url+'index/3.svg',
activeIconUrl: proxy.$url+'index/3_1.svg',
},
{
text: '我的',
url: '/pages/index/user',
iconUrl: proxy.$url+'index/4.svg',
activeIconUrl: proxy.$url+'index/4_1.svg',
},
],
})
</script>
<style>
</style>
+94
View File
@@ -0,0 +1,94 @@
<template>
<view>
<scroll-view scroll-x show-scrollbar="false" class="scroll-x-wrapper p-x-32">
<view class="navs flex-center ju-flex-start nowrap" style="width: auto;">
<view
class="navItem flex-center flex-column flex1 shrink nowrap"
:class="{ tabIndex: i == tabIndex, c34: i == tabIndex }"
v-for="(v, i) in props.list"
:key="i"
@click="navChange(i)"
>
<view class="navText"> {{ v.name }} </view>
<image src="/static/index/active.png" mode="scaleToFill" />
</view>
</view>
</scroll-view>
<view class="goodsPages">
<goods-item
v-for="(tab, i) in props.list"
:key="tab.id || i"
:ref="(el) => mescrollItems[i] && (mescrollItems[i].value = el)"
:i="i"
:index="tabIndex"
:tabs="props.list"
></goods-item>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue';
import goodsItem from '../goodsItem/goodsItem.vue';
import { onPageScroll, onReachBottom, onShow } from '@dcloudio/uni-app';
import useMescrollMore from '@/uni_modules/mescroll-uni/hooks/useMescrollMore.js';
let props = defineProps({
list: {
type: Array,
default: () => [],
},
});
// 动态生成与 tabs 同步的 refs 数组,供 useMescrollMore 使用
const mescrollItems = props.list.map(() => ref(null));
const { tabIndex, getMescroll, scrollToLastY } = useMescrollMore(
mescrollItems,
onPageScroll,
onReachBottom,
);
// let tabIndex = ref(0);
const navChange = (i) => {
// scrollToLastY()
tabIndex.value = i;
};
</script>
<style lang="scss" scoped>
.scroll-x-wrapper {
width: 100%;
white-space: nowrap;
}
.navs {
// padding: 0 32rpx;
box-sizing: border-box;
height: 120rpx;
// padding-bottom: 10rpx;
.navItem {
color: #777777;
font-size: 32rpx;
// width: 20%;
// text-align: center;
// margin-right: 40rpx;
white-space: nowrap;
flex-shrink: 0; // 防止被压缩
image {
width: 40rpx;
height: 12rpx;
opacity: 0;
margin-top: 12rpx;
}
}
.tabIndex {
color: #777777;
font-size: 36rpx;
font-weight: 500;
image {
opacity: 1;
}
}
}
.goodsPages {
padding: 0 32rpx;
padding-top: 12rpx;
box-sizing: border-box;
}
</style>
+220
View File
@@ -0,0 +1,220 @@
<template>
<view>
<card_pages
ref="cardPages"
:navList="props.list"
:currentTab="tabIndex"
@upCallback="getData"
:height="height + 'px'"
:oneShow="true"
>
<template #nav>
<scroll-view scroll-x show-scrollbar="false" class="scroll-x-wrapper p-x-32">
<view class="navs flex-center ju-flex-start nowrap" style="width: auto">
<view
class="navItem flex-center flex-column c33 flex1 shrink nowrap"
:class="{ tabIndex: i == tabIndex, c0: i == tabIndex }"
v-for="(v, i) in props.list"
:key="i"
@click="navChange(i)"
>
<view class="navText"> {{ v.name }} </view>
<image src="/static/index/active1.png" mode="scaleToFill" />
</view>
</view>
</scroll-view>
</template>
<template #content>
<view class="goodsPages">
<view class="flex-row wrap w100" ref="cardRef">
<view class="cardItem" v-for="(v, i) in goods" :key="i">
<card_goods :data="v"></card_goods>
</view> </view
></view>
</template>
</card_pages>
</view>
<!-- <view>
<scroll-view scroll-x show-scrollbar="false" class="scroll-x-wrapper p-x-32">
<view class="navs flex-center ju-flex-start nowrap" style="width: auto;">
<view
class="navItem flex-center flex-column c33 flex1 shrink nowrap"
:class="{ tabIndex: i == tabIndex, c0: i == tabIndex }"
v-for="(v, i) in props.list"
:key="i"
@click="navChange(i)"
>
<view class="navText"> {{ v.name }} </view>
<image src="/static/index/active1.png" mode="scaleToFill" />
</view>
</view>
</scroll-view>
<view class="goodsPages">
<goods-item
v-for="(tab, i) in props.list"
:key="tab.id || i"
:ref="(el) => mescrollItems[i] && (mescrollItems[i].value = el)"
:i="i"
:index="tabIndex"
:tabs="props.list"
></goods-item>
</view>
</view> -->
</template>
<script setup>
import { ref, watch } from 'vue';
import goodsItem from '../goodsItem/goodsItem.vue';
import card_goods from '../goodsItem/card_goods.vue';
import SpuApi from '@/sheep/api/product/spu';
// import { onPageScroll, onReachBottom, onShow } from '@dcloudio/uni-app';
// import useMescrollMore from '@/uni_modules/mescroll-uni/hooks/useMescrollMore.js';
let cardPages = ref(null);
let props = defineProps({
list: {
type: Array,
default: () => [],
},
});
// 动态生成与 tabs 同步的 refs 数组,供 useMescrollMore 使用
// const mescrollItems = props.list.map(() => ref(null));
// const { tabIndex, getMescroll, scrollToLastY } = useMescrollMore(
// mescrollItems,
// onPageScroll,
// onReachBottom,
// );
let tabIndex = ref(0);
let goods = ref([]);
let height = ref('');
const navChange = (i) => {
// scrollToLastY()
tabIndex.value = i;
upData()
};
const getData = (mescroll) => {
if (!props.list || !props.list.length) {
cardPages.value.getState(false);
return;
}
SpuApi.getSpuPage({
pageNo: mescroll.num,
pageSize: mescroll.size,
tagTypeId: props.list[tabIndex.value].id,
})
.then((res) => {
if (res.code !== 0) {
if (cardPages.value) {
cardPages.value.getState(false);
}
return;
}
const list = res.data.list || []; // 当前页数据
if (mescroll.num == 1) goods.value = []; //如果是第一页需手动制空列表
goods.value = goods.value.concat(list); //追加新数据
hasMore.value = goods.value.length < res.data.total;
// 计算容器高度
getHeight(mescroll.num);
if (cardPages.value) {
cardPages.value.getState(true, list.length);
}
})
.catch(() => {
cardPages.value.getState(false);
});
};
const getHeight = (num) => {
if (!goods.value.length) {
// 541
height.value = 10;
return;
}
// 相除向上取整
let cardHeight = Math.ceil(goods.value.length / 2) * 541;
let sysInfo = uni.getSystemInfoSync();
const windowHeight = sysInfo.windowHeight;
const value1 = windowHeight - sysInfo.statusBarHeight - uni.upx2px(88) - uni.upx2px(120);
let value2 = uni.upx2px(cardHeight) + 55 + uni.upx2px(12);
// if(hasMore){
// value2 = uni.upx2px(cardHeight) + uni.upx2px(12)
// }
const isGreater = value1 > value2;
if (isGreater) {
height.value = value2;
} else {
height.value = value1;
}
// console.error(windowHeight)
// console.log("最大高"+value1)
// console.log("内容高"+value2)
// console.error(height.value)
};
const upData = () => {
if (cardPages.value) {
cardPages.value.downCallback();
}
};
watch(
() => props.list,
() => {
if (props.list && props.list.length) {
upData();
}
},
{
immediate: true,
deep: true,
},
);
</script>
<style lang="scss" scoped>
.scroll-x-wrapper {
width: 100%;
white-space: nowrap;
}
.navs {
// padding: 0 32rpx;
box-sizing: border-box;
height: 120rpx;
// padding-bottom: 10rpx;
.navItem {
color: #777777;
font-size: 32rpx;
// width: 20%;
// text-align: center;
margin-right: 40rpx;
white-space: nowrap;
flex-shrink: 0; // 防止被压缩
image {
width: 40rpx;
height: 12rpx;
opacity: 0;
margin-top: 12rpx;
}
}
.tabIndex {
color: #333333;
font-size: 36rpx;
font-weight: 500;
image {
opacity: 1;
}
}
}
.goodsPages {
padding: 0 32rpx;
padding-top: 12rpx;
box-sizing: border-box;
}
.cardItem {
width: calc(50% - 8rpx);
margin-right: 16rpx;
&:nth-child(2n) {
margin-right: 0;
}
}
</style>
+115
View File
@@ -0,0 +1,115 @@
<template>
<view>
<view class="navs flex-center ju-flex-start">
<view
class="navItem flex-center flex-column"
:class="{ tabIndex: i == tabIndex }"
v-for="(v, i) in props.list"
@click="navChange(i)"
>
<view class="navText">
{{ v.name }}
</view>
<image src="/static/index/active.png" mode="scaleToFill" />
</view>
</view>
<mescroll-body
:down="downOption"
@init="mescrollInit"
top="0"
@down="downCallback"
:up="upOption"
@up="upCallback"
@emptyclick="emptyClick"
:height="10"
>
<goods-item :goods="goods" v-if="goods.length > 0"></goods-item>
</mescroll-body>
</view>
</template>
<script setup>
import { ref } from 'vue';
import useMescroll from '@/uni_modules/mescroll-uni/hooks/useMescroll.js';
import SpuApi from '@/sheep/api/product/spu';
import goodsItem from '../goodsItem/goodsItem2.vue';
let props = defineProps({
list: {
type: Array,
default: () => [],
},
});
let tabIndex = ref(0);
let goods = ref([]);
const { mescrollInit, downCallback, getMescroll } = useMescroll(); // 调用mescroll的hook
defineExpose({ getMescroll }); // 使父组件可以通过ref调用到getMescroll方法 (必须)
const downOption = {
use: false, // 是否启用下拉刷新; 默认true
};
const upOption = {
noMoreSize: 4,
empty:{
tip: '~ 搜索无数据 ~', // 提示
}
};
const upCallback = (mescroll) => {
SpuApi.getSpuPage({
pageNo: mescroll.num,
pageSize: mescroll.size,
tagTypeId: props.list[tabIndex.value].id,
})
.then((res) => {
const list = res.data.list || []; // 当前页数据
if (mescroll.num == 1) goods.value = []; //如果是第一页需手动制空列表
goods.value = goods.value.concat(list); //追加新数据
mescroll.endSuccess(list.length); // 请求成功, 结束加载
})
.catch(() => {
mescroll.endErr(); // 请求失败, 结束加载
});
mescroll.endErr(); // 请求失败, 结束加载
};
//点击空布局按钮的回调
const emptyClick = () => {
uni.showToast({
title: '点击了按钮,具体逻辑自行实现',
});
};
// let tabIndex = ref(0);
const navChange = (i) => {
// scrollToLastY()
goods.value = [];
tabIndex.value = i;
const m = getMescroll();
m.setPageNum(1);
m.resetUpScroll(false);
};
</script>
<style lang="scss" scoped>
.navs {
.navItem {
color: #777777;
font-size: 24rpx;
width: 20%;
// text-align: center;
image {
width: 40rpx;
height: 12rpx;
opacity: 0;
margin-top: 12rpx;
}
}
.tabIndex {
color: #333333;
font-size: 32rpx;
font-weight: 500;
image {
opacity: 1;
}
}
}
</style>
+315
View File
@@ -0,0 +1,315 @@
<template>
<view
class="w100"
:class="{
'card-goods1': props.type == 1,
'card-goods2': props.type == 2,
'card-goods3': props.type == 3,
}"
>
<view
class="shrink"
@click="utils.go('/pages/goods/info', { id: props.data.id })"
:class="{
goodsImg1: props.type == 1,
goodsImg2: props.type == 2,
goodsImg3: props.type == 3,
}"
>
<image
class=""
:src="props.data.picUrl ? sheep.$url.cdn(props.data.picUrl) : '/static/icon/null1.png'"
mode="aspectFill"
/>
</view>
<view class="goodItem" :class="{itemBg: props.type == 1}" @click="utils.go('/pages/goods/info', { id: props.data.id })">
<view class="wrap">
<view
class="title "
:class="{ lineTwo: props.type == 2, lineOne: props.type == 1 || props.type == 3, c34: props.type == 2 || props.type == 1, c34: props.type == 3 }"
>{{ props.data.name }} </view
>
<view
class="flex-center m-t-10 m-b-12"
:class="{ 'ju-between': props.data.tagSaleName, 'ju-flex-end': !props.data.tagSaleName }"
v-if="props.type == 1"
>
<view class="label" v-if="props.data.tagSaleName">{{ props.data.tagSaleName }}</view>
<view class="num">已售{{ props.data.salesCount }}</view>
</view>
<view v-else-if="props.type == 2">
<view class="flex-center ju-between mt10 wrap">
<view class="num size26 m-r-4">{{ props.data.categoryText }}</view>
<view class="num">销量:{{ props.data.salesCount }}</view>
</view>
<view class="flex-row wrap" v-if="props.data.tagSaleName">
<view
class="label mr10 mb10"
v-for="(v, i) in props.data.tagSaleName.split(',')"
:key="i"
>{{ v }}</view
>
<!-- <view class="label">标签2</view> -->
</view>
</view>
</view>
<view class="flex-center ju-between">
<view class="price"
><span class="f500" style="font-size: 24rpx;">¥</span
><span class="priceNum f500">{{ fen2yuan(props.data.price) }}</span>
<span v-if="props.type == 1 && props.data.unit">/{{ props.data.unit || '' }}</span>
<!-- <span
class="marketPrice"
v-else
style="color: 20rpx; color: #777777; text-decoration: line-through; margin-left: 8rpx"
>¥{{ fen2yuan(props.data.marketPrice) }}</span
> -->
</view>
<!-- -->
<uni-badge :text="props.data.cartCount" v-if="props.type == 2 && props.data.cartCount" absolute="rightTop" :customStyle="{background: '#FF0000'}">
<view class="shopIcon" :class="{ 'shopIcon1': props.type == 2 }" @click.stop="changeSelectSku">
<image src="/static/index/shop.png" mode="scaleToFill" />
</view>
</uni-badge>
<view class="shopIcon" :class="{ 'shopIcon1': props.type == 2 }" @click.stop="changeSelectSku" v-else>
<image src="/static/index/shop.png" mode="scaleToFill" />
</view>
</view>
</view>
<s-select-sku
v-if="showSelectSku"
:goodsInfo="state.goodsInfo"
:show="showSelectSku"
@addCart="onAddCart"
@buy="onBuy"
@change="onSkuChange"
@close="showSelectSku = false"
/>
</view>
</template>
<script setup>
import sheep from '@/sheep';
import { ref, reactive, watch } from 'vue';
import SpuApi from '@/sheep/api/product/spu';
import { fen2yuan } from '@/sheep/hooks/useGoods';
const props = defineProps({
data: {
type: Object,
default() {
return {};
},
},
type: {
//1:首页 2:分类 3:搜索
type: Number,
default: 1,
},
search: {
type: String,
default: '',
},
});
watch(
() => props.data,
() => {},
{
immediate: true,
deep: true,
},
);
let showSelectSku = ref(false);
const changeSelectSku = async () => {
let res = await getData();
showSelectSku.value = true;
};
const getData = async () => {
let res = await SpuApi.getSpuDetail(props.data.id);
if (res.code !== 0 || !res.data) {
state.goodsInfo = null;
state.skeletonLoading = false;
return;
}
// 加载到商品
state.skeletonLoading = false;
state.goodsInfo = res.data;
// 获取结算信息
// getSettlementByIds(state.goodsId);
};
const state = reactive({
goodsId: 0,
skeletonLoading: true, // SPU 加载中
goodsInfo: {}, // SPU 信息
showSelectSku: false, // 是否展示 SKU 选择弹窗
selectedSku: {}, // 选中的 SKU
settlementSku: {}, // 结算的 SKU:由于 selectedSku 不进行默认选中,所以初始使用结算价格最低的 SKU 作为基础展示
showModel: false, // 是否展示 Coupon 优惠劵的弹窗
couponInfo: [], // 可领取的 Coupon 优惠劵的列表
showActivityModel: false, // 【满减送/限时折扣】是否展示 Activity 营销活动的弹窗
rewardActivity: {}, // 【满减送】活动
activityList: [], // 【秒杀/拼团/砍价】可参与的 Activity 营销活动的列表
});
// 添加购物车
function onAddCart(e) {
//console.log(e);
if (!e.id) {
sheep.$helper.toast('请选择商品规格');
return;
}
sheep.$store('cart').add(e);
showSelectSku.value = false;
}
// 立即购买
function onBuy(e) {
if (!e.id) {
sheep.$helper.toast('请选择商品规格');
return;
}
showSelectSku.value = false;
sheep.$router.go('/pages/order/confirm', {
data: JSON.stringify({
items: [
{
skuId: e.id,
count: e.goods_num,
categoryId: state.goodsInfo.categoryId,
},
],
}),
});
}
// 规格变更
function onSkuChange(e) {
state.selectedSku = e;
state.settlementSku = e;
}
</script>
<style lang="scss" scoped>
.goodItem {
padding: 20rpx 24rpx;
box-sizing: border-box;
margin-bottom: 32rpx;
border-radius: 0 0 8rpx 8rpx;
.title {
font-size: 28rpx;
line-height: 30rpx;
font-weight: 500;
color: #333333;
}
.label {
font-size: 20rpx;
color: #ff5040;
border: 1px solid #ff5040;
border-radius: 8rpx;
height: 34rpx;
line-height: 34rpx;
padding: 0 8rpx;
box-sizing: border-box;
}
.num {
color: #777777;
font-size: 24rpx;
}
.price {
color: #ee0a24;
font-size: 24rpx;
}
.priceNum {
font-size: 36rpx;
font-weight: 600;
}
.shopIcon {
width: 50rpx;
height: 50rpx;
image {
width: 100%;
height: 100%;
}
}
.shopIcon1{
width: 52rpx;
height: 52rpx;
image {
width: 100%;
height: 100%;
}
}
}
.shrink{
border-radius: 10rpx;
overflow: hidden;
image {
width: 100%;
height: 100%;
}
}
.goodsImg2 {
width: 200rpx;
height: 200rpx;
}
.goodsImg3 {
width: 96rpx;
height: 96rpx;
}
.goodsImg1 {
// width: 100%;
// aspect-ratio: 1/1;
border-radius:10rpx 10rpx 0 0;
position: relative;
}
.goodsImg1::before{
content: '';
display: block;
padding-top: 100%;
}
.goodsImg1 image{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.card-goods1 {
display: flex;
flex-direction: column;
}
.card-goods2,
.card-goods3 {
width: 100%;
display: flex;
flex-direction: row;
margin-bottom: 36rpx;
flex-wrap: nowrap;
.goodItem {
flex: 1;
padding: 0;
margin: 0;
display: flex;
flex-direction: column;
justify-content: space-between;
padding-left: 12rpx;
box-sizing: border-box;
}
}
.card-goods3 {
.priceNum {
font-size: 28rpx;
}
.marketPrice {
font-size: 24rpx;
}
}
.itemBg{
background-color: #ffffff;
}
</style>
+170
View File
@@ -0,0 +1,170 @@
<template>
<view>
<view v-show="i === props.index">
<!-- top="120"下拉布局往下偏移,防止被悬浮菜单遮住 -->
<mescroll-body
@init="mescrollInit"
top="0"
:down="downOption"
@down="downCallback"
:up="upOption"
@up="upCallback"
@emptyclick="emptyClick"
:height="10"
>
<!-- 数据列表 -->
<!-- <good-list :list="goods"></good-list> -->
<!-- <view v-for="(v,i) in goods" :key="i">
{{ v.picUrl }}
</view> -->
<!-- <view class="flex-row">
<view class="flex1 cardItem" v-for="(v, i) in goods" :key="i">
<card_goods :data="v"></card_goods>
</view>
</view> -->
<custom-waterfalls-flow-vue3-2
:value="goods"
:column="props.column" :columnSpace="1"
:seat="2"
imageKey="picUrl"
v-if="goods.length"
>
<!-- #ifdef MP-WEIXIN -->
<view v-for="(v, i) in goods" :key="i" :slot="`slot${i}`">
{{goods.length}}
<!-- <card_goods :data="v"></card_goods> -->
</view>
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
<template v-slot:default="item">
<card_goods :data="item"></card_goods>
</template>
<!-- <view v-for="(v, i) in goods" :key="i" v-slot:default="v">
<card_goods :data="v"></card_goods>
</view> -->
<!-- #endif -->
</custom-waterfalls-flow-vue3-2>
</mescroll-body>
</view>
</view>
</template>
<script setup>
import { ref, watch } from 'vue';
import useMescroll from '@/uni_modules/mescroll-uni/hooks/useMescroll.js';
import SpuApi from '@/sheep/api/product/spu';
import card_goods from './card_goods.vue'
let goods = ref([]);
const column = ref(2);
const columnChange = ref(false);
const props = defineProps({
i: Number, // 每个tab页的专属下标
index: {
// 当前tab的下标
type: Number,
default() {
return 0;
},
},
tabs: {
// 为了请求数据,演示用,可根据自己的项目判断是否要传
type: Array,
default() {
return [];
},
},
column: {
type: Number,
default() {
return 2;
},
},
});
watch(props.column, (val) => {
if (val !== column.value) {
columnChange.value = true;
setTimeout(() => {
columnChange.value = false;
}, 100);
column.value = val;
}
});
const { mescrollInit, downCallback, getMescroll } = useMescroll(); // 调用mescroll的hook
defineExpose({ getMescroll }); // 使父组件可以通过ref调用到getMescroll方法 (必须)
const isAutoInit = props.i === props.index; // 自动加载当前tab的数据
const downOption = {
auto: isAutoInit, // 自动加载当前tab的数据
};
const upOption = {
auto: false, // 不自动加载
noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
empty: {
tip: '~ 空空如也 ~', // 提示
},
};
const isInit = ref(isAutoInit); // 当前tab是否已初始化
// 监听下标的变化
watch(
() => props.index,
(val) => {
if (props.i === val && !isInit.value) mescrollTrigger();
},
);
// 主动触发加载
const mescrollTrigger = () => {
isInit.value = true; // 标记为true
const mescroll = getMescroll();
if (mescroll) {
if (mescroll.optDown.use) {
mescroll.triggerDownScroll();
} else {
mescroll.triggerUpScroll();
}
}
};
const upCallback = (mescroll) => {
SpuApi.getSpuPage({
pageNo: mescroll.num,
pageSize: mescroll.size,
tagTypeId: props.tabs[props.i].id,
})
.then((res) => {
const list = res.data.list || []; // 当前页数据
if(list.length){
list.forEach(e=>{
e.hide = true
})
}
if (mescroll.num == 1) goods.value = []; //如果是第一页需手动制空列表
goods.value = goods.value.concat(list); //追加新数据
mescroll.endSuccess(list.length); // 请求成功, 结束加载
})
.catch(() => {
mescroll.endErr(); // 请求失败, 结束加载
});
mescroll.endErr(); // 请求失败, 结束加载
};
//点击空布局按钮的回调
const emptyClick = () => {
uni.showToast({
title: '点击了按钮,具体逻辑自行实现',
});
};
</script>
<style lang="scss" scoped>
.cardItem{
margin-right: 16rpx;
}
</style>
+200
View File
@@ -0,0 +1,200 @@
<template>
<view class="goodsItem-container">
<view v-show="i === props.index">
<!-- top="120"下拉布局往下偏移,防止被悬浮菜单遮住 -->
<mescroll-uni
@init="mescrollInit"
top="0"
:down="downOption"
@down="downCallback"
:up="upOption"
@up="upCallback"
@emptyclick="emptyClick"
v-if="i === props.index"
:height="height + 'px'"
>
<!-- 数据列表 -->
<!-- <good-list :list="goods"></good-list> -->
<!-- <view v-for="(v,i) in goods" :key="i">
{{ v.picUrl }}
</view> -->
<view class="flex-row wrap w100" ref="cardRef">
<view class="cardItem" v-for="(v, i) in goods" :key="i">
<card_goods :data="v"></card_goods>
</view>
</view>
</mescroll-uni>
</view>
</view>
</template>
<script setup>
import { ref, watch, getCurrentInstance } from 'vue';
import { onPageScroll, onReachBottom } from '@dcloudio/uni-app';
import useMescroll from '@/uni_modules/mescroll-uni/hooks/useMescroll.js';
import SpuApi from '@/sheep/api/product/spu';
import card_goods from './card_goods.vue';
const { proxy } = getCurrentInstance();
let goods = ref([]);
const column = ref(2);
const columnChange = ref(false);
const height = ref(0);
const props = defineProps({
i: Number, // 每个tab页的专属下标
index: {
// 当前tab的下标
type: Number,
default() {
return 0;
},
},
tabs: {
// 为了请求数据,演示用,可根据自己的项目判断是否要传
type: Array,
default() {
return [];
},
},
column: {
type: Number,
default() {
return 2;
},
},
});
watch(
() => props.column,
(val) => {
if (val !== column.value) {
columnChange.value = true;
setTimeout(() => {
columnChange.value = false;
}, 100);
column.value = val;
}
},
);
const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, onReachBottom); // 调用mescroll的hook
defineExpose({ getMescroll }); // 使父组件可以通过ref调用到getMescroll方法 (必须)
const isAutoInit = props.i === props.index; // 自动加载当前tab的数据
const downOption = {
auto: isAutoInit, // 自动加载当前tab的数据
};
const upOption = {
use: true, // 必须明确启用上拉加载功能
auto: true, // 不自动加载
noMoreSize: 1, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
empty: {
tip: '~ 空空如也 ~', // 提示
},
page: {
num: 0, // 当前页码,默认0,回调之前会加1
size: 10, // 每页数据的数量
},
offset: 150, // 距底部100px时触发上拉加载
};
const isInit = ref(isAutoInit); // 当前tab是否已初始化
// 监听下标的变化
watch(
() => props.index,
(val) => {
if (props.i === val && !isInit.value) mescrollTrigger();
},
);
// 主动触发加载
const mescrollTrigger = () => {
isInit.value = true; // 标记为true
const mescroll = getMescroll();
if (mescroll) {
if (mescroll.optDown.use) {
mescroll.triggerDownScroll();
} else {
mescroll.triggerUpScroll();
}
}
};
let cardRef = ref(null);
// 是否有下一页
let hasMore = ref(true);
const upCallback = (mescroll) => {
SpuApi.getSpuPage({
pageNo: mescroll.num,
pageSize: mescroll.size,
tagTypeId: props.tabs[props.i].id,
})
.then((res) => {
const list = res.data.list || []; // 当前页数据
// if(list.length){
// list.forEach(e=>{
// e.hide = true
// })
// }
if (mescroll.num == 1) goods.value = []; //如果是第一页需手动制空列表
goods.value = goods.value.concat(list); //追加新数据
hasMore.value = goods.value.length < res.data.total;
// 计算容器高度
getHeight(mescroll.num);
mescroll.endSuccess(list.length); // 请求成功, 结束加载
})
.catch(() => {
mescroll.endErr(); // 请求失败, 结束加载
});
};
//点击空布局按钮的回调
const emptyClick = () => {
uni.showToast({
title: '点击了按钮,具体逻辑自行实现',
});
};
const getHeight = (num) => {
if (!goods.value.length) {
// 541
height.value = 10
return
}
// 相除向上取整
let cardHeight = Math.ceil(goods.value.length / 2) * (541)
let sysInfo = uni.getSystemInfoSync()
const windowHeight = sysInfo.windowHeight;
const value1 = windowHeight - sysInfo.statusBarHeight - uni.upx2px(88) - uni.upx2px(120)
let value2 = uni.upx2px(cardHeight) + 55 + uni.upx2px(12)
// if(hasMore){
// value2 = uni.upx2px(cardHeight) + uni.upx2px(12)
// }
const isGreater = value1 > value2;
if(isGreater){
height.value = value2
}else{
height.value = value1
}
// console.error(windowHeight)
// console.log("最大高"+value1)
// console.log("内容高"+value2)
// console.error(height.value)
};
</script>
<style lang="scss" scoped>
.goodsItem-container {
width: 100%;
height: 100%;
overflow: hidden;
}
.cardItem {
width: calc(50% - 8rpx);
margin-right: 16rpx;
&:nth-child(2n) {
margin-right: 0;
}
}
</style>
+89
View File
@@ -0,0 +1,89 @@
<template>
<custom-waterfalls-flow-vue3-2
:value="props.goods"
:column="props.column"
:columnSpace="3"
imageKey="picUrl"
v-if="props.goods.length"
>
<!-- #ifdef MP-WEIXIN -->
<view v-for="(v, i) in props.goods" :key="i" :slot="`slot${i}`">
<card_goods :data="v"></card_goods>
</view>
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
<template v-slot:default="item">
<card_goods :data="item"></card_goods>
</template>
<!-- #endif -->
</custom-waterfalls-flow-vue3-2>
</template>
<script setup>
import { ref, watch } from 'vue';
import useMescroll from '@/uni_modules/mescroll-uni/hooks/useMescroll.js';
import SpuApi from '@/sheep/api/product/spu';
import card_goods from './card_goods.vue'
const props = defineProps({
goods: {
type: Array,
required: true,
default() {
return [];
},
},
column: {
type: Number,
default() {
return 1;
},
},
});
</script>
<style lang="scss" scoped>
.goodItem{
background-color: #fff;
padding: 20rpx 26rpx;
box-sizing: border-box;
margin-bottom: 32rpx;
.title{
font-size: 24rpx;
line-height: 30rpx;
color: #333333;
font-weight: 500;
}
.label{
font-size: 20rpx;
color: #ff5040;
border: 1px solid #ff5040;
border-radius: 8rpx;
height: 34rpx;
line-height: 34rpx;
padding: 0 8rpx;
box-sizing: border-box;
margin-top: 10rpx;
margin-bottom: 12rpx;
}
.num{
color: #777777;
font-size: 20rpx;
}
.price{
color: #EE0A24;
font-size: 24rpx;
}
.priceNum{
font-size: 34rpx;
}
.shopIcon{
width: 48rpx;
height: 48rpx;
image{
width: 100%;
height: 100%;
}
}
}
</style>
+132
View File
@@ -0,0 +1,132 @@
<template>
<view>
<view class="maoScroll-main" :style="`height:${(lineHeight + props.mt) * showLine}rpx;`">
<view :style="`margin-top:-${marginTop}rpx;`">
<view
v-for="(item, index) in showdata"
:key="`maoScroll${index}`"
:style="`height:${lineHeight}rpx;margin-top:${props.mt}rpx;`"
>
<slot :line="item" />
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref, watch, onMounted, onUnmounted, defineProps } from 'vue';
const props = defineProps({
data: {
type: Array,
default: () => [],
},
showNum: {
type: Number,
default: 3,
},
lineHeight: {
type: Number,
default: 60,
},
animationScroll: {
type: Number,
default: 500,
},
animation: {
type: Number,
default: 2000,
},
mt: {
type: Number,
default:16
}
});
const showdata = ref([]);
const marginTop = ref(0);
const showLine = ref(0);
let animationInterval = null;
let stepInterval = null;
// 初始化函数
const init = () => {
// 清除之前的定时器,避免内存泄漏
if (animationInterval) {
clearInterval(animationInterval);
}
if (stepInterval) {
clearInterval(stepInterval);
}
showLine.value = props.showNum < props.data.length ? props.showNum : props.data.length;
showdata.value = [];
// 填充数据
for (let i = 0; i < props.data.length; i++) {
showdata.value.push(props.data[i]);
}
for (let i = 0; i < showLine.value; i++) {
showdata.value.push(props.data[i]);
}
// 启动定时器
animationInterval = setInterval(animationFunc, props.animation);
};
// 动画函数
const animationFunc = () => {
if (marginTop.value >= props.data.length * props.lineHeight) {
marginTop.value = 0;
}
const stepTime = props.animationScroll / props.lineHeight;
let step = 0;
// 清除之前可能存在的步进定时器
if (stepInterval) {
clearInterval(stepInterval);
}
stepInterval = setInterval(() => {
marginTop.value++;
step++;
if (step >= props.lineHeight) {
clearInterval(stepInterval);
stepInterval = null;
}
}, stepTime);
};
// 监听数据变化
watch(
() => props.data,
() => {
init();
},
{ deep: true },
);
// 组件挂载时初始化
onMounted(() => {
init();
});
// 组件卸载时清理定时器
onUnmounted(() => {
if (animationInterval) {
clearInterval(animationInterval);
}
if (stepInterval) {
clearInterval(stepInterval);
}
});
</script>
<style>
.maoScroll-main {
width: 100%;
overflow: hidden;
}
</style>
+83
View File
@@ -0,0 +1,83 @@
<template>
<view>
<view class="maoScroll-main" :style="'height:'+(lineHeight*showLine)+'rpx;'">
<view :style="'margin-top:-'+marginTop+'rpx;'">
<view v-for="(item,index) in showdata" :key="'maoScroll'+index" :style="'height:'+lineHeight+'rpx;'">
<slot :line="item" />
</view>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'maoScroll',
data() {
return {
showdata: [],
marginTop: 0,
showLine: 0,
}
},
props:{
data: {
type: Array,
default: []
},
showNum: {
type: Number,
default: 3,
},
lineHeight: {
type: Number,
default: 60,
},
animationScroll: {
type: Number,
default: 500,
},
animation: {
type: Number,
default: 2000,
}
},
methods: {
init: function(){
this.showLine = this.showNum < this.data.length ? this.showNum : this.data.length;
for(let i = 0; i < this.data.length; i++){
this.showdata.push(this.data[i]);
}
for(let i = 0; i < this.showLine; i++){
this.showdata.push(this.data[i]);
}
setInterval(this.animationFunc, this.animation);
},
animationFunc: function(){
if(this.marginTop >= this.data.length*this.lineHeight){
this.marginTop = 0;
}
let stepTime = this.animationScroll/this.lineHeight;
var step = 0;
let self = this;
var index = setInterval(function(){
self.marginTop = self.marginTop + 1;
step++;
if (step >= self.lineHeight) {
clearInterval(index);
}
}, stepTime);
}
},
watch: {
data(outdata, newdata) {
this.init();
}
}
}
</script>
<style>
.maoScroll-main{width: 100%;overflow: hidden;}
</style>
+163
View File
@@ -0,0 +1,163 @@
<template>
<view class="order_con" :class="{ bg24: props.theme == 2 }">
<view class="flex-center ju-between m-b-28"
v-if="(props.type == 2 || props.type == 4) && props.data.logisticsNo">
<view>{{ props.data.logisticsName }} {{ props.data.logisticsNo }}</view>
<view class="flex-center">
<view @click.stop="onCopy(props.data.logisticsNo)">复制</view>
<truckLine :data="props.data" :code="2" v-if="props.data.deliveryTime && props.data.logisticsNo"></truckLine>
</view>
</view>
<view class="con_item flex-center ju-between" v-for="(v, i) in props.data.items" :key="i"
:class="{ 'al-flex-start': props.type == 3 || props.type == 4 }">
<view class="order_img shrink" :class="{ 'm-r-16': props.type == 3 }">
<image :src="`${v.picUrl}`" mode="aspectFill" />
</view>
<view class="flex1">
<view class="flex-row ju-between m-b-6">
<view class="size28 spuName lineTwo" :class="{ 'p-r-10': props.type == 3, c0: props.theme == 2 }">
{{ v.spuName }}
</view>
<view class="shrink price" v-if="props.type != 4"><span class="size24">¥</span><span class="size36"
style="font-weight: 600">{{ fen2yuan(v.price) }}</span></view>
</view>
<view v-if="props.type == 4">
<view class="m-b-12 size24 h_52" v-for="(item, i) in v.items" :key="i">
<view class="flex1 flex-center ju-between h_52 bg18 radius8 p-l-8 p-r-16">
<view class="lineOne c19">
{{item?.properties.length > 1? item?.properties.reduce((items2, items) => items2.valueName + ' ' + items.valueName,): item?.properties[0].valueName}}
</view>
<view class="flex-center">
<view class="c19">x{{ item.count }}</view>
<view class=" size28 m-l-12 weight900">¥<span class="">{{ fen2yuan(item.price) }}</span>
</view>
</view>
</view>
<view class="c13 size28 weight900">
¥<span class="size40">{{ fen2yuan(item.payPrice) }}</span>
</view>
</view>
</view>
<view class="flex-row ju-between" :class="{ 'm-t-8': props.type == 3 }" v-else>
<view class="valueName size28" :class="{ c19: props.theme == 2 }">{{
v.properties.map((property) => property.valueName).join(' ')
}}</view>
<view class="shrink size28 c_333" :class="{ c0: props.theme == 2 }">{{
`x${v.count}`
}}</view>
</view>
<view class="btn flex-row ju-flex-end" v-if="props.type == 2">
<button class="ss-reset-button btnItem btnItem1"
v-if="[10, 20].includes(props.data.status) && v.afterSaleStatus === 0" @tap.stop="
sheep.$router.go('/pages/order/aftersale/apply', {
orderId: props.data.id,
itemId: v.id,
})
">
申请售后
</button>
<view class="btnItem btnItem1" v-if="v.afterSaleStatus === 10" @click="cancelAfterSale(v)">
取消售后
</view>
<view class="btnItem" v-if="v.afterSaleStatus === 20"> 售后成功 </view>
</view>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, reactive, getCurrentInstance, defineProps } from 'vue';
import { fen2yuan } from '@/sheep/hooks/useGoods';
import AfterSaleApi from '@/sheep/api/trade/afterSale';
import sheep from '@/sheep';
const { proxy } = getCurrentInstance() as any;
let emit = defineEmits(['getOrderDetail']);
const props = defineProps({
data: {
type: Object,
default() {
return {};
},
},
type: {
type: String,
default: '0', //0列表2订单详情 3订单列表 4ai订单详情
},
theme: {
type: String,
default: '2', //1浅色 2深色
},
});
const cancelAfterSale = (v) => {
uni.showModal({
title: '提示',
content: '确定要取消此申请吗?',
confirmColor: '#FA7E31',
success: async function (res) {
if (!res.confirm) {
return;
}
const { code } = await AfterSaleApi.cancelAfterSale(v.afterSaleId);
if (code === 0) {
getOrderDetail();
}
},
});
};
const getOrderDetail = () => {
emit('getOrderDetail');
};
const onCopy = (text) => {
sheep.$helper.copyText(text);
};
</script>
<style scoped lang="scss">
.order_con {
.con_item {
margin-bottom: 24rpx;
.order_img {
width: 160rpx;
height: 160rpx;
border-radius: 8rpx;
overflow: hidden;
margin-right: 12rpx;
image {
width: 100%;
height: 100%;
}
}
.spuName {
color: #333333;
}
.valueName {
color: #777777;
}
}
}
.price {
color: #ee0a24;
font-size: 24rpx;
}
.btnItem {
line-height: 50rpx;
padding: 0 20rpx;
box-sizing: border-box;
border-radius: 94px 94px 94px 94px;
margin-top: 12rpx;
font-size: 24rpx;
border: none;
}
.btnItem1 {
background: #F2F2F2;
}
</style>
+211
View File
@@ -0,0 +1,211 @@
<template>
<view class="card_order bg24 size34" @click="
utils.go('/pages/order/detail', { id: props.index != 5 ? props.data.id : props.data.orderId })
">
<view class="flex-center ju-between createTime">
<view class="flex-center shrink">
<view class="size28">订单编号: {{ props.data.no }}</view>
<view class="copy flex-center" @tap.stop="onCopy(props.data.no)" style="margin-left: 10px">
<image :src="`${$url}goods/copy2.svg`" mode="scaleToFill" />
</view>
</view>
<view class="stateText size28" style="margin-left: 10px" :class="formatOrderColor(props.data)"
v-if="props.index != 5">
{{ formatOrderStatus(props.data) }}
</view>
<view class="stateText size28" v-else>
{{ formatAfterSaleStatus(props.data) }}
</view>
</view>
<card_order :data="props.data" v-if="props.index != 5" type="3"></card_order>
<view v-else class="con_item flex-center ju-between al-flex-start">
<view class="order_img shrink">
<image :src="`${props.data.picUrl}`" mode="aspectFill" />
</view>
<view class="flex1 flex-column ju-between">
<view class="flex-row ju-between">
<view class="size28 spuName lineTwo c0">{{ props.data.spuName }}</view>
<view class="shrink price">
<span class="size24">¥</span><span class="size36"
style="font-weight: 600">{{ fen2yuan(props.data.refundPrice) }}</span>
</view>
</view>
<view class="flex-row ju-between m-t-10">
<view class="valueName size24">{{
props.data.properties.map((property) => property.valueName).join(' ')
}}</view>
<view class="shrink size24 c0">{{ `x${props.data.count}` }}</view>
</view>
<view class="btn flex-row ju-flex-end">
<button class="ss-reset-button btnItem btnItem1" @tap.stop="onApply"
v-if="statusChange(['10', '20', '30', '62', '63'], String(props.data.status))">取消售后</button>
<button class="ss-reset-button btnItem btnItem1" style="margin-left: 20rpx"
v-if="statusChange(['20'], String(props.data.status))" @tap.stop="
sheep.$router.go('/pages/order/aftersale/return-delivery', { id: props.data.id })
">
填写物流信息
</button>
</view>
</view>
</view>
<view class="flex-row ju-flex-end" v-if="props.index != 5">
<view class="flex-center size24">{{ `共${props.data.productCount}件商品 合计: `
}}
<!-- <view class="price">¥{{ fen2yuan(props.data.payPrice) }}</view> -->
<view class="shrink price"><span class="size24">¥</span><span class="size36"
style="font-weight: 600;">{{ fen2yuan(props.data.payPrice) }}</span></view>
</view>
</view>
<view class="" style="margin-top: 32rpx" v-if="props.index != 5">
<card_orderBan :data="props.data" @downData="downData"></card_orderBan>
</view>
</view>
</template>
<script setup lang="ts">
import {
ref,
reactive,
onMounted,
onUnmounted,
getCurrentInstance,
watch,
nextTick,
defineProps,
defineEmits,
} from 'vue';
import {
fen2yuan,
formatOrderColor,
formatOrderStatus,
handleOrderButtons,
formatAfterSaleStatus,
} from '@/sheep/hooks/useGoods';
import card_order from './card_order.vue';
import card_orderBan from '@/components/card_orderBan/card_orderBan.vue';
import AfterSaleApi from '@/sheep/api/trade/afterSale';
import sheep from '@/sheep/index';
let emit = defineEmits(['downData']);
let { proxy } = getCurrentInstance();
let props = defineProps({
data: {
type: Object,
default() {
return {};
},
},
index: {
type: Number,
default: 0,
},
});
let data = reactive({});
watch(
() => props.data,
(val) => {
data = val;
},
{
deep: true,
immediate: true,
},
);
const downData = () => {
emit('downData');
};
// 复制
const onCopy = (no) => {
proxy.$sheep.$helper.copyText(no);
};
const onApply = () => {
uni.showModal({
title: '提示',
content: '确定要取消此申请吗?',
confirmColor: '#FA7E31',
success: async function (res) {
if (!res.confirm) {
return;
}
const { code } = await AfterSaleApi.cancelAfterSale(props.data.id);
if (code === 0) {
emit('downData');
}
},
});
};
const statusChange = (arr, status) => {
return arr.indexOf(status) != -1;
};
</script>
<style lang="scss" scoped>
.card_order {
padding: 24rpx;
box-sizing: border-box;
border-radius: 8rpx;
}
.stateText {}
.createTime {
margin-bottom: 32rpx;
}
.price {
color: #ee0a24;
font-size: 24rpx;
}
.copy {
width: 24rpx;
height: 24rpx;
margin-left: 14rpx;
image {
width: 100%;
height: 100%;
}
}
.con_item {
margin-bottom: 24rpx;
.order_img {
width: 160rpx;
height: 160rpx;
border-radius: 8rpx;
overflow: hidden;
margin-right: 12rpx;
image {
width: 100%;
height: 100%;
}
}
.spuName {
color: #323232;
}
.valueName {
color: #777777;
}
}
.price {
color: #ee0a24;
font-size: 24rpx;
}
.btnItem {
line-height: 50rpx;
padding: 0 20rpx;
box-sizing: border-box;
border-radius: 94px 94px 94px 94px;
margin-top: 12rpx;
font-size: 24rpx;
border: none;
}
.btnItem1 {
background: #F2F2F2;
}
</style>
@@ -0,0 +1,625 @@
<template>
<view class="page_right flex-column" :class="{ search: props.source == 'search' }">
<view class="screen flex-center ju-evenly">
<view v-for="(v, i) in dataObj.screenNav" :key="i" class="screenItem flex-center"
:class="{ activeItem: v.status }" @click="screenChange(i)">
<view class="">{{ v.name }}</view>
<view class="c_icon flex-column" v-if="i != 2">
<image class="icon_up" :src="`/static/icon/screenUp${v.status == 1 ? 1 : 0}.svg`"
mode="scaleToFill" />
<image class="icon_down" :src="`/static/icon/screenDown${v.status == 2 ? 1 : 0}.svg`"
mode="scaleToFill" />
</view>
<view class="c_icon flex-column" v-else>
<image v-if="v.status == 1" class="icon_up" :src="`/static/icon/screenUp1.svg`"
mode="scaleToFill" />
<image v-if="v.status == 2 || !v.status" class="icon_down" :src="`/static/icon/screenDown0.svg`" />
</view>
</view>
</view>
<view class="goods w100 flex1">
<mescroll-uni @init="mescrollInit" @down="downCallback" :up="upOption" @up="upCallback"
:height="props.height">
<view v-for="(v, i) in props.dataList" :key="i" class="goodsItem">
<card_goods :data="v" :type="props.type"></card_goods>
</view>
</mescroll-uni>
</view>
<!-- 筛选条件 -->
<su-popup :show="show" round="10" @close="close">
<view class="screen_popup flex-column ju-between">
<view class="screen_title center">
<view class="size32 f500 c34">全部筛选</view>
<uni-icons class="colse" type="closeempty" color="#333333" size="20" @click="close" />
</view>
<view class="screen_content flex-row flex1">
<view class="screen_left">
<view v-for="(v, i) in screenNav" :key="i" @click="screenNavChange(i, v.id)"
class="screen_nav_item center" :class="{ activeItem: screenIndex == i }">
{{ v.name }}
</view>
</view>
<view class="screen_right flex1" ref="rightRef">
<scroll-view scroll-y="true" style="height: 50vh;" :scroll-into-view="scrollIntoView"
:scroll-with-animation="true">
<view :id="'item' + i" v-for="(v, i) in screenNav" :key="i" class="screen_right_item"
:ref="(ref) => (itemRefs[i] = ref)">
<view>
<view class="screen_title">{{ v.title }}</view>
<view class="screen_data flex-row wrap">
<view v-for="(item, index) in v.data" :key="index"
class="screen_iteem flex-center" @click="screenItemClick(i, index, item)"
:class="{
screen_activeItem: v.ids.includes(item.id),
screen_none: index >= v.colMax - 1 && !v.more,
screen_iteem1: v.col == 2,
screen_iteem2: v.col == 3,
}">
<view class="size28 flex-center lineTwo center">{{ item.name }}</view>
</view>
<view class="screen_moreIteem center flex-center"
v-if="v.data.length >= v.colMax - 1 && !v.more && v.name != '价格区间'"
@click="v.more = true">
<view class="moreText size28">更多</view>
<view class="down"></view>
</view>
<view class="flex-center priceBox ju-between" v-if="v.name == '价格区间'">
<input class="flex1" type="number" placeholder="自定最低价"
placeholder-style="text-align: center;color: #5a6981;font-size: 28rpx;"
v-model="v.arr.minValue" />
<text class="">-</text>
<input class="flex1" type="number" placeholder="自定最高价"
placeholder-style="text-align: center;color: #5a6981;font-size: 28rpx;"
v-model="v.arr.maxValue" />
</view>
</view>
</view>
</view>
</scroll-view>
</view>
</view>
<view class="screen_btns flex-center ju-between">
<view class="screen_clear screen_btn size32 center" @click="screenClear">清空选择</view>
<view class="screen_confirm screen_btn center size32" @click="screenConfirm">确认</view>
</view>
</view>
</su-popup>
</view>
</template>
<script setup>
import SpuApi from '@/sheep/api/product/spu';
import * as api from '@/sheep/api/index/index.js';
import {
getCurrentInstance,
defineProps,
reactive,
ref,
watch,
nextTick
} from 'vue';
import {
onPageScroll,
onReachBottom
} from '@dcloudio/uni-app';
import useMescroll from '@/uni_modules/mescroll-uni/hooks/useMescroll.js';
import card_goods from '@/components/goodsItem/card_goods.vue';
import {
onLoad
} from '@dcloudio/uni-app';
const {
mescrollInit,
downCallback,
getMescroll
} = useMescroll(onPageScroll, onReachBottom); // 调用mescroll的hook
const {
proxy
} = getCurrentInstance();
const props = defineProps({
dataList: {
type: Array,
default: () => [],
},
subclassification: {
type: Array,
default: () => [],
},
height: {
type: String,
default: '50%',
},
source: {
type: String,
default: '',
},
type: {
type: Number,
default: 2,
},
});
const dataObj = reactive({
screenNav: [{
name: '销量',
status: 0,
},
{
name: '价格',
status: 0,
},
{
name: '筛选',
status: 0,
},
],
});
const upOption = {
noMoreSize: 4,
empty: {
tip: '~ 无数据 ~', // 提示
},
};
const changeData = () => {
const mescroll = getMescroll();
if (mescroll) {
mescroll.resetUpScroll();
}
};
let dataParams = ref({});
let screenObj = ref({});
const upCallback = async (mescroll) => {
let params = {
...dataParams.value,
...screenObj.value,
};
proxy.$emit('getData', {
...mescroll,
params,
});
};
const screenChange = (i) => {
let obj = {
sortAsc: true,
sortField: 'salesCount', //salesCount销量 price价格
};
if (i == 0) {
dataObj.screenNav[1].status = 0;
}
if (i == 1) {
dataObj.screenNav[0].status = 0;
}
switch (dataObj.screenNav[i].status) {
case 0:
dataObj.screenNav[i].status = 1;
obj.sortAsc = true;
break;
case 1:
if (i != 2) {
dataObj.screenNav[i].status = 2;
} else {
dataObj.screenNav[i].status = 0;
}
obj.sortAsc = false;
break;
case 2:
dataObj.screenNav[i].status = 1;
break;
}
if (i != 2) {
if (i == 1) {
obj.sortField = 'price';
}
dataParams.value = obj;
changeData();
} else {
show.value = true;
}
};
// 请求结果
const requestResult = (result = true, num = 0) => {
const mescroll = getMescroll();
if (result) {
mescroll.endSuccess(num);
} else {
mescroll.endErr();
}
};
let show = ref(false);
const close = () => {
show.value = false;
dataObj.screenNav[2].status = 0;
};
let screenNav = ref([{
id: 1,
name: '价格区间',
title: '价格区间(元)',
data: [],
ids: [],
arr: {},
multi: false, //是否多选
col: 2,
colMax: 5,
more: false,
},
{
id: 2,
name: '分类',
title: '分类',
data: [],
ids: [],
multi: false,
col: 3,
colMax: 6,
more: false,
},
{
id: 3,
name: '品牌',
title: '品牌',
data: [],
ids: [],
multi: true,
col: 3,
colMax: 6,
more: false,
},
{
id: 4,
name: '优惠',
title: '优惠',
data: [],
ids: [],
multi: true,
col: 3,
colMax: 6,
more: false,
},
]);
let rightRef = ref(null);
let staticHeight = ref(0);
let screenIndex = ref(0);
let itemRefs = ref(screenNav.value.map(() => ref(null)));
let scrollIntoView = ref("")
const screenNavChange = (i, id) => {
screenIndex.value = i;
scrollIntoView.value = 'item' + i;
};
const screenItemClick = (i, index, item) => {
let ids = screenNav.value[i].ids;
let multi = screenNav.value[i].multi;
if (ids.indexOf(item.id) == -1) {
console.log(multi);
if (!multi) {
ids = [];
}
ids.push(item.id);
} else {
ids.splice(ids.indexOf(item.id), 1);
}
screenNav.value[i].ids = ids;
};
const screenClear = () => {
screenNav.value.forEach((e) => {
e.ids = [];
e.arr = {};
});
dataParams.value = {};
changeData();
};
const priceData = (arr, id) => {
return arr.find((item) => item.id === id) || {};
};
const screenConfirm = () => {
let obj = screenNav.value[0];
dataParams.value = {
categoryIds: screenNav.value[1].ids.join(','),
brandIds: screenNav.value[2].ids.join(','),
tagTypeId: screenNav.value[3].ids.join(','),
categoryId: '',
minValue: obj.arr.minValue || obj.arr.minValue == 0 || priceData(obj.data, obj.ids[0]).minValue,
maxValue: obj.arr.maxValue || obj.arr.maxValue == 0 || priceData(obj.data, obj.ids[0]).maxValue,
minPrice: obj.arr.minValue || obj.arr.minValue == 0 || priceData(obj.data, obj.ids[0]).minValue,
maxPrice: obj.arr.maxValue || obj.arr.maxValue == 0 || priceData(obj.data, obj.ids[0]).maxValue,
};
changeData();
close();
};
watch(
() => props.subclassification,
(val) => {
screenNav.value.forEach((e) => {
if (e.name == '分类') {
e.data = props.subclassification;
}
});
}, {
immediate: true,
deep: true,
},
);
let getbrandlist = () => {
api.getbrandlist().then((res) => {
if (res.code != 0) return;
screenNav.value.forEach((e) => {
if (e.name == '品牌') {
e.data = res.data;
}
});
});
};
const getproducttaglist = () => {
api.getproducttaglist({
categoryId: 2
}).then((res) => {
if (res.code != 0) return;
screenNav.value.forEach((e) => {
if (e.name == '优惠') {
e.data = res.data;
}
});
});
};
const getpricerangelist = () => {
api.getpricerangelist().then((res) => {
if (res.code != 0) return;
screenNav.value.forEach((e) => {
if (e.name == '价格区间') {
e.data = res.data;
}
});
});
};
onLoad(() => {
getbrandlist();
getproducttaglist();
// 获取价格
getpricerangelist();
});
const clearAll = () => {
screenNav.value.forEach((e) => {
e.ids = [];
e.arr = {};
e.more = false;
});
dataParams.value = {};
screenObj.value = {};
dataObj.screenNav.forEach((e) => {
e.status = 0;
});
changeData();
};
defineExpose({
changeData,
requestResult,
clearAll,
});
</script>
<style scoped lang="scss">
.page_right {
height: 100%;
background-color: #fff;
// overflow-y: auto;
.screen {
width: 100%;
height: 96rpx;
}
.goods {
// height: calc(100% - 96rpx);
height: calc(100%);
overflow-y: auto;
}
.screenItem {
color: #323233;
font-size: 28rpx;
}
.activeItem {
color: #fa9c31;
}
.icon_up,
.icon_down {
width: 16rpx;
height: 8rpx;
margin-left: 10rpx;
}
.icon_up {
margin-bottom: 4rpx;
}
.icon_down {}
}
.goodsItem {
padding: 0 20rpx;
box-sizing: border-box;
}
.goodsImg {
width: 200rpx;
height: 200rpx;
border-radius: 10rpx;
overflow: hidden;
image {
width: 100%;
height: 100%;
}
}
.screen_popup {
padding-top: 46rpx;
/* #ifdef H5 */
padding-bottom: 100rpx;
/* #endif */
box-sizing: border-box;
position: relative;
z-index: 1000;
.screen_title {
box-sizing: border-box;
// margin-bottom: 58rpx;
}
.colse {
position: absolute;
top: 42rpx;
right: 22rpx;
}
.screen_content {
.screen_left {
min-height: 100%;
overflow-y: auto;
background-color: #F3F6F8;
;
.screen_nav_item {
width: 162rpx;
line-height: 86rpx;
}
.activeItem {
color: #FA7E31;
background-color: #F3F6F8;
;
}
}
.screen_right {
padding: 0 18rpx;
box-sizing: border-box;
overflow-y: auto;
.screen_right_item {
margin-bottom: 34rpx;
.screen_title {
margin-bottom: 8rpx;
line-height: 70rpx;
}
.screen_iteem {
line-height: 40rpx;
height: 114rpx;
background-color: #F2F5F7;
margin-bottom: 10rpx;
border-radius: 12rpx;
padding: 16rpx 10rpx;
box-sizing: border-box;
}
.screen_iteem1 {
width: calc((100% - 6rpx) / 2);
margin-right: 6rpx;
&:nth-child(2n) {
margin-right: 0;
}
}
.screen_iteem2 {
&:nth-child(3n) {
// margin-right: 0;
}
width: calc((100% - 12rpx) / 2);
margin-right: 6rpx;
}
.screen_moreIteem {
color: #121212;
width: calc((100% - 12rpx) / 2);
margin-bottom: 10rpx;
line-height: 84rpx;
}
.moreText {
// color: #ffffff;
}
.down {
width: 0rpx;
height: 0;
border-left: 9rpx solid transparent;
border-right: 9rpx solid transparent;
border-top: 12rpx solid #666666;
margin-left: 6rpx;
}
.screen_activeItem {
background-color: #FFEFE5;
color: #FA7E31;
}
.screen_none {
display: none;
}
}
}
}
.screen_btns {
padding: 44rpx 18rpx;
box-sizing: border-box;
.screen_btn {
width: calc(100% - 54rpx);
height: 82rpx;
border-radius: 12rpx;
background-color: #FFEFE5;
color: #FA7E31;
line-height: 82rpx;
margin-right: 18rpx;
}
.screen_clear {}
.screen_confirm {
background: linear-gradient(270deg, #F7772E 0%, #EE0A24 99%);
color: #ffffff;
}
}
}
.priceBox {
height: 84rpx;
border-radius: 12rpx;
background-color: #F2F5F7;
padding: 0 40rpx;
box-sizing: border-box;
input {
width: 30%;
}
.pricePlace {
text-align: center;
color: #333333;
font-size: 24rpx;
}
}
.search {
.screen {
justify-content: space-between;
padding: 0 58rpx;
box-sizing: border-box;
}
.goodsItem {
padding: 0 32rpx;
}
}
</style>
+76
View File
@@ -0,0 +1,76 @@
<template>
<view>
<view class="w_32 h_32 m-l-14" @click.stop="logistics">
<image class="w100 h100" src="/static/truck-line.svg" mode="scaleToFill" />
</view>
<su-popup :show="show" round="10" @close="close">
<view class="steps">
<view class="colse flex-center ju-flex-end"
><uni-icons class="m-r-50" type="closeempty" color="#333333" size="20" @click="close" />
</view>
<uni-steps :options="list" active-color="#007AFF" :active="0" direction="column" />
</view>
</su-popup>
</view>
</template>
<script setup>
import { ref, onMounted, watch } from 'vue';
import { getExpressTrackList } from '@/sheep/api/index/index';
let props = defineProps({
data: {
type: Object,
default: () => {},
},
code: {
type: Number,
default: 1, //1:商城订单 2:AI店铺订单 3:AI店铺赠送订单
}
});
let show = ref(false);
let list = ref([]);
const logistics = () => {
// 获取物流信息并显示弹窗
getData();
show.value = true;
};
const close = () => {
show.value = false;
};
const getData = async () => {
console.log(props.data);
let { data, code } = await getExpressTrackList({
id: props.data.id,
code: props.code,
});
if (code !== 0) return;
list.value = [];
data.forEach((item) => {
let obj = {
title: item.content,
desc: item.time,
};
list.value.push(obj);
});
};
</script>
<style scoped lang="scss">
.steps {
height: 100vh;
overflow-y: auto;
min-height: 500rpx;
padding: 30rpx;
padding-left: 15rpx;
padding-top: 60rpx;
box-sizing: border-box;
position: relative;
}
.colse {
position: fixed;
top: 0rpx;
width: 100%;
height: 70rpx;
background-color: #fff;
z-index: 999;
}
</style>
+21
View File
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
<title>优购商城</title>
<!--preload-links-->
<!--app-context-->
</head>
<body>
<div id="app"><!--app-html--></div>
<script type="module" src="/main.js">
</script>
<!-- <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
<script>
const vConsole = new window.VConsole();
</script> -->
</body>
</html>
+9
View File
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"jsx": "preserve",
"baseUrl": ".",
"paths": {
"@/*": ["./*"]
}
}
}
+35
View File
@@ -0,0 +1,35 @@
import App from './App';
import {
createSSRApp,
getCurrentInstance
} from 'vue';
import {
setupPinia
} from './sheep/store';
import * as utils from './utils/index'
import sheep from '@/sheep';
import {
fen2yuan
} from '@/sheep/hooks/useGoods';
import {
debounce
} from '@/utils/common'
export function createApp() {
const app = createSSRApp(App);
setupPinia(app);
app.config.globalProperties.$url = 'https://sycbuck.oss-cn-hangzhou.aliyuncs.com/app/'
app.config.globalProperties.$ygUrl = 'https://swzhyg.oss-cn-hangzhou.aliyuncs.com/static/'
app.config.globalProperties.utils = utils;
app.config.globalProperties.$sheep = sheep;
app.config.globalProperties.$fen2yuan = fen2yuan;
app.config.globalProperties.$debounce = debounce;
app.config.globalProperties.$proxy = getCurrentInstance();
return {
app,
};
}
+145
View File
@@ -0,0 +1,145 @@
{
"name" : "优购商城",
"appid" : "__UNI__8B19741",
"description" : "",
"versionName" : "1.3.2",
"versionCode" : 132,
"transformPx" : false,
"app-plus" : {
"privacy" : {
"prompt" : "none"
},
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
"modules" : {
"Camera" : {},
"Payment" : {},
"OAuth" : {},
"Share" : {}
},
"distribute" : {
"android" : {
"schemes" : [ "weixin" ],
"permissions" : [
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-permission android:name=\"android.permission.INTERNET\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.REQUEST_INSTALL_PACKAGES\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>"
],
"abiFilters" : [ "arm64-v8a", "x86" ],
"minSdkVersion" : 21
},
"ios" : {
"privacyDescription" : {
"NSPhotoLibraryUsageDescription" : "需要同意访问您的相册选取图片才能完善该条目",
"NSPhotoLibraryAddUsageDescription" : ""
},
"dSYMs" : false
},
"sdkConfigs" : {
"payment" : {
"alipay" : {
"__platform__" : [ "ios", "android" ]
},
"weixin" : {
"__platform__" : [ "ios", "android" ],
"appid" : "wx23b0c321b5d74d63",
"UniversalLinks" : ""
}
},
"oauth" : {
"weixin" : {
"appid" : "wx23b0c321b5d74d63",
"UniversalLinks" : ""
}
},
"share" : {
"weixin" : {
"appid" : "wx23b0c321b5d74d63",
"UniversalLinks" : ""
}
}
},
"icons" : {
"android" : {
"hdpi" : "unpackage/res/icons/72x72.png",
"xhdpi" : "unpackage/res/icons/96x96.png",
"xxhdpi" : "unpackage/res/icons/144x144.png",
"xxxhdpi" : "unpackage/res/icons/192x192.png"
},
"ios" : {
"appstore" : "unpackage/res/icons/1024x1024.png",
"ipad" : {
"app" : "unpackage/res/icons/76x76.png",
"app@2x" : "unpackage/res/icons/152x152.png",
"notification" : "unpackage/res/icons/20x20.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"proapp@2x" : "unpackage/res/icons/167x167.png",
"settings" : "unpackage/res/icons/29x29.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"spotlight" : "unpackage/res/icons/40x40.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png"
},
"iphone" : {
"app@2x" : "unpackage/res/icons/120x120.png",
"app@3x" : "unpackage/res/icons/180x180.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"notification@3x" : "unpackage/res/icons/60x60.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"settings@3x" : "unpackage/res/icons/87x87.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png",
"spotlight@3x" : "unpackage/res/icons/120x120.png"
}
}
},
"splashscreen" : {
"androidStyle" : "default",
"useOriginalMsgbox" : true
}
}
},
"quickapp" : {},
"mp-weixin" : {
"appid" : "wx23b0c321b5d74d63",
"setting" : {
"urlCheck" : true,
"postcss" : true,
"minified" : true,
"es6" : true
},
"usingComponents" : true,
"permission" : {}
},
"mp-alipay" : {
"usingComponents" : true
},
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao" : {
"usingComponents" : true
},
"uniStatistics" : {
"enable" : false
},
"vueVersion" : "3",
"h5" : {
"router" : {
"base" : "/apph5/"
}
}
}
+108
View File
@@ -0,0 +1,108 @@
{
"id": "shopro",
"name": "shopro",
"displayName": "数维智合",
"version": "2025.09",
"description": "数维智合,一套代码,同时发行到iOS、Android、H5、微信小程序多个平台,请使用手机扫码快速体验强大功能",
"scripts": {
"prettier": "prettier --write \"{pages,sheep}/**/*.{js,json,tsx,css,less,scss,vue,html,md}\""
},
"repository": "https://github.com/sheepjs/shop.git",
"keywords": [
"商城",
"B2C",
"商城模板"
],
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/sheepjs/shop/issues"
},
"homepage": "https://github.com/dcloudio/hello-uniapp#readme",
"dcloudext": {
"category": [
"前端页面模板",
"uni-app前端项目模板"
],
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "u",
"aliyun": "u"
},
"client": {
"App": {
"app-vue": "y",
"app-nvue": "u"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
},
"Vue": {
"vue2": "u",
"vue3": "y"
}
}
}
},
"dependencies": {
"dayjs": "^1.11.18",
"echarts": "^6.0.0",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"luch-request": "^3.0.8",
"pinia": "2.0.23",
"pinia-plugin-persist-uni": "1.2.0",
"qrcode": "^1.5.4",
"tslib": "^2.8.1",
"weixin-js-sdk": "^1.6.0",
"zrender": "^6.0.0",
"uqrcodejs": "^4.0.7"
},
"devDependencies": {
"prettier": "^2.8.7",
"vconsole": "^3.15.0"
}
}
+975
View File
@@ -0,0 +1,975 @@
{
"easycom": {
"autoscan": true,
"custom": {
"^s-(.*)": "@/sheep/components/s-$1/s-$1.vue",
"^su-(.*)": "@/sheep/ui/su-$1/su-$1.vue"
}
},
"pages": [{
"path": "pages/index/startPage",
"aliasPath": "/",
"style": {
"navigationBarTitleText": "启动页",
"enablePullDownRefresh": false
},
"meta": {
"auth": false,
"sync": true,
"title": "启动页",
"group": "通用"
}
},
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "首页",
"enablePullDownRefresh": false
},
"meta": {
"sync": true,
"title": "首页",
"group": "商城"
}
},
{
"path": "pages/index/user",
"style": {
"navigationBarTitleText": "个人中心"
},
"meta": {
"sync": true,
"title": "个人中心",
"group": "商城"
}
},
{
"path": "pages/index/category",
"style": {
"navigationBarTitleText": "商品分类"
},
"meta": {
"sync": true,
"title": "商品分类",
"group": "商城"
}
},
{
"path": "pages/index/cart",
"style": {
"navigationBarTitleText": "购物车",
"navigationStyle": "custom"
},
"meta": {
"sync": true,
"title": "购物车",
"group": "商城"
}
},
{
"path": "pages/cart/cart",
"style": {
"navigationBarTitleText": "购物车",
"navigationStyle": "custom",
"enablePullDownRefresh": false
},
"meta": {
"sync": true,
"title": "购物车",
"group": "商城"
}
}
],
"subPackages": [
{
"root": "pages/goods",
"pages": [{
"path": "index",
"style": {
"navigationBarTitleText": "商品详情"
},
"meta": {
"sync": true,
"title": "普通商品",
"group": "商品"
}
},
{
"path": "groupon",
"style": {
"navigationBarTitleText": "拼团商品"
},
"meta": {
"sync": true,
"title": "拼团商品",
"group": "商品"
}
},
{
"path": "seckill",
"style": {
"navigationBarTitleText": "秒杀商品"
},
"meta": {
"sync": true,
"title": "秒杀商品",
"group": "商品"
}
},
{
"path": "point",
"style": {
"navigationBarTitleText": "积分商品"
},
"meta": {
"sync": true,
"title": "积分商品",
"group": "商品"
}
},
{
"path": "list",
"style": {
"navigationBarTitleText": "商品列表"
},
"meta": {
"sync": true,
"title": "商品列表",
"group": "商品"
}
},
{
"path": "comment/add",
"style": {
"navigationBarTitleText": "评价商品"
},
"meta": {
"auth": true
}
},
{
"path": "comment/list",
"style": {
"navigationBarTitleText": "商品评价"
}
},
{
"path": "info",
"style": {
"navigationBarTitleText": "商品详情",
"enablePullDownRefresh": false
}
}
]
},
{
"root": "pages/order",
"pages": [{
"path": "detail",
"style": {
"navigationBarTitleText": "订单详情"
},
"meta": {
"auth": true,
"title": "订单详情"
}
},
{
"path": "confirm",
"style": {
"navigationBarTitleText": "确认订单"
},
"meta": {
"auth": true,
"title": "确认订单"
}
},
{
"path": "list",
"style": {
"navigationBarTitleText": "我的订单"
},
"meta": {
"auth": true,
"sync": true,
"title": "用户订单",
"group": "订单中心"
}
},
{
"path": "aftersale/apply",
"style": {
"navigationBarTitleText": "申请售后"
},
"meta": {
"auth": true,
"title": "申请售后"
}
},
{
"path": "aftersale/return-delivery",
"style": {
"navigationBarTitleText": "退货物流"
},
"meta": {
"auth": true,
"title": "退货物流"
}
},
{
"path": "express/log",
"style": {
"navigationBarTitleText": "物流轨迹"
},
"meta": {
"auth": true,
"title": "物流轨迹"
}
}
]
},
{
"root": "pages/user",
"pages": [{
"path": "info",
"style": {
"navigationBarTitleText": "我的信息"
},
"meta": {
"auth": true,
"sync": true,
"title": "用户信息",
"group": "用户中心"
}
},
{
"path": "goods-collect",
"style": {
"navigationBarTitleText": "我的收藏"
},
"meta": {
"auth": true,
"sync": true,
"title": "商品收藏",
"group": "用户中心"
}
},
{
"path": "goods-log",
"style": {
"navigationBarTitleText": "我的足迹"
},
"meta": {
"auth": true,
"sync": true,
"title": "浏览记录",
"group": "用户中心"
}
},
{
"path": "address/list",
"style": {
"navigationBarTitleText": "收货地址"
},
"meta": {
"auth": true,
"sync": true,
"title": "地址管理",
"group": "用户中心"
}
},
{
"path": "goods_details_store/index",
"style": {
"navigationBarTitleText": "自提门店"
},
"meta": {
"auth": true,
"sync": true,
"title": "地址管理",
"group": "用户中心"
}
},
{
"path": "wallet/money",
"style": {
"navigationBarTitleText": "我的余额"
},
"meta": {
"auth": true,
"sync": true,
"title": "用户余额",
"group": "用户中心"
}
},
{
"path": "wallet/score",
"style": {
"navigationBarTitleText": "我的积分"
},
"meta": {
"auth": true,
"sync": true,
"title": "用户积分",
"group": "用户中心"
}
}
]
},
{
"root": "pages/commission",
"pages": [{
"path": "index",
"style": {
"navigationBarTitleText": "分销"
},
"meta": {
"auth": true,
"sync": true,
"title": "分销中心",
"group": "分销商城"
}
},
{
"path": "wallet",
"style": {
"navigationBarTitleText": "我的佣金"
},
"meta": {
"auth": true,
"sync": true,
"title": "用户佣金",
"group": "分销中心"
}
},
{
"path": "goods",
"style": {
"navigationBarTitleText": "推广商品"
},
"meta": {
"auth": true,
"sync": true,
"title": "推广商品",
"group": "分销商城"
}
},
{
"path": "order",
"style": {
"navigationBarTitleText": "分销订单"
},
"meta": {
"auth": true,
"sync": true,
"title": "分销订单",
"group": "分销商城"
}
},
{
"path": "team",
"style": {
"navigationBarTitleText": "我的团队"
},
"meta": {
"auth": true,
"sync": true,
"title": "我的团队",
"group": "分销商城"
}
},
{
"path": "promoter",
"style": {
"navigationBarTitleText": "推广人排行榜"
},
"meta": {
"auth": true,
"sync": true,
"title": "推广人排行榜",
"group": "分销商城"
}
},
{
"path": "commission-ranking",
"style": {
"navigationBarTitleText": "佣金排行榜"
},
"meta": {
"auth": true,
"sync": true,
"title": "佣金排行榜",
"group": "分销商城"
}
},
{
"path": "withdraw",
"style": {
"navigationBarTitleText": "申请提现"
},
"meta": {
"auth": true,
"sync": true,
"title": "申请提现",
"group": "分销商城"
}
}
]
},
{
"root": "pages/app",
"pages": [{
"path": "sign",
"style": {
"navigationBarTitleText": "签到中心"
},
"meta": {
"auth": true,
"sync": true,
"title": "签到中心",
"group": "应用"
}
}]
},
{
"root": "pages/public",
"pages": [{
"path": "setting",
"style": {
"navigationBarTitleText": "系统设置"
},
"meta": {
"sync": true,
"title": "系统设置",
"group": "通用"
}
},
{
"path": "richtext",
"style": {
"navigationBarTitleText": "富文本"
},
"meta": {
"sync": true,
"title": "富文本",
"group": "通用"
}
},
{
"path": "faq",
"style": {
"navigationBarTitleText": "常见问题"
},
"meta": {
"sync": true,
"title": "常见问题",
"group": "通用"
}
},
{
"path": "error",
"style": {
"navigationBarTitleText": "错误页面"
}
},
{
"path": "webview",
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "update",
"style": {
"navigationBarTitleText": "页面更新",
"enablePullDownRefresh": false
}
},
{
"path": "versions/versions",
"style": {
"navigationBarTitleText": "版本号",
"enablePullDownRefresh": false
}
},
{
"path": "realname",
"style": {
"navigationBarTitleText": "实名",
"enablePullDownRefresh": false
}
},
{
"path": "logoff",
"style": {
"navigationBarTitleText": "账号注销"
}
},
{
"path" : "test",
"style" :
{
"navigationBarTitleText" : "test"
}
},
{
"path": "login",
"style": {
"navigationBarTitleText": "登录"
}
},
{
"path": "search",
"style": {
"navigationBarTitleText": "搜索"
},
"meta": {
"sync": true,
"title": "搜索",
"group": "商城"
}
},
{
"path": "page",
"style": {
"navigationBarTitleText": ""
},
"meta": {
"auth": false,
"sync": true,
"title": "自定义页面",
"group": "商城"
}
},
{
"path": "huamao",
"style": {
"navigationBarTitleText": "华贸"
}
}
]
},
{
"root": "pages/coupon",
"pages": [{
"path": "list",
"style": {
"navigationBarTitleText": "领券中心"
},
"meta": {
"sync": true,
"title": "领券中心",
"group": "优惠券"
}
},
{
"path": "detail",
"style": {
"navigationBarTitleText": "优惠券"
},
"meta": {
"auth": false,
"sync": true,
"title": "优惠券详情",
"group": "优惠券"
}
}
]
},
{
"root": "pages/chat",
"pages": [{
"path": "index",
"style": {
"navigationBarTitleText": "客服",
"app-plus": {
"softinputMode": "adjustResize"
}
},
"meta": {
"auth": true,
"sync": true,
"title": "客服",
"group": "客服"
}
}]
},
{
"root": "pages/pay",
"pages": [{
"path": "index",
"style": {
"navigationBarTitleText": "收银台"
}
},
{
"path": "result",
"style": {
"navigationBarTitleText": "支付结果"
}
},
{
"path": "recharge",
"style": {
"navigationBarTitleText": "充值余额"
},
"meta": {
"auth": true,
"sync": true,
"title": "充值余额",
"group": "支付"
}
},
{
"path": "recharge-log",
"style": {
"navigationBarTitleText": "充值记录"
},
"meta": {
"auth": true,
"sync": true,
"title": "充值记录",
"group": "支付"
}
}
]
},
{
"root": "pages/activity",
"pages": [{
"path": "groupon/detail",
"style": {
"navigationBarTitleText": "拼团详情"
}
},
{
"path": "groupon/order",
"style": {
"navigationBarTitleText": "我的拼团",
"enablePullDownRefresh": true
},
"meta": {
"auth": true,
"sync": true,
"title": "拼团订单",
"group": "营销活动"
}
},
{
"path": "index",
"style": {
"navigationBarTitleText": "营销商品"
},
"meta": {
"sync": true,
"title": "营销商品",
"group": "营销活动"
}
},
{
"path": "groupon/list",
"style": {
"navigationBarTitleText": "拼团活动"
},
"meta": {
"sync": true,
"title": "拼团活动",
"group": "营销活动"
}
},
{
"path": "seckill/list",
"style": {
"navigationBarTitleText": "秒杀活动"
},
"meta": {
"sync": true,
"title": "秒杀活动",
"group": "营销活动"
}
},
{
"path": "point/list",
"style": {
"navigationBarTitleText": "积分商城"
},
"meta": {
"sync": true,
"title": "积分商城",
"group": "营销活动"
}
}
]
},
{
"root": "pages/home",
"pages": [{
"path": "feedback",
"style": {
"navigationBarTitleText": "反馈页面",
"enablePullDownRefresh": false
}
},
{
"path": "share",
"style": {
"navigationBarTitleText": "邀请好友",
"enablePullDownRefresh": false
}
},
{
"path": "agency",
"style": {
"navigationBarTitleText": "我的收益",
"enablePullDownRefresh": false
}
},
{
"path": "staff",
"style": {
"navigationBarTitleText": "我的社员",
"enablePullDownRefresh": false
}
},
{
"path": "pass",
"style": {
"navigationBarTitleText": "修改密码",
"enablePullDownRefresh": false
}
},
{
"path": "phone",
"style": {
"navigationBarTitleText": "修改手机号",
"enablePullDownRefresh": false
}
},
{
"path": "agreement",
"style": {
"navigationBarTitleText": "协议",
"enablePullDownRefresh": false,
"navigationStyle": "default"
}
},
{
"path": "seed",
"style": {
"navigationBarTitleText": "金种子",
"enablePullDownRefresh": false
}
},
{
"path": "pointsDetail",
"style": {
"navigationBarTitleText": "明细",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pay/seed",
"style": {
"navigationBarTitleText": "金种子",
"enablePullDownRefresh": false
}
},
{
"path": "pay/withdrawRecord",
"style": {
"navigationBarTitleText": "提现记录",
"enablePullDownRefresh": false
}
},
{
"path": "pay/withdraw",
"style": {
"navigationBarTitleText": "提现",
"enablePullDownRefresh": false
}
},
{
"path": "calculate",
"style": {
"navigationBarTitleText": "calculate"
}
},
{
"path": "recharge",
"style": {
"navigationBarTitleText": "充值"
}
},
{
"path": "rechargeRecord",
"style": {
"navigationBarTitleText": "充值消费记录"
}
},
{
"path": "noRelease",
"style": {
"navigationBarTitleText": "待释放明细"
}
},
{
"path" : "wallet",
"style" :
{
"navigationBarTitleText" : "钱包"
}
}
]
},
{
"root": "pages/AI",
"pages": [{
"path": "index",
"style": {
"navigationBarTitleText": "AI店铺",
"enablePullDownRefresh": false
}
},
{
"path": "member",
"style": {
"navigationBarTitleText": "开通会员",
"enablePullDownRefresh": false
}
},
{
"path": "comDetails",
"style": {
"navigationBarTitleText": "商品详情",
"enablePullDownRefresh": false
}
},
{
"path": "placeOrder",
"style": {
"navigationBarTitleText": "确认订单",
"enablePullDownRefresh": false
}
},
{
"path": "cashierDesk",
"style": {
"navigationBarTitleText": "收银台",
"enablePullDownRefresh": false
}
},
{
"path": "orderInfo",
"style": {
"navigationBarTitleText": "订单详情",
"enablePullDownRefresh": false
}
},
{
"path": "giftOrder",
"style": {
"navigationBarTitleText": "确认订单",
"enablePullDownRefresh": false
}
},
{
"path": "giftCashierDesk",
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "giftOrderInfo",
"style": {
"navigationBarTitleText": "订单详情",
"enablePullDownRefresh": false
}
}
]
},
{
"root": "pages/increment",
"pages": [{
"path": "index",
"style": {
"navigationBarTitleText": "绿色积分增值系统"
}
},
{
"path": "user",
"style": {
"navigationBarTitleText": "我的"
}
},
{
"path": "detail",
"style": {
"navigationBarTitleText": "明细"
}
},
{
"path": "info",
"style": {
"navigationBarTitleText": "商品详情"
}
}
]
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "数维智合",
"navigationBarBackgroundColor": "#FFFFFF",
"backgroundColor": "#FFFFFF",
"navigationStyle": "custom"
},
"tabBar": {
"color": "#979797",
"selectedColor": "#FA7E31",
"backgroundColor": "#ffffff",
"height": "50px",
"fontSize": "10px",
"spacing": "3px",
"iconWidth": "24px",
"midButton": {
"width": "44px",
"height": "50px",
"backgroundImage": "/static/index/6.png"
},
"list": [{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "static/index/1.png",
"selectedIconPath": "static/index/1_1.png"
},
{
"pagePath": "pages/index/category",
"text": "分类",
"iconPath": "static/index/2.png",
"selectedIconPath": "static/index/2_1.png"
},
{
"pagePath": "pages/cart/cart",
"text": "购物车",
"iconPath": "static/index/3.png",
"selectedIconPath": "static/index/3_1.png"
},
{
"pagePath": "pages/index/user",
"text": "我的",
"iconPath": "static/index/4.png",
"selectedIconPath": "static/index/4_1.png"
}
]
},
"condition": {
//模式配置,仅开发期间生效
"current": 0, //当前激活的模式(list 的索引项)
"list": [{
"name": "", //模式名称
"path": "", //启动页面,必选
"query": "" //启动参数,在页面的onLoad函数里面得到
}]
}
}
+332
View File
@@ -0,0 +1,332 @@
<template>
<s-pages title="收银台" :goLeft="false" @onClickLeft="onClickLeft">
<view class="p-x-32">
<view class="center p-t-96 weight500 size100"><span class="size48">¥</span>
{{ fen2yuan(state.orderInfo.payPrice) }}
</view>
<view class="center m-t-20 m-b-66">{{ payDescText }}</view>
<view>
<radio-group @change="onTapPay">
<label class="" v-for="item in state.payMethods" :key="item.title">
<view class="flex-center ju-between m-b-40" :class="{ 'disabled-pay-item': item.disabled }">
<view class="flex-center">
<image class="h_64 w_64" v-if="item.disabled"
:src="sheep.$url.static('/static/img/shop/pay/cod_disabled.png')"
mode="aspectFit" />
<image class="h_64 w_64" v-else :src="sheep.$url.static(item.icon)" mode="aspectFit" />
<text class="pay-title m-l-12">{{ item.title }}</text>
</view>
<view class="check-box ss-flex ss-col-center ss-p-l-10">
<view class="userInfo-money ss-m-r-10" v-if="item.value === 'wallet'">
余额: {{ fen2yuan(totalRecharge) }}元
</view>
<view class="">
<radio :value="item.value" color="var(--ui-BG-Main)"
backgroundColor="rgba(255, 255, 255, 0)" :disabled="item.disabled"
:checked="state.payment === item.value" />
</view>
</view>
</view>
</label>
</radio-group>
</view>
<!-- 工具 -->
<view class="modal-footer ss-flex ss-row-center ss-col-center ss-m-t-80 ss-m-b-40">
<button v-if="state.payStatus === 0" class="ss-reset-button past-due-btn">
检测支付环境中
</button>
<button v-else-if="state.payStatus === -1" class="ss-reset-button past-due-btn" disabled>
支付已过期
</button>
<button v-else class="ai-button2" @tap="onPay" :disabled="state.payStatus !== 1"
:class="{ 'disabled-btn': state.payStatus !== 1 }">
立即支付
</button>
</view>
</view>
</s-pages>
</template>
<script setup lang="ts">
import {
ref,
reactive,
onMounted,
onUnmounted,
getCurrentInstance,
watch,
nextTick,
computed,
} from 'vue';
let { proxy } = getCurrentInstance();
import { onLoad, onShow } from '@dcloudio/uni-app';
import * as api from '@/sheep/api/ai/index';
import sheep from '@/sheep';
import PayChannelApi from '@/sheep/api/pay/channel';
import { fen2yuan, useDurationTime } from '@/sheep/hooks/useGoods';
import { getPayMethods, goPayResult } from '@/sheep/platform/pay';
import { SYSCONST } from '@/sheep/helper/const';
import { getWallet } from '@/sheep/api/home/pay';
let id = ref('');
let payOrderId = ref('');
let orderInfo = ref({});
const userWallet = ref();
let totalRecharge = ref();
// 检测支付环境
const state = reactive({
orderType: 'aiGoods', // 订单类型; goods - 商品订单, recharge - 充值订单 aiRecharge
orderInfo: {}, // 支付单信息
payStatus: 0, // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付
payMethods: [], // 可选的支付方式
payment: '', // 选中的支付方式
});
const getOrderDetail = async () => {
let { code, data } = await api.getOrderDetail({ id: id.value });
console.log('订单详情', code, data);
if (code !== 0 || !data) {
state.payStatus = -2;
return;
}
state.orderInfo = data || {};
// 设置支付状态
checkPayStatus();
// 获得支付方式
await setPayMethods();
};
// 获得支付方式
async function setPayMethods() {
const { data, code } = await PayChannelApi.getEnableChannelCodeList(state.orderInfo.appId || 1);
// console.log('支付方式', code, data);
if (code !== 0) {
return;
}
state.payMethods = getPayMethods(data);
console.log('支付方式', state.payMethods);
// 金额超出阈值,仅允许余额支付
if (state.orderInfo?.totalPrice >= SYSCONST.MAX_PRICE) {
state.payMethods = state.payMethods.map((item) => ({
...item,
disabled: item.value !== 'wallet' ? true : item.disabled,
}));
state.payment = 'wallet';
}
state.payMethods.find((item) => {
if (item.value && !item.disabled) {
state.payment = item.value;
return true;
}
});
}
// 支付文案提示
const payDescText = computed(() => {
if (state.payStatus === 2) {
return '该订单已支付';
}
if (state.payStatus === 1 && state.orderInfo?.payExpireTime) {
const time = useDurationTime(state.orderInfo.payExpireTime);
if (time?.ms <= 0) {
state.payStatus = -1;
return '';
}
return `剩余支付时间 ${time?.h}:${time?.m}:${time?.s} `;
}
if (state.payStatus === -2) {
return '未查询到支付单信息';
}
return '';
});
// 状态转换:payOrder.status => payStatus
function checkPayStatus() {
if (state.orderInfo.status === 10 || state.orderInfo.status === 20) {
// 支付成功
state.payStatus = 2;
// 跳转回支付成功页
uni.showModal({
title: '提示',
content: '订单已支付',
confirmColor: '#FA7E31',
showCancel: false,
success: function () {
goPayResult(state.orderInfo.id, state.orderType);
},
});
return;
}
if (state.orderInfo.status === 30) {
// 支付关闭
state.payStatus = -1;
return;
}
state.payStatus = 1; // 待支付
}
// 切换支付方式
function onTapPay(e) {
state.payment = e.detail.value;
}
let type = ref(); //2充值
onLoad(async (options) => {
id.value = options.id || '';
payOrderId.value = options.payOrderId || '';
type.value = options.type || '';
if (type.value == 2) {
state.orderType = 'aiRecharge';
state.orderInfo.totalPrice = options.price * 100;
// state.orderInfo.price = options.price || '';
// 设置支付状态
checkPayStatus();
// 获得支付方式
await setPayMethods();
} else {
getOrderDetail();
}
});
onShow(() => {
getWallet().then((res) => {
if (res.code === 0) {
totalRecharge.value = res.data.totalRecharge;
}
});
});
const onPay = () => {
// console.log(userWallet.value.totalRecharge);
if (state.payment === '') {
sheep.$helper.toast('请选择支付方式');
return;
}
if (state.orderInfo.totalPrice >= SYSCONST.MAX_PRICE && state.payment !== 'wallet') {
sheep.$helper.toast('请选择余额支付');
return;
}
if (state.payment === 'wallet') {
uni.showModal({
title: '提示',
content: '确定要支付吗?',
confirmColor: '#FA7E31',
success: function (res) {
if (res.confirm) {
// sheep.$platform.pay(state.payment, state.orderType, payOrderId.value);
if (totalRecharge.value < state.orderInfo.totalPrice) {
uni.showToast({
title: '余额不足请充值',
icon: 'none',
});
setTimeout(() => {
uni.navigateTo({
url: '/pages/home/recharge',
});
}, 1000);
} else {
sheep.$platform.pay(state.payment, state.orderType, payOrderId.value);
}
}
},
});
} else {
sheep.$platform.pay(state.payment, state.orderType, payOrderId.value);
}
};
const onClickLeft = () => {
uni.navigateBack({
delta: 1,
});
};
</script>
<style lang="scss" scoped>
.pay-icon {
width: 36rpx;
height: 36rpx;
margin-right: 26rpx;
}
.ss-modal-box {
// max-height: 1000rpx;
.modal-header {
position: relative;
padding: 60rpx 20rpx 40rpx;
.money-text {
color: $red;
font-size: 46rpx;
font-weight: bold;
font-family: OPPOSANS;
&::before {
content: '¥';
font-size: 30rpx;
}
}
.time-text {
font-size: 26rpx;
color: $gray-b;
}
.close-icon {
position: absolute;
top: 10rpx;
right: 20rpx;
font-size: 46rpx;
opacity: 0.2;
}
}
.modal-content {
overflow-y: auto;
.pay-title {
font-size: 26rpx;
font-weight: 500;
color: #333333;
}
.pay-tip {
font-size: 26rpx;
color: #bbbbbb;
}
.pay-item {
height: 86rpx;
}
.disabled-pay-item {
.pay-title {
color: #999999;
}
}
.userInfo-money {
font-size: 26rpx;
color: #bbbbbb;
line-height: normal;
}
}
.save-btn {
width: 710rpx;
height: 80rpx;
border-radius: 40rpx;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
color: $white;
}
.disabled-btn {
background: #e5e5e5;
color: #999999;
}
.past-due-btn {
width: 710rpx;
height: 80rpx;
border-radius: 40rpx;
background-color: #999;
color: #fff;
}
}
</style>
+470
View File
@@ -0,0 +1,470 @@
<template>
<s-layout title="商品详情">
<view>
<detailSkeleton v-if="state.skeletonLoading" />
<!-- 下架/售罄提醒 -->
<s-empty v-else-if="state.goodsInfo === null" text="商品不存在或已下架" icon="/static/soldout-empty.png" showAction
actionText="再逛逛" actionUrl="/pages/AI/index" />
<block v-else>
<view class="detail-swiper-selector">
<!-- 商品轮播图 -->
<su-swiper class="" isPreview :list="formatGoodsSwiper(state.goodsInfo.sliderPicUrls)" otStyle="tag"
imageMode="widthFix" dotCur="bg-mask-40" :seizeHeight="750" />
<!-- 限时折扣/会员价的优惠信息 -->
<view v-if="!show" class="session">
<view class="bg w100 h100 h_152">
<image class="w100 h100" :src="$url + 'ai/2.png'" mode="scaleToFill" />
</view>
<view class="sessionCon w100 h100 h_152 flex-center ju-between p-x-40">
<view>
<view class="flex-row al-flex-end m-b-8" style="color: #fff">
<view class="size44 weight500">
<span class="size32">¥</span>{{ $fen2yuan(state.goodsInfo.discountedPrice?state.goodsInfo.discountedPrice:state.goodsInfo.price) }}
</view>
<view class="size24 m-l-14 m-r-6 through" v-if="state.goodsInfo.marketPrice">
¥{{ $fen2yuan(state.goodsInfo.discountedPrice?state.goodsInfo.price:state.goodsInfo.marketPrice) }}</view>
<view class="size24">已售</view>
</view>
<view class="flex-row relative">
<view class="w_348 h_37">
<image class="w100 h100" :src="$url + 'ai/3.png'" mode="scaleToFill" />
</view>
<view class="absolute t0 l0 size20 c27 line37 p-l-10">
限时省{{ $fen2yuan(state.goodsInfo.marketPrice - state.goodsInfo.price) }}元
</view>
</view>
</view>
<view>
<view class="c15 size28 m-b-22">距离活动{{ timeText }}</view>
<view>
<uni-countdown color="#FFFFFF" background-color="#FF393A" border-color="#FF393A" :show-day="false"
:hour="hour" :minute="minute" :second="second" @timeup="timeup"></uni-countdown>
</view>
</view>
</view>
</view>
<!-- 价格+标题 -->
<view class="title-card detail-card ss-p-y-32 ss-p-x-32" :class="{ 'm-t-52': !show }">
<view class="title-text ss-line-2 ss-m-b-6 flex-center ju-flex-start">
<view class="label m-r-10 shrink" v-if="state.goodsInfo.tagSaleName">{{
state.goodsInfo.tagSaleName
}}</view>
<view>{{ state.goodsInfo.name }}</view>
</view>
<view class="subtitle-text ss-line-1">{{ state.goodsInfo.introduction }}</view>
</view>
<!-- 功能卡片 -->
<view class="detail-cell-card detail-card ss-flex-col">
<detail-cell-sku v-model="state.selectedSku.goods_sku_text" :sku="state.selectedSku" @tap="addCar" theme="2"
v-if="timeText !== '开始'" />
<detail-cell v-if="state.goodsInfo.deliverPlace || state.goodsInfo.deliverTime" label="发货" :value="`${state.goodsInfo.deliverPlace || ''} ${state.goodsInfo.deliverPlace || state.goodsInfo.deliverTime ? '|' : ''
} ${state.goodsInfo.deliverTime || ''}`" />
<detail-cell theme="2" label="运费" value="免运费(请以提交订单为准)" />
</view>
<!-- 详情 -->
<detail-content-card class="detail-content-selector" :content="state.goodsInfo.description" />
</view>
</block>
<view class="theme-ai">
<card_payment ref="paymentRef" source="orderInfo" :actionStatus="timeText" @addCar="addCar" />
</view>
</view>
</s-layout>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick } from 'vue';
import { onLoad, onPageScroll } from '@dcloudio/uni-app';
import sheep from '@/sheep';
// import { onPageScroll} from '@dcloudio/uni-app';
import card_payment from '@/components/card_payment/card_payment';
import detailNavbar from '../goods/components/detail/detail-navbar.vue';
import detailCellSku from '../goods/components/detail/detail-cell-sku.vue';
import detailCell from '../goods/components/detail/detail-cell.vue';
import detailTabbar from '../goods/components/detail/detail-tabbar.vue';
import detailSkeleton from '../goods/components/detail/detail-skeleton.vue';
import detailCommentCard from '../goods/components/detail/detail-comment-card.vue';
import detailContentCard from '../goods/components/detail/detail-content-card.vue';
import detailActivityTip from '../goods/components/detail/detail-activity-tip.vue';
import {
formatSales,
formatGoodsSwiper,
fen2yuan,
fen2yuanSimple,
formatDiscountPercent,
getRewardActivityRuleItemDescriptions,
} from '@/sheep/hooks/useGoods';
import * as api from '@/sheep/api/ai/index';
let { proxy } = getCurrentInstance();
const state = reactive({
skeletonLoading: false,
goodsInfo: {},
selectedSku: {}, // 选中的 SKU
});
const getInfo = async () => {
let res = await api.getSpuDetail(id.value, shoppingPlazaId.value);
if (res.code === 0) {
state.goodsInfo = res.data;
timeChange();
}
};
let id = ref();
let shoppingPlazaId = ref();
onLoad(async (options) => {
// 滚到顶部
uni.pageScrollTo({
scrollTop: 0,
});
id.value = options.id;
shoppingPlazaId.value = options.shopId;
getInfo();
}); // 规格变更
function onSkuChange(e) {
state.selectedSku = e;
state.settlementSku = e;
}
const onAddCart = () => { };
const onBuy = () => { };
let paymentRef = ref(null);
const addCar = () => {
paymentRef.value.addCar({ ...state.goodsInfo, shoppingPlazaId: shoppingPlazaId.value });
};
/**
* 倒计时
*/
let show = ref(false);
let timeText = ref('开始');
let hour = ref(0);
let minute = ref(0);
let second = ref(0);
const timeup = () => {
show.value = true;
timeChange();
};
const timeChange = () => {
show.value = false;
let data = state.goodsInfo;
let endTime = data.endTime;
let startTime = data.startTime;
// 当前时间戳
let currentTime = Date.now();
let time = null;
if (currentTime < startTime) {
timeText.value = '开始';
time = startTime - currentTime;
} else if (currentTime > startTime && currentTime < endTime) {
timeText.value = '结束';
time = endTime - currentTime;
} else {
show.value = true;
timeText.value = '已结束';
}
if (time) {
hour.value = Math.floor(time / 1000 / 60 / 60);
minute.value = Math.floor(time / 1000 / 60) % 60;
second.value = Math.floor(time / 1000) % 60;
}
};
// inner
let navBar = ref('inner');
let scrollTop = ref(0);
onPageScroll((e) => {
//console.log(e)
scrollTop.value = e.scrollTop;
if (e.scrollTop > 20) {
navBar.value = 'normal';
} else {
navBar.value = 'inner';
}
});
let sysInfo = uni.getSystemInfoSync();
const windowHeight = sysInfo.windowHeight;
let height = ref(0);
height.value = sysInfo.statusBarHeight + uni.upx2px(88);
</script>
<style lang="scss" scoped>
.detail-card {
background-color: #ffffff;
border-radius: 10rpx;
overflow: hidden;
margin-bottom: 40rpx;
// color: #ffffff;
}
// 价格标题卡片
.title-card {
.price-box {
.price-text {
font-size: 42rpx;
font-weight: 500;
color: #ff3000;
line-height: 30rpx;
font-family: OPPOSANS;
&::before {
content: '¥';
font-size: 30rpx;
}
}
.origin-price-text {
font-size: 26rpx;
font-weight: 400;
text-decoration: line-through;
color: $gray-c;
font-family: OPPOSANS;
&::before {
content: '¥';
}
}
}
.sales-text {
font-size: 26rpx;
font-weight: 500;
color: $gray-c;
}
.discounts-box {
.tag-content {
flex: 1;
min-width: 0;
white-space: nowrap;
}
.tag-box {
overflow: hidden;
text-overflow: ellipsis;
}
.tag {
flex-shrink: 0;
padding: 4rpx 10rpx;
font-size: 24rpx;
font-weight: 500;
border-radius: 4rpx;
color: var(--ui-BG-Main);
background: var(--ui-BG-Main-tag);
}
.discounts-title {
font-size: 24rpx;
font-weight: 500;
color: var(--ui-BG-Main);
line-height: normal;
}
.cicon-forward {
color: var(--ui-BG-Main);
font-size: 24rpx;
line-height: normal;
margin-top: 4rpx;
}
}
.title-text {
font-size: 32rpx;
line-height: 42rpx;
}
.subtitle-text {
font-size: 26rpx;
font-weight: 400;
color: $dark-9;
line-height: 42rpx;
}
}
// 购买
.buy-box {
.add-btn {
width: 240rpx;
height: 72rpx;
font-weight: 500;
font-size: 30rpx;
border-radius: 12rpx 0 0 12rpx;
background: #fa8735;
color: #ffffff;
}
.buy-btn {
width: 240rpx;
height: 72rpx;
font-weight: 500;
font-size: 30rpx;
border-radius: 0 12rpx 12rpx 0;
background: #fe3b48;
color: #ffffff;
}
.disabled-btn {
width: 428rpx;
height: 72rpx;
border-radius: 40rpx;
background: #999999;
color: $white;
}
}
.model-box {
height: 60vh;
.model-content {
height: 56vh;
}
.title {
font-size: 36rpx;
font-weight: bold;
color: #333333;
}
.subtitle {
font-size: 26rpx;
font-weight: 500;
color: #333333;
}
}
// 限时折扣
.discount {
position: relative;
}
.disImg {
width: 750rpx;
height: 100rpx;
position: absolute;
top: 0;
z-index: -1;
}
.discountCont {
width: 680rpx;
height: 90rpx;
margin: 10rpx auto 0 auto;
// background-color: gold;
}
.disContT {
width: 680rpx;
height: 50rpx;
display: flex;
justify-content: space-between;
}
.disContT1 {
// width: 400rpx;
// height: 50rpx;
// background-color: green;
display: flex;
justify-content: flex-start;
align-items: center;
}
.disContT2 {
width: 200rpx;
height: 50rpx;
line-height: 50rpx;
// background-color: gold;
font-size: 30rpx;
text-align: end;
color: #ff393a;
font-weight: bolder;
font-style: oblique 20deg;
letter-spacing: 0.1rem;
}
.disContT1P {
color: white;
font-size: 44rpx;
}
.disContT1End {
// width: 180rpx;
padding: 0 20rpx;
height: 36rpx;
line-height: 36rpx;
text-align: center;
background-color: #fee2be;
color: #f71b1b;
font-size: 23rpx;
border-radius: 20rpx;
margin-left: 26rpx;
}
.disContB {
width: 680rpx;
height: 40rpx;
display: flex;
justify-content: space-between;
font-size: 20rpx;
color: white;
align-items: center;
}
.disContB1 {
width: 300rpx;
height: 40rpx;
line-height: 40rpx;
color: #ffcccc;
font-size: 24rpx;
// 删除线
text-decoration: line-through;
padding-left: 6rpx;
}
.disContB2 {
width: 300rpx;
height: 40rpx;
line-height: 40rpx;
display: flex;
justify-content: flex-end;
}
.label {
display: inline-block;
font-size: 20rpx;
color: #ff5040;
border: 1px solid #ff5040;
border-radius: 8rpx;
padding: 0 8rpx;
box-sizing: border-box;
}
.session {
position: relative;
}
.bg {
position: absolute;
top: 0;
top: -100rpx;
left: 0;
}
.sessionCon {
position: absolute;
top: 0;
top: -100rpx;
left: 0;
}
:deep(.uni-countdown__number) {
font-size: 24rpx !important;
width: 40rpx !important;
height: 40rpx !important;
line-height: 40rpx !important;
}
:deep(.uni-countdown__splitor) {
color: #ff393a !important;
}
</style>
+357
View File
@@ -0,0 +1,357 @@
<template>
<s-pages title="收银台" :goLeft="false" @onClickLeft="onClickLeft">
<view class="p-x-32">
<view class="center p-t-96 weight500 size100"
><span class="size48">¥</span>
<!-- {{ fen2yuan(state.orderInfo.totalPrice) }} -->
{{ fen2yuan(state.orderInfo.totalPrice) }}
</view>
<view class="center m-t-20 m-b-66">{{ payDescText }}</view>
<view>
<radio-group @change="onTapPay">
<label class="" v-for="item in state.payMethods" :key="item.title">
<view
class="flex-center ju-between m-b-40"
:class="{ 'disabled-pay-item': item.disabled }"
>
<view class="flex-center">
<image
class="h_64 w_64"
v-if="item.disabled"
:src="sheep.$url.static('/static/img/shop/pay/cod_disabled.png')"
mode="aspectFit"
/>
<image
class="h_64 w_64"
v-else
:src="sheep.$url.static(item.icon)"
mode="aspectFit"
/>
<text class="pay-title m-l-12">{{ item.title }}</text>
</view>
<view class="check-box ss-flex ss-col-center ss-p-l-10">
<view class="userInfo-money ss-m-r-10" v-if="item.value === 'wallet'">
余额: {{ fen2yuan(totalRecharge) }}元
</view>
<view class="">
<radio
:value="item.value"
color="#366DEE"
backgroundColor="rgba(255, 255, 255, 0)"
:disabled="item.disabled"
:checked="state.payment === item.value"
/>
</view>
</view>
<!-- <view class="">
<radio :value="item.value" color="#366DEE" backgroundColor="rgba(255, 255, 255, 0)"
:disabled="item.disabled" :checked="state.payment === item.value" />
</view> -->
</view>
</label>
</radio-group>
</view>
<!-- 工具 -->
<view class="modal-footer ss-flex ss-row-center ss-col-center ss-m-t-80 ss-m-b-40">
<button v-if="state.payStatus === 0" class="ss-reset-button past-due-btn">
检测支付环境中
</button>
<button v-else-if="state.payStatus === -1" class="ss-reset-button past-due-btn" disabled>
支付已过期
</button>
<button
v-else
class="ai-button2"
@tap="onPay"
:disabled="state.payStatus !== 1"
:class="{ 'disabled-btn': state.payStatus !== 1 }"
>
立即支付
</button>
</view>
</view>
</s-pages>
</template>
<script setup lang="ts">
import {
ref,
reactive,
onMounted,
onUnmounted,
getCurrentInstance,
watch,
nextTick,
computed,
} from 'vue';
let { proxy } = getCurrentInstance();
import { onLoad, onShow } from '@dcloudio/uni-app';
import * as api from '@/sheep/api/ai/index';
import sheep from '@/sheep';
import PayChannelApi from '@/sheep/api/pay/channel';
import { fen2yuan, useDurationTime } from '@/sheep/hooks/useGoods';
import { getPayMethods, goPayResult } from '@/sheep/platform/pay';
import { SYSCONST } from '@/sheep/helper/const';
import { getWallet } from '@/sheep/api/home/pay';
let id = ref('');
let payOrderId = ref('');
let orderInfo = ref({});
const userWallet = ref();
let totalRecharge = ref();
// 检测支付环境
const state = reactive({
orderType: 'aiGoods', // 订单类型; goods - 商品订单, recharge - 充值订单 aiRecharge
orderInfo: {}, // 支付单信息
payStatus: 0, // 0=检测支付环境, -2=未查询到支付单信息, -1=支付已过期, 1=待支付,2=订单已支付
payMethods: [], // 可选的支付方式
payment: '', // 选中的支付方式
});
const getOrderDetail = async () => {
let { code, data } = await api.getGiftOrderDetail({ id: id.value });
if (code !== 0 || !data) {
state.payStatus = -2;
return;
}
state.orderInfo = data || {};
// 设置支付状态
checkPayStatus();
// 获得支付方式
await setPayMethods();
};
// 获得支付方式
async function setPayMethods() {
const { data, code } = await PayChannelApi.getEnableChannelCodeList(state.orderInfo.appId || 1);
if (code !== 0) {
return;
}
state.payMethods = getPayMethods(data);
// 金额超出阈值,仅允许余额支付
if (state.orderInfo?.totalPrice >= SYSCONST.MAX_PRICE) {
state.payMethods = state.payMethods.map((item) => ({
...item,
disabled: item.value !== 'wallet' ? true : item.disabled,
}));
state.payment = 'wallet';
}
state.payMethods.find((item) => {
if (item.value && !item.disabled) {
state.payment = item.value;
return true;
}
});
}
// 支付文案提示
const payDescText = computed(() => {
if (state.payStatus === 2) {
return '该订单已支付';
}
if (state.payStatus === 1 && state.orderInfo?.payExpireTime) {
const time = useDurationTime(state.orderInfo.payExpireTime);
if (time?.ms <= 0) {
state.payStatus = -1;
return '';
}
return `剩余支付时间 ${time?.h}:${time?.m}:${time?.s} `;
}
if (state.payStatus === -2) {
return '未查询到支付单信息';
}
return '';
});
// 状态转换:payOrder.status => payStatus
function checkPayStatus() {
if (state.orderInfo.status === 10 || state.orderInfo.status === 20) {
// 支付成功
state.payStatus = 2;
// 跳转回支付成功页
uni.showModal({
title: '提示',
content: '订单已支付',
confirmColor: '#FA7E31',
showCancel: false,
success: function () {
goPayResult(state.orderInfo.id, state.orderType);
},
});
return;
}
if (state.orderInfo.status === 30) {
// 支付关闭
state.payStatus = -1;
return;
}
state.payStatus = 1; // 待支付
}
// 切换支付方式
function onTapPay(e) {
state.payment = e.detail.value;
}
let type = ref(); //2充值
onLoad(async (options) => {
// console.log(options);
id.value = options.id || '';
payOrderId.value = options.payOrderId || '';
type.value = options.type || '';
if (type.value == 2) {
state.orderType = 'aiRecharge';
state.orderInfo.totalPrice = options.price * 100;
// state.orderInfo.price = options.price;
// 设置支付状态
checkPayStatus();
// 获得支付方式
await setPayMethods();
} else {
getOrderDetail();
}
});
onShow(() => {
getWallet().then((res) => {
if (res.code === 0) {
totalRecharge.value = res.data.totalRecharge;
}
});
});
const onPay = () => {
// console.log(userWallet.value.totalRecharge);
if (state.payment === '') {
sheep.$helper.toast('请选择支付方式');
return;
}
if (state.orderInfo.totalPrice >= SYSCONST.MAX_PRICE && state.payment !== 'wallet') {
sheep.$helper.toast('请选择余额支付');
return;
}
if (state.payment === 'wallet') {
uni.showModal({
title: '提示',
content: '确定要支付吗?',
confirmColor: '#FA7E31',
success: function (res) {
if (res.confirm) {
// sheep.$platform.pay(state.payment, state.orderType, payOrderId.value);
if (totalRecharge.value < state.orderInfo.totalPrice) {
uni.showToast({
title: '余额不足请充值',
icon: 'none',
});
setTimeout(() => {
uni.navigateTo({
url: '/pages/home/recharge',
});
}, 1000);
} else {
sheep.$platform.pay(state.payment, state.orderType, payOrderId.value);
}
}
},
});
} else {
sheep.$platform.pay(state.payment, state.orderType, payOrderId.value);
}
};
const onClickLeft = () => {
uni.navigateBack({
delta: 1,
});
};
</script>
<style lang="scss" scoped>
.pay-icon {
width: 36rpx;
height: 36rpx;
margin-right: 26rpx;
}
.ss-modal-box {
// max-height: 1000rpx;
.modal-header {
position: relative;
padding: 60rpx 20rpx 40rpx;
.money-text {
color: $red;
font-size: 46rpx;
font-weight: bold;
font-family: OPPOSANS;
&::before {
content: '¥';
font-size: 30rpx;
}
}
.time-text {
font-size: 26rpx;
color: $gray-b;
}
.close-icon {
position: absolute;
top: 10rpx;
right: 20rpx;
font-size: 46rpx;
opacity: 0.2;
}
}
.modal-content {
overflow-y: auto;
.pay-title {
font-size: 26rpx;
font-weight: 500;
color: #333333;
}
.pay-tip {
font-size: 26rpx;
color: #bbbbbb;
}
.pay-item {
height: 86rpx;
}
.disabled-pay-item {
.pay-title {
color: #999999;
}
}
.userInfo-money {
font-size: 26rpx;
color: #bbbbbb;
line-height: normal;
}
}
.save-btn {
width: 710rpx;
height: 80rpx;
border-radius: 40rpx;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
color: $white;
}
.disabled-btn {
background: #e5e5e5;
color: #999999;
}
.past-due-btn {
width: 710rpx;
height: 80rpx;
border-radius: 40rpx;
background-color: #999;
color: #fff;
}
}
</style>
+160
View File
@@ -0,0 +1,160 @@
<template>
<s-pages title="确认订单">
<view class="p-b-132">
<AddressSelection v-model="addressState" theme="2" @getSettlementInfo="getSettlementInfo" />
<view class="p-x-32 m-t-24">
<view class="bg24 p-x-20 p-t-20 radius16">
<view v-if="settlementInfo.items && settlementInfo.items.length">
<view class="m-b-24 no-click-wrap" v-for="(v, i) in settlementInfo.items" :key="i">
<aiOrder :data="v" :source="3" />
<view class="no-click-block" @click.stop.prevent></view>
</view>
</view>
<view class="flex-row ju-between m-b-36">
<view class="c25 size28">商品金额</view>
<view>¥{{ $fen2yuan(settlementInfo?.price?.totalPrice || 0) }}</view>
</view>
<view class="flex-row ju-between m-b-36">
<view class="c25 size28">运费</view>
<view>¥{{ $fen2yuan(settlementInfo?.price?.deliveryPrice || 0) }}</view>
</view>
<view class="flex-center ju-flex-end borderTop">
<span class="size26 line96">合计: </span>
<span class="c13 size28 m-l-12 line96 weight900"
>¥{{ $fen2yuan(settlementInfo?.price?.payPrice || 0) }}</span
>
</view>
</view>
</view>
</view>
<view class="p-x-32 btn">
<view class="ai-button2" @click="sub">确认订单</view>
</view>
</s-pages>
</template>
<script setup lang="ts">
import { ref, getCurrentInstance } from 'vue';
import AddressSelection from '@/pages/order/addressSelection.vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import aiOrder from '@/components/ai_order/ai_order';
let { proxy } = getCurrentInstance();
import api from '@/sheep/api/member/address';
import * as SpuApi from '@/sheep/api/ai/index';
const addressState = ref({
addressInfo: {},
deliveryType: 1,
isPickUp: false,
pickUpInfo: {},
receiverName: '',
receiverMobile: '',
});
let remark_value = ref();
let spuId = ref();
let spuPrice = ref();
const settlementInfo = ref<any>({});
let addressId = ref('');
const getSettlementInfo = (id = '') => {
addressId.value = id;
SpuApi.getGiftSettlementInfo({
id: id,
spuId: spuId.value,
}).then((res: any) => {
settlementInfo.value = res.data || {};
// 设置收货地址
if (res.data.address) {
addressState.value.addressInfo = res.data.address;
}
// if (settlementInfo.value?.items?.length) {
// settlementInfo.value.items.forEach((e) => {
// e.skuArr = e.items;
// e.skuArr.forEach((item) => {
// item.propertyText = '';
// if(item.properties){
// item.properties.forEach((e1) => {
// item.propertyText += e1.valueName + ' ';
// });
// }
// });
// });
// }
});
};
const sub = async () => {
if (!addressId.value) return proxy.utils.toast('请选择地址');
let res: any = await SpuApi.createOrderOpen({
id: addressId.value,
spuId: spuId.value,
userRemark: remark_value.value,
});
if (res.code === 0) {
proxy.utils.toast('下单成功');
setTimeout(() => {
proxy.utils.go('/pages/AI/giftCashierDesk', {
id: res.data.id,
payOrderId: res.data.payOrderId,
});
}, 1000);
}
};
const getAddress = () => {
api.getAddressList().then((res) => {
if (res.code === 0 && res.data?.length) {
// addressState.value.addressInfo = res.data[0];
// getSettlementInfo(res.data[0].id);
let index = res.data.findIndex((e) => e.defaultStatus);
if (index !== -1) {
addressState.value.addressInfo = res.data[index];
getSettlementInfo(res.data[index].id);
} else {
getSettlementInfo();
}
} else {
getSettlementInfo();
}
});
};
// onLoad((options: any) => {
// if (options.id) {
// spuId.value = options.id;
// }
// if (options.price) {
// spuPrice.value = options.price;
// }
// getSettlementInfo();
// });
onLoad((e) => {
// getCartList();
spuId.value = e.id;
// console.log(e.id);
});
onShow(() => {
getAddress();
});
</script>
<style lang="scss" scoped>
.no-click-wrap {
position: relative;
}
.no-click-block {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.btn {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
padding-bottom: calc(env(safe-area-inset-bottom) + 12rpx);
z-index: 100;
background: transparent;
}
.borderTop {
border-top: 1rpx solid #dfdfdf;
padding: 12rpx 0;
}
</style>
+534
View File
@@ -0,0 +1,534 @@
<!-- 订单详情 -->
<template>
<s-pages title="订单详情">
<view class="flex-center al-flex-end ju-between p-x-32 m-b-54">
<view>
<view class="size40 weight500 m-b-16">{{ statusObj[state.orderInfo.status]?.text }}</view>
<view class="size24">{{ statusObj[state.orderInfo.status]?.text1 }}</view>
</view>
<view class="w_120 h_120" v-if="statusObj[state.orderInfo.status]?.icon">
<image
class="w100 h100"
:src="statusObj[state.orderInfo.status]?.icon"
mode="scaleToFill"
/>
</view>
</view>
<!-- 收货地址 -->
<view class="order-address-box flex-row bg24 c0" v-if="state.orderInfo.receiverAreaId > 0">
<view class="cityImg">
<image :src="`${$url}goods/city1.png`" mode="scaleToFill" />
</view>
<view class="size32">
<view class="ss-flex ss-col-center">
<text class="address-username">
{{ state.orderInfo.receiverName }}
</text>
<text class="address-phone">{{ state.orderInfo.receiverMobile }}</text>
</view>
<view class="address-detail size32">
{{ state.orderInfo.receiverAreaName }} {{ state.orderInfo.receiverDetailAddress }}
</view>
</view>
</view>
<view
class="detail-goods"
:style="[{ marginTop: state.orderInfo.receiverAreaId > 0 ? '0' : '-40rpx' }]"
>
<card_order
theme="2"
class="order-goods"
v-if="state?.orderInfo?.items?.length > 0"
:data="state.orderInfo"
type="4"
@getOrderDetail="getOrderDetail"
></card_order>
<!-- 价格信息 -->
<view class="order-price-box bg24">
<view class="notice-item ss-flex ss-row-between" v-for="(v, i) in priceArr" :key="i">
<text class="title c25">{{ v.title }}</text>
<view class="ss-flex">
<text class="detail c0" :class="{ 'all-price': v.value == 'payPrice' }"
><span>{{ v.type == 2 ? '-' : '' }}</span
>¥{{ fen2yuan(state.orderInfo[v.value]) }}</text
>
</view>
</view>
</view>
<!-- 订单信息 -->
<view
class="notice-box bg24"
:class="{
'm-b-90':
statusObj[state.orderInfo.status]?.btn1 || statusObj[state.orderInfo.status]?.btn2,
}"
>
<view class="notice-box__content">
<view class="notice-item--center">
<view class="ss-flex ss-flex-1 flex-row ju-between">
<text class="title c25">订单编号</text>
<text class="detail right c0">{{ state.orderInfo.no }}</text>
</view>
<view class="copy" @click.stop="onCopy">
<image :src="`${$url}goods/copy1.png`" mode="scaleToFill" />
</view>
<truckLine :data="state.orderInfo" :code="3" v-if="state.orderInfo.deliveryTime"></truckLine>
</view>
<view class="notice-item flex-row ju-between">
<text class="title c25">下单时间</text>
<text class="detail right c0">
{{ sheep.$helper.timeFormat(state.orderInfo.createTime, 'yyyy-mm-dd hh:MM:ss') }}
</text>
</view>
<view class="notice-item flex-row ju-between" v-if="state.orderInfo.payTime">
<text class="title c25">支付时间:</text>
<text class="detail right c0">
{{ sheep.$helper.timeFormat(state.orderInfo.payTime, 'yyyy-mm-dd hh:MM:ss') }}
</text>
</view>
<view class="notice-item flex-row ju-between">
<text class="title c25">支付方式</text>
<text class="detail right c0">{{ state.orderInfo.payChannelName || '-' }}</text>
</view>
</view>
</view>
<view
class="flex btns bg16"
v-if="statusObj[state.orderInfo.status]?.btn1 || statusObj[state.orderInfo.status]?.btn2"
>
<view
class="ai-button1 h_70 line70 size28"
:class="{
'm-r-28': statusObj[state.orderInfo.status]?.btn2,
}"
v-if="statusObj[state.orderInfo.status]?.btn1"
@click="btn(1)"
>
{{ statusObj[state.orderInfo.status]?.btn1 }}</view
>
<view
class="ai-button3 h_70 line70 size28"
v-if="statusObj[state.orderInfo.status]?.btn2"
@click="btn(2)"
>{{ statusObj[state.orderInfo.status]?.btn2 }}</view
>
</view>
</view>
</s-pages>
</template>
<script setup>
import sheep from '@/sheep';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { reactive, ref, getCurrentInstance } from 'vue';
import { isEmpty } from 'lodash-es';
import {
fen2yuan,
formatOrderStatus,
formatOrderStatusDescription,
handleOrderButtons,
} from '@/sheep/hooks/useGoods';
import * as OrderApi from '@/sheep/api/ai/index';
import DeliveryApi from '@/sheep/api/trade/delivery';
import PickUpVerify from '@/pages/order/pickUpVerify.vue';
import card_order from '@/components/orderItem/card_order.vue';
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
const headerBg = sheep.$url.css('/static/img/shop/order/order_bg.png');
let { proxy } = getCurrentInstance();
const state = reactive({
orderInfo: {},
merchantTradeNo: '', // 商户订单号
comeinType: '', // 进入订单详情的来源类型
});
let statusObj = ref({
0: {
text: '待付款',
text1: '付款时间还剩余',
btn1: '去支付',
btn2: '取消订单',
},
10: {
text: '待发货',
text1: '您的商品即将发货...',
icon: `${proxy.$url}ai/member/12.png`,
},
20: {
text: '待收货',
text1: '您的商品已发货,待您确认收货...',
icon: `${proxy.$url}ai/member/12.png`,
btn1: '确认收货',
},
30: {
text: '已完成',
text1: '您的订单已完成,感谢您的购买!',
},
40: {
text: '已取消',
text1: '您的订单已取消!',
},
});
// ========== 门店自提(核销) ==========
const systemStore = ref({}); // 门店信息
// 复制
const onCopy = () => {
sheep.$helper.copyText(state.orderInfo.no);
};
const pickUpVerifyRef = ref();
let orderId = ref();
async function getOrderDetail() {
let id = orderId.value;
// 对详情数据进行适配
let res;
res = await OrderApi.getGiftOrderInfo({
id,
});
if (res.code === 0) {
state.orderInfo = res.data;
handleOrderButtons(state.orderInfo);
if (state.orderInfo.deliveryType === 2 && state.orderInfo.payStatus) {
pickUpVerifyRef.value && pickUpVerifyRef.value.markCode(res.data.pickUpVerifyCode);
}
} else {
}
}
onShow(async () => {
//onShow中获取订单列表,保证跳转后页面为最新状态
await getOrderDetail();
});
onLoad(async (options) => {
if (options.id) {
orderId.value = options.id;
}
await getOrderDetail();
});
const priceArr = ref([
{
title: '商品金额',
value: 'totalPrice',
type: 1,
},
{
title: '运费',
value: 'deliveryPrice',
type: 1,
},
{
title: '实付金额',
value: 'payPrice',
type: 1,
},
]);
const btn = async (type) => {
if (state.orderInfo.status === 0 && type === 1) {
// 去支付
goPay();
}
if (state.orderInfo.status === 0 && type === 2) {
// 取消订单
cancelOrder();
}
if (state.orderInfo.status === 20 && type === 1) {
// 确认收货confirmReceive
OrderApi.giftConfirmReceive({
id: orderId.value,
}).then((res) => {
if (res.code === 0) {
getOrderDetail();
}
});
}
};
const goPay = () => {
proxy.utils.go('/pages/AI/cashierDesk', {
id: state.orderInfo.id,
payOrderId: state.orderInfo.payOrderId,
});
};
const cancelOrder = () => {
OrderApi.cancelOrder({
id: orderId.value,
}).then((res) => {
if (res.code === 0) {
getOrderDetail();
}
});
};
</script>
<style lang="scss" scoped>
.score-img {
width: 36rpx;
height: 36rpx;
margin: 0 4rpx;
}
.apply-btn {
width: 140rpx;
height: 50rpx;
border-radius: 25rpx;
font-size: 24rpx;
border: 2rpx solid #dcdcdc;
line-height: normal;
margin-left: 16rpx;
}
.state-box {
color: rgba(#fff, 0.9);
width: 100%;
background: v-bind(headerBg) no-repeat,
linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
background-size: 750rpx 100%;
box-sizing: border-box;
.state-img {
width: 60rpx;
height: 60rpx;
margin-right: 20rpx;
}
}
.order-address-box {
background-color: #fff;
border-radius: 12rpx;
margin: 20rpx 32rpx 24rpx 32rpx;
padding: 24rpx 30rpx 24rpx 20rpx;
font-size: 32rpx;
box-sizing: border-box;
color: #1b1b21;
.address-username {
margin-right: 20rpx;
}
.address-detail {
margin-top: 20rpx;
}
}
.detail-goods {
border-radius: 10rpx;
padding: 0 32rpx;
.order-list {
margin-bottom: 20rpx;
background-color: #fff;
.order-card {
padding: 20rpx 0;
.order-sku {
font-size: 24rpx;
font-weight: 400;
color: rgba(153, 153, 153, 1);
width: 450rpx;
margin-bottom: 20rpx;
.order-num {
margin-right: 10rpx;
}
}
.tag-btn {
margin-left: 16rpx;
font-size: 24rpx;
height: 36rpx;
color: var(--ui-BG-Main);
border: 2rpx solid var(--ui-BG-Main);
border-radius: 14rpx;
padding: 0 4rpx;
}
}
}
}
// 订单信息。
.notice-box {
background: #fff;
border-radius: 12rpx;
margin-bottom: 24rpx;
.notice-box__head {
font-size: 30rpx;
font-weight: 500;
color: rgba(51, 51, 51, 1);
line-height: 80rpx;
border-bottom: 1rpx solid #dfdfdf;
padding: 0 25rpx;
}
.notice-box__content {
padding: 20rpx;
.self-pickup-box {
width: 100%;
.self-pickup--img {
width: 200rpx;
height: 200rpx;
margin: 40rpx 0;
}
}
}
.notice-item,
.notice-item--center {
display: flex;
align-items: center;
line-height: normal;
margin-bottom: 24rpx;
.title {
font-size: 28rpx;
color: #3b3b3b;
}
.detail {
font-size: 28rpx;
color: #323232;
flex: 1;
}
}
}
.copy-btn {
width: 100rpx;
line-height: 50rpx;
border-radius: 25rpx;
padding: 0;
background: rgba(238, 238, 238, 1);
font-size: 22rpx;
font-weight: 400;
color: rgba(51, 51, 51, 1);
}
// 订单价格信息
.order-price-box {
background-color: #fff;
border-radius: 12rpx;
padding: 20rpx;
margin-bottom: 24rpx;
.notice-item {
line-height: 70rpx;
.title {
font-size: 28rpx;
color: #3b3b3b;
}
.detail {
font-size: 28rpx;
color: #323232;
font-family: OPPOSANS;
}
}
.all-rpice-item {
justify-content: flex-end;
align-items: center;
.title {
font-size: 26rpx;
font-weight: 500;
color: #3b3b3b;
line-height: normal;
}
}
}
.all-price {
color: #ee0a24 !important;
}
// 底部
.footer-box {
height: 100rpx;
width: 100%;
box-sizing: border-box;
border-radius: 10rpx;
padding-right: 20rpx;
.cancel-btn {
width: 160rpx;
height: 60rpx;
background: #eeeeee;
border-radius: 30rpx;
margin-right: 20rpx;
font-size: 26rpx;
font-weight: 400;
color: #333333;
}
.pay-btn {
width: 160rpx;
height: 60rpx;
font-size: 26rpx;
border-radius: 30rpx;
font-weight: 500;
color: #fff;
}
}
.cityImg {
width: 48rpx;
height: 48rpx;
margin-top: 16rpx;
margin-right: 16rpx;
image {
width: 100%;
height: 100%;
}
}
.order-goods {
padding: 24rpx 20rpx;
box-sizing: border-box;
background-color: #fff;
margin-bottom: 24rpx;
border-radius: 12rpx;
}
.right {
text-align: right;
}
.copy {
width: 32rpx;
height: 32rpx;
margin-left: 14rpx;
image {
width: 100%;
height: 100%;
}
}
.orderBan {
height: 100rpx;
width: 100%;
padding: 0 24rpx;
box-sizing: border-box;
box-shadow: 0px -4px 30px 0px rgba(0, 0, 0, 0.1);
}
.btns {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
padding: 10rpx 32rpx;
box-sizing: border-box;
}
</style>
+365
View File
@@ -0,0 +1,365 @@
<template>
<s-pages title="AI店铺" :goLeft="false" @onClickLeft="onClickLeft">
<view class="p-x-32 h100 flex-column">
<view class="search flex-center m-t-48 m-b-56">
<view class="searchLeft flex1 flex-center p-l-40 p-r-40">
<uni-icons class="m-r-20" type="search" color="#8F8F8F" size="" />
<uni-easyinput
class="flex1"
v-model="searchText"
type="text"
placeholder="请搜索想要的商品"
:inputBorder="false"
@blur="search"
@clear="clearSearch"
placeholderStyle="color: #D3D3D3;font-size: 28rpx;"
:styles="{ color: '', fontSize: '28rpx' }"
/>
</view>
<view class="m-l-24" @click="search">搜索</view>
</view>
<view class="flex1">
<card_pages
ref="pageCommodity"
:navList="nav"
:currentTab="index"
@upCallback="getData"
:height="height + 'px'"
:oneShow="true"
>
<template #nav>
<view class="flex-center ju-flex-start">
<view
v-for="(tab, i) in nav"
:key="tab.id"
class="m-r-32 navItem flex-center flex-column size28 line32 c28"
:class="{ active: index == i, c29: index == i }"
@click="navChange(i)"
>
<view class="">
{{ tab.name }}
</view>
<view class="navIcon p-b-10">
<image class="w100" :src="$ygUrl + 'ai_index_current.png'" mode="widthFix" />
</view>
</view>
</view>
<view class="m-b-20" v-if="timeRound.length && index === 0">
<scroll-view scroll-x class="time-scroll">
<view class="flex">
<view
v-for="(item, i) in timeRound"
:key="i"
class="timeNav m-r-30"
:class="{ activeTime: selectedTimeId === item.id }"
@click="changeTimeRound(item, i)"
>
{{ item.name }}
</view>
</view>
</scroll-view>
</view>
</template>
<template #content>
<view class="p-t-16">
<view class="m-b-24" v-for="(v, i) in dataList" :key="i">
<aiOrder
:data="v"
@addCar="addCar"
:source="index"
@update="update"
@shipment="shipment"
/>
</view>
</view>
</template>
</card_pages>
</view>
</view>
<view class="" v-if="payShow">
<card_payment
ref="paymentRef"
@updataList="clearSearch"
@updatePrice="updatePrice"
:addShow="addShow"
:minSalesCountShow="navName == '折扣区' ? true : false"
/>
</view>
</s-pages>
</template>
<script setup>
import { ref, reactive, onMounted, watch, getCurrentInstance } from 'vue';
import SpuApi from '@/sheep/api/product/spu';
import CartApi from '@/sheep/api/trade/cart.js';
import * as api from '@/sheep/api/ai/index';
import aiOrder from '@/components/ai_order/ai_order';
import card_payment from '@/components/card_payment/card_payment';
import { onShow } from '@dcloudio/uni-app';
const { proxy } = getCurrentInstance();
const searchText = ref('');
const search = (text = '') => {
pageCommodity.value.downCallback();
};
const clearSearch = () => {
searchText.value = '';
pageCommodity.value.downCallback();
};
const getCartList = async () => {
let res = await api.getShopCartList({});
if (res.code === 0) {
if (res.data.length || addShow.value) {
payShow.value = true;
} else {
payShow.value = false;
}
}
};
/* 选品广场时间轮次 */
const timeRound = ref([]);
const selectedTimeId = ref(null);
let navName = ref('');
function changeTimeRound(e, i) {
navName.value = e.name;
selectedTimeId.value = e?.id ?? null;
if (pageCommodity.value) {
pageCommodity.value.downCallback();
}
}
function getSpuTimeList() {
api.getSpuTimeList({}).then((res) => {
if (res.code === 0) {
timeRound.value = res.data || [];
selectedTimeId.value = timeRound.value?.[0]?.id ?? null;
navName.value = timeRound.value?.[0]?.name;
}
});
}
/* */
onShow(() => {
getSpuTimeList();
getCartList();
// if(paymentRef.value){
// paymentRef.value.getCartList()
// }
});
const update = () => {
if (pageCommodity.value) {
pageCommodity.value.downCallback();
}
};
// 购物车数据
let carArr = ref([]);
let height = ref(0);
let system = uni.getSystemInfoSync();
let h =
system.windowHeight -
system.statusBarHeight -
uni.upx2px(88) -
uni.upx2px(76) -
uni.upx2px(48) -
uni.upx2px(67) -
uni.upx2px(70) +
uni.upx2px(8);
let index = ref(0);
let price = ref(0);
let payShow = ref(false);
let addShow = ref(false);
watch(
() => [payShow.value],
() => {
if (payShow.value) {
height.value = h - uni.upx2px(128);
} else {
height.value = h;
}
},
{
immediate: true,
deep: true,
},
);
// watch(
// () => [carArr.value, index.value,price.value],
// () => {
// if (carArr.value.length && !index.value && price.value > 0) {
// payShow.value = true
// height.value = h - uni.upx2px(128);
// } else {
// payShow.value = false
// height.value = h;
// }
// },
// {
// immediate: true,
// deep: true,
// },
// );
let nav = ref([
{
name: '选品广场',
id: 1,
},
{
name: '我的店铺',
id: 2,
},
]);
let pageCommodity = ref(null);
let dataList = ref([]);
const getData = async (mescroll) => {
if (mescroll.dataObj.index != index.value) {
return;
}
let res = null;
if (index.value) {
res = await api.getOrderPage({
pageNo: mescroll?.num || 1,
pageSize: mescroll?.size || 10,
keyWord: searchText.value,
});
} else {
res = await api.getSpuPage({
pageNo: mescroll?.num || 1,
pageSize: mescroll?.size || 10,
keyWord: searchText.value,
timeId: selectedTimeId.value,
...mescroll.params,
});
}
// CartApi.getCartList()
if (res.code !== 0) {
pageCommodity.value.getState(false);
return;
}
let curPageData = []; // 当前页数据
if (index.value) {
let list = res.data.list;
let arr = [];
if (list.length) {
list.forEach((e) => {
e.items1 = JSON.parse(JSON.stringify(e.items));
if (e?.items?.length) {
e.items.forEach((item) => {
item.skuArr = item.items;
item.status = e.status;
item.id = item.spuId;
item.spuId = e.payOrderId;
item.shoppingPlazaId = e.roundTimeId;
item.items1 = e.items1
arr.push(item);
});
}
});
}
// 多规格
if (arr.length) {
arr.forEach((e) => {
if (e.skuArr && e.skuArr.length) {
e.skuArr.forEach((item) => {
item.propertyText = '';
if (item?.properties) {
item.properties.forEach((e1) => {
item.propertyText += e1.valueName + ' ';
});
}
});
}
});
}
curPageData = arr;
} else {
curPageData = res.data?.list || [];
}
if (mescroll?.num == 1) {
dataList.value = [];
}
dataList.value = dataList.value.concat(curPageData);
console.log(dataList.value);
pageCommodity.value.getState(true, curPageData.length);
};
let paymentRef = ref(null);
const addCar = (data) => {
payShow.value = true;
addShow.value = true;
setTimeout(() => {
if (paymentRef.value) {
paymentRef.value.addCar(data);
}
}, 500);
};
const navChange = (i) => {
index.value = i;
dataList.value = [];
if (pageCommodity.value) {
pageCommodity.value.downCallback();
}
if (index.value) {
payShow.value = false;
} else {
payShow.value = true;
}
};
const onClickLeft = () => {
uni.reLaunch({
url: '/pages/AI/member',
});
};
const updatePrice = (val) => {
addShow.value = val;
getCartList();
};
//延迟/立即发货
function shipment(e) {
pageCommodity.value.downCallback();
}
</script>
<style lang="scss" scoped>
.time-scroll {
width: 100%;
white-space: nowrap;
}
.timeNav {
display: inline-flex;
align-items: center;
font-size: 30rpx;
}
.searchLeft {
background: #fff;
height: 72rpx;
border-radius: 36rpx;
}
.navItem {
.navIcon {
opacity: 0;
width: 39rpx;
}
}
.active {
font-size: 32rpx !important;
.navIcon {
opacity: 1;
}
}
.c28 {
color: #000 !important;
}
.c29 {
color: #fb4d32 !important;
}
.activeTime {
color: #fb4d32;
font-weight: 600;
}
</style>
+632
View File
@@ -0,0 +1,632 @@
<template>
<s-layout navbar="inner" :goLeft="false" @onClickLeft="onClickLeft" theme="2" color="#ffffff" :index="1000">
<view class="theme-ai pages bg1" :style="{ top: -height + 'px' }">
<view class="w100 bg">
<image class="w100" :src="$ygUrl + 'ai_member_bg.png'" mode="widthFix" />
</view>
<view class="con p-t-282 p-x-32">
<view class="w100 flex-center m-b-48">
<view class="titleImg">
<image class="w100" :src="$ygUrl + 'member_1.png'" mode="widthFix" />
</view>
</view>
<view class="arr flex-row wrap w100 m-b-24">
<view class="item m-b-32" v-for="(v, i) in arr" :key="i">
<view class="itemBg">
<image class="w100" :src="$ygUrl + 'member_2.png'" mode="scaleToFill" />
</view>
<view class="itemCon flex-center p-y-24 p-l-8 p-r-22">
<view class="itemIcon shrink">
<image :src="v.icon" mode="widthFix" />
</view>
<view>
<view class="t1 size28 m-b-8 line38">{{ v.title }}</view>
<view class="t2 size22">{{ v.title1 }}</view>
</view>
</view>
</view>
</view>
<!-- 等级 -->
<view class="card3" v-if="!status && openStatus === 0">
<view class="card3_bg">
<image class="w100" :src="$ygUrl + 'ai_member_bg2.png'" mode="scaleToFill" />
</view>
<view class="text1 size24 p-x-14"> 限时福利 </view>
<view class="card3_img1">
<image class="w100" :src="$url + 'ai/member/9.png'" mode="widthFix" />
</view>
<view class="card3_con flex-center ju-flex-start p-t-54 p-b-44 p-l-22">
<view class="card3_img m-r-30">
<image class="w100" :src="$ygUrl + 'member_icon_5.png'" mode="widthFix" />
</view>
<view class="m-r-16">
<view class="m-b-8 c_money size56 weight900"><span class="size32">¥</span>{{
getPriceRes.activityPrice }}</view>
<view class="c12 through size24">原价¥{{ getPriceRes.originalPrice }}</view>
</view>
<view>
<view class="size32 c10 f500">数字居民</view>
<view class="size24 c11">尊贵身份 居民特享</view>
</view>
</view>
</view>
<view v-if="status && levelObj && levelObj.bgIcon" class="h_244 m-b-32 relative">
<view class="h100 w100">
<image class="h100 w100" :src="$url + levelObj.bgIcon" mode="scaleToFill" />
</view>
<view class="absolute w100 h100 flex-column ju-between t0 l0">
<view class="flex-row">
<view class="size22 p-x-16 h_40 line40 center m-t-4 m-l-4" :style="{
background: levelObj.color2,
color: levelObj.color1,
borderRadius: '16rpx 0 16rpx 0',
}">
当前等级<span v-if="level">V{{ level }}</span>
</view>
</view>
<view class="w_190 h_174 absolute t-32 r40">
<image class="w100 h100" :src="$url + levelObj.icon1" mode="scaleToFill" />
</view>
<view class="flex al-flex-end h_72">
<image class="w_208 h100 m-l-34" :src="$url + levelObj.textIcon" mode="scaleToFill" />
<!-- <view class="m-b-10">
<uni-icons type="star-filled" size="18" :color="levelObj.color1" v-for="(item,i) in 0" :key="i" />
</view> -->
<uni-rate :value="levelObj.levelStartNum" :max="levelObj.levelStarMax" size="18"
:color="levelObj.color2" :active-color="levelObj.color1" readonly class="m-b-10"
v-if="level !== 3 && status === 1" />
</view>
<view class="progress relative m-l-34">
<view class="w100 absolute t0 l0 h_8" :style="{ background: levelObj.bg2 }"></view>
<view class="absolute t0 l0 h_8" :style="{
background: levelObj.bg1,
width: `${userInfo?.progress?.currentProgress || 0}%`,
}">
</view>
<view class="absolute t-4 w_16 h_16 qiu radius16" :style="{
background: levelObj.bg1,
left: `${userInfo?.progress?.currentProgress || 0}%`,
}">
</view>
<view class="absolute t-34 w_80 center size20" :style="{
color: levelObj.bg1,
marginLeft: '-40rpx',
left: `${userInfo?.progress?.currentProgress || 0}%`,
}">
<!-- {{ parseInt(userInfo?.progress?.currentProgress) || 0 }}% -->
</view>
</view>
<view class="m-l-34 m-b-18 weight500 size22" :style="{ color: levelObj.color3 }">
{{ levelObj.text }}
</view>
</view>
</view>
<!-- m-b-258 -->
<view class="card4" v-if="mesArr.length">
<maoScroll :data="mesArr" :lineHeight="72" :animation="1000" :animationScroll="1000" :showNum="3">
<template #default="{ line }">
<view class="bg14 radius8 p-x-16 flex-center ju-flex-start h100"
style="display: line-block">
<view class="m-r-18 userImg flex-center">
<image class="w_56 h_56" :src="line.avatar" mode="scaleToFill" v-if="line.avatar"
style="border-radius: 50%" />
<image v-else class="w_56 h_56" :src="`${$url}home/head.png`" mode="scaleToFill"
style="border-radius: 50%" />
<view class="userType" v-if="userType[parseInt(line.userType)]?.icon">
<image class="w_20 h_20" :src="$url + userType[parseInt(line.userType)]?.icon"
mode="scaleToFill" />
</view>
</view>
<view class="size28 line54" v-html="line.messageContent"></view>
</view>
</template>
</maoScroll>
</view>
<!-- 商品 v-if="!status"-->
<view class="goods-wrap m-b-258">
<view class="goods-item" v-for="(item, i) in goods_list">
<view class="pic">
<view class="buy-status" v-if="status"> 已购买 </view>
<image :src="item.picUrl" />
</view>
<view class="right">
<view>
<view class="title lineTwo">
{{ item.name }}
</view>
<view class="spec">
<!-- xx | xx -->
</view>
</view>
<view class="bottom">
<view class="price"> <text>¥</text>{{ $fen2yuan(item.price) }} </view>
<view class="btn" @click="buyGoods(item)" v-if="!status && num"> 立即购买 </view>
<view class="btn" @click="goOrderDetail(item)" v-if="status"> 订单详情 </view>
</view>
</view>
</view>
</view>
<view class="card6 bg1">
<view class="ai-button" @click="sub" v-if="!status && num && openStatus === 0">
立即开通
</view>
<view class="ai-button" @click="sub" v-if="status"> 进入店铺 </view>
<view class="card5">
<view class="radio-box">
<radio-group @change="radioChange">
<label class="flex-center ju-flex-start">
<radio color="#FB4D32" class="radio" value="1" :checked="radioValue" />
<view class="flex-center size24">
我已阅读并同意
<text class="c8" @click="go()">《臻选优购服务协议》</text>
</view>
</label>
</radio-group>
</view>
</view>
</view>
</view>
</view>
</s-layout>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import maoScroll from '@/components/mao-scroll/mao-scroll';
import { userType } from '@/sheep/helper/user';
import * as api from '@/sheep/api/ai';
import sheep from '@/sheep';
let openStatus = ref(0); //判断是需要开通商品 0-不发货,1-发货
let { proxy } = getCurrentInstance();
let arr = ref([
{
icon: proxy.$ygUrl + 'member_icon_1.png',
title: '品牌中国 数字家园',
title1: '中国塑品牌 数字建家园',
},
{
icon: proxy.$ygUrl + 'member_icon_2.png',
title: '权益代码 数字账本',
title1: '代码明权属 账本存变动',
},
{
icon: proxy.$ygUrl + 'member_icon_3.png',
title: '数据驱动 平台赋能',
title1: '数据驱决策 平台赋动能​',
},
{
icon: proxy.$ygUrl + 'member_icon_4.png',
title: '高维素质 数字世界',
title1: '素质提维度 适配数字境',
},
]);
let mesArr = ref([]);
let orderId = ref();
let getPriceRes = reactive({
originalPrice: 0,
activityPrice: 0,
});
const radioValue = ref();
let goods_list = ref([]);
const radioChange = (e) => {
radioValue.value = e.detail.value;
};
const go = () => {
uni.navigateTo({
url: '/pages/home/agreement?type=4',
});
};
const goAIindex = () => {
proxy.utils.go('/pages/AI/index');
};
function buyGoods(e) {
if (!radioValue.value) {
proxy.utils.toast('请先阅读并同意协议');
return;
}
uni.navigateTo({
url: `/pages/AI/giftOrder?id=${e.id}`,
});
}
function goOrderDetail(e) {
uni.navigateTo({
url: `/pages/AI/giftOrderInfo?id=${orderId.value}`,
});
}
const sub = async () => {
if (radioValue.value) {
// proxy.utils.toast('开通成功');
// setTimeout(() => {
// proxy.utils.go('/pages/AI/index');
// }, 1000);
if (status.value) {
proxy.utils.go('/pages/AI/index');
return;
}
let res = await api.createOpen({});
setTimeout(() => {
proxy.utils.go('/pages/AI/cashierDesk', {
id: res.data.id,
payOrderId: res.data.payOrderId,
type: 2,
price: getPriceRes.activityPrice,
});
}, 1000);
} else {
proxy.utils.toast('请先阅读并同意协议');
}
};
let userInfo = ref({});
let level = ref(0);
let levelObj = ref({});
const getInfo = async () => {
let res: any = await api.getLevelInfo({});
if (res.code === 0) {
userInfo.value = res.data;
level.value = res.data.currentLevel?.level;
levelObj.value = userType[level.value];
//星星(推荐人)最大数量限制
if (level.value === 0) {
levelObj.value.levelStarMax = 5;
} else {
levelObj.value.levelStarMax = 3;
}
//星星(推荐人)数量
if (res.data.currentLevel.level === 3) {
levelObj.value.levelStartNum = 3;
} else {
levelObj.value.levelStartNum = 5 - Number(res.data.progress.upgradeRequirements.slice(2, 3));
}
// console.log(levelObj.value);
}
};
let num = ref(0);
let status = ref(0); // 0 未开通 1 已开通
//获取是否开通商品发货
async function getOpenStatus() {
const res = await api.getAiOpenStatus();
openStatus.value = res.data;
return res;
}
const loadPageData = async () => {
uni.showLoading({ title: '加载中' });
try {
const [openStatusRes, statusRes, messageRes, remainingRes, priceRes] = await Promise.all([
api.getAiOpenStatus(),
api.checkShopStatus({}),
api.getMessageList({ pageNo: 1, pageSize: 10 }),
api.getRemainingCount({}),
api.getPrice(),
]);
openStatus.value = openStatusRes.data;
status.value = statusRes.data;
await getProduct(status.value);
if (status.value) {
radioValue.value = true;
await getInfo();
}
mesArr.value = messageRes.code === 0 ? messageRes.data : [];
num.value = remainingRes.data;
if (remainingRes.code === 0 && remainingRes.data <= 0 && !status.value) {
uni.showModal({
title: '提示',
content: 'AI店铺开通数量已用完,请联系客服',
cancelText: '返回',
success: function (res) {
if (res.confirm) {
} else if (res.cancel) {
uni.navigateBack({ delta: 1 });
}
},
});
}
getPriceRes.activityPrice = Number(priceRes.data.activityPrice).toFixed(2);
getPriceRes.originalPrice = Number(priceRes.data.originalPrice).toFixed(2);
} finally {
uni.hideLoading();
}
};
onShow(async () => {
await loadPageData();
});
const onClickLeft = () => {
uni.switchTab({ url: '/pages/index/index' });
};
let sysInfo = uni.getSystemInfoSync();
const windowHeight = sysInfo.windowHeight;
let height = ref(0);
height.value = sysInfo.statusBarHeight + uni.upx2px(88);
//获取开通ai店铺赠送商品
function getProduct(status) {
if (status === 1) {
api.getGiftOrder().then((res) => {
orderId.value = res.data.id;
// console.log(res);
if (res.data) {
res.data.items.forEach((e) => {
e.name = e.spuName;
});
goods_list.value = res.data.items;
}
});
} else if (status === 0) {
if (openStatus.value === 1) {
api.getAiProduct({
pageNo: 1,
pageSize: 100,
}).then((res) => {
goods_list.value = res.data.list;
});
}
}
}
</script>
<style lang="scss" scoped>
.card4 {
margin-bottom: 60rpx;
}
.pages {
min-height: 100vh;
position: relative;
padding-bottom: 84rpx;
.bg {
z-index: 1;
position: absolute;
top: 0;
left: 0;
}
.con {
position: relative;
z-index: 20;
.goods-wrap {
.goods-item {
margin-bottom: 24rpx;
display: flex;
.pic {
width: 206rpx;
min-width: 206rpx;
height: 206rpx;
background: #d8d8d8;
border-radius: 12rpx;
overflow: hidden;
margin-right: 16rpx;
position: relative;
z-index: 0;
.buy-status {
background: #366eee;
// display: inline-flex;
border-radius: 0 0 12rpx 0;
font-size: 16rpx;
line-height: 28rpx;
padding: 0 8rpx;
position: absolute;
color: #fff;
top: 0;
left: 0;
z-index: 1;
}
image {
width: 100%;
height: 100%;
}
}
.right {
width: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
.title {
font-size: 28rpx;
// color: #FFFFFF;
line-height: 34rpx;
}
.spec {
font-size: 24rpx;
color: #999999;
line-height: 30rpx;
margin-top: 10rpx;
}
.bottom {
display: flex;
align-items: center;
justify-content: space-between;
.price {
color: #ee0a24;
line-height: 42rpx;
text {
font-size: 24rpx;
}
}
.btn {
line-height: 54rpx;
border-radius: 94rpx;
background: linear-gradient(270deg, var(--color3) 0%, var(--color2) 99%);
padding: 0 24rpx;
color: #fff;
}
}
}
}
}
.titleImg {
width: calc(566 / 686 * 100%);
}
.arr {
.item {
width: calc(100% / 2 - 15rpx);
margin-right: 30rpx;
&:nth-child(2n) {
margin-right: 0;
}
position: relative;
.itemBg {
position: absolute;
width: 100%;
height: 100%;
image {
width: 100%;
height: 100%;
}
}
.itemIcon {
width: 60rpx;
image {
width: 100%;
}
}
.itemCon {
position: relative;
.t1 {
color: #f13428;
}
.t2 {
color: #f7772e;
}
}
}
}
}
}
.card3 {
position: relative;
margin-bottom: 44rpx;
.f500 {
color: #fb4d32 !important;
}
.c11 {
color: #f7772e !important;
}
.card3_img {
width: 108rpx;
}
.card3_bg {
position: absolute;
width: 100%;
height: 100%;
image {
width: 100%;
height: 100%;
}
}
.card3_con {
position: relative;
}
.text1 {
position: absolute;
left: 28rpx;
top: -20rpx;
line-height: 40rpx;
background: linear-gradient(128deg, #f1873b 0%, #ec5d2d 99%);
color: #fff;
border-radius: 8rpx;
}
.card3_img1 {
width: 129rpx;
position: absolute;
top: 0;
right: 0;
}
}
.card4 {
.bg14 {
background: #fff !important;
}
}
.card5 {
margin-top: 20rpx;
.c8 {
color: #fb4d32 !important;
}
.radio-box {}
.radio {
transform: scale(0.6);
}
}
:deep(.uni-radio-input) {
background-color: rgba($color: #000000, $alpha: 0);
}
.userImg {
position: relative;
.userType {
position: absolute;
bottom: 0rpx;
right: -10rpx;
}
}
.card5 {}
.card6 {
width: 100%;
position: fixed;
bottom: 0rpx;
left: 0;
padding: 0 32rpx;
box-sizing: border-box;
padding-top: 24rpx;
padding-bottom: 50rpx;
.ai-button {
color: #fff;
}
}
.progress {
width: 63%;
}
.qiu {}
.level-title {
font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
font-weight: 400;
font-size: 51rpx;
line-height: 66rpx;
}
</style>
+524
View File
@@ -0,0 +1,524 @@
<!-- 订单详情 -->
<template>
<s-pages title="订单详情">
<view class="flex-center al-flex-end ju-between p-x-32 m-b-54">
<view>
<view class="size40 weight500 m-b-16">{{ statusObj[state.orderInfo.status]?.text }}</view>
<view class="size24">{{ statusObj[state.orderInfo.status]?.text1 }}</view>
</view>
<view class="w_120 h_120" v-if="statusObj[state.orderInfo.status]?.icon">
<image
class="w100 h100"
:src="statusObj[state.orderInfo.status]?.icon"
mode="scaleToFill"
/>
</view>
</view>
<!-- 收货地址 -->
<view class="order-address-box flex-row bg24 c0" v-if="state.orderInfo.receiverAreaId > 0">
<view class="cityImg">
<image :src="`${$url}goods/city1.png`" mode="scaleToFill" />
</view>
<view class="size32">
<view class="ss-flex ss-col-center">
<text class="address-username">
{{ state.orderInfo.receiverName }}
</text>
<text class="address-phone">{{ state.orderInfo.receiverMobile }}</text>
</view>
<view class="address-detail size32">
{{ state.orderInfo.receiverAreaName }} {{ state.orderInfo.receiverDetailAddress }}
</view>
</view>
</view>
<view
class="detail-goods"
:style="[{ marginTop: state.orderInfo.receiverAreaId > 0 ? '0' : '-40rpx' }]"
>
<card_order
theme="2"
class="order-goods"
v-if="state?.orderInfo?.items?.length > 0"
:data="state.orderInfo"
type="4"
@getOrderDetail="getOrderDetail"
></card_order>
<!-- 价格信息 -->
<view class="order-price-box bg24">
<view class="notice-item ss-flex ss-row-between" v-for="(v, i) in priceArr" :key="i">
<text class="title c25">{{ v.title }}</text>
<view class="ss-flex">
<text class="detail c0" :class="{ 'all-price': v.value == 'payPrice' }"
><span>{{ v.type == 2 ? '-' : '' }}</span
>¥{{ fen2yuan(state.orderInfo[v.value]) }}</text
>
</view>
</view>
</view>
<!-- 订单信息 -->
<view
class="notice-box bg24"
:class="{
'm-b-90':
statusObj[state.orderInfo.status]?.btn1 || statusObj[state.orderInfo.status]?.btn2,
}"
>
<view class="notice-box__content">
<view class="notice-item--center">
<view class="ss-flex ss-flex-1 flex-row ju-between">
<text class="title c25">订单编号</text>
<text class="detail right c0">{{ state.orderInfo.no }}</text>
</view>
<view class="copy" @click.stop="onCopy">
<image :src="`${$url}goods/copy2.svg`" mode="scaleToFill" />
</view>
<!-- <truckLine :data="state.orderInfo" :code="2" v-if="state.orderInfo.deliveryTime"></truckLine> -->
</view>
<view class="notice-item flex-row ju-between">
<text class="title c25">下单时间</text>
<text class="detail right c0">
{{ sheep.$helper.timeFormat(state.orderInfo.createTime, 'yyyy-mm-dd hh:MM:ss') }}
</text>
</view>
<view class="notice-item flex-row ju-between" v-if="state.orderInfo.payTime">
<text class="title c25">支付时间:</text>
<text class="detail right c0">
{{ sheep.$helper.timeFormat(state.orderInfo.payTime, 'yyyy-mm-dd hh:MM:ss') }}
</text>
</view>
<view class="notice-item flex-row ju-between">
<text class="title c25">支付方式</text>
<text class="detail right c0">{{ state.orderInfo.payChannelName || '-' }}</text>
</view>
</view>
</view>
<view
class="flex btns bg16"
v-if="statusObj[state.orderInfo.status]?.btn1 || statusObj[state.orderInfo.status]?.btn2"
>
<view
class="ai-button1 h_70 line70 size28"
:class="{
'm-r-28': statusObj[state.orderInfo.status]?.btn2,
}"
v-if="statusObj[state.orderInfo.status]?.btn1"
@click="btn(1)"
>{{ statusObj[state.orderInfo.status]?.btn1 }}</view
>
<view
class="ai-button3 h_70 line70 size28"
v-if="statusObj[state.orderInfo.status]?.btn2"
@click="btn(2)"
>{{ statusObj[state.orderInfo.status]?.btn2 }}</view
>
</view>
</view>
</s-pages>
</template>
<script setup>
import sheep from '@/sheep';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { reactive, ref, getCurrentInstance } from 'vue';
import { isEmpty } from 'lodash-es';
import {
fen2yuan,
formatOrderStatus,
formatOrderStatusDescription,
handleOrderButtons,
} from '@/sheep/hooks/useGoods';
import * as OrderApi from '@/sheep/api/ai/index';
import DeliveryApi from '@/sheep/api/trade/delivery';
import PickUpVerify from '@/pages/order/pickUpVerify.vue';
import card_order from '@/components/orderItem/card_order.vue';
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
const headerBg = sheep.$url.css('/static/img/shop/order/order_bg.png');
let { proxy } = getCurrentInstance();
const state = reactive({
orderInfo: {},
merchantTradeNo: '', // 商户订单号
comeinType: '', // 进入订单详情的来源类型
});
let statusObj = ref({
0: {
text: '待付款',
text1: '付款时间还剩余',
btn1: '去支付',
btn2: '取消订单',
},
10: {
text: '待发货',
text1: '您的商品即将发货...',
icon: `${proxy.$url}ai/member/12.png`,
},
20: {
text: '待收货',
text1: '您的商品已发货,待您确认收货...',
icon: `${proxy.$url}ai/member/12.png`,
btn1: '确认收货',
},
30: {
text: '已完成',
text1: '您的订单已完成,感谢您的购买!',
},
40: {
text: '已取消',
text1: '您的订单已取消!',
},
});
// ========== 门店自提(核销) ==========
const systemStore = ref({}); // 门店信息
// 复制
const onCopy = () => {
sheep.$helper.copyText(state.orderInfo.no);
};
const pickUpVerifyRef = ref();
let orderId = ref();
async function getOrderDetail() {
let id = orderId.value;
// 对详情数据进行适配
let res;
res = await OrderApi.getOrderDetail({ id });
if (res.code === 0) {
state.orderInfo = res.data;
handleOrderButtons(state.orderInfo);
if (state.orderInfo.deliveryType === 2 && state.orderInfo.payStatus) {
pickUpVerifyRef.value && pickUpVerifyRef.value.markCode(res.data.pickUpVerifyCode);
}
} else {
}
}
onShow(async () => {
//onShow中获取订单列表,保证跳转后页面为最新状态
await getOrderDetail();
});
onLoad(async (options) => {
if (options.id) {
orderId.value = options.id;
}
// await getOrderDetail();
});
const priceArr = ref([
{
title: '商品金额',
value: 'totalPrice',
type: 1,
},
{
title: '运费',
value: 'deliveryPrice',
type: 1,
},
{
title: '实付金额',
value: 'payPrice',
type: 1,
},
]);
const btn = async (type) => {
if (state.orderInfo.status === 0 && type === 1) {
// 去支付
goPay();
}
if (state.orderInfo.status === 0 && type === 2) {
// 取消订单
cancelOrder();
}
if (state.orderInfo.status === 20 && type === 1) {
// 确认收货confirmReceive
OrderApi.confirmReceive({
id: orderId.value,
}).then((res) => {
if (res.code === 0) {
getOrderDetail();
}
});
}
};
const goPay = () => {
proxy.utils.go('/pages/AI/cashierDesk', {
id: state.orderInfo.id,
payOrderId: state.orderInfo.payOrderId,
});
};
const cancelOrder = () => {
OrderApi.cancelOrder({
id: orderId.value,
}).then((res) => {
if (res.code === 0) {
getOrderDetail();
}
});
};
</script>
<style lang="scss" scoped>
.score-img {
width: 36rpx;
height: 36rpx;
margin: 0 4rpx;
}
.apply-btn {
width: 140rpx;
height: 50rpx;
border-radius: 25rpx;
font-size: 24rpx;
border: 2rpx solid #dcdcdc;
line-height: normal;
margin-left: 16rpx;
}
.state-box {
color: rgba(#fff, 0.9);
width: 100%;
background: v-bind(headerBg) no-repeat,
linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
background-size: 750rpx 100%;
box-sizing: border-box;
.state-img {
width: 60rpx;
height: 60rpx;
margin-right: 20rpx;
}
}
.order-address-box {
background-color: #fff;
border-radius: 12rpx;
margin: 20rpx 32rpx 24rpx 32rpx;
padding: 24rpx 30rpx 24rpx 20rpx;
font-size: 32rpx;
box-sizing: border-box;
color: #1b1b21;
.address-username {
margin-right: 20rpx;
}
.address-detail {
margin-top: 20rpx;
}
}
.detail-goods {
border-radius: 10rpx;
padding: 0 32rpx;
.order-list {
margin-bottom: 20rpx;
background-color: #fff;
.order-card {
padding: 20rpx 0;
.order-sku {
font-size: 24rpx;
font-weight: 400;
color: rgba(153, 153, 153, 1);
width: 450rpx;
margin-bottom: 20rpx;
.order-num {
margin-right: 10rpx;
}
}
.tag-btn {
margin-left: 16rpx;
font-size: 24rpx;
height: 36rpx;
color: var(--ui-BG-Main);
border: 2rpx solid var(--ui-BG-Main);
border-radius: 14rpx;
padding: 0 4rpx;
}
}
}
}
// 订单信息。
.notice-box {
background: #fff;
border-radius: 12rpx;
margin-bottom: 24rpx;
.notice-box__head {
font-size: 30rpx;
font-weight: 500;
color: rgba(51, 51, 51, 1);
line-height: 80rpx;
border-bottom: 1rpx solid #dfdfdf;
padding: 0 25rpx;
}
.notice-box__content {
padding: 20rpx;
.self-pickup-box {
width: 100%;
.self-pickup--img {
width: 200rpx;
height: 200rpx;
margin: 40rpx 0;
}
}
}
.notice-item,
.notice-item--center {
display: flex;
align-items: center;
line-height: normal;
margin-bottom: 24rpx;
.title {
font-size: 28rpx;
color: #3b3b3b;
}
.detail {
font-size: 28rpx;
color: #323232;
flex: 1;
}
}
}
.copy-btn {
width: 100rpx;
line-height: 50rpx;
border-radius: 25rpx;
padding: 0;
background: rgba(238, 238, 238, 1);
font-size: 22rpx;
font-weight: 400;
color: rgba(51, 51, 51, 1);
}
// 订单价格信息
.order-price-box {
background-color: #fff;
border-radius: 12rpx;
padding: 20rpx;
margin-bottom: 24rpx;
.notice-item {
line-height: 70rpx;
.title {
font-size: 28rpx;
color: #3b3b3b;
}
.detail {
font-size: 28rpx;
color: #323232;
font-family: OPPOSANS;
}
}
.all-rpice-item {
justify-content: flex-end;
align-items: center;
.title {
font-size: 26rpx;
font-weight: 500;
color: #3b3b3b;
line-height: normal;
}
}
}
.all-price {
color: #ee0a24 !important;
}
// 底部
.footer-box {
height: 100rpx;
width: 100%;
box-sizing: border-box;
border-radius: 10rpx;
padding-right: 20rpx;
.cancel-btn {
width: 160rpx;
height: 60rpx;
background: #eeeeee;
border-radius: 30rpx;
margin-right: 20rpx;
font-size: 26rpx;
font-weight: 400;
color: #333333;
}
.pay-btn {
width: 160rpx;
height: 60rpx;
font-size: 26rpx;
border-radius: 30rpx;
font-weight: 500;
color: #fff;
}
}
.cityImg {
width: 48rpx;
height: 48rpx;
margin-top: 16rpx;
margin-right: 16rpx;
image {
width: 100%;
height: 100%;
}
}
.order-goods {
padding: 24rpx 20rpx;
box-sizing: border-box;
background-color: #fff;
margin-bottom: 24rpx;
border-radius: 12rpx;
}
.right {
text-align: right;
}
.copy {
width: 32rpx;
height: 32rpx;
margin-left: 14rpx;
image {
width: 100%;
height: 100%;
}
}
.orderBan {
height: 100rpx;
width: 100%;
padding: 0 24rpx;
box-sizing: border-box;
box-shadow: 0px -4px 30px 0px rgba(0, 0, 0, 0.1);
}
.btns {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
padding: 10rpx 32rpx;
box-sizing: border-box;
}
</style>
+152
View File
@@ -0,0 +1,152 @@
<template>
<s-pages title="确认订单">
<view class="p-b-132">
<AddressSelection v-model="addressState" theme="2" @getSettlementInfo="getSettlementInfo" />
<view class="p-x-32 m-t-24">
<view class="bg24 p-x-20 p-t-20 radius16">
<view v-if="settlementInfo.items && settlementInfo.items.length">
<view class="m-b-24" v-for="(v, i) in settlementInfo.items" :key="i">
<aiOrder :data="v" :source="3" idName="spuId"/>
</view>
</view>
<view class="flex-row ju-between m-b-36">
<view class="c25 size28">商品金额</view>
<view>¥{{ $fen2yuan(settlementInfo?.price?.payPrice || 0) }}</view>
</view>
<view class="flex-row ju-between m-b-36">
<view class="c25 size28">运费</view>
<view>¥{{ $fen2yuan(settlementInfo?.price?.deliveryPrice || 0) }}</view>
</view>
<view class="flex-center ju-flex-end borderTop">
<span class="size26 line96">合计: </span>
<span class="c13 size28 m-l-12 line96 weight900"
>¥{{ $fen2yuan(settlementInfo?.price?.payPrice || 0) }}</span
>
</view>
</view>
</view>
</view>
<view class="p-x-32 btn">
<view class="ai-button2" @click="sub">确认订单</view>
</view>
</s-pages>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick } from 'vue';
import AddressSelection from '@/pages/order/addressSelection.vue';
import { onLoad } from '@dcloudio/uni-app';
import aiOrder from '@/components/ai_order/ai_order';
import api from '@/sheep/api/member/address';
let { proxy } = getCurrentInstance();
import * as SpuApi from '@/sheep/api/ai/index';
const addressState = ref({
addressInfo: {}, // 选择的收货地址
deliveryType: 1, // 收货方式:1-快递配送,2-门店自提
isPickUp: false, // 门店自提是否开启
pickUpInfo: {}, // 选择的自提门店信息
receiverName: '', // 收件人名称
receiverMobile: '', // 收件人手机
});
const cartList = ref([]);
const getCartList = () => {
SpuApi.getShopCartList({}).then((res) => {
let list = res.data || [];
if (list.length) {
list.forEach((e) => {
e.skuArr = JSON.parse(e.specification);
});
}
cartList.value = list;
});
};
// 获取订单结算信息
const settlementInfo = ref({});
let addressId = ref('');
const getSettlementInfo = (id = '') => {
addressId.value = id;
SpuApi.getSettlementInfo({
id: id,
}).then((res) => {
settlementInfo.value = res.data || {};
if (proxy.$fen2yuan(settlementInfo?.price?.payPrice || 0) >= 5000) {
proxy.utils.toast('订单金额不能超过5000元');
}
if (settlementInfo.value?.items?.length) {
settlementInfo.value.items.forEach((e) => {
e.skuArr = e.items;
e.skuArr.forEach((item) => {
item.propertyText = '';
item.properties.forEach((e1) => {
item.propertyText += e1.valueName + ' ';
});
});
});
}
});
};
const sub = async () => {
if (proxy.$fen2yuan(settlementInfo?.price?.payPrice || 0) >= 5000) {
proxy.utils.toast('订单金额不能超过5000元, 请重新选择商品');
return;
}
if (!addressId.value) return proxy.utils.toast('请选择地址');
let res: any = await SpuApi.createOrder({ id: addressId.value });
if (res.code === 0) {
proxy.utils.toast('下单成功');
setTimeout(() => {
// proxy.utils.go('/pages/AI/cashierDesk', {
// id: res.data.id,
// payOrderId: res.data.payOrderId,
// });
uni.redirectTo({
url: '/pages/AI/cashierDesk?id=' + res.data.id + '&payOrderId=' + res.data.payOrderId,
});
}, 1000);
} else {
}
};
const getAddress = () => {
api.getAddressList().then((res) => {
if (res.code === 0 && res.data?.length) {
// addressState.value.addressInfo = res.data[0];
// getSettlementInfo(res.data[0].id);
let index = res.data.findIndex((e) => e.defaultStatus);
if (index !== -1) {
addressState.value.addressInfo = res.data[index];
getSettlementInfo(res.data[index].id);
} else {
getSettlementInfo();
}
} else {
getSettlementInfo();
}
});
};
onLoad(() => {
// getCartList();
getAddress();
});
</script>
<style lang="scss" scoped>
.pages {
}
.bottom {
}
.borderTop {
border-top: 1px solid #d4d4d4;
}
.btn {
width: 100%;
position: fixed;
bottom: 0rpx;
padding-top: 10rpx;
padding-bottom: 20rpx;
// background: #03011d;
}
</style>
+551
View File
@@ -0,0 +1,551 @@
<!-- 拼团订单的详情 -->
<template>
<s-layout
title="拼团详情"
class="detail-wrap"
:navbar="state.data && !state.loading ? 'inner' : 'normal'"
:onShareAppMessage="shareInfo"
>
<view v-if="state.loading"></view>
<view v-if="state.data && !state.loading">
<!-- 团长信息 + 活动信息 -->
<view
class="recharge-box"
v-if="state.data.headRecord"
:style="[
{
marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
paddingTop: Number(statusBarHeight + 108) + 'rpx',
},
]"
>
<s-goods-item
class="goods-box"
:img="state.data.headRecord.picUrl"
:title="state.data.headRecord.spuName"
:price="state.data.headRecord.combinationPrice"
priceColor="#E1212B"
@tap="
sheep.$router.go('/pages/goods/groupon', {
id: state.data.headRecord.activityId,
})
"
:style="[{ top: Number(statusBarHeight + 108) + 'rpx' }]"
>
<template #groupon>
<view class="ss-flex">
<view class="sales-title">{{ state.data.headRecord.userSize }}人团</view>
<view class="num-title ss-m-l-20">已拼{{ state.data.headRecord.userCount }}件</view>
</view>
</template>
</s-goods-item>
</view>
<view class="countdown-box detail-card ss-p-t-44 ss-flex-col ss-col-center">
<!-- 情况一:拼团成功 -->
<view v-if="state.data.headRecord.status === 1">
<view v-if="state.data.orderId">
<view class="countdown-title ss-flex">
<text class="cicon-check-round" />
恭喜您~拼团成功
</view>
</view>
<view v-else>
<view class="countdown-title ss-flex">
<text class="cicon-info" />
抱歉~该团已满员
</view>
</view>
</view>
<!-- 情况二:拼团失败 -->
<view v-if="state.data.headRecord.status === 2">
<view class="countdown-title ss-flex">
<text class="cicon-info"></text>
{{ state.data.orderId ? '拼团超时,已自动退款' : '该团已解散' }}
</view>
</view>
<!-- 情况三:拼团进行中 -->
<view v-if="state.data.headRecord.status === 0">
<view v-if="state.data.headRecord.expireTime <= new Date().getTime()">
<view class="countdown-title ss-flex">
<text class="cicon-info"></text>
拼团已结束,请关注下次活动
</view>
</view>
<view class="countdown-title ss-flex" v-else>
还差
<view class="num"
>{{ state.data.headRecord.userSize - state.data.headRecord.userCount }}人</view
>
拼团成功
<view class="ss-flex countdown-time">
<view class="countdown-h ss-flex ss-row-center">{{ endTime.h }}</view>
<view class="ss-m-x-4">:</view>
<view class="countdown-num ss-flex ss-row-center">
{{ endTime.m }}
</view>
<view class="ss-m-x-4">:</view>
<view class="countdown-num ss-flex ss-row-center">
{{ endTime.s }}
</view>
</view>
</view>
</view>
<!-- 拼团的记录列表,展示每个参团人 -->
<view class="ss-m-t-60 ss-flex ss-flex-wrap ss-row-center">
<!-- 团长 -->
<view class="header-avatar ss-m-r-24 ss-m-b-20">
<image
:src="
sheep.$url.cdn(state.data.headRecord.avatar) ||
sheep.$url.static('/static/img/shop/default_avatar.png')
"
class="avatar-img"
></image>
<view class="header-tag ss-flex ss-col-center ss-row-center">团长</view>
</view>
<!-- 团员 -->
<view
class="header-avatar ss-m-r-24 ss-m-b-20"
v-for="item in state.data.memberRecords"
:key="item.id"
>
<image
:src="
sheep.$url.cdn(item.avatar) ||
sheep.$url.static('/static/img/shop/default_avatar.png')
"
class="avatar-img"
></image>
<view
class="header-tag ss-flex ss-col-center ss-row-center"
v-if="item.is_leader == '1'"
>
团长
</view>
</view>
<!-- 还有几个坑位 -->
<view
class="default-avatar ss-m-r-24 ss-m-b-20"
v-for="item in state.remainNumber"
:key="item"
>
<image
:src="sheep.$url.static('/static/img/shop/avatar/unknown.png')"
class="avatar-img"
></image>
</view>
</view>
</view>
<!-- 情况一:拼团成功;情况二:拼团失败 -->
<view
v-if="state.data.headRecord.status === 1 || state.data.headRecord.status === 2"
class="ss-m-t-40 ss-flex ss-row-center"
>
<button
class="ss-reset-button order-btn"
v-if="state.data.orderId"
@tap="onDetail(state.data.orderId)"
>
查看订单
</button>
<button class="ss-reset-button join-btn" v-else @tap="onCreateGroupon"> 我要开团 </button>
</view>
<!-- 情况三:拼团进行中,查看订单或参加或邀请好友或参加 -->
<view v-if="state.data.headRecord.status === 0" class="ss-m-t-40 ss-flex ss-row-center">
<view v-if="state.data.headRecord.expireTime <= new Date().getTime()">
<button
class="ss-reset-button join-btn"
v-if="state.data.orderId"
@tap="onDetail(state.data.orderId)"
>
查看订单
</button>
<button
class="ss-reset-button disabled-btn"
v-else
disabled
@tap="onDetail(state.data.orderId)"
>
去参团
</button>
</view>
<view v-else class="ss-flex ss-row-center">
<view v-if="state.data.orderId">
<button class="ss-reset-button join-btn" :disabled="endTime.ms <= 0" @tap="onShare">
邀请好友来拼团
</button>
</view>
<view v-else>
<button
class="ss-reset-button join-btn"
:disabled="endTime.ms <= 0"
@tap="onJoinGroupon()"
>
立即参团
</button>
</view>
</view>
</view>
<view v-if="!isEmpty(state.goodsInfo)">
<!-- 规格与数量弹框 -->
<s-select-groupon-sku
:show="state.showSelectSku"
:goodsInfo="state.goodsInfo"
:grouponAction="state.grouponAction"
:grouponNum="state.grouponNum"
@buy="onBuy"
@change="onSkuChange"
@close="state.showSelectSku = false"
/>
</view>
</view>
<s-empty v-if="!state.data && !state.loading" icon="/static/goods-empty.png" />
</s-layout>
</template>
<script setup>
import { computed, reactive } from 'vue';
import sheep from '@/sheep';
import { onLoad } from '@dcloudio/uni-app';
import { fen2yuan, useDurationTime } from '@/sheep/hooks/useGoods';
import { showShareModal } from '@/sheep/hooks/useModal';
import { isEmpty } from 'lodash-es';
import CombinationApi from '@/sheep/api/promotion/combination';
import SpuApi from '@/sheep/api/product/spu';
import { SharePageEnum } from '@/sheep/helper/const';
const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
const state = reactive({
data: {}, // 拼团详情
goodsId: 0, // 商品ID
goodsInfo: {}, // 商品信息
showSelectSku: false, // 显示规格弹框
selectedSkuPrice: {}, // 选中的规格价格
activity: {}, // 团购活动
grouponId: 0, // 团购ID
grouponNum: 0, // 团购人数
grouponAction: 'create', // 团购操作
combinationHeadId: null, // 拼团团长编号
loading: true,
});
const shareInfo = computed(() => {
if (isEmpty(state.data)) return {};
return sheep.$platform.share.getShareInfo(
{
title: state.data.headRecord.spuName,
image: sheep.$url.cdn(state.data.headRecord.picUrl),
desc: state.data.goods?.subtitle,
params: {
page: SharePageEnum.GROUPON_DETAIL.value,
query: state.data.headRecord.id,
},
},
{
type: 'groupon', // 邀请拼团海报
title: state.data.headRecord.spuName, // 商品标题
image: sheep.$url.cdn(state.data.headRecord.picUrl), // 商品主图
price: fen2yuan(state.data.headRecord.combinationPrice), // 商品价格
grouponNum: state.data.headRecord.userSize, // 拼团人数
},
);
});
// 订单详情
function onDetail(orderId) {
sheep.$router.go('/pages/order/detail', {
id: orderId,
});
}
// 去开团
function onCreateGroupon() {
state.grouponAction = 'create';
state.grouponId = 0;
state.showSelectSku = true;
}
// 规格变更
function onSkuChange(e) {
state.selectedSkuPrice = e;
}
// 立即参团
function onJoinGroupon() {
state.grouponAction = 'join';
state.grouponId = state.data.headRecord.activityId;
state.combinationHeadId = state.data.headRecord.id;
state.grouponNum = state.data.headRecord.userSize;
state.showSelectSku = true;
}
// 立即购买
function onBuy(sku) {
sheep.$router.go('/pages/order/confirm', {
data: JSON.stringify({
order_type: 'goods',
combinationActivityId: state.activity.id,
combinationHeadId: state.combinationHeadId,
items: [
{
skuId: sku.id,
count: sku.count,
},
],
}),
});
}
const endTime = computed(() => {
return useDurationTime(state.data.headRecord.expireTime);
});
// 获取拼团团队详情
async function getGrouponDetail(id) {
const { code, data } = await CombinationApi.getCombinationRecordDetail(id);
if (code === 0) {
state.data = data;
const remainNumber = Number(state.data.headRecord.userSize - state.data.headRecord.userCount);
state.remainNumber = remainNumber > 0 ? remainNumber : 0;
// 获取活动信息
const { data: activity } = await CombinationApi.getCombinationActivity(
data.headRecord.activityId,
);
state.activity = activity;
state.grouponNum = activity.userSize;
// 加载商品信息
const { data: spu } = await SpuApi.getSpuDetail(activity.spuId);
state.goodsId = spu.id;
// 默认显示最低价
activity.products.forEach((product) => {
spu.price = Math.min(spu.price, product.combinationPrice); // 设置 SPU 的最低价格
});
state.goodsInfo = spu;
// 价格、库存使用活动的
spu.skus.forEach((sku) => {
const product = activity.products.find((product) => product.skuId === sku.id);
if (product) {
sku.price = product.combinationPrice;
} else {
// 找不到可能是没配置,则不能发起秒杀
sku.stock = 0;
}
});
} else {
state.data = null;
}
state.loading = false;
}
function onShare() {
showShareModal();
}
onLoad((options) => {
getGrouponDetail(options.id);
});
</script>
<style lang="scss" scoped>
.recharge-box {
position: relative;
margin-bottom: 120rpx;
background: v-bind(headerBg) center/750rpx 100% no-repeat,
linear-gradient(115deg, #f44739 0%, #ff6600 100%);
border-radius: 0 0 5% 5%;
height: 100rpx;
.goods-box {
width: 710rpx;
border-radius: 20rpx;
position: absolute;
left: 20rpx;
box-sizing: border-box;
}
.sales-title {
height: 32rpx;
background: rgba(#ffe0e2, 0.29);
border-radius: 16rpx;
font-size: 24rpx;
font-weight: 400;
padding: 6rpx 20rpx;
color: #f7979c;
}
.num-title {
font-size: 24rpx;
font-weight: 400;
color: #999999;
}
}
.countdown-time {
font-size: 26rpx;
font-weight: 500;
color: #383a46;
.countdown-h {
font-size: 24rpx;
font-family: OPPOSANS;
font-weight: 500;
color: #ffffff;
padding: 0 4rpx;
margin-left: 16rpx;
height: 40rpx;
background: linear-gradient(90deg, #ff6000 0%, #fe832a 100%);
border-radius: 6rpx;
}
.countdown-num {
font-size: 24rpx;
font-family: OPPOSANS;
font-weight: 500;
color: #ffffff;
width: 40rpx;
height: 40rpx;
background: linear-gradient(90deg, #ff6000 0%, #fe832a 100%);
border-radius: 6rpx;
}
}
.countdown-box {
// height: 364rpx;
background: #ffffff;
border-radius: 10rpx;
box-sizing: border-box;
.countdown-title {
font-size: 28rpx;
font-weight: 500;
color: #333333;
.cicon-check-round {
color: #42b111;
margin-right: 24rpx;
}
.cicon-info {
color: #d71e08;
margin-right: 24rpx;
}
.num {
color: #ff6000;
}
}
.header-avatar {
width: 86rpx;
height: 86rpx;
background: #ececec;
border-radius: 50%;
border: 4rpx solid #edc36c;
position: relative;
box-sizing: border-box;
.avatar-img {
width: 100%;
height: 100%;
border-radius: 50%;
}
.header-tag {
width: 72rpx;
height: 36rpx;
font-size: 24rpx;
line-height: nor;
background: linear-gradient(132deg, #f3dfb1, #f3dfb1, #ecbe60);
border-radius: 16rpx;
position: absolute;
left: 4rpx;
top: -36rpx;
}
}
.default-avatar {
width: 86rpx;
height: 86rpx;
background: #ececec;
border-radius: 50%;
.avatar-img {
width: 100%;
height: 100%;
border-radius: 50%;
}
}
.user-avatar {
width: 86rpx;
height: 86rpx;
background: #ececec;
border-radius: 50%;
}
}
.order-btn {
width: 668rpx;
height: 70rpx;
border: 2rpx solid #dfdfdf;
border-radius: 35rpx;
color: #999999;
font-weight: 500;
font-size: 26rpx;
line-height: normal;
}
.disabled-btn {
width: 668rpx;
height: 70rpx;
background: #dddddd;
border-radius: 35rpx;
color: #999999;
font-weight: 500;
font-size: 28rpx;
line-height: normal;
}
.join-btn {
width: 668rpx;
height: 70rpx;
background: linear-gradient(90deg, #ff6000 0%, #fe832a 100%);
box-shadow: 0px 8rpx 6rpx 0px rgba(255, 104, 4, 0.22);
border-radius: 35rpx;
color: #fff;
font-weight: 500;
font-size: 28rpx;
line-height: normal;
}
.detail-cell-wrap {
width: 100%;
padding: 10rpx 20rpx;
box-sizing: border-box;
border-top: 2rpx solid #dfdfdf;
background-color: #fff;
// min-height: 60rpx;
.label-text {
font-size: 28rpx;
font-weight: 400;
}
.cell-content {
font-size: 28rpx;
font-weight: 500;
color: $dark-6;
}
.right-forwrad-icon {
font-size: 28rpx;
font-weight: 500;
color: $dark-9;
}
}
</style>
+225
View File
@@ -0,0 +1,225 @@
<!-- 拼团活动列表 -->
<template>
<s-layout :bgStyle="{ color: '#FE832A' }" navbar="inner">
<view class="page-bg" :style="[{ marginTop: '-' + Number(statusBarHeight + 88) + 'rpx' }]" />
<view class="list-content">
<!-- 参团会员统计 -->
<view class="content-header ss-flex-col ss-col-center ss-row-center">
<view class="content-header-title ss-flex ss-row-center">
<view
v-for="(item, index) in state.summaryData.avatars"
:key="index"
class="picture"
:style="index === 6 ? 'position: relative' : 'position: static'"
>
<span class="avatar" :style="`background-image: url(${item})`" />
<span v-if="index === 6 && state.summaryData.avatars.length > 3" class="mengceng">
<i>···</i>
</span>
</view>
<text class="pic_count">{{ state.summaryData.userCount || 0 }}人参与</text>
</view>
</view>
<scroll-view
class="scroll-box"
:style="{ height: pageHeight + 'rpx' }"
scroll-y="true"
:scroll-with-animation="false"
:enable-back-to-top="true"
>
<view class="goods-box ss-m-b-20" v-for="item in state.pagination.list" :key="item.id">
<s-goods-column
class=""
size="lg"
:data="item"
:grouponTag="true"
@click="sheep.$router.go('/pages/goods/groupon', { id: item.id })"
>
<template v-slot:cart>
<button class="ss-reset-button cart-btn">去拼团</button>
</template>
</s-goods-column>
</view>
<uni-load-more
v-if="state.pagination.total > 0"
:status="state.loadStatus"
:content-text="{
contentdown: '上拉加载更多',
}"
@tap="loadMore"
/>
</scroll-view>
</view>
</s-layout>
</template>
<script setup>
import { reactive } from 'vue';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import CombinationApi from '@/sheep/api/promotion/combination';
const { safeAreaInsets, safeArea } = sheep.$platform.device;
const sysNavBar = sheep.$platform.navbar;
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
const pageHeight =
(safeArea.height + safeAreaInsets.bottom) * 2 + statusBarHeight - sysNavBar - 350;
const headerBg = sheep.$url.css('/static/img/shop/goods/groupon-header.png');
const state = reactive({
pagination: {
list: [],
total: 0,
pageNo: 1,
pageSize: 10,
},
loadStatus: '',
summaryData: {},
});
// 加载统计数据
const getSummary = async () => {
const { data } = await CombinationApi.getCombinationRecordSummary();
state.summaryData = data;
};
// 加载活动列表
async function getList() {
state.loadStatus = 'loading';
const { data } = await CombinationApi.getCombinationActivityPage({
pageNo: state.pagination.pageNo,
pageSize: state.pagination.pageSize,
});
data.list.forEach((activity) => {
state.pagination.list.push({ ...activity, price: activity.combinationPrice });
});
state.pagination.total = data.total;
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
}
// 加载更多
function loadMore() {
if (state.loadStatus === 'noMore') {
return;
}
state.pagination.pageNo++;
getList();
}
// 上拉加载更多
onReachBottom(() => loadMore());
// 页面初始化
onLoad(() => {
getSummary();
getList();
});
</script>
<style lang="scss" scoped>
.page-bg {
width: 100%;
height: 458rpx;
margin-top: -88rpx;
background: v-bind(headerBg) no-repeat;
background-size: 100% 100%;
}
.list-content {
position: relative;
z-index: 3;
margin: -190rpx 20rpx 0 20rpx;
background: #fff;
border-radius: 20rpx 20rpx 0 0;
.content-header {
width: 100%;
border-radius: 20rpx 20rpx 0 0;
height: 100rpx;
background: linear-gradient(180deg, #fff4f7, #ffe4d1);
.content-header-title {
width: 100%;
font-size: 30rpx;
font-weight: 500;
color: #ff2923;
line-height: 30rpx;
position: relative;
.more {
position: absolute;
right: 30rpx;
top: 0;
font-size: 24rpx;
font-weight: 400;
color: #999999;
line-height: 30rpx;
}
.picture {
display: inline-table;
}
.avatar {
width: 38rpx;
height: 38rpx;
display: inline-table;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
border-radius: 50%;
background-repeat: no-repeat;
background-size: cover;
background-position: 0 0;
margin-right: -10rpx;
box-shadow: 0 0 0 1px #fe832a;
}
.pic_count {
margin-left: 30rpx;
font-size: 22rpx;
font-weight: 500;
width: auto;
height: auto;
background: linear-gradient(90deg, #ff6600 0%, #fe832a 100%);
color: #ffffff;
border-radius: 19rpx;
padding: 4rpx 14rpx;
}
.mengceng {
width: 40rpx;
height: 40rpx;
line-height: 36rpx;
background: rgba(51, 51, 51, 0.6);
text-align: center;
border-radius: 50%;
opacity: 1;
position: absolute;
left: -2rpx;
color: #fff;
top: 2rpx;
i {
font-style: normal;
font-size: 20rpx;
}
}
}
}
.scroll-box {
height: 900rpx;
.goods-box {
position: relative;
.cart-btn {
position: absolute;
bottom: 10rpx;
right: 20rpx;
z-index: 11;
height: 50rpx;
line-height: 50rpx;
padding: 0 20rpx;
border-radius: 25rpx;
font-size: 24rpx;
color: #fff;
background: linear-gradient(90deg, #ff6600 0%, #fe832a 100%);
}
}
}
}
</style>
+240
View File
@@ -0,0 +1,240 @@
<!-- 我的拼团订单列表 -->
<template>
<s-layout title="我的拼团">
<su-sticky bgColor="#fff">
<su-tabs
:list="tabMaps"
:scrollable="false"
@change="onTabsChange"
:current="state.currentTab"
></su-tabs>
</su-sticky>
<s-empty v-if="state.pagination.total === 0" icon="/static/goods-empty.png" />
<view v-if="state.pagination.total > 0">
<view
class="order-list-card-box bg-white ss-r-10 ss-m-t-14 ss-m-20"
v-for="record in state.pagination.list"
:key="record.id"
>
<view class="order-card-header ss-flex ss-col-center ss-row-between ss-p-x-20">
<view class="order-no">拼团编号:{{ record.id }}</view>
<view class="ss-font-26" :class="formatOrderColor(record)">
{{ tabMaps.find((item) => item.value === record.status).name }}
</view>
</view>
<view class="border-bottom">
<s-goods-item
:img="record.picUrl"
:title="record.spuName"
:price="record.combinationPrice"
>
<template #groupon>
<view class="ss-flex">
<view class="sales-title"> {{ record.userSize }} 人团 </view>
</view>
</template>
</s-goods-item>
</view>
<view class="order-card-footer ss-flex ss-row-right ss-p-x-20">
<button
class="detail-btn ss-reset-button"
@tap="sheep.$router.go('/pages/order/detail', { id: record.orderId })"
>
订单详情
</button>
<button
class="tool-btn ss-reset-button"
:class="{ 'ui-BG-Main-Gradient': record.status === 0 }"
@tap="sheep.$router.go('/pages/activity/groupon/detail', { id: record.id })"
>
{{ record.status === 0 ? '邀请拼团' : '拼团详情' }}
</button>
</view>
</view>
</view>
<uni-load-more
v-if="state.pagination.total > 0"
:status="state.loadStatus"
:content-text="{
contentdown: '上拉加载更多',
}"
@tap="loadMore"
/>
</s-layout>
</template>
<script setup>
import { reactive } from 'vue';
import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import _ from 'lodash-es';
import { formatOrderColor } from '@/sheep/hooks/useGoods';
import { resetPagination } from '@/sheep/helper/utils';
import CombinationApi from '@/sheep/api/promotion/combination';
// 数据
const state = reactive({
currentTab: 0,
pagination: {
list: [],
total: 0,
pageNo: 1,
pageSize: 5,
},
loadStatus: '',
deleteOrderId: 0,
});
const tabMaps = [
{
name: '全部',
},
{
name: '进行中',
value: 0,
},
{
name: '拼团成功',
value: 1,
},
{
name: '拼团失败',
value: 2,
},
];
// 切换选项卡
function onTabsChange(e) {
resetPagination(state.pagination);
state.currentTab = e.index;
getGrouponList();
}
// 获取订单列表
async function getGrouponList() {
state.loadStatus = 'loading';
const { code, data } = await CombinationApi.getCombinationRecordPage({
pageNo: state.pagination.pageNo,
pageSize: state.pagination.pageSize,
status: tabMaps[state.currentTab].value,
});
if (code !== 0) {
return;
}
state.pagination.list = _.concat(state.pagination.list, data.list);
state.pagination.total = data.total;
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
}
onLoad((options) => {
if (options.type) {
state.currentTab = options.type;
}
getGrouponList();
});
// 加载更多
function loadMore() {
if (state.loadStatus === 'noMore') {
return;
}
state.pagination.pageNo++;
getGrouponList();
}
// 上拉加载更多
onReachBottom(() => {
loadMore();
});
//下拉刷新
onPullDownRefresh(() => {
resetPagination(state.pagination);
getGrouponList();
setTimeout(function () {
uni.stopPullDownRefresh();
}, 800);
});
</script>
<style lang="scss" scoped>
.swiper-box {
flex: 1;
.swiper-item {
height: 100%;
width: 100%;
}
}
.order-list-card-box {
.order-card-header {
height: 80rpx;
.order-no {
font-size: 26rpx;
font-weight: 500;
}
}
.order-card-footer {
height: 100rpx;
.detail-btn {
width: 210rpx;
height: 66rpx;
border: 2rpx solid #dfdfdf;
border-radius: 33rpx;
font-size: 26rpx;
font-weight: 400;
color: #999999;
margin-right: 20rpx;
}
.tool-btn {
width: 210rpx;
height: 66rpx;
border-radius: 33rpx;
font-size: 26rpx;
font-weight: 400;
margin-right: 20rpx;
background: #f6f6f6;
}
.invite-btn {
width: 210rpx;
height: 66rpx;
background: linear-gradient(90deg, #fe832a, #ff6600);
box-shadow: 0px 8rpx 6rpx 0px rgba(255, 104, 4, 0.22);
border-radius: 33rpx;
color: #fff;
font-size: 26rpx;
font-weight: 500;
}
}
}
.sales-title {
height: 32rpx;
background: rgba(#ffe0e2, 0.29);
border-radius: 16rpx;
font-size: 24rpx;
font-weight: 400;
padding: 6rpx 20rpx;
color: #f7979c;
}
.num-title {
font-size: 24rpx;
font-weight: 400;
color: #999999;
}
.warning-color {
color: #faad14;
}
.danger-color {
color: #ff3000;
}
.success-color {
color: #52c41a;
}
</style>
+214
View File
@@ -0,0 +1,214 @@
<!-- 指定满减送的活动列表 -->
<template>
<s-layout class="activity-wrap" :title="state.activityInfo.title">
<!-- 活动信息 -->
<su-sticky bgColor="#fff">
<view class="ss-flex ss-col-top tip-box">
<view class="type-text ss-flex ss-row-center">满减:</view>
<view class="ss-flex-1">
<view class="tip-content" v-for="item in state.activityInfo.rules" :key="item">
{{ item.description }}
</view>
</view>
<image class="activity-left-image" src="/static/activity-left.png" />
<image class="activity-right-image" src="/static/activity-right.png" />
</view>
</su-sticky>
<!-- 商品信息 -->
<view class="ss-flex ss-flex-wrap ss-p-x-20 ss-m-t-20 ss-col-top">
<view class="goods-list-box">
<view class="left-list" v-for="item in state.leftGoodsList" :key="item.id">
<s-goods-column
class="goods-md-box"
size="md"
:data="item"
@click="sheep.$router.go('/pages/goods/index', { id: item.id })"
@getHeight="mountMasonry($event, 'left')"
>
<template v-slot:cart>
<button class="ss-reset-button cart-btn"> </button>
</template>
</s-goods-column>
</view>
</view>
<view class="goods-list-box">
<view class="right-list" v-for="item in state.rightGoodsList" :key="item.id">
<s-goods-column
class="goods-md-box"
size="md"
:data="item"
@click="sheep.$router.go('/pages/goods/index', { id: item.id })"
@getHeight="mountMasonry($event, 'right')"
>
<template v-slot:cart>
<button class="ss-reset-button cart-btn" />
</template>
</s-goods-column>
</view>
</view>
</view>
<uni-load-more
v-if="state.pagination.total > 0"
:status="state.loadStatus"
:content-text="{
contentdown: '上拉加载更多',
}"
@tap="loadMore"
/>
</s-layout>
</template>
<script setup>
import { reactive } from 'vue';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import _ from 'lodash-es';
import RewardActivityApi from '@/sheep/api/promotion/rewardActivity';
import SpuApi from '@/sheep/api/product/spu';
import { appendSettlementProduct } from '@/sheep/hooks/useGoods';
import OrderApi from '@/sheep/api/trade/order';
const state = reactive({
activityId: 0, // 获得编号
activityInfo: {}, // 获得信息
pagination: {
list: [],
total: 1,
pageNo: 1,
pageSize: 8,
},
loadStatus: '',
leftGoodsList: [],
rightGoodsList: [],
});
// 加载瀑布流
let count = 0;
let leftHeight = 0;
let rightHeight = 0;
function mountMasonry(height = 0, where = 'left') {
if (!state.pagination.list[count]) return;
if (where === 'left') {
leftHeight += height;
} else {
rightHeight += height;
}
if (leftHeight <= rightHeight) {
state.leftGoodsList.push(state.pagination.list[count]);
} else {
state.rightGoodsList.push(state.pagination.list[count]);
}
count++;
}
// 加载商品信息
async function getList() {
// 处理拓展参数
const params = {};
if (state.activityInfo.productScope === 2) {
params.ids = state.activityInfo.productSpuIds.join(',');
} else if (state.activityInfo.productScope === 3) {
params.categoryIds = state.activityInfo.productSpuIds.join(',');
}
// 请求数据
state.loadStatus = 'loading';
const { code, data } = await SpuApi.getSpuPage({
pageNo: state.pagination.pageNo,
pageSize: state.pagination.pageSize,
...params,
});
if (code !== 0) {
return;
}
// 拼接结算信息(营销)
await OrderApi.getSettlementProduct(data.list.map((item) => item.id).join(',')).then((res) => {
if (res.code !== 0) {
return;
}
appendSettlementProduct(data.list, res.data);
});
state.pagination.list = _.concat(state.pagination.list, data.list);
state.pagination.total = data.total;
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
mountMasonry();
}
// 加载活动信息
async function getActivity(id) {
const { code, data } = await RewardActivityApi.getRewardActivity(id);
if (code === 0) {
state.activityInfo = data;
}
}
// 加载更多
function loadMore() {
if (state.loadStatus === 'noMore') {
return;
}
state.pagination.pageNo++;
getList();
}
// 上拉加载更多
onReachBottom(() => {
loadMore();
});
onLoad(async (options) => {
state.activityId = options.activityId;
await getActivity(state.activityId);
await getList(state.activityId);
});
</script>
<style lang="scss" scoped>
.goods-list-box {
width: 50%;
box-sizing: border-box;
.left-list {
margin-right: 10rpx;
margin-bottom: 20rpx;
}
.right-list {
margin-left: 10rpx;
margin-bottom: 20rpx;
}
}
.tip-box {
background: #fff0e7;
padding: 20rpx;
width: 100%;
position: relative;
box-sizing: border-box;
.activity-left-image {
position: absolute;
bottom: 0;
left: 0;
width: 58rpx;
height: 36rpx;
}
.activity-right-image {
position: absolute;
top: 0;
right: 0;
width: 72rpx;
height: 50rpx;
}
.type-text {
font-size: 26rpx;
font-weight: 500;
color: #ff6000;
line-height: 42rpx;
}
.tip-content {
font-size: 26rpx;
font-weight: 500;
color: #ff6000;
line-height: 42rpx;
}
}
</style>
+76
View File
@@ -0,0 +1,76 @@
<!-- 积分商城:商品列表 -->
<template>
<s-layout title="积分商城" navbar="normal" :leftWidth="0" :rightWidth="0">
<scroll-view
class="scroll-box"
:style="{ height: pageHeight + 'rpx' }"
scroll-y="true"
:scroll-with-animation="false"
:enable-back-to-top="true"
>
<s-point-card ref="sPointCardRef" class="ss-p-x-20 ss-m-t-20" />
<s-empty
v-if="activityTotal === 0"
icon="/static/goods-empty.png"
text="暂无积分商品"
></s-empty>
<uni-load-more
v-if="activityTotal > 0"
:status="loadStatus"
:content-text="{
contentdown: '上拉加载更多',
}"
@tap="loadMore"
/>
</scroll-view>
</s-layout>
</template>
<script setup>
import sheep from '@/sheep';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import { reactive, ref } from 'vue';
import PointApi from '@/sheep/api/promotion/point';
import SLayout from '@/sheep/components/s-layout/s-layout.vue';
// 计算页面高度
const { safeAreaInsets, safeArea } = sheep.$platform.device;
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
const pageHeight =
(safeArea.height + safeAreaInsets.bottom) * 2 + statusBarHeight - sheep.$platform.navbar - 350;
const sPointCardRef = ref();
// 查询活动列表
const activityPageParams = reactive({
pageNo: 1, // 页码
pageSize: 5, // 每页数量
});
const activityTotal = ref(0); // 活动总数
const activityCount = ref(0); // 已加载活动数量
const loadStatus = ref(''); // 页面加载状态
async function getActivityList() {
loadStatus.value = 'loading';
const { data } = await PointApi.getPointActivityPage(activityPageParams);
await sPointCardRef.value.concatActivity(data.list);
activityCount.value = sPointCardRef.value.getActivityCount();
activityTotal.value = data.total;
loadStatus.value = activityCount.value < activityTotal.value ? 'more' : 'noMore';
}
// 加载更多
function loadMore() {
if (loadStatus.value !== 'noMore') {
activityPageParams.pageNo += 1;
getActivityList();
}
}
// 上拉加载更多
onReachBottom(() => {
loadMore();
});
onLoad(() => {
getActivityList();
});
</script>
+460
View File
@@ -0,0 +1,460 @@
<!-- 秒杀活动列表 -->
<template>
<s-layout :bgStyle="{ color: 'rgb(245,28,19)' }" navbar="inner">
<!--顶部背景图-->
<view
class="page-bg"
:style="[{ marginTop: '-' + Number(statusBarHeight + 88) + 'rpx' }]"
></view>
<!-- 时间段轮播图 -->
<view class="header" v-if="activeTimeConfig?.sliderPicUrls?.length > 0">
<swiper
indicator-dots="true"
autoplay="true"
:circular="true"
interval="3000"
duration="1500"
indicator-color="rgba(255,255,255,0.6)"
indicator-active-color="#fff"
>
<block v-for="(picUrl, index) in activeTimeConfig.sliderPicUrls" :key="index">
<swiper-item class="borRadius14">
<image :src="picUrl" class="slide-image borRadius14" lazy-load />
</swiper-item>
</block>
</swiper>
</view>
<!-- 时间段列表 -->
<view class="flex align-center justify-between ss-p-25">
<!-- 左侧图标 -->
<view class="time-icon">
<image
class="ss-w-100 ss-h-100"
:src="sheep.$url.static('/static/img/shop/priceTag.png')"
/>
</view>
<scroll-view
class="time-list"
:scroll-into-view="activeTimeElId"
scroll-x
scroll-with-animation
>
<view
v-for="(config, index) in timeConfigList"
:key="index"
:class="['item', { active: activeTimeIndex === index }]"
:id="`timeItem${index}`"
@tap="handleChangeTimeConfig(index, config.id)"
>
<!-- 活动起始时间 -->
<view class="time">{{ config.startTime }}</view>
<!-- 活动状态 -->
<view class="status">{{ config?.status }}</view>
</view>
</scroll-view>
</view>
<!-- 内容区 -->
<view class="list-content">
<!-- 活动倒计时 -->
<view class="content-header ss-flex-col ss-col-center ss-row-center">
<view class="content-header-box ss-flex ss-row-center">
<view
class="countdown-box ss-flex"
v-if="activeTimeConfig?.status === TimeStatusEnum.STARTED"
>
<view class="countdown-title ss-m-r-12">距结束</view>
<view class="ss-flex countdown-time">
<view class="ss-flex countdown-h">{{ countDown.h }}</view>
<view class="ss-m-x-4">:</view>
<view class="countdown-num ss-flex ss-row-center">{{ countDown.m }}</view>
<view class="ss-m-x-4">:</view>
<view class="countdown-num ss-flex ss-row-center">{{ countDown.s }}</view>
</view>
</view>
<view v-else> {{ activeTimeConfig?.status }} </view>
</view>
</view>
<!-- 活动列表 -->
<scroll-view
class="scroll-box"
:style="{ height: pageHeight + 'rpx' }"
scroll-y="true"
:scroll-with-animation="false"
:enable-back-to-top="true"
>
<view class="goods-box ss-m-b-20" v-for="activity in activityList" :key="activity.id">
<s-goods-column
size="lg"
:data="{ ...activity, price: activity.seckillPrice }"
:goodsFields="goodsFields"
:seckillTag="true"
>
<!-- 抢购进度 -->
<template #activity>
<view class="limit">
限量
<text class="ss-m-l-5">{{ activity.stock }} {{ activity.unitName }}</text>
</view>
<su-progress :percentage="activity.percent" strokeWidth="10" textInside isAnimate />
</template>
<!-- 抢购按钮 -->
<template #cart>
<button
:class="[
'ss-reset-button cart-btn',
{ disabled: activeTimeConfig?.status === TimeStatusEnum.END },
]"
v-if="activeTimeConfig?.status === TimeStatusEnum.WAIT_START"
>
<span>未开始</span>
</button>
<button
:class="[
'ss-reset-button cart-btn',
{ disabled: activeTimeConfig?.status === TimeStatusEnum.END },
]"
@click="sheep.$router.go('/pages/goods/seckill', { id: activity.id })"
v-else-if="activeTimeConfig?.status === TimeStatusEnum.STARTED"
>
<span>马上抢</span>
</button>
<button
:class="[
'ss-reset-button cart-btn',
{ disabled: activeTimeConfig?.status === TimeStatusEnum.END },
]"
v-else
>
<span>已结束</span>
</button>
</template>
</s-goods-column>
</view>
<uni-load-more
v-if="activityTotal > 0"
:status="loadStatus"
:content-text="{
contentdown: '上拉加载更多',
}"
@tap="loadMore"
/>
</scroll-view>
</view>
</s-layout>
</template>
<script setup>
import { computed, nextTick, reactive, ref } from 'vue';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import { useDurationTime } from '@/sheep/hooks/useGoods';
import SeckillApi from '@/sheep/api/promotion/seckill';
import dayjs from 'dayjs';
import { TimeStatusEnum } from '@/sheep/helper/const';
// 计算页面高度
const { safeAreaInsets, safeArea } = sheep.$platform.device;
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
const pageHeight =
(safeArea.height + safeAreaInsets.bottom) * 2 + statusBarHeight - sheep.$platform.navbar - 350;
const headerBg = sheep.$url.css('/static/img/shop/goods/seckill-header.png');
// 商品控件显示的字段(不显示库存、销量。改为显示自定义的进度条)
const goodsFields = {
name: {
show: true,
},
introduction: {
show: true,
},
price: {
show: true,
},
marketPrice: {
show: true,
},
};
//#region 时间段
// 时间段列表
const timeConfigList = ref([]);
// 查询时间段
const getSeckillConfigList = async () => {
const { data } = await SeckillApi.getSeckillConfigList();
const now = dayjs();
const today = now.format('YYYY-MM-DD');
const select = ref([]);
// 判断时间段的状态
data.forEach((config, index) => {
const startTime = dayjs(`${today} ${config.startTime}`);
const endTime = dayjs(`${today} ${config.endTime}`);
select.value[index] = config.id;
if (now.isBefore(startTime)) {
config.status = TimeStatusEnum.WAIT_START;
} else if (now.isAfter(endTime)) {
config.status = TimeStatusEnum.END;
} else {
config.status = TimeStatusEnum.STARTED;
activeTimeIndex.value = index;
}
});
timeConfigList.value = data;
// 默认选中进行中的活动
handleChangeTimeConfig(activeTimeIndex.value, select.value[activeTimeIndex.value]);
// 滚动到进行中的时间段
scrollToTimeConfig(activeTimeIndex.value);
};
// 滚动到指定时间段
const activeTimeElId = ref(''); // 当前选中的时间段的元素ID
const scrollToTimeConfig = (index) => {
nextTick(() => (activeTimeElId.value = `timeItem${index}`));
};
// 切换时间段
const activeTimeIndex = ref(0); // 当前选中的时间段的索引
const activeTimeConfig = computed(() => timeConfigList.value[activeTimeIndex.value]); // 当前选中的时间段
const handleChangeTimeConfig = (index, id) => {
activeTimeIndex.value = index;
// 查询活动列表
activityPageParams.pageNo = 1;
activityPageParams.configId = id;
activityList.value = [];
getActivityList();
};
// 倒计时
const countDown = computed(() => {
const endTime = activeTimeConfig.value?.endTime;
if (endTime) {
return useDurationTime(`${dayjs().format('YYYY-MM-DD')} ${endTime}`);
}
});
//#endregion
//#region 分页查询活动列表
// 查询活动列表
const activityPageParams = reactive({
configId: 0, // 时间段 ID
pageNo: 1, // 页码
pageSize: 5, // 每页数量
});
const activityTotal = ref(0); // 活动总数
const activityList = ref([]); // 活动列表
const loadStatus = ref(''); // 页面加载状态
async function getActivityList() {
loadStatus.value = 'loading';
const { data } = await SeckillApi.getSeckillActivityPage(activityPageParams);
data.list.forEach((activity) => {
// 计算抢购进度
activity.percent = parseInt(
(100 * (activity.totalStock - activity.stock)) / activity.totalStock,
);
});
activityList.value = activityList.value.concat(...data.list);
activityTotal.value = data.total;
loadStatus.value = activityList.value.length < activityTotal.value ? 'more' : 'noMore';
}
// 加载更多
function loadMore() {
if (loadStatus.value !== 'noMore') {
activityPageParams.pageNo += 1;
getActivityList();
}
}
// 上拉加载更多
onReachBottom(() => loadMore());
//#endregion
// 页面初始化
onLoad(async () => {
await getSeckillConfigList();
});
</script>
<style lang="scss" scoped>
// 顶部背景图
.page-bg {
width: 100%;
height: 458rpx;
background: v-bind(headerBg) no-repeat;
background-size: 100% 100%;
}
// 时间段轮播图
.header {
width: 710rpx;
height: 330rpx;
margin: -276rpx auto 0 auto;
border-radius: 14rpx;
overflow: hidden;
swiper {
height: 330rpx !important;
border-radius: 14rpx;
overflow: hidden;
}
image {
width: 100%;
height: 100%;
border-radius: 14rpx;
overflow: hidden;
img {
border-radius: 14rpx;
}
}
}
// 时间段列表:左侧图标
.time-icon {
width: 75rpx;
height: 70rpx;
}
// 时间段列表
.time-list {
width: 596rpx;
white-space: nowrap;
// 时间段
.item {
display: inline-block;
font-size: 20rpx;
color: #666;
text-align: center;
box-sizing: border-box;
margin-right: 30rpx;
width: 130rpx;
// 开始时间
.time {
font-size: 36rpx;
font-weight: 600;
color: #333;
}
// 选中的时间段
&.active {
.time {
color: var(--ui-BG-Main);
}
// 状态
.status {
height: 30rpx;
line-height: 30rpx;
border-radius: 15rpx;
width: 128rpx;
background: linear-gradient(90deg, var(--ui-BG-Main) 0%, var(--ui-BG-Main-gradient) 100%);
color: #fff;
}
}
}
}
// 内容区
.list-content {
position: relative;
z-index: 3;
margin: 0 20rpx 0 20rpx;
background: #fff;
border-radius: 20rpx 20rpx 0 0;
.content-header {
width: 100%;
border-radius: 20rpx 20rpx 0 0;
height: 150rpx;
background: linear-gradient(180deg, #fff4f7, #ffe6ec);
.content-header-box {
width: 678rpx;
height: 64rpx;
background: rgba($color: #fff, $alpha: 0.66);
border-radius: 32px;
// 场次倒计时内容
.countdown-title {
font-size: 28rpx;
font-weight: 500;
color: #333333;
line-height: 28rpx;
}
// 场次倒计时
.countdown-time {
font-size: 28rpx;
color: rgba(#ed3c30, 0.23);
// 场次倒计时:小时部分
.countdown-h {
font-size: 24rpx;
font-family: OPPOSANS;
font-weight: 500;
color: #ffffff;
padding: 0 4rpx;
height: 40rpx;
background: rgba(#ed3c30, 0.23);
border-radius: 6rpx;
}
// 场次倒计时:分钟、秒
.countdown-num {
font-size: 24rpx;
font-family: OPPOSANS;
font-weight: 500;
color: #ffffff;
width: 40rpx;
height: 40rpx;
background: rgba(#ed3c30, 0.23);
border-radius: 6rpx;
}
}
}
}
// 活动列表
.scroll-box {
height: 900rpx;
// 活动
.goods-box {
position: relative;
// 抢购按钮
.cart-btn {
position: absolute;
bottom: 10rpx;
right: 20rpx;
z-index: 11;
height: 44rpx;
line-height: 50rpx;
padding: 0 20rpx;
border-radius: 25rpx;
font-size: 24rpx;
color: #fff;
background: linear-gradient(90deg, #ff6600 0%, #fe832a 100%);
&.disabled {
background: $gray-b;
color: #fff;
}
}
// 秒杀限量商品数
.limit {
font-size: 22rpx;
color: $dark-9;
margin-bottom: 5rpx;
}
}
}
}
</style>
+452
View File
@@ -0,0 +1,452 @@
<!-- 签到界面 -->
<template>
<s-layout title="签到有礼">
<s-empty v-if="state.loading" icon="/static/data-empty.png" text="签到活动还未开始" />
<view v-if="state.loading" />
<view class="sign-wrap" v-else-if="!state.loading">
<!-- 签到日历 -->
<view class="content-box calendar">
<view class="sign-everyday ss-flex ss-col-center ss-row-between ss-p-x-30">
<text class="sign-everyday-title">签到日历</text>
<view class="sign-num-box">
已连续签到 <text class="sign-num">{{ state.signInfo.continuousDay }}</text> 天
</view>
</view>
<view
class="list acea-row row-between-wrapper"
style="
padding: 0 30rpx;
height: 240rpx;
display: flex;
justify-content: space-between;
align-items: center;
"
>
<view class="item" v-for="(item, index) in state.signConfigList" :key="index">
<view
:class="
(index === state.signConfigList.length ? 'reward' : '') +
' ' +
(state.signInfo.continuousDay >= item.day ? 'rewardTxt' : '')
"
>
第{{ item.day }}天
</view>
<view
class="venus"
:class="
(index + 1 === state.signConfigList.length ? 'reward' : '') +
' ' +
(state.signInfo.continuousDay >= item.day ? 'venusSelect' : '')
"
>
</view>
<view class="num" :class="state.signInfo.continuousDay >= item.day ? 'on' : ''">
+ {{ item.point }}
</view>
</view>
</view>
<!-- 签到按钮 -->
<view class="myDateTable">
<view class="ss-flex ss-col-center ss-row-center sign-box ss-m-y-40">
<button
class="ss-reset-button sign-btn"
v-if="!state.signInfo.todaySignIn"
@tap="onSign"
>
签到
</button>
<button class="ss-reset-button already-btn" v-else disabled> 已签到 </button>
</view>
</view>
</view>
<!-- 签到说明 -->
<view class="bg-white ss-m-t-16 ss-p-t-30 ss-p-b-60 ss-p-x-40">
<view class="activity-title ss-m-b-30">签到说明</view>
<view class="activity-des">1.已累计签到{{ state.signInfo.totalDay }}天</view>
<view class="activity-des">
2.据说连续签到第 {{ state.maxDay }} 天可获得超额积分,要坚持签到哦~~
</view>
<view class="activity-des"> 3.积分可以在购物时抵现金结算的哦 ~~</view>
</view>
</view>
<!-- 签到结果弹窗 -->
<su-popup :show="state.showModel" type="center" round="10" :isMaskClick="false">
<view class="model-box ss-flex-col">
<view class="ss-m-t-56 ss-flex-col ss-col-center">
<text class="cicon-check-round"></text>
<view class="score-title">
<text v-if="state.signResult.point">{{ state.signResult.point }} 积分 </text>
<text v-if="state.signResult.experience"> {{ state.signResult.experience }} 经验</text>
</view>
<view class="model-title ss-flex ss-col-center ss-m-t-22 ss-m-b-30">
已连续打卡 {{ state.signResult.day }} 天
</view>
</view>
<view class="model-bg ss-flex-col ss-col-center ss-row-right">
<view class="title ss-m-b-64">签到成功</view>
<view class="ss-m-b-40">
<button class="ss-reset-button confirm-btn" @tap="onConfirm">确认</button>
</view>
</view>
</view>
</su-popup>
</s-layout>
</template>
<script setup>
import sheep from '@/sheep';
import { onReady } from '@dcloudio/uni-app';
import { reactive } from 'vue';
import SignInApi from '@/sheep/api/member/signin';
const headerBg = sheep.$url.css('/static/img/shop/app/sign.png');
const state = reactive({
loading: true,
signInfo: {}, // 签到信息
signConfigList: [], // 签到配置列表
maxDay: 0, // 最大的签到天数
showModel: false, // 签到弹框
signResult: {}, // 签到结果
});
// 发起签到
async function onSign() {
const { code, data } = await SignInApi.createSignInRecord();
if (code !== 0) {
return;
}
state.showModel = true;
state.signResult = data;
// 重新获得签到信息
await getSignInfo();
}
// 签到确认刷新页面
function onConfirm() {
state.showModel = false;
}
// 获得个人签到统计
async function getSignInfo() {
const { code, data } = await SignInApi.getSignInRecordSummary();
if (code !== 0) {
return;
}
state.signInfo = data;
state.loading = false;
}
// 获取签到配置
async function getSignConfigList() {
const { code, data } = await SignInApi.getSignInConfigList();
if (code !== 0) {
return;
}
state.signConfigList = data;
if (data.length > 0) {
state.maxDay = data[data.length - 1].day;
}
}
onReady(() => {
getSignInfo();
getSignConfigList();
});
</script>
<style lang="scss" scoped>
.header-box {
border-top: 2rpx solid rgba(#dfdfdf, 0.5);
}
// 日历
.calendar {
background: #fff;
.sign-everyday {
height: 100rpx;
background: rgba(255, 255, 255, 1);
border: 2rpx solid rgba(223, 223, 223, 0.4);
.sign-everyday-title {
font-size: 32rpx;
color: rgba(51, 51, 51, 1);
font-weight: 500;
}
.sign-num-box {
font-size: 26rpx;
font-weight: 500;
color: rgba(153, 153, 153, 1);
.sign-num {
font-size: 30rpx;
font-weight: 600;
color: #ff6000;
padding: 0 10rpx;
font-family: OPPOSANS;
}
}
}
// 年月日
.bar {
height: 100rpx;
.date {
font-size: 30rpx;
font-family: OPPOSANS;
font-weight: 500;
color: #333333;
line-height: normal;
}
}
.cicon-back {
margin-top: 6rpx;
font-size: 30rpx;
color: #c4c4c4;
line-height: normal;
}
.cicon-forward {
margin-top: 6rpx;
font-size: 30rpx;
color: #c4c4c4;
line-height: normal;
}
// 星期
.week {
.week-item {
font-size: 24rpx;
font-weight: 500;
color: rgba(153, 153, 153, 1);
flex: 1;
}
}
// 日历表
.myDateTable {
display: flex;
flex-wrap: wrap;
.dateCell {
width: calc(750rpx / 7);
height: 80rpx;
font-size: 26rpx;
font-weight: 400;
color: rgba(51, 51, 51, 1);
}
}
}
.is-sign {
width: 48rpx;
height: 48rpx;
position: relative;
.is-sign-num {
font-size: 24rpx;
font-family: OPPOSANS;
font-weight: 500;
line-height: normal;
}
.is-sign-image {
position: absolute;
left: 0;
top: 0;
width: 48rpx;
height: 48rpx;
}
}
.cell-num {
font-size: 24rpx;
font-family: OPPOSANS;
font-weight: 500;
color: #333333;
line-height: normal;
}
.cicon-title {
position: absolute;
right: -10rpx;
top: -6rpx;
font-size: 20rpx;
color: red;
}
// 签到按钮
.sign-box {
height: 140rpx;
width: 100%;
.sign-btn {
width: 710rpx;
height: 80rpx;
border-radius: 35rpx;
font-size: 30rpx;
font-weight: 500;
box-shadow: 0 0.2em 0.5em rgba(#ff6000, 0.4);
background: linear-gradient(90deg, #ff6000, #fe832a);
color: #fff;
}
.already-btn {
width: 710rpx;
height: 80rpx;
border-radius: 35rpx;
font-size: 30rpx;
font-weight: 500;
}
}
.model-box {
width: 520rpx;
// height: 590rpx;
background: linear-gradient(177deg, #ff6000 0%, #fe832a 100%);
// background: linear-gradient(177deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
border-radius: 10rpx;
.cicon-check-round {
font-size: 70rpx;
color: #fff;
}
.score-title {
font-size: 34rpx;
font-family: OPPOSANS;
font-weight: 500;
color: #fcff00;
}
.model-title {
font-size: 28rpx;
font-weight: 500;
color: #ffffff;
}
.model-bg {
width: 520rpx;
height: 344rpx;
background-size: 100% 100%;
background-image: v-bind(headerBg);
background-repeat: no-repeat;
border-radius: 0 0 10rpx 10rpx;
.title {
font-size: 34rpx;
font-weight: bold;
color: var(--ui-BG-Main-TC);
}
.subtitle {
font-size: 26rpx;
font-weight: 500;
color: #999999;
}
.cancel-btn {
width: 220rpx;
height: 70rpx;
border: 2rpx solid #ff6000;
border-radius: 35rpx;
font-size: 28rpx;
font-weight: 500;
color: #ff6000;
line-height: normal;
margin-right: 10rpx;
}
.confirm-btn {
width: 220rpx;
height: 70rpx;
background: linear-gradient(90deg, #ff6000, #fe832a);
box-shadow: 0 0.2em 0.5em rgba(#ff6000, 0.4);
border-radius: 35rpx;
font-size: 28rpx;
font-weight: 500;
color: #ffffff;
line-height: normal;
}
}
}
//签到说明
.activity-title {
font-size: 32rpx;
font-weight: 500;
color: #333333;
line-height: normal;
}
.activity-des {
font-size: 26rpx;
font-weight: 500;
color: #666666;
line-height: 40rpx;
}
.reward {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAAA4CAYAAAC1+AWFAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQyIDc5LjE2MDkyNCwgMjAxNy8wNy8xMy0wMTowNjozOSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDowYWFmYjU3Mi03MGJhLTRiNDctOTI2Yi0zOThlZDkzZDkxMDkiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RUEyNzZEMjZEMDFCMTFFOEIzQzhEMjMxNjI1NENDQjciIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RUEyNzZEMjVEMDFCMTFFOEIzQzhEMjMxNjI1NENDQjciIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTggKFdpbmRvd3MpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6ZmRjNTM0MmUtNmFkOC1iMDRhLThjZTEtMjk2YWYzM2FkMmUxIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjBhYWZiNTcyLTcwYmEtNGI0Ny05MjZiLTM5OGVkOTNkOTEwOSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PuGQ9m8AAAf3SURBVHja7Jxbb9xEFMe9Xu81u6VJL0kqSCToZ0CCNyp4CQ0FqVAkQAgeEE98EPgEwBOCSoCEQPTCG30BVSpfAaQ2KQ1tc4Fm77v2cv7jmc3UGdvjsTdrJEY68m527Zn5zZlzszeF8XhspWl37/xhZdwK/Di2jqA9ufqM9ndtKz+tTvIpSYdkl7+u52h8lpMjUFdIzvH3VZIPSM6SrHOAM292DkHJ7Rz/rP4/rGhQuQNm5xxUroAVNm//PhUnQ7JEco9LGlBy+znGhsX1O1vNajYbjwm1F0l+JfmN5BeSlwKfx4KybTtWw6TriXao39xpFga8v98q08tPSN7Dn0yvVSqVrEqlbBUKBQvxX78/sIbDoenlxhzs6ySDPNmsj0k+SguqWq0wUGwV6Yj35XIpTXD7Csk3eTPw76c5GUAARtUqlVTA0C5wOzd7WLQF19JoFEAASFRLCQwa9hXJ2rQj+GdJ3sCcQj4vkrw7TVAyMLTBwMiGHSP5luQLEjfkO0O+ZW+ZGPjnuIE8YQoDEyyVnIkdmmaDQxgOR+QU+mku85DkZe5RE23D19KCguYcBSjhEHxNLStBarZTJBdNtuGcqlNVx6q4CBo1iwavipDjsUk6Rdq+I0u1brZdkKpCrDVMYLlBUMVikQ0mGM4EBydWeiYpiaLfWq1GwEbKUAwQPc+Vz3NTlWgEqHq9xo7BpoKVpwbNDwtNbHto9XpdAjaOXWBtWNhWAOV53lQnBiPdarWs+fnjmRr/MLtVLjvUp2O57tCK2wwJ4qxCyECyhXX//n3r3tZWxp4yel4+pPiJRMHydAbR7XYzm5Trutbu3p41pFjq0aNHmV0XY0ywqJ4JrIoOKEwwq7a9s2M5RYe5/+3tnUwXIQGwSlJYyKfeMgVlkprAFu7t/c3OLZfLLLhst9vGmUEKYG/x+WvBQgT7ZTDfE8ZPB5RuCiO33d095o0cx2HhCeThw+1UAbEusIAXbPL5r8XBWuf5UVP2JNgWGLzrelMBhT72yFaVCFSRBK6+SNux1+sxmSYwaDQ0GfOTPGaTc1gPyw2R3nwdTJoRMiCow4U6HXNQKOJ1uz0KAvssGR4MBuw4Gg2ZHyqX/O0HzRKTwHcQw/mhCwLisj8x9EVH9FetViOhYTurkm+EQZgXlAqahf4wvtFoJGsaAshLJD/IcdYaJ1mSV9uvM/mD6fX6oaAANE6jcO6dOxtsUEVKP+yCzVINaJJDAwckTEAu/mG1cRyNXBZlQ8vanY7lkYa77shaWVmJhYVxiSQ7OB6ARLCKz6HNtVqVaR364+Mocy6vkvwEzUKR/6blF/snoDB4ROyixLu/3wodUKMxp5XeQLs2NzdZtGwXAazABolzZZHH4SGgJMCAjF0CaJClpSWr2Wxqb/NWS+0s5Dq+r2Eu30GePJZNkuehWSsyKFmrsPKYWFwqoZsHQlNWV1etra2/2ORlUGF5XhGLxaFiXK5XsM6cXmZbKEm+iPOD2UewXz+tI013SqRdfTmifwqMYOA3SO7GlTUOJ9AHBjLJwyXYamfOLDO7k+Q88c3lpcVEoCYaqkjThH3USI3AZ8PmLz7klcIJcRhFWRWx91VJtDCiSRPbpcVFZqy9iLxNngBGsUigTLytanyYS/Bavn0cMacjadWQ87knQodr3OoPxEm+i+2xFfG3il/qUAEzqVDimsePP0HG2o2EJbRibq7OPKYJqKBxlz2hvIAHc55UIIQ3vBaMs77nVcK2TBkns5WNAQZNTAoM13Y1qhjCrZuACoYNKlAHc+1OlINzuMi5KIPSK5xkS1wEHgzeQUfDkgLr9roJwHanBgoaFfCALc7hSly6A5V7h2RfqCc6hSofxEDZAOt1+4e2GzTN46/F9hQrr5u0q0AdhEKHzQGCXym22ufzv6abSCNivRzMC4O5ol+udZTA9Ap9AxZrjflWw7VOnzrJPF61WmNwvIkJsLW1K9g/dod4LCDchk5eXhYRe5JKaax6IA7DILDqJvZEBJ0O+br5hXlmxEU7eXKBJt2gnPEf2iIdNhlkEY1Gw6D6Opgshka40jcpK8dWUYXhN2mwEdCWEwsL1rFjTeV1EFosLp5ixv3BgwcMmsndueXlZV9L9UridqoafFwIYNKQ0509+3TU40WThpxtdXWFwzKrwWdxtykBrPFkb2dRdweApK1erxvDCltoP2IPv8eQGJbwiOK+4YxuCabS/jDNQgkINldDwSNhFVWBIaDJ/YatWlaqn4UWAYbqoTh8FZ8Fxlo0gdUOrg6LgxSxjsruIC5L+VyVUVNBYZmCMkYrMI0KLGrLxOMhzN9RlTqCEhUYjsfjI9MoPyAeKNMl1bgVzzmg6P+diWbd5BXUS3IFVbFV8XzWXBiwqGg+ac0+rESs6bGxU1I9nxVn4G9FnSylR1e13ElIpK0DzBQUb0hh3iS5nkZ7s3i0+zqHZdR0csmUoJBevJ0WVCaweLuYZjBRwFKC8jioH7OYZCawSLsGJLg5i/tswWwX79fp8wKE27cbKmDI/YRDwBHvFaBw7px0vUJEvxesHD7aLaBd5QPc4H+6jff87+I7yFnOq4DB7eMuTLvdYbfuFWEAzjnPryE3Zb9pzIPSUUzxtzvLJH9a4b+hqfPJvKB5zRsccidlv+awZvyzX11gOqDMVvU/9LPf0C15FKBmarOmACw3oPICSwb2OQlu4+Cxv8/yBCoPNitsAcdWDv9Vwb8CDACdCFE+P8dk8gAAAABJRU5ErkJggg==');
width: 75rpx;
height: 56rpx;
}
.rewardTxt {
width: 74rpx;
height: 32rpx;
background-color: #f4b409;
border-radius: 16rpx;
font-size: 20rpx;
color: var(--ui-BG-Main-TC);
line-height: 32rpx;
text-align: center;
padding: 2rpx;
}
.venus {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAA4CAYAAACohjseAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQyIDc5LjE2MDkyNCwgMjAxNy8wNy8xMy0wMTowNjozOSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDowYWFmYjU3Mi03MGJhLTRiNDctOTI2Yi0zOThlZDkzZDkxMDkiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RDQ3N0E3RkJEMDFCMTFFODhGODVBOTc1NEM5Nzg2NzkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RDQ3N0E3RkFEMDFCMTFFODhGODVBOTc1NEM5Nzg2NzkiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTggKFdpbmRvd3MpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6ZmRjNTM0MmUtNmFkOC1iMDRhLThjZTEtMjk2YWYzM2FkMmUxIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjBhYWZiNTcyLTcwYmEtNGI0Ny05MjZiLTM5OGVkOTNkOTEwOSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PnZClGIAAAT7SURBVHja7JtLcxtFEMdnn1rJUhIrTiS7KLsK/EXwNck3gCMcuUFx4QvACW48buHGMZxJPkiowpjC2LElcKzXSqul/6OdoOB9zezsCCimqmvXtdqd+U33dPf0rq2Tn54zg81KjrGuB75x8FbuddsQWIvkS5IxySA5b5no2DUE94TkKPk7IHmf5JDkUQJdW7MNw623o+Ra698KmAdnDNLeIJwRSHvDcLVDVnYynU771fnLl9eFcLZts+VymQf5iJ6pzfFYJeKgT/IZyTskXdWOPM9jjYbPLMticRyz2Sxk8/lc9XFDksckH1IcDKtq8FOSD6rMIuCCoPHXrBIk/qYDC0MlyO1kTBOSj6uuwXerwPn+63DrrdFo8OsV2ns6nEy3Chwg8lpFyK4OwNrgNGpSvxfFoDzP5etJR8PzsiYETmk+X5BjmpkBrHPGU109TeKqv5X3rT3QQ3ObaPDGRjIZXWZpol+b/cebUUA4iuHw938UoNbk9+zsjP16eqoV4JfjH1uqgLjxe10DiaKIDYZDNqfU7OrqSifjkzxIuwDubV2juLi8ZK7j8oT74uJSJ+BRHqQtC6cS/7A9wtrDvb7v84A9Go2UMyQZSFsWrmz6td4GgyF38a7r8lgGefHiQjnjkYG064ZDmjWktecRnEOCDa9DpjqdTrnUDSk2vJXgsHGdTKa0t5vx/V0Yhvy4WMx5hdf3VqYJDQqTxW+QdmECPM8h8flvPPRFR/QXBEEuKEw9Yz/5AyoDtBkei5zriyw4pGVFmoOHPD7+mQ/ccR1mWzZpyuIacx2Hgzl0FJkIjjBTHBeLiO6LuDZH4zFbRkt63oLt7+8XAmJcIhFP0eTn2C9CgzBTrPjUp7XbW6VSJGjx5OSEBhsz2wGkxc0R967LuukuSWKaFEwMnXJQSL/fZ51Op/QSuL5OdVjY7beFBq2sAlHZ/A8aOTg4YKenv/EBr8Nl5ZUO6jPJRGCg0dJie/d3WbPZlMpPMwpZsN0Y2sOVb7PcOzou22CGe3u7fB3J3Cd+udvvScG9soT0Kt13tAZj4UVRwHmWtZClcj+azX6vxx0GN8ECUFyHjnsEp+KlM8b3TBTKBCDqkA/SIFV20jCbO3duk8OIcgHF7G9ttbinVYFLcTBgeAAP+vc4mAkJVywLibARpZvOjWWA36rApYSI1+DSMhltkJPpRGIyJrXAZeWiWiCnk9kNU4RGl8m5MN1VLFzwWKobLm83kQtZbnMb8lgYJ2aIYH//3g73lEHQ5ECAXYUSu7QWZeCKqmoCcqSyPkQgd8lHbne3uSMRbWenSwNtU476BxtT9oJQOZ3OKKloq6SmmXBlyoZKb3nG4wnXyt1ul9261UkN9ggjvd497mDOz885KGN3pfvKg1OuixY15JCHh2/ymFjUms2AMqD9BFB/qwUQg5ZtrVY9b7H/LxtmZSCbaCr9KgGmpEeG6qpzM2tQBHudb5eKNLfKiUMzgAIyL6uRreHklB9qX4MDlQfLpHUV4AY6AB+rzl4ZyIqa+0aHiX6UlDTwMcK2CqQoEGmEE5+RfFK4N636vWjKh0Cp5ceS38k8JXko8yHQ7W7PXKBPBvYwGegNF4/q12g05mV7HXClqgs1ffEr+/LmaTIx0nCb+uI3U5M64Tadi5aBrBXORLKdB1k7nKndhID8GqUaErze/coEXJ1OJm9CY2bw3wr+FGAAoa6PIUihovYAAAAASUVORK5CYII=');
background-repeat: no-repeat;
background-size: 100% 100%;
width: 56rpx;
height: 56rpx;
margin: 10rpx auto;
}
.venusSelect {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAA4CAYAAACohjseAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQyIDc5LjE2MDkyNCwgMjAxNy8wNy8xMy0wMTowNjozOSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDowYWFmYjU3Mi03MGJhLTRiNDctOTI2Yi0zOThlZDkzZDkxMDkiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6QzkwRkI4NEFEMDFCMTFFODhDNDdBMDVGOTBBN0U2NTQiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6QzkwRkI4NDlEMDFCMTFFODhDNDdBMDVGOTBBN0U2NTQiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTggKFdpbmRvd3MpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6ZmRjNTM0MmUtNmFkOC1iMDRhLThjZTEtMjk2YWYzM2FkMmUxIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjBhYWZiNTcyLTcwYmEtNGI0Ny05MjZiLTM5OGVkOTNkOTEwOSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PkX00M0AAAfVSURBVHjaxFpdcBNVFD67STbppn9poU0LtSBYykBlgKrjqKOtihbq8ICKILyJwxM+6fjCk2/6pC+O4hs+6fgAbWFw1OID+ICMAwwKlRmKLW3Tpvlrskk3m13Pvdm0NNn//HA73+ymd3Pv+e4595xzT5bJ3DgJNWyMelUqNaD36a8N+9kaEeMR3yAERES952sxsbtya2lIbgQxqH72IT5EbEW8pZKuHkGlugyLyT3aBtW+qpJkKb/qgEeMIAYNnhlUn+Edz2NuokqtNVdTTbqVyhO0Q67qJMt2MnXbTq/cp+9+ZkyOYYFxN4EiLaF5SbokccyKkWRS1z4we4ZDfIE4hmhxvJLNu8HTtg85ekGRRcjOXwIp9pfT4aKIs4iP+f4zYrl78HPEqbLMJNAPXHBI/SQjSTd+PoD3LpCi15wMGVBlSiM+NfSihJ8Jjlt4Rheu5n7wtL+B93IJPO37aH8Z45+ohBdtKUtz7a+jJLK+/dN+BTX5p5MpWh6HF6XNE9iLwr9mSG6VZP65bPR6NVI1BwQZF3BtA+Bq2oG3Pt3HFCVnfUHaX6XQHCeXgVz8Nojz4+SDzTgo2yfIBV9G89utzi5DtRvDcnQ+JSciyd+rH+hdjb22tFOp5mreCUrocg0CPet5LATJvHbldWSiGllIzZpdeR2ZqFPtZTNJSIQeQGv3DucEbcrLmkRSXvP/cs4RZm6Ow/T1McffpyiSJTZ+jDfOZFDlOuARo5p9aKJ2IYkpCN+9AmLsIcSm/3Y0BkWpPCPRX9/nDVI1BTTAI0YRA9r99gWbv3MF90MGvG4WQrfHnRMslWcQMRL55SivbaJk064FjxhFDGj0gad5u22zkrMZiExcBQ7JcW4GlhfuQ3L+gSMTzc9fItcgYiTy8xHeTIOGmnMHtoEn2G971cP3MAUTk+B2MeBBkh4kGbp92ZEGyfxEDj1NLl56j9fbg4U9N6C179zNPZhK7cV7yRZkSYTI3atIjgUXywCLINf03L8gRGZtj0dA5CDyaMg5SPZk+OLhFZLMwtg7hTLDKGJAM09s6QGuY6+upxLTKcgkFmE5FUdFIYQEiHgv4VURl4BjgZon0SA9EeKKi1kZliU8Nnn84OabwIPw+huB8zdR+OqbwdcYMAwB4ux1yEYmtLp+I5WBdft/EApx8Cs9cu6mblyxXXTl9FpOFGDyjzGQMwlwIQlUEDAMagqvhBTVHl4ZplDezpsq+UdOTkMuIcByfBYElCWHmsgpLHQ/NwTe+gaTBH0XWkgGpPgDrfLHl4gTTOj8IVLdTqkF2aIslwF+2zCeGDjzIJ5OwtSVc6Cko9QMCUmWyZMiZJn8cI8E7Lwm11wJOTypBPuHoCG4yVrgz2VBmFBj69pGTvv1hVSN0XSxHE8LRUbaW9G01wdPvHgQQtcugJwMU5LFpIrWDjXMUGIsMNRR5DwcBPcMQV1L0NKchYHIkU2WkiVrTvgT6XEjyN/TY08R5KyAaWc6n3tagMvjhuCzQ+jlOmylVPRZjw/an9kPdYF1lucjIPLJmERoyP9j+8GflIIXPYW4XOKVJAmWZ27Y8nAMaq5t9yB4WjeumJ4hOaIErx/W978JXH2TbY9K5ZNKMhzC5dSjyTapQ5IyFxozvLJGz9Hp/Am+Y7utH8kan+yDhYVp8lVgdDWX33f+ji3gruNpnLPTxNl/8vKtbeTAeKDj0DmhuGShT3Jxkp4guGCv5cnT0QX0hgq4dOnBSshIxxehUbZJbu4OSJEpbXJvnxf0zoP6JMP/keVGTfZYEiCDQlttmXjE1hlTnJ3A+Ketuc53RwSz86AuSXFxitYzueBWUyGWE9E1pqiozoRhXdQJMLAaEyUMMdJyGp2Ux4Lm7iG5h5rkNhweFUpLFtonZANNTmOA3WzmFiGLGY3XlSel0DpOCzRs6gWXj4fkgwnIhKZIcKDhgsTLTCICfMs683gb1tbchiNjgt0TfYFkym7JQkyl8nkoixkMesiGzT1Q19q20t+0dTvwnU/A0iQSDYeoNinBQLOTE/2BjUcvCE5rMoJ2XcSYYBr3FOPmoHHLU+APdtJMpvg7bp8XAr19mKJ1weK9u5CJxUDpMt+HxfJ2HbsoVLzwa1aT4fw8dD3/Au43lv7YYjQF19gAHXv6UYMJa7UepQZFJzMT9fp9lJidorCvgbfkSRXbBB2UDRX5MdREnZYNwZECRcxQXLUnl8s5KPw6MNFsdBFzzdaaE8xGwrUx0eXZORrw3c1NNdEk0ZwUi2OQn7fvZBz9fEZKDjNzFLqn7dYApnVtNtKvecx5oxVfHCsmSt4ts/0rrxiO5NO6jvUWyC0guZgT+SPllu4Jzjr9AT0bjqKWQ1qH0RWQfvKcwzm+s6BB01X6RC1pHIf82w02NRmnsng7WjX28iJqLu5Ec4XXSE5XYg+S91A+UlHS/H2riXfq1n3N8mM2HKOOgutsodkNqZKIMxGQokvFw40jhnFMoZZ70CzyrpLd2S0kb00Oa5KMJDC8LAHL4QEmK4HGKYaSq+/bJFTyZ/GyX+VK3pzUStA1SRJrkTNZrWHG1e8IGuMZt5eqrUH9U8iwUbVci1w1BKnW65RWSVaVnBomAKoI3E9IQEEipX3jap9Q1hxmBElBocp/AmIYcQaRQSQQ36r/E8odvepOxoa5khfRT1pf+8q0/wUYAFU/P0XyeZQPAAAAAElFTkSuQmCC');
}
.num {
font-size: 36rpx;
font-family: 'Guildford Pro';
}
.item {
align-items: center;
justify-content: space-between;
flex-direction: column;
height: 130rpx;
}
.reward {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAAA4CAYAAAC1+AWFAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQyIDc5LjE2MDkyNCwgMjAxNy8wNy8xMy0wMTowNjozOSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDowYWFmYjU3Mi03MGJhLTRiNDctOTI2Yi0zOThlZDkzZDkxMDkiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RUEyNzZEMjZEMDFCMTFFOEIzQzhEMjMxNjI1NENDQjciIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RUEyNzZEMjVEMDFCMTFFOEIzQzhEMjMxNjI1NENDQjciIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTggKFdpbmRvd3MpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6ZmRjNTM0MmUtNmFkOC1iMDRhLThjZTEtMjk2YWYzM2FkMmUxIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjBhYWZiNTcyLTcwYmEtNGI0Ny05MjZiLTM5OGVkOTNkOTEwOSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PuGQ9m8AAAf3SURBVHja7Jxbb9xEFMe9Xu81u6VJL0kqSCToZ0CCNyp4CQ0FqVAkQAgeEE98EPgEwBOCSoCEQPTCG30BVSpfAaQ2KQ1tc4Fm77v2cv7jmc3UGdvjsTdrJEY68m527Zn5zZlzszeF8XhspWl37/xhZdwK/Di2jqA9ufqM9ndtKz+tTvIpSYdkl7+u52h8lpMjUFdIzvH3VZIPSM6SrHOAM292DkHJ7Rz/rP4/rGhQuQNm5xxUroAVNm//PhUnQ7JEco9LGlBy+znGhsX1O1vNajYbjwm1F0l+JfmN5BeSlwKfx4KybTtWw6TriXao39xpFga8v98q08tPSN7Dn0yvVSqVrEqlbBUKBQvxX78/sIbDoenlxhzs6ySDPNmsj0k+SguqWq0wUGwV6Yj35XIpTXD7Csk3eTPw76c5GUAARtUqlVTA0C5wOzd7WLQF19JoFEAASFRLCQwa9hXJ2rQj+GdJ3sCcQj4vkrw7TVAyMLTBwMiGHSP5luQLEjfkO0O+ZW+ZGPjnuIE8YQoDEyyVnIkdmmaDQxgOR+QU+mku85DkZe5RE23D19KCguYcBSjhEHxNLStBarZTJBdNtuGcqlNVx6q4CBo1iwavipDjsUk6Rdq+I0u1brZdkKpCrDVMYLlBUMVikQ0mGM4EBydWeiYpiaLfWq1GwEbKUAwQPc+Vz3NTlWgEqHq9xo7BpoKVpwbNDwtNbHto9XpdAjaOXWBtWNhWAOV53lQnBiPdarWs+fnjmRr/MLtVLjvUp2O57tCK2wwJ4qxCyECyhXX//n3r3tZWxp4yel4+pPiJRMHydAbR7XYzm5Trutbu3p41pFjq0aNHmV0XY0ywqJ4JrIoOKEwwq7a9s2M5RYe5/+3tnUwXIQGwSlJYyKfeMgVlkprAFu7t/c3OLZfLLLhst9vGmUEKYG/x+WvBQgT7ZTDfE8ZPB5RuCiO33d095o0cx2HhCeThw+1UAbEusIAXbPL5r8XBWuf5UVP2JNgWGLzrelMBhT72yFaVCFSRBK6+SNux1+sxmSYwaDQ0GfOTPGaTc1gPyw2R3nwdTJoRMiCow4U6HXNQKOJ1uz0KAvssGR4MBuw4Gg2ZHyqX/O0HzRKTwHcQw/mhCwLisj8x9EVH9FetViOhYTurkm+EQZgXlAqahf4wvtFoJGsaAshLJD/IcdYaJ1mSV9uvM/mD6fX6oaAANE6jcO6dOxtsUEVKP+yCzVINaJJDAwckTEAu/mG1cRyNXBZlQ8vanY7lkYa77shaWVmJhYVxiSQ7OB6ARLCKz6HNtVqVaR364+Mocy6vkvwEzUKR/6blF/snoDB4ROyixLu/3wodUKMxp5XeQLs2NzdZtGwXAazABolzZZHH4SGgJMCAjF0CaJClpSWr2Wxqb/NWS+0s5Dq+r2Eu30GePJZNkuehWSsyKFmrsPKYWFwqoZsHQlNWV1etra2/2ORlUGF5XhGLxaFiXK5XsM6cXmZbKEm+iPOD2UewXz+tI013SqRdfTmifwqMYOA3SO7GlTUOJ9AHBjLJwyXYamfOLDO7k+Q88c3lpcVEoCYaqkjThH3USI3AZ8PmLz7klcIJcRhFWRWx91VJtDCiSRPbpcVFZqy9iLxNngBGsUigTLytanyYS/Bavn0cMacjadWQ87knQodr3OoPxEm+i+2xFfG3il/qUAEzqVDimsePP0HG2o2EJbRibq7OPKYJqKBxlz2hvIAHc55UIIQ3vBaMs77nVcK2TBkns5WNAQZNTAoM13Y1qhjCrZuACoYNKlAHc+1OlINzuMi5KIPSK5xkS1wEHgzeQUfDkgLr9roJwHanBgoaFfCALc7hSly6A5V7h2RfqCc6hSofxEDZAOt1+4e2GzTN46/F9hQrr5u0q0AdhEKHzQGCXym22ufzv6abSCNivRzMC4O5ol+udZTA9Ap9AxZrjflWw7VOnzrJPF61WmNwvIkJsLW1K9g/dod4LCDchk5eXhYRe5JKaax6IA7DILDqJvZEBJ0O+br5hXlmxEU7eXKBJt2gnPEf2iIdNhlkEY1Gw6D6Opgshka40jcpK8dWUYXhN2mwEdCWEwsL1rFjTeV1EFosLp5ixv3BgwcMmsndueXlZV9L9UridqoafFwIYNKQ0509+3TU40WThpxtdXWFwzKrwWdxtykBrPFkb2dRdweApK1erxvDCltoP2IPv8eQGJbwiOK+4YxuCabS/jDNQgkINldDwSNhFVWBIaDJ/YatWlaqn4UWAYbqoTh8FZ8Fxlo0gdUOrg6LgxSxjsruIC5L+VyVUVNBYZmCMkYrMI0KLGrLxOMhzN9RlTqCEhUYjsfjI9MoPyAeKNMl1bgVzzmg6P+diWbd5BXUS3IFVbFV8XzWXBiwqGg+ac0+rESs6bGxU1I9nxVn4G9FnSylR1e13ElIpK0DzBQUb0hh3iS5nkZ7s3i0+zqHZdR0csmUoJBevJ0WVCaweLuYZjBRwFKC8jioH7OYZCawSLsGJLg5i/tswWwX79fp8wKE27cbKmDI/YRDwBHvFaBw7px0vUJEvxesHD7aLaBd5QPc4H+6jff87+I7yFnOq4DB7eMuTLvdYbfuFWEAzjnPryE3Zb9pzIPSUUzxtzvLJH9a4b+hqfPJvKB5zRsccidlv+awZvyzX11gOqDMVvU/9LPf0C15FKBmarOmACw3oPICSwb2OQlu4+Cxv8/yBCoPNitsAcdWDv9Vwb8CDACdCFE+P8dk8gAAAABJRU5ErkJggg==');
width: 75rpx;
height: 56rpx;
}
.on {
color: #f4b409;
}
</style>
+351
View File
@@ -0,0 +1,351 @@
<template>
<s-pages tabbar="/pages/cart/cart" title="购物车" :showLeftButton="false" color="#ffffff">
<s-empty
v-if="state.list.length === 0"
icon="/static/cart-empty.png"
text="购物车空空如也,快去逛逛吧~"
/>
<!-- 头部 -->
<view v-if="state.list.length" class="cart-box ss-flex ss-flex-col ss-row-between">
<view class="cart-header ss-flex ss-col-center ss-row-between ss-p-x-30">
<view></view>
<view class="header-right">
<view v-if="state.editMode" class="" @tap="onChangeEditMode(false)"> 取消 </view>
<view v-else class="f500" @tap="onChangeEditMode(true)"> 管理 </view>
</view>
</view>
<!-- 内容 -->
<view class="cart-content ss-flex-1 ss-p-x-30 ss-m-b-40 m-b-100">
<view
v-for="item in state.list"
:key="item.id"
class="goods-box ss-r-10"
@click="goInfo(item.spu.id)"
>
<view class="ss-flex ss-col-center">
<label
class="check-box ss-flex ss-col-center ss-p-l-10"
@tap.stop="onSelectSingle(item.id)"
>
<radio
:checked="state.selectedIds.includes(item.id)"
color="var(--color32)"
style="transform: scale(0.8)"
backgroundColor="var(--color31)"
@tap.stop="onSelectSingle(item.id)"
/>
</label>
<s-goods-item
:img="item.spu.picUrl || item.goods.image"
:price="item.sku?.price || 0"
:skuText="
item.sku?.properties.length > 1
? item.sku?.properties.reduce(
(items2, items) => items2.valueName + ' ' + items.valueName,
)
: item.sku?.properties[0].valueName
"
:title="item.spu.name"
:titleWidth="400"
priceColor="#FF3000"
>
<template v-if="!state.editMode" v-slot:tool>
<view
v-if="item.spu?.status !== 1 && !state.editMode"
class="down-box size24"
style="text-align: left; color: #999"
>
该商品已下架
</view>
<view
v-else-if="item.spu?.stock <= 0 && !state.editMode"
class="down-box size24"
style="text-align: left; color: #999"
>
该商品无库存
</view>
<su-number-box
v-else
v-model="item.count"
:max="item.sku?.stock"
:min="0"
:step="1"
@change="onNumberChange($event, item)"
background="var(--color18)"
color="var(--color34)"
/>
</template>
</s-goods-item>
</view>
</view>
</view>
<!-- 底部 -->
<su-fixed v-if="state.list.length > 0" :isInset="false" :val="valNum" bottom placeholder>
<view class="cart-footer ss-flex ss-col-center ss-row-between ss-p-x-30 border-bottom">
<view class="ss-flex ss-col-center flex1">
<label class="check-box ss-flex ss-col-center ss-p-r-30 flex1" @tap="onSelectAll">
<radio
:checked="state.isAllSelected"
color="var(--color32)"
style="transform: scale(0.8)"
backgroundColor="var(--color31)"
@tap.stop="onSelectAll"
/>
<view class="ss-m-l-8 c0"> 全选</view>
</label>
<view class="flex-center" style="margin-right: 14rpx">
<text class="size26 c0">总计:</text>
<view class="price-text c13">
<span class="f500">¥</span>
<span class="priceNum">
{{ fen2yuan(state.totalPriceSelected) }}
</span>
</view>
<!-- <view class="text-price price-text size34" style="color: #ee0a24">
{{ fen2yuan(state.totalPriceSelected) }}
</view> -->
</view>
</view>
<view class="footer-right">
<button
v-if="state.editMode"
class="ss-reset-button pay-btn ui-Shadow-Main"
@tap="onDelete"
>
删除
</button>
<button v-else class="ss-reset-button pay-btn ui-Shadow-Main" @tap="onConfirm">
去结算
{{ state.selectedIds?.length ? `(${state.selectedIds.length})` : '' }}
</button>
</view>
</view>
</su-fixed>
</view>
</s-pages>
</template>
<script setup>
import { ref } from 'vue';
import sheep from '@/sheep';
import { onShow, onLoad } from '@dcloudio/uni-app';
import SpuApi from '@/sheep/api/product/spu';
import { computed, reactive } from 'vue';
import { fen2yuan } from '@/sheep/hooks/useGoods';
import { isEmpty } from '@/sheep/helper/utils';
onLoad(() => {
uni.hideNavigationBarLoading();
});
// 隐藏原生tabBar
// uni.hideTabBar({
// fail: () => {},
// });
const sys_navBar = sheep.$platform.navbar;
const cart = sheep.$store('cart');
const state = reactive({
editMode: computed(() => cart.editMode),
list: computed(() => cart.list),
selectedList: [],
selectedIds: computed(() => cart.selectedIds),
isAllSelected: computed(() => cart.isAllSelected),
totalPriceSelected: computed(() => cart.totalPriceSelected),
});
// 单选选中
function onSelectSingle(id) {
cart.selectSingle(id);
}
// 编辑、取消
function onChangeEditMode(flag) {
cart.onChangeEditMode(flag);
}
// 全选
function onSelectAll() {
cart.selectAll(!state.isAllSelected);
}
// 结算
async function onConfirm() {
const items = [];
state.selectedList = state.list.filter((item) => state.selectedIds.includes(item.id));
state.selectedList.map((item) => {
// 此处前端做出修改
items.push({
skuId: item.sku?.id,
count: item.count,
cartId: item.id,
categoryId: item.spu.categoryId,
});
});
if (isEmpty(items)) {
sheep.$helper.toast('请先选择商品');
return;
}
if (fen2yuan(state.totalPriceSelected) >= 5000) {
sheep.$helper.toast('订单金额不能超过5000元, 请重新选择商品');
return;
}
await validateDeliveryType(state.selectedList.map((item) => item.spu).map((spu) => spu.id));
sheep.$router.go('/pages/order/confirm', {
data: JSON.stringify({
items,
}),
});
}
/**
* 校验配送方式冲突
*
* @param {string[]} spuIds - 商品ID数组
* @returns {Promise<void>}
* @throws {Error} 当配送方式冲突或获取商品信息失败时抛出错误
*/
async function validateDeliveryType(spuIds) {
// 获取商品信息
const { data: spuList } = await SpuApi.getSpuListByIds(spuIds.join(','));
if (isEmpty(spuList)) {
sheep.$helper.toast('未找到商品信息');
throw new Error('未找到商品信息');
}
// 获取所有商品的配送方式列表
const deliveryTypesList = spuList.map((item) => item.deliveryTypes);
// 检查配送方式冲突
const hasConflict = checkDeliveryConflicts(deliveryTypesList);
if (hasConflict) {
sheep.$helper.toast('选中商品支持的配送方式冲突,不允许提交');
throw new Error('选中商品支持的配送方式冲突,不允许提交');
}
}
/**
* 检查配送方式列表中是否存在冲突
* @description
* 示例场景:
* A 商品支持:[快递, 自提]
* B 商品支持:[快递]
* C 商品支持:[自提]
*
* 对比结果:
* A 和 B:不冲突 (有交集:快递)
* A 和 C:不冲突 (有交集:自提)
* B 和 C:冲突 (无交集)
* @param {Array<Array<number>>} deliveryTypesList - 配送方式列表的数组
* @returns {boolean} 是否存在冲突
*/
function checkDeliveryConflicts(deliveryTypesList) {
for (let i = 0; i < deliveryTypesList.length - 1; i++) {
const currentTypes = deliveryTypesList[i];
for (let j = i + 1; j < deliveryTypesList.length; j++) {
const nextTypes = deliveryTypesList[j];
// 检查是否没有交集(即冲突)
const hasNoIntersection = !currentTypes.some((type) => nextTypes.includes(type));
if (hasNoIntersection) {
return true;
}
}
}
return false;
}
function onNumberChange(e, cartItem) {
//console.log(e);
if (e === 0) {
cart.delete(cartItem.id);
return;
}
if (cartItem.goods_num === e) return;
cartItem.goods_num = e;
cart.update({
goods_id: cartItem.id,
goods_num: e,
goods_sku_price_id: cartItem.goods_sku_price_id,
});
}
async function onDelete() {
cart.delete(state.selectedIds);
}
function getCartList() {
cart.getList();
}
onShow(() => {
getCartList();
});
const goInfo = (id) => {
uni.navigateTo({
url: '/pages/goods/info?id=' + id,
});
};
let valNum = ref(0);
// #ifdef APP-PLUS
valNum.value = 0;
// #endif
// #ifndef APP-PLUS
valNum.value = 50;
// #endif
</script>
<style lang="scss" scoped>
:deep(.ui-fixed) {
height: 72rpx;
}
.cart-box {
width: 100%;
box-sizing: border-box;
border-radius: 0 0 16rpx 16rpx;
overflow: hidden;
.cart-header {
height: 70rpx;
width: 100%;
// position: fixed;
// left: 0;
// top: v-bind('sys_navBar') rpx;
z-index: 1000;
box-sizing: border-box;
border-radius: 16rpx 16rpx 0 0;
}
.cart-footer {
height: 100rpx;
background-color: var(--color16);
box-shadow: 0px 0px 18px 0px rgba(0, 0, 0, 0.04);
.pay-btn {
width: 180rpx;
height: 70rpx;
font-size: 28rpx;
line-height: 28rpx;
font-weight: 500;
border-radius: 40rpx;
}
}
.cart-content {
.goods-box {
position: relative;
margin-bottom: 22rpx;
}
}
}
.price-text {
.priceNum {
font-size: 36rpx;
font-weight: 600;
}
}
.ss-reset-button {
background: linear-gradient(270deg, #f7772e 0%, #ee0a24 99%);
color: #ffffff;
}
</style>
+19
View File
@@ -0,0 +1,19 @@
<template>
<s-goods-item
:title="goodsData.spuName"
:img="goodsData.picUrl"
:price="goodsData.price"
:skuText="goodsData.introduction"
priceColor="#FF3000"
:titleWidth="400"
/>
</template>
<script setup>
const props = defineProps({
goodsData: {
type: Object,
default: {},
},
});
</script>
+109
View File
@@ -0,0 +1,109 @@
<template>
<view class="send-wrap ss-flex">
<view class="left ss-flex ss-flex-1">
<optimize-input
class="ss-flex-1 ss-p-l-22"
:inputBorder="false"
:clearable="false"
v-model="message"
placeholder="请输入你要咨询的问题"
></optimize-input>
</view>
<text class="sicon-basic bq" @tap.stop="onTools('emoji')"></text>
<text
v-if="!message"
class="sicon-edit"
:class="{ 'is-active': toolsMode === 'tools' }"
@tap.stop="onTools('tools')"
/>
<button
v-if="message"
class="ss-reset-button send-btn"
@tap="sendMessage"
:disabled="isDisabled || sending"
:class="{ disabled: isDisabled || sending }"
>
<text v-if="sending">发送中</text>
<text v-else>发送</text>
</button>
</view>
</template>
<script setup>
import { computed, ref, onUnmounted } from 'vue';
import OptimizeInput from '@/pages/chat/components/optimize-input.vue';
/**
* 消息发送组件
*/
const props = defineProps({
// 消息
modelValue: {
type: String,
default: '',
},
// 工具模式
toolsMode: {
type: String,
default: '',
},
});
const emits = defineEmits(['update:modelValue', 'onTools', 'sendMessage']);
const message = computed({
get() {
return props.modelValue;
},
set(newValue) {
emits(`update:modelValue`, newValue);
},
});
// 打开工具菜单
function onTools(mode) {
emits('onTools', mode);
}
// 发送消息
function sendMessage() {
emits('sendMessage');
}
</script>
<style scoped lang="scss">
.send-wrap {
padding: 18rpx 20rpx;
background: #fff;
.left {
height: 64rpx;
border-radius: 32rpx;
background: var(--ui-BG-1);
}
.bq {
font-size: 50rpx;
margin-left: 10rpx;
}
.sicon-edit {
font-size: 50rpx;
margin-left: 10rpx;
transform: rotate(0deg);
transition: all linear 0.2s;
&.is-active {
transform: rotate(45deg);
}
}
.send-btn {
width: 100rpx;
height: 60rpx;
line-height: 60rpx;
border-radius: 30rpx;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
font-size: 26rpx;
color: #fff;
margin-left: 11rpx;
}
}
</style>
+293
View File
@@ -0,0 +1,293 @@
<template>
<!-- 聊天列表使用scroll-view原生组件,整体倒置 -->
<scroll-view
:scroll-top="scroll.top"
class="chat-scroll-view"
scroll-y
:refresher-enabled="false"
@scroll="onScroll"
@scrolltolower="loadMoreHistory"
style="transform: scaleY(-1)"
>
<!-- 消息列表容器 -->
<view class="message-container">
<!-- 加载更多提示 -->
<view v-if="isLoading" class="loading-more" style="transform: scaleY(-1)">
<text>加载中...</text>
</view>
<!-- 消息列表 -->
<view class="message-list">
<view
v-for="(item, index) in messageList"
:key="item.id"
class="message-item"
style="transform: scaleY(-1)"
>
<!-- 消息渲染 -->
<MessageListItem
:message="item"
:message-index="index"
:message-list="messageList"
></MessageListItem>
</view>
</view>
</view>
</scroll-view>
<!-- 底部聊天输入框 -->
<su-fixed bottom>
<view v-if="showTip" class="back-top ss-flex ss-row-center ss-m-b-10" @tap="scrollToTop">
<text class="back-top-item ss-flex ss-row-center">
{{ showNewMessageTip ? '有新消息' : '回到底部' }}
</text>
</view>
<slot name="bottom"></slot>
</su-fixed>
</template>
<script setup>
import MessageListItem from '@/pages/chat/components/messageListItem.vue';
import { onMounted, reactive, ref, computed } from 'vue';
import KeFuApi from '@/sheep/api/promotion/kefu';
import { isEmpty } from '@/sheep/helper/utils';
import { formatDate } from '@/sheep/helper/utils';
import sheep from '@/sheep';
const { safeAreaInsets } = sheep.$platform.device;
const safeAreaInsetsBottom = safeAreaInsets.bottom + 'px'; // 底部安全区域
const messageList = ref([]); // 消息列表
const showTip = ref(false); // 显示提示
const showNewMessageTip = ref(false); // 显示有新消息提示
const refreshMessage = ref(false); // 更新消息列表
const isLoading = ref(false); // 是否正在加载更多
const hasMore = ref(true); // 是否还有更多数据
const keyboardHeight = ref(0); // 键盘高度
const scroll = ref({
top: 0,
oldTop: 0,
}); // 滚动位置记录
const queryParams = reactive({
no: 1,
limit: 20,
createTime: undefined,
}); // 查询参数
// 计算聊天窗口高度
const chatScrollHeight = computed(() => {
const baseHeight = 'calc(100vh - 150px - ' + safeAreaInsetsBottom + ')';
if (keyboardHeight.value > 0) {
// 键盘弹起状态,减去键盘高度
return `calc(${baseHeight} - ${keyboardHeight.value}px)`;
}
return baseHeight;
});
// 获得消息分页列表
const getMessageList = async () => {
isLoading.value = true;
try {
const { data } = await KeFuApi.getKefuMessageList(queryParams);
if (isEmpty(data)) {
hasMore.value = false;
return;
}
if (queryParams.no > 1 && refreshMessage.value) {
const newMessageList = [];
for (const message of data) {
if (messageList.value.some((val) => val.id === message.id)) {
continue;
}
newMessageList.push(message);
}
// 新消息追加到开头
messageList.value = [...newMessageList, ...messageList.value];
refreshMessage.value = false; // 更新好后重置状态
return;
}
if (queryParams.no > 1) {
// 加载更多历史消息,追加到现有列表末尾(因为是倒置的,所以旧消息在底部/列表末尾)
if (data.length < queryParams.limit) {
hasMore.value = false; // 如果返回的数据少于请求的数量,说明没有更多数据了
}
// 过滤掉已存在的消息
const historyMessages = data.filter(
(msg) => !messageList.value.some((existing) => existing.id === msg.id),
);
if (historyMessages.length > 0) {
messageList.value = [...messageList.value, ...historyMessages];
}
} else {
// 首次加载
messageList.value = data;
if (data.length < queryParams.limit) {
hasMore.value = false;
}
}
if (data.slice(-1).length > 0) {
// 设置最后一次历史查询的最后一条消息的 createTime
queryParams.createTime = formatDate(data.slice(-1)[0].createTime);
}
} finally {
isLoading.value = false;
}
};
/** 加载更多历史数据 */
const loadMoreHistory = async () => {
if (isLoading.value || !hasMore.value) return;
// 增加页码
queryParams.no += 1;
await getMessageList();
};
/** 刷新消息列表 */
const refreshMessageList = async (message = undefined) => {
if (typeof message !== 'undefined') {
// 追加数据到列表开头(因为是倒置的,所以新消息在顶部/列表开头)
messageList.value.unshift(message);
showNewMessageTip.value = true;
} else {
queryParams.createTime = undefined;
refreshMessage.value = true;
await getMessageList();
}
// 若已是第一页则不做处理
if (queryParams.no > 1) {
showTip.value = true;
} else {
scrollToTop();
}
};
/** 滚动到顶部(倒置后相当于滚动到最新消息) */
const scrollToTop = () => {
scroll.value.top = scroll.value.oldTop;
setTimeout(() => {
scroll.value.top = 0;
}, 200); // 等待 view 层同步
showTip.value = false;
};
/** 设置键盘高度 */
const setKeyboardHeight = (height) => {
keyboardHeight.value = height;
// 键盘弹起时,滚动到最新消息
if (height > 0) {
scrollToTop();
}
};
defineExpose({ getMessageList, refreshMessageList });
/** 监听消息列表滚动 */
const onScroll = (e) => {
const { scrollTop } = e.detail;
scroll.value.oldTop = scrollTop;
// 当滚动位置超过一定值时,显示"新消息"提示
if (scrollTop > 100) {
showTip.value = true;
} else {
showTip.value = false;
}
};
// 监听键盘弹起和收起事件
const setupKeyboardListeners = () => {
// #ifdef H5
// H5环境
window.addEventListener('resize', () => {
// 窗口大小变化可能是由键盘引起的
if (
document.activeElement &&
(document.activeElement.tagName === 'INPUT' ||
document.activeElement.tagName === 'TEXTAREA')
) {
// 估算键盘高度,实际上是窗口高度变化
const currentHeight = window.innerHeight;
const viewportHeight = window.visualViewport
? window.visualViewport.height
: window.innerHeight;
const keyboardHeight = currentHeight - viewportHeight;
setKeyboardHeight(keyboardHeight > 0 ? keyboardHeight : 0);
} else {
setKeyboardHeight(0);
}
});
// #endif
// #ifdef MP-WEIXIN
// TODO puhui999: 小程序键盘弹起还有点问题,看看怎么适配
// 微信小程序环境
uni.onKeyboardHeightChange((res) => {
setKeyboardHeight(res.height);
});
// #endif
};
onMounted(() => {
queryParams.no = 1; // 确保首次加载是第一页
scroll.value = {
top: 0,
oldTop: 0,
};
getMessageList();
setupKeyboardListeners();
});
</script>
<style lang="scss" scoped>
.chat-scroll-view {
height: v-bind(chatScrollHeight);
width: 100%;
position: relative;
background-color: #f8f8f8;
z-index: 1;
}
.message-container {
width: 100%;
/* 确保容器至少有一屏高度 */
min-height: 100vh;
display: flex;
flex-direction: column;
justify-content: flex-end;
}
.message-list {
width: 100%;
display: flex;
flex-direction: column;
padding-bottom: 20px;
}
.message-item {
margin-bottom: 10px;
}
.loading-more {
width: 100%;
height: 40px;
display: flex;
justify-content: center;
align-items: center;
color: #999;
font-size: 14px;
}
.back-top {
.back-top-item {
height: 30px;
width: 100px;
background-color: #fff;
border-radius: 30px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
}
</style>
+297
View File
@@ -0,0 +1,297 @@
<template>
<view class="chat-box">
<!-- 消息渲染 -->
<view class="message-item ss-flex-col scroll-item">
<view class="ss-flex ss-row-center ss-col-center">
<!-- 系统消息 -->
<view
v-if="message.contentType === KeFuMessageContentTypeEnum.SYSTEM"
class="system-message"
>
{{ message.content }}
</view>
<!-- 日期 - 移到消息内容上方显示 -->
<view
v-if="
message.contentType !== KeFuMessageContentTypeEnum.SYSTEM &&
showTime(message, messageIndex)
"
class="date-message"
>
{{ formatDate(message.createTime) }}
</view>
</view>
<!-- 消息体渲染管理员消息和用户消息并左右展示 -->
<view
v-if="message.contentType !== KeFuMessageContentTypeEnum.SYSTEM"
class="ss-flex ss-col-top"
:class="[
message.senderType === UserTypeEnum.ADMIN
? `ss-row-left`
: message.senderType === UserTypeEnum.MEMBER
? `ss-row-right`
: '',
]"
>
<!-- 客服头像 -->
<image
v-show="message.senderType === UserTypeEnum.ADMIN"
class="chat-avatar ss-m-r-24"
:src="sheep.$url.cdn(message.senderAvatar) || sheep.$url.static('')"
mode="aspectFill"
lazy-load
/>
<!-- 内容 -->
<template v-if="message.contentType === KeFuMessageContentTypeEnum.TEXT">
<view class="message-box" :class="{ admin: message.senderType === UserTypeEnum.ADMIN }">
<mp-html :content="processedContent" :domain="sheep.$url.cdn('')" lazy-load />
</view>
</template>
<template v-if="message.contentType === KeFuMessageContentTypeEnum.IMAGE">
<view
class="message-box"
:class="{ admin: message.senderType === UserTypeEnum.ADMIN }"
:style="{ width: '200rpx' }"
>
<su-image
class="message-img"
isPreview
:previewList="[sheep.$url.cdn(getMessageContent(message).picUrl || message.content)]"
:current="0"
:src="sheep.$url.cdn(getMessageContent(message).picUrl || message.content)"
:height="200"
:width="200"
mode="aspectFill"
/>
</view>
</template>
<template v-if="message.contentType === KeFuMessageContentTypeEnum.PRODUCT">
<div class="ss-m-b-10">
<GoodsItem
:goodsData="getMessageContent(message)"
@tap="
sheep.$router.go('/pages/goods/index', { id: getMessageContent(message).spuId })
"
/>
</div>
</template>
<template v-if="message.contentType === KeFuMessageContentTypeEnum.ORDER">
<OrderItem
:orderData="getMessageContent(message)"
@tap="sheep.$router.go('/pages/order/detail', { id: getMessageContent(message).id })"
/>
</template>
<!-- user头像 -->
<image
v-if="message.senderType === UserTypeEnum.MEMBER"
class="chat-avatar ss-m-l-24"
:src="
sheep.$url.cdn(userInfo.avatar) ||
sheep.$url.static('/static/img/shop/chat/default.png')
"
mode="aspectFill"
>
</image>
</view>
</view>
</view>
</template>
<script setup>
import { computed, unref } from 'vue';
import dayjs from 'dayjs';
import { KeFuMessageContentTypeEnum, UserTypeEnum } from '@/pages/chat/util/constants';
import { emojiList } from '@/pages/chat/util/emoji';
import sheep from '@/sheep';
import { formatDate, jsonParse } from '@/sheep/helper/utils';
import GoodsItem from '@/pages/chat/components/goods.vue';
import OrderItem from '@/pages/chat/components/order.vue';
const props = defineProps({
// 消息
message: {
type: Object,
default: () => ({}),
},
// 消息索引
messageIndex: {
type: Number,
default: 0,
},
// 消息列表
messageList: {
type: Array,
default: () => [],
},
});
const getMessageContent = computed(() => (item) => jsonParse(item.content)); // 解析消息内容
const userInfo = computed(() => sheep.$store('user').userInfo);
//======================= 工具 =======================
const showTime = computed(() => (item, index) => {
if (unref(props.messageList)[index + 1]) {
let dateString = dayjs(unref(props.messageList)[index + 1].createTime).fromNow();
return dateString !== dayjs(unref(item).createTime).fromNow();
}
return false;
});
// 缓存表情映射
const emojiMap = computed(() => {
const map = new Map();
emojiList.forEach((emoji) => {
map.set(emoji.name, emoji.file);
});
return map;
});
// 处理表情 - 进行缓存优化
function replaceEmoji(data) {
let newData = data;
if (typeof newData !== 'object') {
let reg = /\[(.+?)]/g; // [] 中括号
let zhEmojiName = newData.match(reg);
if (zhEmojiName) {
zhEmojiName.forEach((item) => {
const emojiFile = emojiMap.value.get(item) || '';
if (emojiFile) {
newData = newData.replace(
item,
`<img class="chat-img" style="width: 24px;height: 24px;margin: 0 3px;vertical-align: middle;" src="${sheep.$url.cdn(
'/static/img/chat/emoji/' + emojiFile,
)}"/>`,
);
}
});
}
}
return newData;
}
// 预处理内容,避免重复计算
const processedContent = computed(() => {
if (props.message.contentType === KeFuMessageContentTypeEnum.TEXT) {
return replaceEmoji(getMessageContent.value(props.message).text || props.message.content);
}
return props.message.content;
});
</script>
<style scoped lang="scss">
.message-item {
margin-bottom: 10rpx;
}
.date-message,
.system-message {
width: fit-content;
border-radius: 12rpx;
padding: 8rpx 16rpx;
margin-bottom: 16rpx;
background-color: var(--ui-BG-3);
color: #999;
font-size: 24rpx;
}
.chat-avatar {
width: 70rpx;
height: 70rpx;
border-radius: 50%;
}
.send-status {
color: #333;
height: 80rpx;
margin-right: 8rpx;
display: flex;
align-items: center;
.loading {
width: 32rpx;
height: 32rpx;
-webkit-animation: rotating 2s linear infinite;
animation: rotating 2s linear infinite;
@-webkit-keyframes rotating {
0% {
transform: rotateZ(0);
}
100% {
transform: rotateZ(360deg);
}
}
@keyframes rotating {
0% {
transform: rotateZ(0);
}
100% {
transform: rotateZ(360deg);
}
}
}
.warning {
width: 32rpx;
height: 32rpx;
color: #ff3000;
}
}
.message-box {
max-width: 50%;
font-size: 16px;
white-space: normal;
word-break: break-all;
word-wrap: break-word;
padding: 20rpx;
color: #fff;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
margin-top: 3px;
margin-bottom: 9px;
border-top-left-radius: 10px;
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
&.admin {
background: #fff;
color: #333;
margin-top: 3px;
margin-bottom: 9px;
border-radius: 0 10px 10px 10px;
}
:deep() {
.imgred {
width: 100%;
}
.imgred,
img {
width: 100%;
}
}
}
:deep() {
.goods,
.order {
max-width: 500rpx;
}
}
.message-img {
width: 100px;
height: 100px;
border-radius: 6rpx;
}
.error-img {
width: 400rpx;
height: 400rpx;
}
</style>
+539
View File
@@ -0,0 +1,539 @@
<template>
<view
class="uni-easyinput"
:class="{ 'uni-easyinput-error': msg }"
:style="{ color: inputBorder && msg ? '#e43d33' : styles.color }"
>
<view
class="uni-easyinput__content"
:class="{
'is-input-border': inputBorder,
'is-input-error-border': inputBorder && msg,
'is-textarea': type === 'textarea',
'is-disabled': disabled,
}"
:style="{
'border-color': inputBorder && msg ? '#dd524d' : styles.borderColor,
'background-color': disabled ? styles.disableColor : '',
}"
>
<uni-icons
v-if="prefixIcon"
class="content-clear-icon"
:type="prefixIcon"
color="#c0c4cc"
@click="onClickIcon('prefix')"
></uni-icons>
<textarea
v-if="type === 'textarea'"
class="uni-easyinput__content-textarea"
:class="{ 'input-padding': inputBorder }"
:name="name"
:value="val"
:placeholder="placeholder"
:placeholderStyle="placeholderStyle"
:disabled="disabled"
placeholder-style="color: #bbbbbb;font-size: 28rpx;font-weight: 400;line-height: normal;"
:maxlength="inputMaxlength"
:focus="focused"
:autoHeight="autoHeight"
:adjust-position="false"
@input="onInput"
@blur="onBlur"
@focus="onFocus"
@confirm="onConfirm"
></textarea>
<input
v-else
:type="type === 'password' ? 'text' : type"
class="uni-easyinput__content-input"
:style="{
'padding-right': type === 'password' || clearable || prefixIcon ? '' : '10px',
'padding-left': paddingLeft + 'px',
}"
:name="name"
:value="val"
:password="!showPassword && type === 'password'"
:placeholder="placeholder"
:placeholderStyle="placeholderStyle"
placeholder-style="color: #bbbbbb;font-size: 28rpx;font-weight: 400;line-height: normal;"
:disabled="disabled"
:maxlength="inputMaxlength"
:focus="focused"
:confirmType="confirmType"
:adjust-position="false"
@focus="onFocus"
@blur="onBlur"
@input="onInput"
@change="onInput"
@confirm="onConfirm"
:cursor-spacing="30"
always-embed
/>
<template v-if="type === 'password' && passwordIcon">
<uni-icons
v-if="val"
class="content-clear-icon"
:class="{ 'is-textarea-icon': type === 'textarea' }"
:type="showPassword ? 'eye-slash-filled' : 'eye-filled'"
:size="18"
color="#c0c4cc"
@click="onEyes"
></uni-icons>
</template>
<template v-else-if="suffixIcon">
<uni-icons
v-if="suffixIcon"
class="content-clear-icon"
:type="suffixIcon"
color="#c0c4cc"
@click="onClickIcon('suffix')"
></uni-icons>
</template>
<template v-else>
<uni-icons
class="content-clear-icon"
:class="{ 'is-textarea-icon': type === 'textarea' }"
type="clear"
:size="clearSize"
v-if="clearable && val && !disabled"
color="#c0c4cc"
@click="onClear"
></uni-icons>
</template>
<slot name="right"></slot>
</view>
</view>
</template>
<script>
// import {
// debounce,
// throttle
// } from './common.js'
/**
* Easyinput 输入框
* @description 此组件可以实现表单的输入与校验,包括 "text" 和 "textarea" 类型。
* @tutorial https://ext.dcloud.net.cn/plugin?id=3455
* @property {String} value 输入内容
* @property {String } type 输入框的类型(默认text) password/text/textarea/..
* @value text 文本输入键盘
* @value textarea 多行文本输入键盘
* @value password 密码输入键盘
* @value number 数字输入键盘,注意iOS上app-vue弹出的数字键盘并非9宫格方式
* @value idcard 身份证输入键盘,信、支付宝、百度、QQ小程序
* @value digit 带小数点的数字键盘 ,App的nvue页面、微信、支付宝、百度、头条、QQ小程序支持
* @property {Boolean} clearable 是否显示右侧清空内容的图标控件,点击可清空输入框内容(默认true)
* @property {Boolean} autoHeight 是否自动增高输入区域,type为textarea时有效(默认false)
* @property {String } placeholder 输入框的提示文字
* @property {String } placeholderStyle placeholder的样式(内联样式,字符串),如"color: #ddd"
* @property {Boolean} focus 是否自动获得焦点(默认false)
* @property {Boolean} disabled 是否禁用(默认false)
* @property {Number } maxlength 最大输入长度,设置为 -1 的时候不限制最大长度(默认140)
* @property {String } confirmType 设置键盘右下角按钮的文字,仅在type="text"时生效(默认done)
* @property {Number } clearSize 清除图标的大小,单位px(默认15)
* @property {String} prefixIcon 输入框头部图标
* @property {String} suffixIcon 输入框尾部图标
* @property {Boolean} trim 是否自动去除两端的空格
* @value both 去除两端空格
* @value left 去除左侧空格
* @value right 去除右侧空格
* @value start 去除左侧空格
* @value end 去除右侧空格
* @value all 去除全部空格
* @value none 不去除空格
* @property {Boolean} inputBorder 是否显示input输入框的边框(默认true)
* @property {Boolean} passwordIcon type=password时是否显示小眼睛图标
* @property {Object} styles 自定义颜色
* @event {Function} input 输入框内容发生变化时触发
* @event {Function} focus 输入框获得焦点时触发
* @event {Function} blur 输入框失去焦点时触发
* @event {Function} confirm 点击完成按钮时触发
* @event {Function} iconClick 点击图标时触发
* @example <uni-easyinput v-model="mobile"></uni-easyinput>
*/
export default {
name: 'optimize-input',
emits: ['click', 'iconClick', 'update:modelValue', 'input', 'focus', 'blur', 'confirm'],
model: {
prop: 'modelValue',
event: 'update:modelValue',
},
props: {
name: String,
value: [Number, String],
modelValue: [Number, String],
type: {
type: String,
default: 'text',
},
clearable: {
type: Boolean,
default: true,
},
autoHeight: {
type: Boolean,
default: false,
},
placeholder: String,
placeholderStyle: String,
focus: {
type: Boolean,
default: false,
},
disabled: {
type: Boolean,
default: false,
},
maxlength: {
type: [Number, String],
default: 140,
},
confirmType: {
type: String,
default: 'done',
},
clearSize: {
type: [Number, String],
default: 15,
},
inputBorder: {
type: Boolean,
default: true,
},
prefixIcon: {
type: String,
default: '',
},
suffixIcon: {
type: String,
default: '',
},
trim: {
type: [Boolean, String],
default: true,
},
passwordIcon: {
type: Boolean,
default: true,
},
styles: {
type: Object,
default() {
return {
color: '#333',
disableColor: '#F7F6F6',
borderColor: '#e5e5e5',
};
},
},
errorMessage: {
type: [String, Boolean],
default: '',
},
paddingLeft: {
type: [Number, String],
default: 0,
},
},
data() {
return {
focused: false,
errMsg: '',
val: '',
showMsg: '',
border: false,
isFirstBorder: false,
showClearIcon: false,
showPassword: false,
};
},
computed: {
msg() {
return this.errorMessage || this.errMsg;
},
// 因为uniapp的input组件的maxlength组件必须要数值,这里转为数值,用户可以传入字符串数值
inputMaxlength() {
return Number(this.maxlength);
},
},
watch: {
value(newVal) {
if (this.errMsg) this.errMsg = '';
this.val = newVal;
// fix by mehaotian is_reset 在 uni-forms 中定义
if (this.form && this.formItem && !this.is_reset) {
this.is_reset = false;
this.formItem.setValue(newVal);
}
},
modelValue(newVal) {
if (this.errMsg) this.errMsg = '';
this.val = newVal;
if (this.form && this.formItem && !this.is_reset) {
this.is_reset = false;
this.formItem.setValue(newVal);
}
},
focus(newVal) {
this.$nextTick(() => {
this.focused = this.focus;
});
},
},
created() {
if (!this.value && this.value !== 0) {
this.val = this.modelValue;
}
if (!this.modelValue && this.modelValue !== 0) {
this.val = this.value;
}
this.form = this.getForm('uniForms');
this.formItem = this.getForm('uniFormsItem');
if (this.form && this.formItem) {
if (this.formItem.name) {
if (!this.is_reset) {
this.is_reset = false;
this.formItem.setValue(this.val);
}
this.rename = this.formItem.name;
this.form.inputChildrens.push(this);
}
}
},
mounted() {
this.$nextTick(() => {
this.focused = this.focus;
});
},
methods: {
/**
* 初始化变量值
*/
init() {},
onClickIcon(type) {
this.$emit('iconClick', type);
},
/**
* 获取父元素实例
*/
getForm(name = 'uniForms') {
let parent = this.$parent;
let parentName = parent.$options.name;
while (parentName !== name) {
parent = parent.$parent;
if (!parent) return false;
parentName = parent.$options.name;
}
return parent;
},
onEyes() {
this.showPassword = !this.showPassword;
},
onInput(event) {
let value = event.detail.value;
// 判断是否去除空格
if (this.trim) {
if (typeof this.trim === 'boolean' && this.trim) {
value = this.trimStr(value);
}
if (typeof this.trim === 'string') {
value = this.trimStr(value, this.trim);
}
}
if (this.errMsg) this.errMsg = '';
this.val = value;
// TODO 兼容 vue2
this.$emit('input', value);
// TODO 兼容 vue3
this.$emit('update:modelValue', value);
},
onFocus(event) {
this.$emit('focus', event);
},
onBlur(event) {
let value = event.detail.value;
this.$emit('blur', event);
},
onConfirm(e) {
this.$emit('confirm', e.detail.value);
},
onClear(event) {
this.val = '';
// TODO 兼容 vue2
this.$emit('input', '');
// TODO 兼容 vue2
// TODO 兼容 vue3
this.$emit('update:modelValue', '');
},
fieldClick() {
this.$emit('click');
},
trimStr(str, pos = 'both') {
if (pos === 'both') {
return str.trim();
} else if (pos === 'left') {
return str.trimLeft();
} else if (pos === 'right') {
return str.trimRight();
} else if (pos === 'start') {
return str.trimStart();
} else if (pos === 'end') {
return str.trimEnd();
} else if (pos === 'all') {
return str.replace(/\s+/g, '');
} else if (pos === 'none') {
return str;
}
return str;
},
},
};
</script>
<style lang="scss">
$uni-error: #e43d33;
$uni-border-1: #dcdfe6 !default;
.uni-easyinput {
/* #ifndef APP-NVUE */
width: 100%;
/* #endif */
flex: 1;
position: relative;
text-align: left;
color: #333;
font-size: 14px;
}
.uni-easyinput__content {
flex: 1;
/* #ifndef APP-NVUE */
width: 100%;
display: flex;
box-sizing: border-box;
min-height: 72rpx;
/* #endif */
flex-direction: row;
align-items: center;
}
.uni-easyinput__content-input {
/* #ifndef APP-NVUE */
width: auto;
/* #endif */
position: relative;
overflow: hidden;
flex: 1;
line-height: 56rpx;
font-size: 28rpx;
height: 56rpx;
}
.uni-easyinput__placeholder-class {
color: #bbbbbb;
font-size: 28rpx;
font-weight: 400;
line-height: normal;
}
.is-textarea {
align-items: flex-start;
}
.is-textarea-icon {
margin-top: 5px;
}
.uni-easyinput__content-textarea {
position: relative;
overflow: hidden;
flex: 1;
line-height: 1.5;
font-size: 14px;
padding-top: 6px;
padding-bottom: 10px;
height: 80px;
/* #ifndef APP-NVUE */
min-height: 80px;
width: auto;
/* #endif */
}
.input-padding {
padding-left: 10px;
}
.content-clear-icon {
padding: 0 5px;
}
.label-icon {
margin-right: 5px;
margin-top: -1px;
}
// 显示边框
.is-input-border {
/* #ifndef APP-NVUE */
display: flex;
box-sizing: border-box;
/* #endif */
flex-direction: row;
align-items: center;
border: 1px solid $uni-border-1;
border-radius: 4px;
}
.uni-error-message {
position: absolute;
bottom: -17px;
left: 0;
line-height: 12px;
color: $uni-error;
font-size: 12px;
text-align: left;
}
.uni-error-msg--boeder {
position: relative;
bottom: 0;
line-height: 22px;
}
.is-input-error-border {
border-color: $uni-error;
.uni-easyinput__placeholder-class {
// color: mix(#fff, $uni-error, 50%);
}
}
.uni-easyinput--border {
margin-bottom: 0;
padding: 10px 15px;
// padding-bottom: 0;
border-top: 1px #eee solid;
}
.uni-easyinput-error {
padding-bottom: 0;
}
.is-first-border {
/* #ifndef APP-NVUE */
border: none;
/* #endif */
/* #ifdef APP-NVUE */
border-width: 0;
/* #endif */
}
.is-disabled {
border-color: red;
background-color: #f7f6f6;
color: #d5d5d5;
.uni-easyinput__placeholder-class {
color: #d5d5d5;
font-size: 12px;
}
}
</style>
+114
View File
@@ -0,0 +1,114 @@
<template>
<view class="bg-white order-list-card-box ss-r-10 ss-m-t-14 ss-m-20" :key="orderData.id">
<view class="order-card-header ss-flex ss-col-center ss-row-between ss-p-x-20">
<view class="order-no">订单号:{{ orderData.no }}</view>
<view class="order-state ss-font-26" :class="formatOrderColor(orderData)">
{{ formatOrderStatus(orderData) }}
</view>
</view>
<view class="border-bottom" v-for="item in orderData.items" :key="item.id">
<s-goods-item
:img="item.picUrl"
:title="item.spuName"
:skuText="item.properties.map((property) => property.valueName).join(' ')"
:price="item.price"
:num="item.count"
/>
</view>
<view class="pay-box ss-m-t-30 ss-flex ss-row-right ss-p-r-20">
<view class="ss-flex ss-col-center">
<view class="discounts-title pay-color"
>共 {{ orderData.productCount }} 件商品,总金额:</view
>
<view class="discounts-money pay-color"> ¥{{ fen2yuan(orderData.payPrice) }} </view>
</view>
</view>
</view>
</template>
<script setup>
import { fen2yuan, formatOrderColor, formatOrderStatus } from '@/sheep/hooks/useGoods';
const props = defineProps({
orderData: {
type: Object,
default: {},
},
});
</script>
<style lang="scss" scoped>
.order-list-card-box {
.order-card-header {
height: 80rpx;
.order-no {
font-size: 26rpx;
font-weight: 500;
}
.order-state {
}
}
.pay-box {
.discounts-title {
font-size: 24rpx;
line-height: normal;
color: #999999;
}
.discounts-money {
font-size: 24rpx;
line-height: normal;
color: #999;
font-family: OPPOSANS;
}
.pay-color {
color: #333;
}
}
.order-card-footer {
height: 100rpx;
.more-item-box {
padding: 20rpx;
.more-item {
height: 60rpx;
.title {
font-size: 26rpx;
}
}
}
.more-btn {
color: $dark-9;
font-size: 24rpx;
}
.content {
width: 154rpx;
color: #333333;
font-size: 26rpx;
font-weight: 500;
}
}
}
.warning-color {
color: #faad14;
}
.danger-color {
color: #ff3000;
}
.success-color {
color: #52c41a;
}
.info-color {
color: #999999;
}
</style>
+151
View File
@@ -0,0 +1,151 @@
<template>
<su-popup :show="show" showClose round="10" backgroundColor="#eee" @close="emits('close')">
<view class="select-popup">
<view class="title">
<span>{{ mode == 'goods' ? '我的浏览' : '我的订单' }}</span>
</view>
<scroll-view
class="scroll-box"
scroll-y="true"
:scroll-with-animation="true"
:show-scrollbar="false"
@scrolltolower="loadmore"
>
<view
class="item"
v-for="item in state.pagination.data"
:key="item.id"
@tap="emits('select', { type: mode, data: item })"
>
<template v-if="mode == 'goods'">
<GoodsItem :goodsData="item" />
</template>
<template v-if="mode == 'order'">
<OrderItem :orderData="item" />
</template>
</view>
<uni-load-more :status="state.loadStatus" :content-text="{ contentdown: '上拉加载更多' }" />
</scroll-view>
</view>
</su-popup>
</template>
<script setup>
import { reactive, watch } from 'vue';
import _ from 'lodash-es';
import GoodsItem from './goods.vue';
import OrderItem from './order.vue';
import OrderApi from '@/sheep/api/trade/order';
import SpuHistoryApi from '@/sheep/api/product/history';
const emits = defineEmits(['select', 'close']);
const props = defineProps({
mode: {
type: String,
default: 'goods',
},
show: {
type: Boolean,
default: false,
},
});
watch(
() => props.mode,
() => {
state.pagination.data = [];
if (props.mode) {
getList(state.pagination.page);
}
},
);
const state = reactive({
loadStatus: '',
pagination: {
data: [],
current_page: 1,
total: 1,
last_page: 1,
},
});
async function getList(page, list_rows = 5) {
state.loadStatus = 'loading';
const res =
props.mode == 'goods'
? await SpuHistoryApi.getBrowseHistoryPage({
page,
list_rows,
})
: await OrderApi.getOrderPage({
page,
list_rows,
});
let orderList = _.concat(state.pagination.data, res.data.list);
state.pagination = {
...res.data,
data: orderList,
};
if (state.pagination.current_page < state.pagination.last_page) {
state.loadStatus = 'more';
} else {
state.loadStatus = 'noMore';
}
}
function loadmore() {
if (state.loadStatus !== 'noMore') {
getList(state.pagination.current_page + 1);
}
}
</script>
<style lang="scss" scoped>
.select-popup {
max-height: 600rpx;
.title {
height: 100rpx;
line-height: 100rpx;
padding: 0 26rpx;
background: #fff;
border-radius: 20rpx 20rpx 0 0;
span {
font-size: 32rpx;
position: relative;
&::after {
content: '';
display: block;
width: 100%;
height: 2px;
z-index: 1;
position: absolute;
left: 0;
bottom: -15px;
background: var(--ui-BG-Main);
pointer-events: none;
}
}
}
.scroll-box {
height: 500rpx;
}
.item {
background: #fff;
margin: 26rpx 26rpx 0;
border-radius: 20rpx;
:deep() {
.image {
width: 140rpx;
height: 140rpx;
}
}
}
}
</style>
+164
View File
@@ -0,0 +1,164 @@
<template>
<su-popup :show="showTools" @close="handleClose">
<view class="ss-modal-box ss-flex-col">
<slot></slot>
<view class="content ss-flex ss-flex-1">
<template v-if="toolsMode === 'emoji'">
<swiper
class="emoji-swiper"
:indicator-dots="true"
circular
indicator-active-color="#7063D2"
indicator-color="rgba(235, 231, 255, 1)"
:autoplay="false"
:interval="3000"
:duration="1000"
>
<swiper-item v-for="emoji in emojiPage" :key="emoji">
<view class="ss-flex ss-flex-wrap">
<image
v-for="item in emoji"
:key="item"
class="emoji-img"
:src="sheep.$url.cdn(`/static/img/chat/emoji/${item.file}`)"
@tap="onEmoji(item)"
>
</image>
</view>
</swiper-item>
</swiper>
</template>
<template v-else>
<view class="image">
<s-uploader
file-mediatype="image"
:imageStyles="{ width: 50, height: 50, border: false }"
@select="imageSelect({ type: 'image', data: $event })"
>
<image
class="icon"
:src="sheep.$url.static('/static/img/shop/chat/image.png')"
mode="aspectFill"
></image>
</s-uploader>
<view>图片</view>
</view>
<view class="goods" @tap="onShowSelect('goods')">
<image
class="icon"
:src="sheep.$url.static('/static/img/shop/chat/goods.png')"
mode="aspectFill"
></image>
<view>商品</view>
</view>
<view class="order" @tap="onShowSelect('order')">
<image
class="icon"
:src="sheep.$url.static('/static/img/shop/chat/order.png')"
mode="aspectFill"
></image>
<view>订单</view>
</view>
</template>
</view>
</view>
</su-popup>
</template>
<script setup>
/**
* 聊天工具
*/
import { emojiPage } from '@/pages/chat/util/emoji';
import sheep from '@/sheep';
const props = defineProps({
// 工具模式
toolsMode: {
type: String,
default: '',
},
// 控制工具菜单弹出
showTools: {
type: Boolean,
default: () => false,
},
});
const emits = defineEmits(['onEmoji', 'imageSelect', 'onShowSelect', 'close']);
// 关闭弹出工具菜单
function handleClose() {
emits('close');
}
// 选择表情
function onEmoji(emoji) {
emits('onEmoji', emoji);
}
// 选择图片
function imageSelect(val) {
emits('imageSelect', val);
}
// 选择商品或订单
function onShowSelect(mode) {
emits('onShowSelect', mode);
}
</script>
<style scoped lang="scss">
.content {
width: 100%;
align-content: space-around;
border-top: 1px solid #dfdfdf;
padding: 20rpx 0 0;
.emoji-swiper {
width: 100%;
height: 280rpx;
padding: 0 20rpx;
.emoji-img {
width: 50rpx;
height: 50rpx;
display: inline-block;
margin: 10rpx;
}
}
.image,
.goods,
.order {
width: 33.3%;
height: 280rpx;
text-align: center;
font-size: 24rpx;
color: #333;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.icon {
width: 50rpx;
height: 50rpx;
margin-bottom: 21rpx;
}
}
:deep() {
.uni-file-picker__container {
justify-content: center;
}
.file-picker__box {
display: none;
&:last-of-type {
display: flex;
}
}
}
}
</style>
+222
View File
@@ -0,0 +1,222 @@
<template>
<s-layout
class="chat-wrap"
:title="!isReconnecting ? '连接客服成功' : '会话重连中'"
navbar="inner"
>
<!-- 覆盖头部导航栏背景颜色 -->
<view class="page-bg" :style="{ height: sys_navBar + 'px' }"></view>
<!-- 聊天区域 -->
<MessageList ref="messageListRef">
<template #bottom>
<message-input
v-model="chat.msg"
@on-tools="onTools"
@send-message="onSendMessage"
:auto-focus="false"
:show-char-count="true"
:max-length="500"
></message-input>
</template>
</MessageList>
<!-- 聊天工具 -->
<tools-popup
:show-tools="chat.showTools"
:tools-mode="chat.toolsMode"
@close="handleToolsClose"
@on-emoji="onEmoji"
@image-select="onSelect"
@on-show-select="onShowSelect"
>
<message-input
v-model="chat.msg"
@on-tools="onTools"
@send-message="onSendMessage"
:auto-focus="false"
:show-char-count="true"
:max-length="500"
></message-input>
</tools-popup>
<!-- 商品订单选择 -->
<SelectPopup
:mode="chat.selectMode"
:show="chat.showSelect"
@select="onSelect"
@close="chat.showSelect = false"
/>
</s-layout>
</template>
<script setup>
import MessageList from '@/pages/chat/components/messageList.vue';
import { reactive, ref, toRefs } from 'vue';
import sheep from '@/sheep';
import ToolsPopup from '@/pages/chat/components/toolsPopup.vue';
import MessageInput from '@/pages/chat/components/messageInput.vue';
import SelectPopup from '@/pages/chat/components/select-popup.vue';
import {
KeFuMessageContentTypeEnum,
WebSocketMessageTypeConstants,
} from '@/pages/chat/util/constants';
import FileApi from '@/sheep/api/infra/file';
import KeFuApi from '@/sheep/api/promotion/kefu';
import { useWebSocket } from './util/useWebSocket';
import { jsonParse } from '@/sheep/helper/utils';
const sys_navBar = sheep.$platform.navbar;
const chat = reactive({
msg: '',
scrollInto: '',
showTools: false,
toolsMode: '',
showSelect: false,
selectMode: '',
});
// 发送消息
async function onSendMessage() {
if (!chat.msg) return;
try {
const data = {
contentType: KeFuMessageContentTypeEnum.TEXT,
content: JSON.stringify({ text: chat.msg }),
};
await KeFuApi.sendKefuMessage(data);
chat.msg = '';
} finally {
chat.showTools = false;
}
}
const messageListRef = ref();
//======================= 聊天工具相关 start =======================
function handleToolsClose() {
chat.showTools = false;
chat.toolsMode = '';
}
function onEmoji(item) {
chat.msg += item.name;
}
// 点击工具栏开关
function onTools(mode) {
if (isReconnecting.value) {
sheep.$helper.toast('您已掉线!请返回重试');
return;
}
// 第二次点击关闭
if (chat.showTools && chat.toolsMode === mode) {
handleToolsClose();
return;
}
// 切换工具栏
if (chat.showTools && chat.toolsMode !== mode) {
chat.showTools = false;
chat.toolsMode = '';
}
// 延迟打开等一下过度效果
setTimeout(() => {
chat.toolsMode = mode;
chat.showTools = true;
}, 200);
}
function onShowSelect(mode) {
chat.showTools = false;
chat.showSelect = true;
chat.selectMode = mode;
}
async function onSelect({ type, data }) {
let msg;
switch (type) {
case 'image':
const res = await FileApi.uploadFile(data.tempFiles[0].path);
msg = {
contentType: KeFuMessageContentTypeEnum.IMAGE,
content: JSON.stringify({ picUrl: res.data }),
};
break;
case 'goods':
msg = {
contentType: KeFuMessageContentTypeEnum.PRODUCT,
content: JSON.stringify(data),
};
break;
case 'order':
msg = {
contentType: KeFuMessageContentTypeEnum.ORDER,
content: JSON.stringify(data),
};
break;
}
if (msg) {
// 发送消息
// scrollBottom();
await KeFuApi.sendKefuMessage(msg);
await messageListRef.value.refreshMessageList();
chat.showTools = false;
chat.showSelect = false;
chat.selectMode = '';
}
}
//======================= 聊天工具相关 end =======================
const { options } = useWebSocket({
// 连接成功
onConnected: async () => {},
// 收到消息
onMessage: async (data) => {
const type = data.type;
if (!type) {
console.error('未知的消息类型:' + data);
return;
}
// 2.2 消息类型:KEFU_MESSAGE_TYPE
if (type === WebSocketMessageTypeConstants.KEFU_MESSAGE_TYPE) {
// 刷新消息列表
await messageListRef.value.refreshMessageList(jsonParse(data.content));
return;
}
// 2.3 消息类型:KEFU_MESSAGE_ADMIN_READ
if (type === WebSocketMessageTypeConstants.KEFU_MESSAGE_ADMIN_READ) {
console.log('管理员已读消息');
// 更新消息已读状态
sheep.$helper.toast('客服已读您的消息');
}
},
});
const isReconnecting = toRefs(options).isReconnecting; // 重连状态
</script>
<style scoped lang="scss">
.chat-wrap {
.page-bg {
width: 100%;
position: absolute;
top: 0;
left: 0;
background-color: var(--ui-BG-Main);
z-index: 1;
}
.status {
position: relative;
box-sizing: border-box;
z-index: 3;
height: 70rpx;
padding: 0 30rpx;
background: var(--ui-BG-Main-opacity-1);
display: flex;
align-items: center;
font-size: 30rpx;
font-weight: 400;
color: var(--ui-BG-Main);
}
}
</style>
+19
View File
@@ -0,0 +1,19 @@
export const KeFuMessageContentTypeEnum = {
TEXT: 1, // 文本消息
IMAGE: 2, // 图片消息
VOICE: 3, // 语音消息
VIDEO: 4, // 视频消息
SYSTEM: 5, // 系统消息
// ========== 商城特殊消息 ==========
PRODUCT: 10, // 商品消息
ORDER: 11, // 订单消息"
};
export const UserTypeEnum = {
MEMBER: 1, // 会员 面向 c 端,普通用户
ADMIN: 2, // 管理员 面向 b 端,管理后台
};
// Promotion 的 WebSocket 消息类型枚举类
export const WebSocketMessageTypeConstants = {
KEFU_MESSAGE_TYPE: 'kefu_message_type', // 客服消息类型
KEFU_MESSAGE_ADMIN_READ: 'kefu_message_read_status_change', // 客服消息管理员已读
};
+58
View File
@@ -0,0 +1,58 @@
export const emojiList = [
{ name: '[笑掉牙]', file: 'xiaodiaoya.png' },
{ name: '[可爱]', file: 'keai.png' },
{ name: '[冷酷]', file: 'lengku.png' },
{ name: '[闭嘴]', file: 'bizui.png' },
{ name: '[生气]', file: 'shengqi.png' },
{ name: '[惊恐]', file: 'jingkong.png' },
{ name: '[瞌睡]', file: 'keshui.png' },
{ name: '[大笑]', file: 'daxiao.png' },
{ name: '[爱心]', file: 'aixin.png' },
{ name: '[坏笑]', file: 'huaixiao.png' },
{ name: '[飞吻]', file: 'feiwen.png' },
{ name: '[疑问]', file: 'yiwen.png' },
{ name: '[开心]', file: 'kaixin.png' },
{ name: '[发呆]', file: 'fadai.png' },
{ name: '[流泪]', file: 'liulei.png' },
{ name: '[汗颜]', file: 'hanyan.png' },
{ name: '[惊悚]', file: 'jingshu.png' },
{ name: '[困~]', file: 'kun.png' },
{ name: '[心碎]', file: 'xinsui.png' },
{ name: '[天使]', file: 'tianshi.png' },
{ name: '[晕]', file: 'yun.png' },
{ name: '[啊]', file: 'a.png' },
{ name: '[愤怒]', file: 'fennu.png' },
{ name: '[睡着]', file: 'shuizhuo.png' },
{ name: '[面无表情]', file: 'mianwubiaoqing.png' },
{ name: '[难过]', file: 'nanguo.png' },
{ name: '[犯困]', file: 'fankun.png' },
{ name: '[好吃]', file: 'haochi.png' },
{ name: '[呕吐]', file: 'outu.png' },
{ name: '[龇牙]', file: 'ziya.png' },
{ name: '[懵比]', file: 'mengbi.png' },
{ name: '[白眼]', file: 'baiyan.png' },
{ name: '[饿死]', file: 'esi.png' },
{ name: '[凶]', file: 'xiong.png' },
{ name: '[感冒]', file: 'ganmao.png' },
{ name: '[流汗]', file: 'liuhan.png' },
{ name: '[笑哭]', file: 'xiaoku.png' },
{ name: '[流口水]', file: 'liukoushui.png' },
{ name: '[尴尬]', file: 'ganga.png' },
{ name: '[惊讶]', file: 'jingya.png' },
{ name: '[大惊]', file: 'dajing.png' },
{ name: '[不好意思]', file: 'buhaoyisi.png' },
{ name: '[大闹]', file: 'danao.png' },
{ name: '[不可思议]', file: 'bukesiyi.png' },
{ name: '[爱你]', file: 'aini.png' },
{ name: '[红心]', file: 'hongxin.png' },
{ name: '[点赞]', file: 'dianzan.png' },
{ name: '[恶魔]', file: 'emo.png' },
];
export let emojiPage = {};
emojiList.forEach((item, index) => {
if (!emojiPage[Math.floor(index / 30) + 1]) {
emojiPage[Math.floor(index / 30) + 1] = [];
}
emojiPage[Math.floor(index / 30) + 1].push(item);
});
+150
View File
@@ -0,0 +1,150 @@
import { onBeforeUnmount, reactive, ref } from 'vue';
import { baseUrl, websocketPath } from '@/sheep/config';
import { copyValueToTarget } from '@/sheep/helper/utils';
import { getRefreshToken } from '@/sheep/request';
/**
* WebSocket 创建 hook
* @param opt 连接配置
* @return {{options: *}}
*/
export function useWebSocket(opt) {
const options = reactive({
url: (baseUrl + websocketPath).replace('http', 'ws') + '?token=' + getRefreshToken(), // ws 地址
isReconnecting: false, // 正在重新连接
reconnectInterval: 3000, // 重连间隔,单位毫秒
heartBeatInterval: 5000, // 心跳间隔,单位毫秒
pingTimeoutDuration: 1000, // 超过这个时间,后端没有返回pong,则判定后端断线了。
heartBeatTimer: null, // 心跳计时器
destroy: false, // 是否销毁
pingTimeout: null, // 心跳检测定时器
reconnectTimeout: null, // 重连定时器ID的属性
onConnected: () => {}, // 连接成功时触发
onClosed: () => {}, // 连接关闭时触发
onMessage: (data) => {}, // 收到消息
});
const SocketTask = ref(null); // SocketTask 由 uni.connectSocket() 接口创建
const initEventListeners = () => {
// 监听 WebSocket 连接打开事件
SocketTask.value.onOpen(() => {
console.log('WebSocket 连接成功');
// 连接成功时触发
options.onConnected();
// 开启心跳检查
startHeartBeat();
});
// 监听 WebSocket 接受到服务器的消息事件
SocketTask.value.onMessage((res) => {
try {
if (res.data === 'pong') {
// 收到心跳重置心跳超时检查
resetPingTimeout();
} else {
options.onMessage(JSON.parse(res.data));
}
} catch (error) {
console.error(error);
}
});
// 监听 WebSocket 连接关闭事件
SocketTask.value.onClose((event) => {
// 情况一:实例销毁
if (options.destroy) {
options.onClosed();
} else {
// 情况二:连接失败重连
// 停止心跳检查
stopHeartBeat();
// 重连
reconnect();
}
});
};
// 发送消息
const sendMessage = (message) => {
if (SocketTask.value && !options.destroy) {
SocketTask.value.send({ data: message });
}
};
// 开始心跳检查
const startHeartBeat = () => {
options.heartBeatTimer = setInterval(() => {
sendMessage('ping');
options.pingTimeout = setTimeout(() => {
// 如果在超时时间内没有收到 pong,则认为连接断开
reconnect();
}, options.pingTimeoutDuration);
}, options.heartBeatInterval);
};
// 停止心跳检查
const stopHeartBeat = () => {
clearInterval(options.heartBeatTimer);
resetPingTimeout();
};
// WebSocket 重连
const reconnect = () => {
if (options.destroy || !SocketTask.value) {
// 如果WebSocket已被销毁或尚未完全关闭,不进行重连
return;
}
// 重连中
options.isReconnecting = true;
// 清除现有的重连标志,以避免多次重连
if (options.reconnectTimeout) {
clearTimeout(options.reconnectTimeout);
}
// 设置重连延迟
options.reconnectTimeout = setTimeout(() => {
// 检查组件是否仍在运行和WebSocket是否关闭
if (!options.destroy) {
// 重置重连标志
options.isReconnecting = false;
// 初始化新的WebSocket连接
initSocket();
}
}, options.reconnectInterval);
};
const resetPingTimeout = () => {
if (options.pingTimeout) {
clearTimeout(options.pingTimeout);
options.pingTimeout = null; // 清除超时ID
}
};
const close = () => {
options.destroy = true;
stopHeartBeat();
if (options.reconnectTimeout) {
clearTimeout(options.reconnectTimeout);
}
if (SocketTask.value) {
SocketTask.value.close();
SocketTask.value = null;
}
};
const initSocket = () => {
options.destroy = false;
copyValueToTarget(options, opt);
SocketTask.value = uni.connectSocket({
url: options.url,
complete: () => {},
success: () => {},
});
initEventListeners();
};
initSocket();
onBeforeUnmount(() => {
close();
});
return { options };
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,125 @@
<!-- 分销账户:展示基本统计信息 -->
<template>
<view class="account-card">
<view class="account-card-box">
<view class="ss-flex ss-row-between card-box-header">
<view class="ss-flex">
<view class="header-title ss-m-r-16">账户信息</view>
<button
class="ss-reset-button look-btn ss-flex"
@tap="state.showMoney = !state.showMoney"
>
<uni-icons
:type="state.showMoney ? 'eye-filled' : 'eye-slash-filled'"
color="#A57A55"
size="20"
/>
</button>
</view>
<view class="ss-flex" @tap="sheep.$router.go('/pages/commission/wallet')">
<view class="header-title ss-m-r-4">查看明细</view>
<text class="cicon-play-arrow" />
</view>
</view>
<!-- 收益 -->
<view class="card-content ss-flex">
<view class="ss-flex-1 ss-flex-col ss-col-center">
<view class="item-title">当前佣金(元)</view>
<view class="item-detail">
{{ state.showMoney ? fen2yuan(state.summary.brokeragePrice || 0) : '***' }}
</view>
</view>
<view class="ss-flex-1 ss-flex-col ss-col-center">
<view class="item-title">昨天的佣金(元)</view>
<view class="item-detail">
{{ state.showMoney ? fen2yuan(state.summary.yesterdayPrice || 0) : '***' }}
</view>
</view>
<view class="ss-flex-1 ss-flex-col ss-col-center">
<view class="item-title">累计已提(元)</view>
<view class="item-detail">
{{ state.showMoney ? fen2yuan(state.summary.withdrawPrice || 0) : '***' }}
</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import sheep from '@/sheep';
import { computed, reactive, onMounted } from 'vue';
import BrokerageApi from '@/sheep/api/trade/brokerage';
import { fen2yuan } from '@/sheep/hooks/useGoods';
const userInfo = computed(() => sheep.$store('user').userInfo);
const state = reactive({
showMoney: false,
summary: {},
});
onMounted(async () => {
let { code, data } = await BrokerageApi.getBrokerageUserSummary();
if (code === 0) {
state.summary = data || {};
}
});
</script>
<style lang="scss" scoped>
.account-card {
width: 694rpx;
margin: 0 auto;
padding: 2rpx;
background: linear-gradient(180deg, #ffffff 0.88%, #fff9ec 100%);
border-radius: 12rpx;
z-index: 3;
position: relative;
.account-card-box {
background: #ffefd6;
.card-box-header {
padding: 0 30rpx;
height: 72rpx;
box-shadow: 0px 2px 6px #f2debe;
.header-title {
font-size: 24rpx;
font-weight: 500;
color: #a17545;
line-height: 30rpx;
}
.cicon-play-arrow {
color: #a17545;
font-size: 24rpx;
line-height: 30rpx;
}
}
.card-content {
height: 190rpx;
background: #fdfae9;
.item-title {
font-size: 24rpx;
font-weight: 500;
color: #cba67e;
line-height: 30rpx;
margin-bottom: 24rpx;
}
.item-detail {
font-size: 36rpx;
font-family: OPPOSANS;
font-weight: bold;
color: #692e04;
line-height: 30rpx;
}
}
}
}
</style>
@@ -0,0 +1,171 @@
<!-- 提现方式的 select 组件 -->
<template>
<su-popup :show="show" class="ss-checkout-counter-wrap" @close="hideModal">
<view class="ss-modal-box bg-white ss-flex-col">
<view class="modal-header ss-flex-col ss-col-left">
<text class="modal-title ss-m-b-20">选择提现方式</text>
</view>
<view class="modal-content ss-flex-1 ss-p-b-100">
<radio-group @change="onChange">
<label
class="container-list ss-p-l-34 ss-p-r-24 ss-flex ss-col-center ss-row-center"
v-for="(item, index) in typeList"
:key="index"
>
<view class="container-icon ss-flex ss-m-r-20">
<image :src="sheep.$url.static(item.icon)" />
</view>
<view class="ss-flex-1">{{ item.title }}</view>
<radio
:value="item.value"
color="var(--ui-BG-Main)"
:checked="item.value === state.currentValue"
:disabled="!methods.includes(parseInt(item.value))"
/>
</label>
</radio-group>
</view>
<view class="modal-footer ss-flex ss-row-center ss-col-center">
<button class="ss-reset-button save-btn" @tap="onConfirm">确定</button>
</view>
</view>
</su-popup>
</template>
<script setup>
import { reactive } from 'vue';
import sheep from '@/sheep';
const props = defineProps({
modelValue: {
type: Object,
default() {},
},
show: {
type: Boolean,
default: false,
},
methods: {
// 开启的提现方式
type: Array,
default: [],
},
});
const emits = defineEmits(['update:modelValue', 'change', 'close']);
const state = reactive({
currentValue: '',
});
const typeList = [
{
icon: '/static/img/shop/pay/wallet.png',
title: '钱包余额',
value: '1',
},
{
icon: '/static/img/shop/pay/bank.png',
title: '银行卡转账',
value: '2',
},
{
icon: '/static/img/shop/pay/wechat.png',
title: '微信收款码', // 微信手动转账
value: '3',
},
{
icon: '/static/img/shop/pay/alipay.png',
title: '支付宝收款码', // 支付宝手动转账
value: '4',
},
{
icon: '/static/img/shop/pay/wechat_api.png',
title: '微信零钱', // 微信 API 转账
value: '5',
},
{
icon: '/static/img/shop/pay/alipay_api.png',
title: '支付宝余额', // 支付宝 API 转账
value: '6',
},
];
function onChange(e) {
state.currentValue = e.detail.value;
}
const onConfirm = async () => {
if (state.currentValue === '') {
sheep.$helper.toast('请选择提现方式');
return;
}
// 赋值
emits('update:modelValue', {
type: state.currentValue,
});
// 关闭弹窗
emits('close');
};
const hideModal = () => {
emits('close');
};
</script>
<style lang="scss" scoped>
.ss-modal-box {
border-radius: 30rpx 30rpx 0 0;
max-height: 1000rpx;
.modal-header {
position: relative;
padding: 60rpx 40rpx 40rpx;
.modal-title {
font-size: 32rpx;
font-weight: bold;
}
.close-icon {
position: absolute;
top: 10rpx;
right: 20rpx;
font-size: 46rpx;
opacity: 0.2;
}
}
.modal-content {
overflow-y: auto;
.container-list {
height: 96rpx;
border-bottom: 2rpx solid rgba(#dfdfdf, 0.5);
font-size: 28rpx;
font-weight: 500;
color: #333333;
.container-icon {
width: 36rpx;
height: 36rpx;
}
}
}
.modal-footer {
height: 120rpx;
.save-btn {
width: 710rpx;
height: 80rpx;
border-radius: 40rpx;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
color: $white;
}
}
}
image {
width: 100%;
height: 100%;
}
</style>
@@ -0,0 +1,101 @@
<!-- 分销权限弹窗:再没有权限时,进行提示 -->
<template>
<su-popup
:show="state.show"
type="center"
round="10"
@close="state.show = false"
:isMaskClick="false"
maskBackgroundColor="rgba(0, 0, 0, 0.7)"
>
<view class="notice-box">
<view class="img-wrap">
<image
class="notice-img"
:src="sheep.$url.static('/static/img/shop/commission/forbidden.png')"
mode="aspectFill"
/>
</view>
<view class="notice-title"> 抱歉!您没有分销权限 </view>
<view class="notice-detail"> 该功能暂不可用 </view>
<button
class="ss-reset-button notice-btn ui-Shadow-Main ui-BG-Main-Gradient"
@tap="sheep.$router.back()"
>
知道了
</button>
<button class="ss-reset-button back-btn" @tap="sheep.$router.back()"> 返回 </button>
</view>
</su-popup>
</template>
<script setup>
import { onShow } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import { reactive } from 'vue';
import BrokerageApi from '@/sheep/api/trade/brokerage';
const state = reactive({
show: false,
});
onShow(async () => {
// 读取是否有分销权限
const { code, data } = await BrokerageApi.getBrokerageUser();
if (code === 0 && !data?.brokerageEnabled) {
state.show = true;
}
});
</script>
<style lang="scss" scoped>
.notice-box {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: #fff;
width: 612rpx;
min-height: 658rpx;
background: #ffffff;
padding: 30rpx;
border-radius: 20rpx;
.img-wrap {
margin-bottom: 50rpx;
.notice-img {
width: 180rpx;
height: 170rpx;
}
}
.notice-title {
font-size: 35rpx;
font-weight: bold;
color: #333;
margin-bottom: 28rpx;
}
.notice-detail {
font-size: 28rpx;
font-weight: 400;
color: #999999;
line-height: 36rpx;
margin-bottom: 50rpx;
}
.notice-btn {
width: 492rpx;
line-height: 70rpx;
border-radius: 35rpx;
font-size: 28rpx;
font-weight: 500;
color: #ffffff;
margin-bottom: 10rpx;
}
.back-btn {
width: 492rpx;
line-height: 70rpx;
font-size: 28rpx;
font-weight: 500;
color: var(--ui-BG-Main-gradient);
background: none;
}
}
</style>
@@ -0,0 +1,113 @@
<!-- 分销商信息 -->
<template>
<!-- 用户资料 -->
<view class="user-card ss-flex ss-col-bottom">
<view class="card-top ss-flex ss-row-between">
<view class="ss-flex">
<view class="head-img-box">
<image class="head-img" :src="sheep.$url.cdn(userInfo.avatar)" mode="aspectFill"></image>
</view>
<view class="ss-flex-col">
<view class="user-name">{{ userInfo.nickname }}</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import sheep from '@/sheep';
import { computed, reactive } from 'vue';
const userInfo = computed(() => sheep.$store('user').userInfo);
const headerBg = sheep.$url.css('/static/img/shop/commission/background.png');
const state = reactive({
showMoney: false,
});
</script>
<style lang="scss" scoped>
// 用户资料卡片
.user-card {
width: 700rpx;
height: 192rpx;
margin: 0 auto;
margin-top: -88rpx;
padding-top: 88rpx;
background: v-bind(headerBg) no-repeat;
background-size: 100% 100%;
.head-img-box {
margin-right: 20rpx;
width: 100rpx;
height: 100rpx;
border-radius: 50%;
position: relative;
background: #fce0ad;
.head-img {
width: 92rpx;
height: 92rpx;
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
.card-top {
box-sizing: border-box;
padding-bottom: 34rpx;
.user-name {
font-size: 32rpx;
font-weight: bold;
color: #692e04;
line-height: 30rpx;
margin-bottom: 20rpx;
}
.log-btn {
width: 84rpx;
height: 42rpx;
border: 2rpx solid rgba(#ffffff, 0.33);
border-radius: 21rpx;
font-size: 22rpx;
font-weight: 400;
color: #ffffff;
margin-bottom: 20rpx;
}
.look-btn {
color: #fff;
width: 40rpx;
height: 40rpx;
}
}
.user-info-box {
.tag-box {
background: #ff6000;
border-radius: 18rpx;
line-height: 36rpx;
.tag-img {
width: 36rpx;
height: 36rpx;
border-radius: 50%;
margin-left: -2rpx;
}
.tag-title {
font-size: 24rpx;
padding: 0 10rpx;
font-weight: 500;
line-height: 36rpx;
color: #fff;
}
}
}
}
</style>
@@ -0,0 +1,181 @@
<!-- 分销首页:明细列表 -->
<template>
<view class="distribution-log-wrap">
<view class="header-box">
<image class="header-bg" :src="sheep.$url.static('/static/img/shop/commission/title2.png')" />
<view class="ss-flex header-title">
<view class="title">实时动态</view>
<text class="cicon-forward" />
</view>
</view>
<scroll-view
scroll-y="true"
@scrolltolower="loadmore"
class="scroll-box log-scroll"
scroll-with-animation="true"
>
<view v-if="state.pagination.list">
<view
class="log-item-box ss-flex ss-row-between"
v-for="item in state.pagination.list"
:key="item.id"
>
<view class="log-item-wrap">
<view class="log-item ss-flex ss-ellipsis-1 ss-col-center">
<view class="ss-flex ss-col-center">
<image
class="log-img"
:src="sheep.$url.static('/static/img/shop/avatar/notice.png')"
mode="aspectFill"
/>
</view>
<view class="log-text ss-ellipsis-1">
{{ item.title }} {{ fen2yuan(item.price) }} 元
</view>
</view>
</view>
<text class="log-time">{{ dayjs(item.createTime).fromNow() }}</text>
</view>
</view>
<!-- 加载更多 -->
<uni-load-more
v-if="state.pagination.total > 0"
:status="state.loadStatus"
color="#333333"
@tap="loadmore"
/>
</scroll-view>
</view>
</template>
<script setup>
import sheep from '@/sheep';
import { reactive } from 'vue';
import _ from 'lodash-es';
import dayjs from 'dayjs';
import BrokerageApi from '@/sheep/api/trade/brokerage';
import { fen2yuan } from '../../../sheep/hooks/useGoods';
const state = reactive({
loadStatus: '',
pagination: {
list: [],
total: 0,
pageNo: 1,
pageSize: 8,
},
});
async function getLog() {
state.loadStatus = 'loading';
const { code, data } = await BrokerageApi.getBrokerageRecordPage({
pageNo: state.pagination.pageNo,
pageSize: state.pagination.pageSize,
});
if (code !== 0) {
return;
}
state.pagination.list = _.concat(state.pagination.list, data.list);
state.pagination.total = data.total;
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
}
getLog();
// 加载更多
function loadmore() {
if (state.loadStatus === 'noMore') {
return;
}
state.pagination.pageNo++;
getLog();
}
</script>
<style lang="scss" scoped>
.distribution-log-wrap {
width: 690rpx;
margin: 0 auto;
margin-bottom: 20rpx;
border-radius: 12rpx;
z-index: 3;
position: relative;
.header-box {
width: 690rpx;
height: 76rpx;
position: relative;
.header-bg {
width: 690rpx;
height: 76rpx;
}
.header-title {
position: absolute;
left: 20rpx;
top: 24rpx;
}
.title {
font-size: 28rpx;
font-weight: 500;
color: #ffffff;
line-height: 30rpx;
}
.cicon-forward {
font-size: 30rpx;
font-weight: 400;
color: #ffffff;
line-height: 30rpx;
}
}
.log-scroll {
height: 600rpx;
background: #fdfae9;
padding: 10rpx 20rpx 0;
box-sizing: border-box;
border-radius: 0 0 12rpx 12rpx;
.log-item-box {
margin-bottom: 20rpx;
.log-time {
// margin-left: 30rpx;
text-align: right;
font-size: 24rpx;
font-family: OPPOSANS;
font-weight: 400;
color: #c4c4c4;
}
}
.loadmore-wrap {
// line-height: 80rpx;
}
.log-item {
// background: rgba(#ffffff, 0.2);
border-radius: 24rpx;
padding: 6rpx 20rpx 6rpx 12rpx;
.log-img {
width: 40rpx;
height: 40rpx;
border-radius: 50%;
margin-right: 10rpx;
}
.log-text {
max-width: 480rpx;
font-size: 24rpx;
font-weight: 500;
color: #333333;
}
}
}
}
</style>
@@ -0,0 +1,145 @@
<!-- 分销:商菜单栏 -->
<template>
<view class="menu-box ss-flex-col">
<view class="header-box">
<image class="header-bg" :src="sheep.$url.static('/static/img/shop/commission/title1.png')" />
<view class="ss-flex header-title">
<view class="title">功能专区</view>
<text class="cicon-forward"></text>
</view>
</view>
<view class="menu-list ss-flex ss-flex-wrap">
<view
v-for="(item, index) in state.menuList"
:key="index"
class="item-box ss-flex-col ss-col-center"
@tap="sheep.$router.go(item.path)"
>
<image
class="menu-icon ss-m-b-10"
:src="sheep.$url.static(item.img)"
mode="aspectFill"
></image>
<view>{{ item.title }}</view>
</view>
</view>
</view>
</template>
<script setup>
import sheep from '@/sheep';
import { reactive } from 'vue';
const state = reactive({
menuList: [
{
img: '/static/img/shop/commission/commission_icon1.png',
title: '我的团队',
path: '/pages/commission/team',
},
{
img: '/static/img/shop/commission/commission_icon2.png',
title: '佣金明细',
path: '/pages/commission/wallet',
},
{
img: '/static/img/shop/commission/commission_icon3.png',
title: '分销订单',
path: '/pages/commission/order',
},
{
img: '/static/img/shop/commission/commission_icon4.png',
title: '推广商品',
path: '/pages/commission/goods',
},
// {
// img: '/static/img/shop/commission/commission_icon5.png',
// title: '我的资料',
// path: '/pages/commission/apply',
// isAgentFrom: true,
// },
{
img: '/static/img/shop/commission/commission_icon7.png',
title: '邀请海报',
path: 'action:showShareModal',
},
{
img: '/static/img/shop/commission/commission_icon8.png',
title: '推广排行',
path: '/pages/commission/promoter',
},
{
img: '/static/img/shop/commission/commission_icon9.png',
title: '佣金排行',
path: '/pages/commission/commission-ranking',
},
],
});
</script>
<style lang="scss" scoped>
.menu-box {
margin: 0 auto;
width: 690rpx;
margin-bottom: 20rpx;
margin-top: 20rpx;
border-radius: 12rpx;
z-index: 3;
position: relative;
}
.header-box {
width: 690rpx;
height: 76rpx;
position: relative;
.header-bg {
width: 690rpx;
height: 76rpx;
}
.header-title {
position: absolute;
left: 20rpx;
top: 24rpx;
}
.title {
font-size: 28rpx;
font-weight: 500;
color: #ffffff;
line-height: 30rpx;
}
.cicon-forward {
font-size: 30rpx;
font-weight: 400;
color: #ffffff;
line-height: 30rpx;
}
}
.menu-list {
padding: 50rpx 0 10rpx 0;
background: #fdfae9;
border-radius: 0 0 12rpx 12rpx;
}
.item-box {
width: 25%;
margin-bottom: 40rpx;
}
.menu-icon {
width: 68rpx;
height: 68rpx;
background: #ffffff;
border-radius: 50%;
}
.menu-title {
font-size: 26rpx;
font-weight: 500;
color: #ffffff;
}
</style>
+165
View File
@@ -0,0 +1,165 @@
<!-- 分销商品列表 -->
<template>
<s-layout title="推广商品" :onShareAppMessage="state.shareInfo">
<view class="goods-item ss-m-20" v-for="item in state.pagination.list" :key="item.id">
<s-goods-item
size="lg"
:img="item.picUrl"
:title="item.name"
:subTitle="item.introduction"
:price="item.price"
:originPrice="item.marketPrice"
priceColor="#333"
@tap="sheep.$router.go('/pages/goods/index', { id: item.id })"
>
<template #rightBottom>
<view class="ss-flex ss-row-between">
<view class="commission-num" v-if="item.brokerageMinPrice === undefined">
预计佣金:计算中
</view>
<view
class="commission-num"
v-else-if="item.brokerageMinPrice === item.brokerageMaxPrice"
>
预计佣金:{{ fen2yuan(item.brokerageMinPrice) }}
</view>
<view class="commission-num" v-else>
预计佣金:{{ fen2yuan(item.brokerageMinPrice) }} ~
{{ fen2yuan(item.brokerageMaxPrice) }}
</view>
<button
class="ss-reset-button share-btn ui-BG-Main-Gradient"
@tap.stop="onShareGoods(item)"
>
分享赚
</button>
</view>
</template>
</s-goods-item>
</view>
<s-empty
v-if="state.pagination.total === 0"
icon="/static/goods-empty.png"
text="暂无推广商品"
/>
<!-- 加载更多 -->
<uni-load-more
v-if="state.pagination.total > 0"
:status="state.loadStatus"
:content-text="{
contentdown: '上拉加载更多',
}"
@tap="loadMore"
/>
</s-layout>
</template>
<script setup>
import sheep from '@/sheep';
import $share from '@/sheep/platform/share';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import { reactive } from 'vue';
import _ from 'lodash-es';
import { showShareModal } from '@/sheep/hooks/useModal';
import SpuApi from '@/sheep/api/product/spu';
import BrokerageApi from '@/sheep/api/trade/brokerage';
import { fen2yuan } from '@/sheep/hooks/useGoods';
const state = reactive({
pagination: {
list: [],
total: 0,
pageNo: 1,
pageSize: 8,
},
loadStatus: '',
shareInfo: {},
});
function onShareGoods(goodsInfo) {
state.shareInfo = $share.getShareInfo(
{
title: goodsInfo.name,
image: sheep.$url.cdn(goodsInfo.picUrl),
desc: goodsInfo.introduction,
params: {
page: '2',
query: goodsInfo.id,
},
},
{
type: 'goods', // 商品海报
title: goodsInfo.name, // 商品名称
image: sheep.$url.cdn(goodsInfo.picUrl), // 商品主图
price: fen2yuan(goodsInfo.price), // 商品价格
original_price: fen2yuan(goodsInfo.marketPrice), // 商品原价
},
);
showShareModal();
}
async function getGoodsList() {
state.loadStatus = 'loading';
let { code, data } = await SpuApi.getSpuPage({
pageSize: state.pagination.pageSize,
pageNo: state.pagination.pageNo,
});
if (code !== 0) {
state.loadStatus = 'error'; // 处理错误状态
return;
}
// 使用 Promise.all 来等待所有佣金请求完成
await Promise.all(
data.list.map(async (item) => {
try {
const res = await BrokerageApi.getProductBrokeragePrice(item.id);
item.brokerageMinPrice = res.data.brokerageMinPrice;
item.brokerageMaxPrice = res.data.brokerageMaxPrice;
} catch (error) {
console.error(`获取商品【${item.name}】的佣金时出错:`, error);
}
}),
);
// 在所有请求完成后合并列表和更新状态
state.pagination.list = _.concat(state.pagination.list, data.list);
state.pagination.total = data.total;
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
}
onLoad(() => {
getGoodsList();
});
// 加载更多
function loadMore() {
if (state.loadStatus === 'noMore') {
return;
}
state.pagination.pageNo++;
getGoodsList();
}
// 上拉加载更多
onReachBottom(() => {
loadMore();
});
</script>
<style lang="scss" scoped>
.goods-item {
.commission-num {
font-size: 24rpx;
font-weight: 500;
color: $red;
}
.share-btn {
width: 120rpx;
height: 50rpx;
border-radius: 25rpx;
}
}
</style>
+57
View File
@@ -0,0 +1,57 @@
<!-- 分销中心 -->
<template>
<s-layout
navbar="inner"
class="index-wrap"
title="分销中心"
:bgStyle="bgStyle"
:onShareAppMessage="shareInfo"
>
<!-- 分销商信息 -->
<commission-info />
<!-- 账户信息 -->
<account-info />
<!-- 菜单栏 -->
<commission-menu />
<!-- 分销记录 -->
<commission-log />
<!-- 权限弹窗 -->
<commission-auth />
</s-layout>
</template>
<script setup>
import { computed } from 'vue';
import commissionInfo from './components/commission-info.vue';
import accountInfo from './components/account-info.vue';
import commissionLog from './components/commission-log.vue';
import commissionMenu from './components/commission-menu.vue';
import commissionAuth from './components/commission-auth.vue';
import sheep from '@/sheep';
import { SharePageEnum } from '@/sheep/helper/const';
/** 分销邀请 */
const shareInfo = computed(() => {
return sheep.$platform.share.getShareInfo(
{
params: {
page: SharePageEnum.HOME.value, // 用户通邀请进入到首页
},
},
{
type: 'user',
},
);
});
const bgStyle = {
color: '#F7D598',
};
</script>
<style lang="scss" scoped>
:deep(.page-main) {
background-size: 100% 100% !important;
}
</style>
+332
View File
@@ -0,0 +1,332 @@
<!-- 分销 - 订单明细 -->
<template>
<s-layout title="分销订单" :class="state.scrollTop ? 'order-warp' : ''" navbar="inner">
<view
class="header-box"
:style="[
{
marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
paddingTop: Number(statusBarHeight + 108) + 'rpx',
},
]"
>
<!-- 团队数据总览 -->
<view class="team-data-box ss-flex ss-col-center ss-row-between" style="width: 100%">
<view class="data-card" style="width: 100%">
<view class="total-item" style="width: 100%">
<view class="item-title" style="text-align: center">累计推广订单(单)</view>
<view class="total-num" style="text-align: center">
{{ state.totals }}
</view>
</view>
</view>
</view>
</view>
<!-- tab -->
<su-sticky bgColor="#fff">
<su-tabs
:list="tabMaps"
:scrollable="false"
:current="state.currentTab"
@change="onTabsChange"
>
</su-tabs>
</su-sticky>
<!-- 订单 -->
<view class="order-box">
<view class="order-item" v-for="item in state.pagination.list" :key="item">
<view class="order-header">
<view class="no-box ss-flex ss-col-center ss-row-between">
<text class="order-code">订单编号:{{ item.bizId }}</text>
<text class="order-state">
{{ item.status === 0 ? '待结算' : item.status === 1 ? '已结算' : '已取消' }}
( 佣金 {{ fen2yuan(item.price) }} 元 )
</text>
</view>
<view class="order-from ss-flex ss-col-center ss-row-between">
<view class="from-user ss-flex ss-col-center">
<text>{{ item.title }}</text>
</view>
<view class="order-time">
{{ sheep.$helper.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss') }}
</view>
</view>
</view>
</view>
<!-- 数据为空 -->
<s-empty v-if="state.pagination.total === 0" icon="/static/order-empty.png" text="暂无订单" />
<!-- 加载更多 -->
<uni-load-more
v-if="state.pagination.total > 0"
:status="state.loadStatus"
:content-text="{
contentdown: '上拉加载更多',
}"
@tap="loadMore"
/>
</view>
</s-layout>
</template>
<script setup>
import sheep from '@/sheep';
import { onLoad, onPageScroll, onReachBottom } from '@dcloudio/uni-app';
import { reactive } from 'vue';
import _ from 'lodash-es';
import { resetPagination } from '@/sheep/helper/utils';
import BrokerageApi from '@/sheep/api/trade/brokerage';
import { fen2yuan } from '../../sheep/hooks/useGoods';
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
onPageScroll((e) => {
state.scrollTop = e.scrollTop <= 100;
});
const state = reactive({
totals: 0, // 累计推广订单(单)
scrollTop: false,
currentTab: 0,
loadStatus: '',
pagination: {
list: [],
total: 0,
pageNo: 1,
pageSize: 8,
},
});
const tabMaps = [
{
name: '全部',
value: -1,
},
{
name: '待结算',
value: 0, // 待结算
},
{
name: '已结算',
value: 1, // 已结算
},
];
// 切换选项卡
function onTabsChange(e) {
resetPagination(state.pagination);
state.currentTab = e.index;
getOrderList();
}
// 获取订单列表
async function getOrderList() {
state.loadStatus = 'loading';
const tab = tabMaps[state.currentTab];
const queryParams = {
pageSize: state.pagination.pageSize,
pageNo: state.pagination.pageNo,
bizType: 1, // 获得推广佣金
status: tab.value,
};
if (tab.value < 0) {
delete queryParams.status;
}
const { code, data } = await BrokerageApi.getBrokerageRecordPage(queryParams);
if (code !== 0) {
return;
}
state.pagination.list = _.concat(state.pagination.list, data.list);
state.pagination.total = data.total;
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
if (state.currentTab === 0) {
state.totals = data.total;
}
}
onLoad(() => {
getOrderList();
});
// 加载更多
function loadMore() {
if (state.loadStatus === 'noMore') {
return;
}
state.pagination.pageNo++;
getOrderList();
}
// 上拉加载更多
onReachBottom(() => {
loadMore();
});
</script>
<style lang="scss" scoped>
.header-box {
box-sizing: border-box;
padding: 0 20rpx 20rpx 20rpx;
width: 750rpx;
background: v-bind(headerBg) no-repeat,
linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
background-size: 750rpx 100%;
// 团队信息总览
.team-data-box {
.data-card {
width: 305rpx;
background: #ffffff;
border-radius: 20rpx;
padding: 20rpx;
.total-item {
margin-bottom: 30rpx;
.item-title {
font-size: 24rpx;
font-weight: 500;
color: #999999;
line-height: normal;
margin-bottom: 20rpx;
}
.total-num {
font-size: 38rpx;
font-weight: 500;
color: #333333;
font-family: OPPOSANS;
}
}
.category-num {
font-size: 26rpx;
font-weight: 500;
color: #333333;
font-family: OPPOSANS;
}
}
}
// 直推
.direct-box {
margin-top: 20rpx;
.direct-item {
width: 340rpx;
background: #ffffff;
border-radius: 20rpx;
padding: 20rpx;
box-sizing: border-box;
.item-title {
font-size: 22rpx;
font-weight: 500;
color: #999999;
margin-bottom: 6rpx;
}
.item-value {
font-size: 38rpx;
font-weight: 500;
color: #333333;
font-family: OPPOSANS;
}
}
}
}
// 订单
.order-box {
.order-item {
background: #ffffff;
border-radius: 10rpx;
margin: 20rpx;
.order-footer {
padding: 20rpx;
font-size: 24rpx;
color: #999;
}
.order-header {
.no-box {
padding: 20rpx;
.order-code {
font-size: 26rpx;
font-weight: 500;
color: #333333;
}
.order-state {
font-size: 26rpx;
font-weight: 500;
color: var(--ui-BG-Main);
}
}
.order-from {
padding: 20rpx;
.from-user {
font-size: 24rpx;
font-weight: 400;
color: #666666;
.user-avatar {
width: 26rpx;
height: 26rpx;
border-radius: 50%;
margin-right: 8rpx;
}
.user-name {
font-size: 24rpx;
font-weight: 400;
color: #999999;
}
}
.order-time {
font-size: 24rpx;
font-weight: 400;
color: #999999;
}
}
}
.commission-box {
.name {
font-size: 24rpx;
font-weight: 400;
color: #999999;
}
}
.commission-num {
font-size: 30rpx;
font-weight: 500;
color: $red;
font-family: OPPOSANS;
&::before {
content: '¥';
font-size: 22rpx;
}
}
.order-status {
line-height: 30rpx;
padding: 0 10rpx;
border-radius: 30rpx;
margin-left: 20rpx;
font-size: 24rpx;
color: var(--ui-BG-Main);
}
}
}
</style>
File diff suppressed because one or more lines are too long
+604
View File
@@ -0,0 +1,604 @@
<!-- 页面 -->
<template>
<s-layout title="我的团队" :class="state.scrollTop ? 'team-wrap' : ''" navbar="inner">
<view
class="header-box"
:style="[
{
marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
paddingTop: Number(statusBarHeight + 108) + 'rpx',
},
]"
>
<!-- 推广数据总览 -->
<view class="team-data-box ss-flex ss-col-center ss-row-between" style="width: 100%">
<view class="data-card" style="width: 100%">
<view class="total-item" style="width: 100%">
<view class="item-title" style="text-align: center">推广人数</view>
<view class="total-num" style="text-align: center">
{{
state.summary.firstBrokerageUserCount + state.summary.secondBrokerageUserCount || 0
}}
</view>
</view>
</view>
</view>
</view>
<view class="promoter-list">
<!--<view
class="promoterHeader bg-color"
style="backgroundcolor: #e93323 !important; height: 218rpx; color: #fff"
>
<view class="headerCon acea-row row-between" style="padding: 28px 29px 0 29px">
<view>
<view class="name" style="color: #fff">推广人数</view>
<view>
<text class="num" style="color: #fff">
{{
state.summary.firstBrokerageUserCount + state.summary.secondBrokerageUserCount ||
0
}}
</text>
人
</view>
</view>
<view class="iconfont icon-tuandui" />
</view>
</view>-->
<view style="padding: 0 20rpx">
<view class="nav acea-row row-around l1" style="margin-top: 20rpx">
<view :class="state.level == 1 ? 'item on' : 'item'" @click="setType(1)">
一级({{ state.summary.firstBrokerageUserCount || 0 }})
</view>
<view :class="state.level == 2 ? 'item on' : 'item'" @click="setType(2)">
二级({{ state.summary.secondBrokerageUserCount || 0 }})
</view>
</view>
<view
class="search acea-row row-between-wrapper"
style="display: flex; height: 100rpx; align-items: center"
>
<view class="input">
<input
placeholder="点击搜索会员名称"
v-model="state.nickname"
confirm-type="search"
name="search"
@confirm="submitForm"
/>
</view>
<image
:src="sheep.$url.static('/static/img/shop/search.png')"
mode=""
style="width: 60rpx; height: 64rpx"
@click="submitForm"
/>
</view>
<view class="list">
<view class="sortNav acea-row row-middle" style="display: flex; align-items: center">
<view
class="sortItem"
@click="setSort('userCount', 'asc')"
v-if="sort === 'userCountDESC'"
>
团队排序
<image :src="sheep.$url.static('/static/img/shop/sort1.png')" />
</view>
<view
class="sortItem"
@click="setSort('userCount', 'desc')"
v-else-if="sort === 'userCountASC'"
>
团队排序
<image :src="sheep.$url.static('/static/img/shop/sort3.png')" />
</view>
<view class="sortItem" @click="setSort('userCount', 'desc')" v-else>
团队排序
<image :src="sheep.$url.static('/static/img/shop/sort2.png')" />
</view>
<view class="sortItem" @click="setSort('price', 'asc')" v-if="sort === 'priceDESC'">
金额排序
<image :src="sheep.$url.static('/static/img/shop/sort1.png')" />
</view>
<view
class="sortItem"
@click="setSort('price', 'desc')"
v-else-if="sort === 'priceASC'"
>
金额排序
<image :src="sheep.$url.static('/static/img/shop/sort3.png')" />
</view>
<view class="sortItem" @click="setSort('price', 'desc')" v-else>
金额排序
<image :src="sheep.$url.static('/static/img/shop/sort2.png')" />
</view>
<view
class="sortItem"
@click="setSort('orderCount', 'asc')"
v-if="sort === 'orderCountDESC'"
>
订单排序
<image :src="sheep.$url.static('/static/img/shop/sort1.png')" />
</view>
<view
class="sortItem"
@click="setSort('orderCount', 'desc')"
v-else-if="sort === 'orderCountASC'"
>
订单排序
<image :src="sheep.$url.static('/static/img/shop/sort3.png')" />
</view>
<view class="sortItem" @click="setSort('orderCount', 'desc')" v-else>
订单排序
<image :src="sheep.$url.static('/static/img/shop/sort2.png')" />
</view>
</view>
<block v-for="(item, index) in state.pagination.list" :key="index">
<view class="item acea-row row-between-wrapper" style="display: flex">
<view
class="picTxt acea-row row-between-wrapper"
style="display: flex; align-items: center"
>
<view class="pictrue">
<image :src="item.avatar" />
</view>
<view class="text">
<view class="name line1">{{ item.nickname }}</view>
<view>
加入时间:
{{ sheep.$helper.timeFormat(item.brokerageTime, 'yyyy-mm-dd hh:MM:ss') }}
</view>
</view>
</view>
<view
class="right"
style="
justify-content: center;
flex-direction: column;
display: flex;
margin-left: auto;
"
>
<view>
<text class="num font-color">{{ item.brokerageUserCount || 0 }} </text>人
</view>
<view>
<text class="num">{{ item.orderCount || 0 }}</text
>单</view
>
<view>
<text class="num">{{ fen2yuan(item.brokeragePrice) || 0 }}</text
>元
</view>
</view>
</view>
</block>
<block v-if="state.pagination.list.length === 0">
<view style="text-align: center; margin-top: 30rpx">暂无推广人数</view>
</block>
</view>
</view>
</view>
<!-- <home></home> -->
<!-- <view class="header-box" :style="[
{
marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
paddingTop: Number(statusBarHeight + 108) + 'rpx',
},
]">
<view v-if="userInfo.parent_user" class="referrer-box ss-flex ss-col-center">
推荐人:
<image class="referrer-avatar ss-m-r-10" :src="sheep.$url.cdn(userInfo.parent_user.avatar)"
mode="aspectFill">
</image>
{{ userInfo.parent_user.nickname }}
</view>
<view class="team-data-box ss-flex ss-col-center ss-row-between">
<view class="data-card">
<view class="total-item">
<view class="item-title">团队总人数(人)</view>
<view class="total-num">
{{ (state.summary.firstBrokerageUserCount+ state.summary.secondBrokerageUserCount)|| 0 }}
</view>
</view>
<view class="category-item ss-flex">
<view class="ss-flex-1">
<view class="item-title">一级成员</view>
<view class="category-num">{{ state.summary.firstBrokerageUserCount || 0 }}</view>
</view>
<view class="ss-flex-1">
<view class="item-title">二级成员</view>
<view class="category-num">{{ state.summary.secondBrokerageUserCount || 0 }}</view>
</view>
</view>
</view>
<view class="data-card">
<view class="total-item">
<view class="item-title">团队分销商人数(人)</view>
<view class="total-num">{{ agentInfo?.child_agent_count_all || 0 }}</view>
</view>
<view class="category-item ss-flex">
<view class="ss-flex-1">
<view class="item-title">一级分销商</view>
<view class="category-num">{{ agentInfo?.child_agent_count_1 || 0 }}</view>
</view>
<view class="ss-flex-1">
<view class="item-title">二级分销商</view>
<view class="category-num">{{ agentInfo?.child_agent_count_2 || 0 }}</view>
</view>
</view>
</view>
</view>
</view>
<view class="list-box">
<uni-list :border="false">
<uni-list-chat v-for="item in state.pagination.data" :key="item.id" :avatar-circle="true"
:title="item.nickname" :avatar="sheep.$url.cdn(item.avatar)"
:note="filterUserNum(item.agent?.child_user_count_1)">
<view class="chat-custom-right">
<view v-if="item.avatar" class="tag-box ss-flex ss-col-center">
<image class="tag-img" :src="sheep.$url.cdn(item.avatar)" mode="aspectFill">
</image>
<text class="tag-title">{{ item.nickname }}</text>
</view>
<text
class="time-text">{{ sheep.$helper.timeFormat(item.brokerageTime, 'yyyy-mm-dd hh:MM:ss') }}</text>
</view>
</uni-list-chat>
</uni-list>
</view>
<s-empty v-if="state.pagination.total === 0" icon="/static/data-empty.png" text="暂无团队信息">
</s-empty> -->
</s-layout>
</template>
<script setup>
import sheep from '@/sheep';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import { computed, reactive, ref } from 'vue';
import _ from 'lodash-es';
import { onPageScroll } from '@dcloudio/uni-app';
import BrokerageApi from '@/sheep/api/trade/brokerage';
import { fen2yuan } from '../../sheep/hooks/useGoods';
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
// const agentInfo = computed(() => sheep.$store('user').agentInfo);
const userInfo = computed(() => sheep.$store('user').userInfo);
const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
onPageScroll((e) => {
state.scrollTop = e.scrollTop <= 100;
});
let sort = ref();
const state = reactive({
summary: {},
pagination: {
pageNo: 1,
pageSize: 8,
list: [],
total: 0,
},
loadStatus: '',
// ↓ 新 ui 逻辑
level: 1,
nickname: ref(''),
sortKey: '',
isAsc: '',
});
function filterUserNum(num) {
if (_.isNil(num)) {
return '';
}
return `下级团队${num}人`;
}
function submitForm() {
state.pagination.list = [];
getTeamList();
}
async function getTeamList() {
state.loadStatus = 'loading';
let { code, data } = await BrokerageApi.getBrokerageUserChildSummaryPage({
pageNo: state.pagination.pageNo,
pageSize: state.pagination.pageSize,
level: state.level,
'sortingField.order': state.isAsc,
'sortingField.field': state.sortKey,
nickname: state.nickname,
});
if (code !== 0) {
return;
}
state.pagination.list = _.concat(state.pagination.list, data.list);
state.pagination.total = data.total;
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
}
function setType(e) {
state.pagination.list = [];
state.level = e + '';
getTeamList();
}
function setSort(sortKey, isAsc) {
state.pagination.list = [];
sort = sortKey + isAsc.toUpperCase();
state.isAsc = isAsc;
state.sortKey = sortKey;
getTeamList();
}
onLoad(async () => {
await getTeamList();
// 概要数据
let { data } = await BrokerageApi.getBrokerageUserSummary();
state.summary = data;
});
// 加载更多
function loadMore() {
if (state.loadStatus === 'noMore') {
return;
}
state.pagination.pageNo++;
getTeamList();
}
// 上拉加载更多
onReachBottom(() => {
loadMore();
});
</script>
<style lang="scss" scoped>
.l1 {
background-color: #fff;
height: 86rpx;
line-height: 86rpx;
font-size: 28rpx;
color: #282828;
border-bottom: 1rpx solid #eee;
border-top-left-radius: 14rpx;
border-top-right-radius: 14rpx;
display: flex;
justify-content: space-around;
}
.header-box {
box-sizing: border-box;
padding: 0 20rpx 20rpx 20rpx;
width: 750rpx;
z-index: 3;
position: relative;
background: v-bind(headerBg) no-repeat,
linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
background-size: 750rpx 100%;
// 团队信息总览
.team-data-box {
.data-card {
width: 305rpx;
background: #ffffff;
border-radius: 20rpx;
padding: 20rpx;
.item-title {
font-size: 22rpx;
font-weight: 500;
color: #999999;
line-height: 30rpx;
margin-bottom: 10rpx;
}
.total-item {
margin-bottom: 30rpx;
}
.total-num {
font-size: 38rpx;
font-weight: 500;
color: #333333;
font-family: OPPOSANS;
}
.category-num {
font-size: 26rpx;
font-weight: 500;
color: #333333;
font-family: OPPOSANS;
}
}
}
}
.list-box {
z-index: 3;
position: relative;
}
.chat-custom-right {
.time-text {
font-size: 22rpx;
font-weight: 400;
color: #999999;
}
.tag-box {
background: rgba(0, 0, 0, 0.2);
border-radius: 21rpx;
line-height: 30rpx;
padding: 5rpx 10rpx;
width: 140rpx;
.tag-img {
width: 34rpx;
height: 34rpx;
margin-right: 6rpx;
border-radius: 50%;
}
.tag-title {
font-size: 18rpx;
font-weight: 500;
color: rgba(255, 255, 255, 1);
line-height: 20rpx;
}
}
}
// 推荐人
.referrer-box {
font-size: 28rpx;
font-weight: 500;
color: #ffffff;
padding: 20rpx;
.referrer-avatar {
width: 34rpx;
height: 34rpx;
border-radius: 50%;
}
}
.promoter-list .nav {
background-color: #fff;
height: 86rpx;
line-height: 86rpx;
font-size: 28rpx;
color: #282828;
border-bottom: 1rpx solid #eee;
border-top-left-radius: 14rpx;
border-top-right-radius: 14rpx;
margin-top: -30rpx;
}
.promoter-list .nav .item.on {
border-bottom: 5rpx solid;
// $theme-color
color: var(--ui-BG-Main);
// $theme-color
}
.promoter-list .search {
width: 100%;
background-color: #fff;
height: 100rpx;
padding: 0 24rpx;
box-sizing: border-box;
border-bottom-left-radius: 14rpx;
border-bottom-right-radius: 14rpx;
}
.promoter-list .search .input {
width: 592rpx;
height: 60rpx;
border-radius: 50rpx;
background-color: #f5f5f5;
text-align: center;
position: relative;
}
.promoter-list .search .input input {
height: 100%;
font-size: 26rpx;
width: 610rpx;
text-align: center;
}
.promoter-list .search .input .placeholder {
color: #bbb;
}
.promoter-list .search .input .iconfont {
position: absolute;
right: 28rpx;
color: #999;
font-size: 28rpx;
top: 50%;
transform: translateY(-50%);
}
.promoter-list .search .iconfont {
font-size: 32rpx;
color: #515151;
height: 60rpx;
line-height: 60rpx;
}
.promoter-list .list {
margin-top: 20rpx;
}
.promoter-list .list .sortNav {
background-color: #fff;
height: 76rpx;
border-bottom: 1rpx solid #eee;
color: #333;
font-size: 28rpx;
border-top-left-radius: 14rpx;
border-top-right-radius: 14rpx;
}
.promoter-list .list .sortNav .sortItem {
text-align: center;
flex: 1;
}
.promoter-list .list .sortNav .sortItem image {
width: 24rpx;
height: 24rpx;
margin-left: 6rpx;
vertical-align: -3rpx;
}
.promoter-list .list .item {
background-color: #fff;
border-bottom: 1rpx solid #eee;
height: 152rpx;
padding: 0 24rpx;
font-size: 24rpx;
color: #666;
}
.promoter-list .list .item .picTxt .pictrue {
width: 106rpx;
height: 106rpx;
border-radius: 50%;
}
.promoter-list .list .item .picTxt .pictrue image {
width: 100%;
height: 100%;
border-radius: 50%;
border: 3rpx solid #fff;
box-shadow: 0 0 10rpx #aaa;
box-sizing: border-box;
}
.promoter-list .list .item .picTxt .text {
// width: 304rpx;
font-size: 24rpx;
color: #666;
margin-left: 14rpx;
}
.promoter-list .list .item .picTxt .text .name {
font-size: 28rpx;
color: #333;
margin-bottom: 13rpx;
}
.promoter-list .list .item .right {
text-align: right;
font-size: 22rpx;
color: #333;
}
.promoter-list .list .item .right .num {
margin-right: 7rpx;
}
</style>
+644
View File
@@ -0,0 +1,644 @@
<!-- 分销 - 佣金明细 -->
<template>
<s-layout class="wallet-wrap" title="佣金">
<!-- 钱包卡片 -->
<view class="header-box ss-flex ss-row-center ss-col-center">
<view class="card-box ui-BG-Main ui-Shadow-Main">
<view class="card-head ss-flex ss-col-center">
<view class="card-title ss-m-r-10">当前佣金(元)</view>
<view
@tap="state.showMoney = !state.showMoney"
class="ss-eye-icon"
:class="state.showMoney ? 'cicon-eye' : 'cicon-eye-off'"
/>
</view>
<view class="ss-flex ss-row-between ss-col-center ss-m-t-30">
<view class="money-num">{{
state.showMoney ? fen2yuan(state.summary.withdrawPrice || 0) : '*****'
}}</view>
<view class="ss-flex">
<view class="ss-m-r-20">
<button
class="ss-reset-button withdraw-btn"
@tap="sheep.$router.go('/pages/commission/withdraw')"
>
提现
</button>
</view>
<button class="ss-reset-button balance-btn ss-m-l-20" @tap="state.showModal = true">
转余额
</button>
</view>
</view>
<view class="ss-flex">
<view class="loading-money">
<view class="loading-money-title">冻结佣金</view>
<view class="loading-money-num">
{{ state.showMoney ? fen2yuan(state.summary.frozenPrice || 0) : '*****' }}
</view>
</view>
<view class="loading-money ss-m-l-100">
<view class="loading-money-title">可提现佣金</view>
<view class="loading-money-num">
{{ state.showMoney ? fen2yuan(state.summary.brokeragePrice || 0) : '*****' }}
</view>
</view>
</view>
</view>
</view>
<su-sticky>
<!-- 统计 -->
<view class="filter-box ss-p-x-30 ss-flex ss-col-center ss-row-between">
<uni-datetime-picker
v-model="state.date"
type="daterange"
@change="onChangeTime"
:end="state.today"
>
<button class="ss-reset-button date-btn">
<text>{{ dateFilterText }}</text>
<text class="cicon-drop-down ss-seldate-icon" />
</button>
</uni-datetime-picker>
<view class="total-box">
<!-- TODO 芋艿:【钱包-可优化】这里暂时不考虑做 -->
<!-- <view class="ss-m-b-10">总收入¥{{ state.pagination.income.toFixed(2) }}</view> -->
<!-- <view>总支出¥{{ (-state.pagination.expense).toFixed(2) }}</view> -->
</view>
</view>
<su-tabs
:list="tabMaps"
@change="onChangeTab"
:scrollable="false"
:current="state.currentTab"
/>
</su-sticky>
<s-empty
v-if="state.pagination.total === 0"
icon="/static/data-empty.png"
text="暂无数据"
></s-empty>
<!-- 转余额弹框 -->
<su-popup
:show="state.showModal"
type="bottom"
round="20"
@close="state.showModal = false"
showClose
>
<view class="ss-p-x-20 ss-p-y-30">
<view class="model-title ss-m-b-30 ss-m-l-20">转余额</view>
<view class="model-subtitle ss-m-b-100 ss-m-l-20">将您的佣金转到余额中继续消费</view>
<view class="input-box ss-flex ss-col-center border-bottom ss-m-b-70 ss-m-x-20">
<view class="unit">¥</view>
<uni-easyinput
:inputBorder="false"
class="ss-flex-1 ss-p-l-10"
v-model="state.price"
type="number"
placeholder="请输入金额"
/>
</view>
<button
class="ss-reset-button model-btn ui-BG-Main-Gradient ui-Shadow-Main"
@tap="onConfirm"
>
确定
</button>
</view>
</su-popup>
<!-- 钱包记录 -->
<view v-if="state.pagination.total > 0">
<!-- 分佣列表 -->
<view v-if="state.currentTab === 0">
<view
class="wallet-list ss-flex border-bottom"
v-for="item in state.pagination.list"
:key="item.id"
>
<view class="list-content">
<view class="title-box ss-flex ss-row-between ss-m-b-20">
<text class="title ss-line-1">{{ item.title }}</text>
<view class="money">
<text v-if="item.price >= 0" class="add">+{{ fen2yuan(item.price) }}</text>
<text v-else class="minus">{{ fen2yuan(item.price) }}</text>
</view>
</view>
<view class="ss-flex ss-row-between ss-col-center">
<text class="time">
{{ sheep.$helper.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss') }}
</text>
<view class="ss-flex ss-col-center">
<text class="status" :class="'status-' + item.status">{{ item.statusName }}</text>
</view>
</view>
</view>
</view>
</view>
<!-- 提现列表 -->
<view v-else>
<view
class="wallet-list ss-flex border-bottom"
v-for="item in state.pagination.list"
:key="item.id"
>
<view class="list-content">
<view class="title-box ss-flex ss-row-between ss-m-b-20">
<text class="title ss-line-1">{{ item.typeName }}</text>
<view class="money">
<text class="minus">{{ fen2yuan(item.price) }}</text>
</view>
</view>
<view class="ss-flex ss-row-between ss-col-center">
<text class="time">
{{ sheep.$helper.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss') }}
</text>
<button
v-if="item.status === 10 && item.type === 5 && item.payTransferId > 0"
class="ss-reset-button confirm-btn ss-m-l-20"
@tap="onRequestMerchantTransfer(item)"
>
确认收款
</button>
<text v-else class="status" :class="'status-' + item.status">{{
item.statusName
}}</text>
</view>
</view>
</view>
</view>
</view>
<!-- <u-gap></u-gap> -->
<uni-load-more
v-if="state.pagination.total > 0"
:status="state.loadStatus"
:content-text="{
contentdown: '上拉加载更多',
}"
/>
</s-layout>
</template>
<script setup>
import { computed, reactive } from 'vue';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import dayjs from 'dayjs';
import _ from 'lodash-es';
import BrokerageApi from '@/sheep/api/trade/brokerage';
import { fen2yuan } from '@/sheep/hooks/useGoods';
import { resetPagination } from '@/sheep/helper/utils';
import PayTransferApi from '@/sheep/api/pay/transfer';
const headerBg = sheep.$url.css('/static/img/shop/user/wallet_card_bg.png');
const state = reactive({
showMoney: false,
summary: {}, // 分销信息
today: '',
date: [],
currentTab: 0,
pagination: {
list: [],
total: 0,
pageNo: 1,
pageSize: 8,
},
loadStatus: '',
price: undefined,
showModal: false,
});
const tabMaps = [
{
name: '分佣',
value: '1',
},
{
name: '提现',
value: '2',
},
];
const dateFilterText = computed(() => {
if (state.date[0] === state.date[1]) {
return state.date[0];
} else {
return state.date.join('~');
}
});
async function getLogList() {
state.loadStatus = 'loading';
let { code, data } = await (state.currentTab === 0
? BrokerageApi.getBrokerageRecordPage({
pageSize: state.pagination.pageSize,
pageNo: state.pagination.pageNo,
'createTime[0]': state.date[0] + ' 00:00:00',
'createTime[1]': state.date[1] + ' 23:59:59',
})
: BrokerageApi.getBrokerageWithdrawPage({
pageSize: state.pagination.pageSize,
pageNo: state.pagination.pageNo,
'createTime[0]': state.date[0] + ' 00:00:00',
'createTime[1]': state.date[1] + ' 23:59:59',
}));
if (code !== 0) {
return;
}
state.pagination.list = _.concat(state.pagination.list, data.list);
state.pagination.total = data.total;
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
}
function onChangeTab(e) {
resetPagination(state.pagination);
state.currentTab = e.index;
getLogList();
}
function onChangeTime(e) {
state.date[0] = e[0];
state.date[1] = e[e.length - 1];
resetPagination(state.pagination);
getLogList();
}
// 确认操作(转账到余额)
async function onConfirm() {
if (state.price <= 0) {
sheep.$helper.toast('请输入正确的金额');
return;
}
uni.showModal({
title: '提示',
content: '确认把您的佣金转入到余额钱包中?',
confirmColor: '#FA7E31',
success: async function (res) {
if (!res.confirm) {
return;
}
const { code } = await BrokerageApi.createBrokerageWithdraw({
type: 1, // 钱包
price: state.price * 100,
});
if (code === 0) {
state.showModal = false;
await getAgentInfo();
onChangeTab({
index: 1,
});
}
},
});
}
async function getAgentInfo() {
const { code, data } = await BrokerageApi.getBrokerageUserSummary();
if (code !== 0) {
return;
}
state.summary = data;
}
// 微信场景下:用户确认收款
// 可见 https://pay.weixin.qq.com/doc/v3/merchant/4012716430 文档
async function onRequestMerchantTransfer(item) {
const requestMerchantTransfer = sheep.$platform.useProvider()
? sheep.$platform.useProvider().requestMerchantTransfer
: undefined;
if (!requestMerchantTransfer) {
sheep.$helper.toast('仅微信平台支持该功能');
return;
}
// 获取提现详情
const { code, data } = await BrokerageApi.getBrokerageWithdraw(item.id);
if (code !== 0) {
return;
}
if (data.status === 11) {
sheep.$helper.toast('该提现单已确认收款');
item.status = 11;
return;
}
if (!data.transferChannelMchId || !data.transferChannelPackageInfo) {
sheep.$helper.toast('提现信息异常,请稍后再试');
return;
}
// 调用微信确认收款
const payTransferId = data.payTransferId;
await requestMerchantTransfer(
data.transferChannelMchId,
data.transferChannelPackageInfo,
async (res) => {
if (res.result !== 'success') {
sheep.$helper.toast(res.errMsg);
return;
}
// 同步转账单状态
try {
const syncTransferResult = await PayTransferApi.syncTransfer(payTransferId);
console.log('syncTransferResult 结果', syncTransferResult);
} catch (e) {
console.error('syncTransferResult 异常', e);
}
// 查询提现单最新状态
const { data } = await BrokerageApi.getBrokerageWithdraw(item.id);
if (data && data.status !== 11) {
sheep.$helper.toast('确认收款成功,但数据存在延迟,请以实际【微信支付】到账为准');
return;
}
sheep.$helper.toast('确认收款成功');
// 更新到列表中
item.status = 11;
},
);
}
onLoad(async (options) => {
state.today = dayjs().format('YYYY-MM-DD');
state.date = [state.today, state.today];
if (options.type === '2') {
// 切换到"提现" tab 下
state.currentTab = 1;
}
getLogList();
getAgentInfo();
});
onReachBottom(() => {
if (state.loadStatus === 'noMore') {
return;
}
state.pagination.pageNo++;
getLogList();
});
</script>
<style lang="scss" scoped>
// 钱包
.header-box {
background-color: $white;
padding: 30rpx;
.card-box {
width: 100%;
min-height: 300rpx;
padding: 40rpx;
background-size: 100% 100%;
border-radius: 30rpx;
overflow: hidden;
position: relative;
z-index: 1;
box-sizing: border-box;
&::after {
content: '';
display: block;
width: 100%;
height: 100%;
z-index: 2;
position: absolute;
top: 0;
left: 0;
background: v-bind(headerBg) no-repeat;
pointer-events: none;
}
.card-head {
color: $white;
font-size: 24rpx;
}
.ss-eye-icon {
font-size: 40rpx;
color: $white;
}
.money-num {
font-size: 40rpx;
line-height: normal;
font-weight: 500;
color: $white;
font-family: OPPOSANS;
}
.reduce-num {
font-size: 26rpx;
font-weight: 400;
color: $white;
}
.withdraw-btn {
width: 120rpx;
height: 60rpx;
line-height: 60rpx;
border-radius: 30px;
font-size: 24rpx;
font-weight: 500;
background-color: $white;
color: var(--ui-BG-Main);
}
.balance-btn {
width: 120rpx;
height: 60rpx;
line-height: 60rpx;
border-radius: 30px;
font-size: 24rpx;
font-weight: 500;
color: $white;
border: 1px solid $white;
}
}
}
.loading-money {
margin-top: 56rpx;
.loading-money-title {
font-size: 24rpx;
font-weight: 400;
color: #ffffff;
line-height: normal;
margin-bottom: 30rpx;
}
.loading-money-num {
font-size: 30rpx;
font-family: OPPOSANS;
font-weight: 500;
color: #fefefe;
}
}
// 筛选
.filter-box {
height: 120rpx;
padding: 0 30rpx;
background-color: $bg-page;
.total-box {
font-size: 24rpx;
font-weight: 500;
color: $dark-9;
}
.date-btn {
background-color: $white;
line-height: 54rpx;
border-radius: 27rpx;
padding: 0 20rpx;
font-size: 24rpx;
font-weight: 500;
color: $dark-6;
.ss-seldate-icon {
font-size: 50rpx;
color: $dark-9;
}
}
}
// tab
.wallet-tab-card {
.tab-item {
height: 80rpx;
position: relative;
.tab-title {
font-size: 30rpx;
}
.cur-tab-title {
font-weight: $font-weight-bold;
}
.tab-line {
width: 60rpx;
height: 6rpx;
border-radius: 6rpx;
position: absolute;
left: 50%;
transform: translateX(-50%);
bottom: 2rpx;
background-color: var(--ui-BG-Main);
}
}
}
// 钱包记录
.wallet-list {
padding: 30rpx;
background-color: #ffff;
.head-img {
width: 70rpx;
height: 70rpx;
border-radius: 50%;
background: $gray-c;
}
.list-content {
justify-content: space-between;
align-items: flex-start;
flex: 1;
.title {
font-size: 28rpx;
color: $dark-3;
width: 400rpx;
}
.time {
color: $gray-c;
font-size: 22rpx;
}
}
.money {
font-size: 28rpx;
font-weight: bold;
font-family: OPPOSANS;
.add {
color: var(--ui-BG-Main);
}
.minus {
color: $dark-3;
}
}
.confirm-btn {
font-size: 22rpx;
color: var(--ui-BG-Main);
background: rgba(var(--ui-BG-Main-rgb), 0.1);
padding: 4rpx 16rpx;
margin: 0;
line-height: 1.4;
border-radius: 20rpx;
border: 1px solid var(--ui-BG-Main);
}
}
.model-title {
font-size: 36rpx;
font-weight: bold;
color: #333333;
}
.model-subtitle {
font-size: 26rpx;
color: #c2c7cf;
}
.model-btn {
width: 100%;
height: 80rpx;
border-radius: 40rpx;
font-size: 28rpx;
font-weight: 500;
color: #ffffff;
line-height: normal;
}
.input-box {
height: 100rpx;
.unit {
font-size: 48rpx;
color: #333;
font-weight: 500;
line-height: normal;
}
.uni-easyinput__placeholder-class {
font-size: 30rpx;
height: 40rpx;
line-height: normal;
}
}
.status {
font-size: 22rpx;
&.status-0 {
color: #ff9900;
}
&.status-1 {
color: #19be6b;
}
&.status-2 {
color: #fa3534;
}
}
</style>
+487
View File
@@ -0,0 +1,487 @@
<!-- 分佣提现 -->
<template>
<s-layout title="申请提现" class="withdraw-wrap" navbar="inner">
<view class="page-bg"></view>
<view
class="wallet-num-box ss-flex ss-col-center ss-row-between"
:style="[
{
marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
paddingTop: Number(statusBarHeight + 108) + 'rpx',
},
]"
>
<view class="">
<view class="num-title">可提现金额(元)</view>
<view class="wallet-num">{{ fen2yuan(state.brokerageInfo.brokeragePrice) }}</view>
</view>
<button
class="ss-reset-button log-btn"
@tap="sheep.$router.go('/pages/commission/wallet', { type: 2 })"
>
提现记录
</button>
</view>
<!-- 提现输入卡片-->
<view class="draw-card">
<view class="bank-box ss-flex ss-col-center ss-row-between ss-m-b-30">
<view class="name">提现至</view>
<view class="bank-list ss-flex ss-col-center" @tap="onAccountSelect(true)">
<view v-if="!state.accountInfo.type" class="empty-text">请选择提现方式</view>
<view v-if="state.accountInfo.type === '1'" class="empty-text">钱包余额</view>
<view v-if="state.accountInfo.type === '2'" class="empty-text">银行卡转账</view>
<view v-if="state.accountInfo.type === '3'" class="empty-text">微信账户</view>
<view v-if="state.accountInfo.type === '4'" class="empty-text">支付宝账户</view>
<view v-if="state.accountInfo.type === '5'" class="empty-text">微信零钱</view>
<text class="cicon-forward" />
</view>
</view>
<!-- 提现金额 -->
<view class="card-title">提现金额</view>
<view class="input-box ss-flex ss-col-center border-bottom">
<view class="unit">¥</view>
<uni-easyinput
:inputBorder="false"
class="ss-flex-1 ss-p-l-10"
v-model="state.accountInfo.price"
type="number"
placeholder="请输入提现金额"
/>
</view>
<!-- 提现账号 -->
<view class="card-title" v-show="['2', '6'].includes(state.accountInfo.type)">
提现账号
</view>
<view
class="input-box ss-flex ss-col-center border-bottom"
v-show="['2', '6'].includes(state.accountInfo.type)"
>
<view class="unit" />
<uni-easyinput
:inputBorder="false"
class="ss-flex-1 ss-p-l-10"
v-model="state.accountInfo.userAccount"
placeholder="请输入提现账号"
/>
</view>
<!-- 收款码 -->
<view class="card-title" v-show="['3', '4'].includes(state.accountInfo.type)">收款码</view>
<view
class="input-box ss-flex ss-col-center"
v-show="['3', '4'].includes(state.accountInfo.type)"
>
<view class="unit" />
<view class="upload-img">
<s-uploader
v-model:url="state.accountInfo.qrCodeUrl"
fileMediatype="image"
limit="1"
mode="grid"
:imageStyles="{ width: '168rpx', height: '168rpx' }"
@success="(payload) => (state.accountInfo.qrCodeUrl = payload.tempFilePaths[0])"
/>
</view>
</view>
<!-- 持卡人姓名 -->
<view class="card-title" v-show="['2', '5', '6'].includes(state.accountInfo.type)">
收款真名
</view>
<view
class="input-box ss-flex ss-col-center border-bottom"
v-show="['2', '5', '6'].includes(state.accountInfo.type)"
>
<view class="unit" />
<uni-easyinput
:inputBorder="false"
class="ss-flex-1 ss-p-l-10"
v-model="state.accountInfo.userName"
placeholder="请输入收款真名"
/>
</view>
<!-- 提现银行 -->
<view class="card-title" v-show="state.accountInfo.type === '2'">提现银行</view>
<view
class="input-box ss-flex ss-col-center border-bottom"
v-show="state.accountInfo.type === '2'"
>
<view class="unit" />
<!--银行改为下拉选择-->
<picker
@change="bankChange"
:value="state.bankListSelectedIndex"
:range="state.bankList"
range-key="label"
style="width: 100%"
>
<uni-easyinput
:inputBorder="false"
:value="state.accountInfo.bankName"
placeholder="请选择银行"
suffixIcon="right"
disabled
:styles="{ disableColor: '#fff', borderColor: '#fff', color: '#333!important' }"
/>
</picker>
</view>
<!-- 开户地址 -->
<view class="card-title" v-show="state.accountInfo.type === '2'">开户地址</view>
<view
class="input-box ss-flex ss-col-center border-bottom"
v-show="state.accountInfo.type === '2'"
>
<view class="unit" />
<uni-easyinput
:inputBorder="false"
class="ss-flex-1 ss-p-l-10"
v-model="state.accountInfo.bankAddress"
placeholder="请输入开户地址"
/>
</view>
<button class="ss-reset-button save-btn ui-BG-Main-Gradient ui-Shadow-Main" @tap="onConfirm">
确认提现
</button>
</view>
<!-- 提现说明 -->
<view class="draw-notice">
<view class="title ss-m-b-30">提现说明</view>
<view class="draw-list"> 最低提现金额 {{ fen2yuan(state.minPrice) }} 元 </view>
<view class="draw-list">
冻结佣金:<text>¥{{ fen2yuan(state.brokerageInfo.frozenPrice) }}</text>
(每笔佣金的冻结期为 {{ state.frozenDays }} 天,到期后可提现)
</view>
</view>
<!-- 选择提现账户 -->
<account-type-select
:show="state.accountSelect"
@close="onAccountSelect(false)"
round="10"
v-model="state.accountInfo"
:methods="state.withdrawTypes"
/>
</s-layout>
</template>
<script setup>
import { onBeforeMount, reactive } from 'vue';
import sheep from '@/sheep';
import accountTypeSelect from './components/account-type-select.vue';
import { fen2yuan } from '@/sheep/hooks/useGoods';
import TradeConfigApi from '@/sheep/api/trade/config';
import BrokerageApi from '@/sheep/api/trade/brokerage';
import DictApi from '@/sheep/api/system/dict';
import SLayout from '@/sheep/components/s-layout/s-layout.vue';
import { getWeixinPayChannelCode, goBindWeixin } from '@/sheep/platform/pay';
const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
const state = reactive({
accountInfo: {
// 提现表单
type: undefined,
userAccount: undefined,
userName: undefined,
qrCodeUrl: undefined,
bankName: undefined,
bankAddress: undefined,
},
accountSelect: false,
brokerageInfo: {}, // 分销信息
frozenDays: 0, // 冻结天数
minPrice: 0, // 最低提现金额
withdrawTypes: [], // 提现方式
bankList: [], // 银行字典数据
bankListSelectedIndex: '', // 选中银行 bankList 的 index
});
// 打开提现方式的弹窗
const onAccountSelect = (e) => {
state.accountSelect = e;
};
// 提交提现
const onConfirm = async () => {
// 参数校验
if (
!state.accountInfo.price ||
state.accountInfo.price > state.brokerageInfo.price ||
state.accountInfo.price <= 0
) {
sheep.$helper.toast('请输入正确的提现金额');
return;
}
if (!state.accountInfo.type) {
sheep.$helper.toast('请选择提现方式');
return;
}
let openid;
if (state.accountInfo.type === '5') {
openid = await sheep.$platform.useProvider('wechat').getOpenid();
// 如果获取不到 openid,微信无法发起支付,此时需要引导
if (!openid) {
goBindWeixin();
return;
}
}
// 提交请求
const data = {
...state.accountInfo,
price: state.accountInfo.price * 100,
};
if (state.accountInfo.type === '5') {
data.userAccount = openid;
data.transferChannelCode = getWeixinPayChannelCode();
} else if (state.accountInfo.type === '6' || state.accountInfo.type === '2') {
delete data.transferChannelCode;
} else {
delete data.userAccount;
delete data.transferChannelCode;
}
let { code } = await BrokerageApi.createBrokerageWithdraw(data);
if (code !== 0) {
return;
}
// 提示
uni.showModal({
title: '操作成功',
content: '您的提现申请已成功提交',
cancelText: '继续提现',
confirmText: '查看记录',
confirmColor: '#FA7E31',
success: (res) => {
if (res.confirm) {
sheep.$router.go('/pages/commission/wallet', { type: 2 });
return;
}
getBrokerageUser();
state.accountInfo = {};
},
});
};
// 获得分销配置
async function getWithdrawRules() {
let { code, data } = await TradeConfigApi.getTradeConfig();
if (code !== 0) {
return;
}
if (data) {
state.minPrice = data.brokerageWithdrawMinPrice || 0;
state.frozenDays = data.brokerageFrozenDays || 0;
state.withdrawTypes = data.brokerageWithdrawTypes;
}
}
// 获得分销信息
async function getBrokerageUser() {
const { data, code } = await BrokerageApi.getBrokerageUser();
if (code === 0) {
state.brokerageInfo = data;
}
}
// 获取提现银行配置字典
async function getDictDataListByType() {
let { code, data } = await DictApi.getDictDataListByType('brokerage_bank_name');
if (code !== 0) {
return;
}
if (data && data.length > 0) {
state.bankList = data;
}
}
// 银行选择
function bankChange(e) {
const value = e.detail.value;
state.bankListSelectedIndex = value;
state.accountInfo.bankName = state.bankList[value].label;
}
onBeforeMount(() => {
getWithdrawRules();
getBrokerageUser();
getDictDataListByType(); //获取银行字典数据
});
</script>
<style lang="scss" scoped>
:deep() {
.uni-input-input {
font-family: OPPOSANS !important;
}
}
.wallet-num-box {
padding: 0 40rpx 80rpx;
background: var(--ui-BG-Main) v-bind(headerBg) center/750rpx 100% no-repeat;
border-radius: 0 0 5% 5%;
.num-title {
font-size: 26rpx;
font-weight: 500;
color: $white;
margin-bottom: 20rpx;
}
.wallet-num {
font-size: 60rpx;
font-weight: 500;
color: $white;
font-family: OPPOSANS;
}
.log-btn {
width: 170rpx;
height: 60rpx;
line-height: 60rpx;
border: 1rpx solid $white;
border-radius: 30rpx;
padding: 0;
font-size: 26rpx;
font-weight: 500;
color: $white;
}
}
// 提现输入卡片
.draw-card {
background-color: $white;
border-radius: 20rpx;
width: 690rpx;
min-height: 560rpx;
margin: -60rpx 30rpx 30rpx 30rpx;
padding: 30rpx;
position: relative;
z-index: 3;
box-sizing: border-box;
.card-title {
font-size: 30rpx;
font-weight: 500;
margin-bottom: 30rpx;
}
.bank-box {
.name {
font-size: 28rpx;
font-weight: 500;
}
.bank-list {
.empty-text {
font-size: 28rpx;
font-weight: 400;
color: $dark-9;
}
.cicon-forward {
color: $dark-9;
}
}
.input-box {
width: 624rpx;
height: 100rpx;
margin-bottom: 40rpx;
.unit {
font-size: 48rpx;
color: #333;
font-weight: 500;
}
.uni-easyinput__placeholder-class {
font-size: 30rpx;
height: 36rpx;
}
:deep(.uni-easyinput__content-input) {
font-size: 48rpx;
}
}
.save-btn {
width: 616rpx;
height: 86rpx;
line-height: 86rpx;
border-radius: 40rpx;
margin-top: 80rpx;
}
}
.bind-box {
.placeholder-text {
font-size: 26rpx;
color: $dark-9;
}
.add-btn {
width: 100rpx;
height: 50rpx;
border-radius: 25rpx;
line-height: 50rpx;
font-size: 22rpx;
color: var(--ui-BG-Main);
background-color: var(--ui-BG-Main-light);
}
}
.input-box {
width: 624rpx;
height: 100rpx;
margin-bottom: 40rpx;
.unit {
font-size: 48rpx;
color: #333;
font-weight: 500;
}
.uni-easyinput__placeholder-class {
font-size: 30rpx;
}
:deep(.uni-easyinput__content-input) {
font-size: 48rpx;
}
}
.save-btn {
width: 616rpx;
height: 86rpx;
line-height: 86rpx;
border-radius: 40rpx;
margin-top: 80rpx;
}
}
// 提现说明
.draw-notice {
width: 684rpx;
background: #ffffff;
border: 2rpx solid #fffaee;
border-radius: 20rpx;
margin: 20rpx 32rpx 0 32rpx;
padding: 30rpx;
box-sizing: border-box;
.title {
font-weight: 500;
color: #333333;
font-size: 30rpx;
}
.draw-list {
font-size: 24rpx;
color: #999999;
line-height: 46rpx;
}
}
</style>
+84
View File
@@ -0,0 +1,84 @@
<template>
<view class="content-container">
<span
v-for="(part, index) in formattedContent"
:key="index"
@click="handleClick(part)"
:class="{ 'highlight-number': part.isNumber, 'phone-number': part.isPhone }"
>
{{ part.text }}
</span>
</view>
</template>
<script>
export default {
name: 'HighlightNumber',
props: {
content: {
type: String,
required: true,
},
},
computed: {
formattedContent() {
const phoneRegex = /(1[3-9]\d{9})/g;
const numberRegex = /(\d+)/g;
let text = this.content;
let result = [];
let match;
// Step 1: 提取手机号
while ((match = phoneRegex.exec(text)) !== null) {
if (match.index > 0) {
const before = text.slice(0, match.index);
result.push(...this.splitAndPush(before, false, false));
}
result.push({ text: match[0], isNumber: true, isPhone: true });
text = text.slice(match.index + match[0].length);
}
// Step 2: 提取普通数字
while ((match = numberRegex.exec(text)) !== null) {
if (match.index > 0) {
const before = text.slice(0, match.index);
result.push(...this.splitAndPush(before, false, false));
}
result.push({ text: match[0], isNumber: true });
text = text.slice(match.index + match[0].length);
}
// Step 3: 添加剩余文本
if (text.length > 0) {
result.push(...this.splitAndPush(text, false, false));
}
return result;
},
},
methods: {
splitAndPush(str, isNumber = false, isPhone = false) {
return str.split('').map((char) => ({ text: char, isNumber, isPhone }));
},
handleClick(part) {
if (part.isPhone) {
this.$emit('phone-click', { phoneNumber: part.text });
} else if (part.isNumber) {
this.$emit('number-click', { number: part.text });
}
},
},
};
</script>
<style scoped>
.highlight-number {
color: #ff5722;
font-weight: bold;
}
.phone-number {
color: #007aff;
text-decoration: underline;
}
</style>
+390
View File
@@ -0,0 +1,390 @@
<!-- 优惠券详情 -->
<template>
<s-layout title="优惠券详情">
<view class="bg-white">
<!-- 详情卡片 -->
<view class="detail-wrap ss-p-20">
<view class="detail-box">
<view class="tag-box ss-flex ss-col-center ss-row-center">
<image
class="tag-image"
:src="sheep.$url.static('/static/img/shop/app/coupon_icon.png')"
mode="aspectFit"
/>
</view>
<view class="top ss-flex-col ss-col-center">
<view class="title ss-m-t-50 ss-m-b-20 ss-m-x-20">{{ state.coupon.name }}</view>
<view class="subtitle ss-m-b-50">
满 {{ fen2yuan(state.coupon.usePrice) }} 元,
{{
state.coupon.discountType === 1
? '减 ' + fen2yuan(state.coupon.discountPrice) + ' 元'
: '打 ' + state.coupon.discountPercent / 10.0 + ' 折'
}}
</view>
<button
class="ss-reset-button ss-m-b-30"
:class="
state.coupon.canTake || state.coupon.status === 1
? 'use-btn' // 优惠劵模版(可领取)、优惠劵(可使用)
: 'disable-btn'
"
:disabled="!state.coupon.canTake"
@click="getCoupon"
>
<text v-if="state.id > 0">{{ state.coupon.canTake ? '立即领取' : '已领取' }}</text>
<text v-else>
{{
state.coupon.status === 1
? '可使用'
: state.coupon.status === 2
? '已使用'
: '已过期'
}}
</text>
</button>
<view class="time ss-m-y-30" v-if="state.coupon.validityType === 2">
有效期:领取后 {{ state.coupon.fixedEndTerm }} 天内可用
</view>
<view class="time ss-m-y-30" v-else>
有效期: {{ sheep.$helper.timeFormat(state.coupon.validStartTime, 'yyyy-mm-dd') }} 至
{{ sheep.$helper.timeFormat(state.coupon.validEndTime, 'yyyy-mm-dd') }}
</view>
<view class="coupon-line ss-m-t-14"></view>
</view>
<view class="bottom">
<view class="type ss-flex ss-col-center ss-row-between ss-p-x-30">
<view>优惠券类型</view>
<view>{{ state.coupon.discountType === 1 ? '满减券' : '折扣券' }}</view>
</view>
<uni-collapse>
<uni-collapse-item title="优惠券说明" v-if="state.coupon.description">
<view class="content ss-p-b-20">
<text class="des ss-p-l-30">{{ state.coupon.description }}</text>
</view>
</uni-collapse-item>
</uni-collapse>
</view>
</view>
</view>
<!-- 适用商品 -->
<view
class="all-user ss-flex ss-row-center ss-col-center"
v-if="state.coupon.productScope === 1"
>
全场通用
</view>
<su-sticky v-else bgColor="#fff">
<view class="goods-title ss-p-20">
{{ state.coupon.productScope === 2 ? '指定商品可用' : '指定分类可用' }}
</view>
<su-tabs
:scrollable="true"
:list="state.tabMaps"
@change="onTabsChange"
:current="state.currentTab"
v-if="state.coupon.productScope === 3"
/>
</su-sticky>
<!-- 指定商品 -->
<view v-if="state.coupon.productScope === 2">
<view v-for="(item, index) in state.pagination.list" :key="index">
<s-goods-column
class="ss-m-20"
size="lg"
:data="item"
@click="sheep.$router.go('/pages/goods/index', { id: item.id })"
:goodsFields="{
title: { show: true },
subtitle: { show: true },
price: { show: true },
original_price: { show: true },
sales: { show: true },
stock: { show: false },
}"
/>
</view>
</view>
<!-- 指定分类 -->
<view v-if="state.coupon.productScope === 3">
<view v-for="(item, index) in state.pagination.list" :key="index">
<s-goods-column
class="ss-m-20"
size="lg"
:data="item"
@click="sheep.$router.go('/pages/goods/index', { id: item.id })"
:goodsFields="{
title: { show: true },
subtitle: { show: true },
price: { show: true },
original_price: { show: true },
sales: { show: true },
stock: { show: false },
}"
></s-goods-column>
</view>
</view>
<uni-load-more
v-if="state.pagination.total > 0 && state.coupon.productScope === 3"
:status="state.loadStatus"
:content-text="{
contentdown: '上拉加载更多',
}"
@tap="loadMore"
/>
<s-empty
v-if="state.coupon.productScope === 3 && state.pagination.total === 0"
paddingTop="0"
icon="/static/soldout-empty.png"
text="暂无商品"
/>
</view>
</s-layout>
</template>
<script setup>
import sheep from '@/sheep';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import { reactive } from 'vue';
import _ from 'lodash-es';
import CouponApi from '@/sheep/api/promotion/coupon';
import { fen2yuan } from '@/sheep/hooks/useGoods';
import SpuApi from '@/sheep/api/product/spu';
import CategoryApi from '@/sheep/api/product/category';
import { resetPagination } from '@/sheep/helper/utils';
const state = reactive({
id: 0, // 优惠劵模版编号 templateId
couponId: 0, // 用户优惠劵编号 couponId
coupon: {}, // 优惠劵信息
pagination: {
list: [],
total: 0,
pageNo: 1,
pageSize: 8,
},
categoryId: 0, // 选中的商品分类编号
tabMaps: [], // 指定分类时,每个分类构成一个 tab
currentTab: 0, // 选中的 tabMaps 下标
loadStatus: '',
});
function onTabsChange(e) {
resetPagination(state.pagination);
state.currentTab = e.index;
state.categoryId = e.value;
getGoodsListByCategory();
}
async function getGoodsListByCategory() {
state.loadStatus = 'loading';
const { code, data } = await SpuApi.getSpuPage({
categoryId: state.categoryId,
pageNo: state.pagination.pageNo,
pageSize: state.pagination.pageSize,
});
if (code !== 0) {
return;
}
state.pagination.list = _.concat(state.pagination.list, data.list);
state.pagination.total = data.total;
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
}
// 获得商品列表,指定商品范围
async function getGoodsListById() {
const { data, code } = await SpuApi.getSpuListByIds(state.coupon.productScopeValues.join(','));
if (code !== 0) {
return;
}
state.pagination.list = data;
}
// 获得分类列表
async function getCategoryList() {
const { data, code } = await CategoryApi.getCategoryListByIds(
state.coupon.productScopeValues.join(','),
);
if (code !== 0) {
return;
}
state.tabMaps = data.map((category) => ({ name: category.name, value: category.id }));
// 加载第一个分类的商品列表
if (state.tabMaps.length > 0) {
state.categoryId = state.tabMaps[0].value;
await getGoodsListByCategory();
}
}
// 领取优惠劵
async function getCoupon() {
const { code } = await CouponApi.takeCoupon(state.id);
if (code !== 0) {
return;
}
uni.showToast({
title: '领取成功',
});
setTimeout(() => {
getCouponContent();
}, 1000);
}
// 加载优惠劵信息
async function getCouponContent() {
const { code, data } =
state.id > 0
? await CouponApi.getCouponTemplate(state.id)
: await CouponApi.getCoupon(state.couponId);
if (code !== 0) {
return;
}
state.coupon = data;
// 不同指定范围,加载不同数据
if (state.coupon.productScope === 2) {
await getGoodsListById();
} else if (state.coupon.productScope === 3) {
await getCategoryList();
}
}
// 加载更多
function loadMore() {
if (state.loadStatus === 'noMore') {
return;
}
state.pagination.pageNo++;
getGoodsListByCategory();
}
onLoad((options) => {
state.id = options.id;
state.couponId = options.couponId;
getCouponContent(state.id, state.couponId);
});
// 上拉加载更多
onReachBottom(() => {
loadMore();
});
</script>
<style lang="scss" scoped>
.goods-title {
font-size: 34rpx;
font-weight: bold;
color: #333333;
}
.detail-wrap {
background: linear-gradient(
180deg,
var(--ui-BG-Main),
var(--ui-BG-Main-gradient),
var(--ui-BG-Main),
#fff
);
}
.detail-box {
// background-color: var(--ui-BG);
border-radius: 6rpx;
position: relative;
margin-top: 100rpx;
.tag-box {
width: 140rpx;
height: 140rpx;
background: var(--ui-BG);
border-radius: 50%;
position: absolute;
top: -70rpx;
left: 50%;
z-index: 6;
transform: translateX(-50%);
.tag-image {
width: 104rpx;
height: 104rpx;
border-radius: 50%;
}
}
.top {
background-color: #fff;
border-radius: 20rpx 20rpx 0 0;
-webkit-mask: radial-gradient(circle at 16rpx 100%, #0000 16rpx, red 0) -16rpx;
padding: 110rpx 0 0 0;
position: relative;
z-index: 5;
.title {
font-size: 40rpx;
color: #333;
font-weight: bold;
}
.subtitle {
font-size: 28rpx;
color: #333333;
}
.use-btn {
width: 386rpx;
height: 80rpx;
line-height: 80rpx;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
border-radius: 40rpx;
color: $white;
}
.disable-btn {
width: 386rpx;
height: 80rpx;
line-height: 80rpx;
background: #e5e5e5;
border-radius: 40rpx;
color: $white;
}
.time {
font-size: 26rpx;
font-weight: 400;
color: #999999;
}
.coupon-line {
width: 95%;
border-bottom: 2rpx solid #eeeeee;
}
}
.bottom {
background-color: #fff;
border-radius: 0 0 20rpx 20rpx;
-webkit-mask: radial-gradient(circle at 16rpx 0%, #0000 16rpx, red 0) -16rpx;
padding: 40rpx 30rpx;
.type {
height: 96rpx;
border-bottom: 2rpx solid #eeeeee;
}
}
.des {
font-size: 24rpx;
font-weight: 400;
color: #666666;
}
}
.all-user {
width: 100%;
height: 300rpx;
font-size: 34rpx;
font-weight: bold;
color: #333333;
}
</style>
+222
View File
@@ -0,0 +1,222 @@
<!-- 优惠券中心 -->
<template>
<s-layout :bgStyle="{ color: '#f2f2f2' }" title="优惠券">
<su-sticky bgColor="#fff">
<su-tabs
:list="tabMaps"
:scrollable="false"
@change="onTabsChange"
:current="state.currentTab"
/>
</su-sticky>
<s-empty
v-if="state.pagination.total === 0"
icon="/static/coupon-empty.png"
text="暂无优惠券"
/>
<!-- 情况一:领劵中心 -->
<template v-if="state.currentTab === 0">
<view v-for="item in state.pagination.list" :key="item.id">
<s-coupon-list
:data="item"
@tap="sheep.$router.go('/pages/coupon/detail', { id: item.id })"
>
<template #default>
<button
class="ss-reset-button card-btn ss-flex ss-row-center ss-col-center"
:class="!item.canTake ? 'border-btn' : ''"
@click.stop="getBuy(item.id)"
:disabled="!item.canTake"
>
{{ item.canTake ? '立即领取' : '已领取' }}
</button>
</template>
</s-coupon-list>
</view>
</template>
<!-- 情况二:我的优惠劵 -->
<template v-else>
<view v-for="item in state.pagination.list" :key="item.id">
<s-coupon-list
:data="item"
type="user"
@tap="sheep.$router.go('/pages/coupon/detail', { couponId: item.id })"
>
<template #default>
<button
class="ss-reset-button card-btn ss-flex ss-row-center ss-col-center"
:class="item.status !== 1 ? 'disabled-btn' : ''"
:disabled="item.status !== 1"
@click.stop="sheep.$router.go('/pages/coupon/detail', { couponId: item.id })"
>
{{ item.status === 1 ? '立即使用' : item.status === 2 ? '已使用' : '已过期' }}
</button>
</template>
</s-coupon-list>
</view>
</template>
<uni-load-more
v-if="state.pagination.total > 0"
:status="state.loadStatus"
:content-text="{
contentdown: '上拉加载更多',
}"
@tap="loadMore"
/>
</s-layout>
</template>
<script setup>
import sheep from '@/sheep';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import { reactive } from 'vue';
import _ from 'lodash-es';
import { resetPagination } from '@/sheep/helper/utils';
import CouponApi from '@/sheep/api/promotion/coupon';
// 数据
const state = reactive({
currentTab: 0, // 当前 tab
type: '1',
pagination: {
list: [],
total: 0,
pageNo: 1,
pageSize: 5,
},
loadStatus: '',
});
const tabMaps = [
{
name: '领券中心',
value: 'all',
},
{
name: '已领取',
value: '1',
},
{
name: '已使用',
value: '2',
},
{
name: '已失效',
value: '3',
},
];
function onTabsChange(e) {
state.currentTab = e.index;
state.type = e.value;
resetPagination(state.pagination);
if (state.currentTab === 0) {
getData();
} else {
getCoupon();
}
}
// 获得优惠劵模版列表
async function getData() {
state.loadStatus = 'loading';
const { data, code } = await CouponApi.getCouponTemplatePage({
pageNo: state.pagination.pageNo,
pageSize: state.pagination.pageSize,
});
if (code !== 0) {
return;
}
state.pagination.list = _.concat(state.pagination.list, data.list);
state.pagination.total = data.total;
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
}
// 获得我的优惠劵
async function getCoupon() {
state.loadStatus = 'loading';
const { data, code } = await CouponApi.getCouponPage({
pageNo: state.pagination.pageNo,
pageSize: state.pagination.pageSize,
status: state.type,
});
if (code !== 0) {
return;
}
state.pagination.list = _.concat(state.pagination.list, data.list);
state.pagination.total = data.total;
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
}
// 领取优惠劵
async function getBuy(id) {
const { code } = await CouponApi.takeCoupon(id);
if (code !== 0) {
return;
}
uni.showToast({
title: '领取成功',
});
setTimeout(() => {
resetPagination(state.pagination);
getData();
}, 1000);
}
// 加载更多
function loadMore() {
if (state.loadStatus === 'noMore') {
return;
}
state.pagination.pageNo++;
if (state.currentTab === 0) {
getData();
} else {
getCoupon();
}
}
onLoad((Option) => {
// 领劵中心
if (Option.type === 'all' || !Option.type) {
getData();
// 我的优惠劵
} else {
Option.type === 'geted'
? (state.currentTab = 1)
: Option.type === 'used'
? (state.currentTab = 2)
: (state.currentTab = 3);
state.type = state.currentTab;
getCoupon();
}
});
onReachBottom(() => {
loadMore();
});
</script>
<style lang="scss" scoped>
.card-btn {
// width: 144rpx;
padding: 0 16rpx;
height: 50rpx;
border-radius: 40rpx;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
color: #ffffff;
font-size: 24rpx;
font-weight: 400;
}
.border-btn {
background: linear-gradient(90deg, var(--ui-BG-Main-opacity-4), var(--ui-BG-Main-light));
color: #fff !important;
}
.disabled-btn {
background: #cccccc;
background-color: #cccccc !important;
color: #fff !important;
}
</style>
+190
View File
@@ -0,0 +1,190 @@
<!-- 评价 -->
<template>
<s-layout title="评价">
<view>
<view v-for="(item, index) in state.orderInfo.items" :key="item.id">
<view>
<view class="commont-from-wrap">
<!-- 评价商品 -->
<s-goods-item
:img="item.picUrl"
:title="item.spuName"
:skuText="item.properties.map((property) => property.valueName).join(' ')"
:price="item.payPrice"
:num="item.count"
/>
</view>
<view class="form-item">
<!-- 评分 -->
<view class="star-box ss-flex ss-col-center">
<view class="star-title ss-m-r-40">商品质量</view>
<uni-rate v-model="state.commentList[index].descriptionScores" />
</view>
<view class="star-box ss-flex ss-col-center">
<view class="star-title ss-m-r-40">服务态度</view>
<uni-rate v-model="state.commentList[index].benefitScores" />
</view>
<!-- 评价 -->
<view class="area-box">
<uni-easyinput
:inputBorder="false"
type="textarea"
maxlength="120"
autoHeight
v-model="state.commentList[index].content"
placeholder="宝贝满足你的期待吗?说说你的使用心得,分享给想买的他们吧~"
/>
<view class="img-box">
<s-uploader
v-model:url="state.commentList[index].images"
fileMediatype="image"
limit="9"
mode="grid"
:imageStyles="{ width: '168rpx', height: '168rpx' }"
@success="(payload) => uploadSuccess(payload, index)"
/>
</view>
</view>
<view class="checkbox-container">
<checkbox-group @change="(event) => toggleAnonymous(index, event)">
<label>
<checkbox value="anonymousChecked" />
匿名评论
</label>
</checkbox-group>
</view>
</view>
</view>
</view>
</view>
<su-fixed bottom placeholder>
<view class="foot_box ss-flex ss-row-center ss-col-center">
<button class="ss-reset-button post-btn ui-BG-Main-Gradient ui-Shadow-Main" @tap="onSubmit">
发布
</button>
</view>
</su-fixed>
</s-layout>
</template>
<script setup>
import sheep from '@/sheep';
import { onLoad } from '@dcloudio/uni-app';
import { reactive } from 'vue';
import OrderApi from '@/sheep/api/trade/order';
const state = reactive({
orderInfo: {},
commentList: [],
id: null,
});
/**
* 切换是否匿名
*
* @param commentIndex 当前评论下标
* @param event 复选框事件
*/
function toggleAnonymous(commentIndex, event) {
state.commentList[commentIndex].anonymous = event.detail.value[0] === 'anonymousChecked';
}
/**
* 发布评论
*
* @returns {Promise<void>}
*/
async function onSubmit() {
// 顺序提交评论
for (const comment of state.commentList) {
await OrderApi.createOrderItemComment(comment);
}
// 都评论好,返回
sheep.$router.back();
}
/**
* 图片添加到表单
*
* @param payload 上传成功后的回调数据
* @param commentIndex 当前评论的下标
*/
function uploadSuccess(payload, commentIndex) {
state.commentList[commentIndex].picUrls = payload.tempFilePaths;
}
onLoad(async (options) => {
if (!options.id) {
sheep.$helper.toast(`缺少订单信息,请检查`);
return;
}
state.id = options.id;
const { code, data } = await OrderApi.getOrderDetail(state.id);
if (code !== 0) {
sheep.$helper.toast('无待评价订单');
return;
}
// 处理评论
data.items.forEach((item) => {
state.commentList.push({
anonymous: false,
orderItemId: item.id,
descriptionScores: 5,
benefitScores: 5,
content: '',
picUrls: [],
});
});
state.orderInfo = data;
});
</script>
<style lang="scss" scoped>
// 评价商品
.goods-card {
margin: 10rpx 0;
padding: 20rpx;
background: #fff;
}
// 评论,选择图片
.form-item {
background: #fff;
.star-box {
height: 100rpx;
padding: 0 25rpx;
}
.star-title {
font-weight: 600;
}
}
.area-box {
width: 690rpx;
min-height: 306rpx;
background: rgba(249, 250, 251, 1);
border-radius: 20rpx;
padding: 28rpx;
margin: auto;
.img-box {
margin-top: 20rpx;
}
}
.checkbox-container {
padding: 10rpx;
}
.post-btn {
width: 690rpx;
line-height: 80rpx;
border-radius: 40rpx;
color: rgba(#fff, 0.9);
margin-bottom: 20rpx;
}
</style>
+168
View File
@@ -0,0 +1,168 @@
<!-- 商品评论的分页 -->
<template>
<s-layout title="全部评论">
<su-tabs
:list="state.type"
:scrollable="false"
@change="onTabsChange"
:current="state.currentTab"
/>
<!-- 评论列表 -->
<view class="ss-m-t-20">
<view class="list-item" v-for="item in state.pagination.list" :key="item">
<comment-item :item="item" />
</view>
</view>
<s-empty v-if="state.pagination.total === 0" text="暂无数据" icon="/static/data-empty.png" />
<!-- 下拉 -->
<uni-load-more
icon-type="auto"
v-if="state.pagination.total > 0"
:status="state.loadStatus"
:content-text="{
contentdown: '上拉加载更多',
}"
@tap="loadMore"
/>
</s-layout>
</template>
<script setup>
import CommentApi from '@/sheep/api/product/comment';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import { reactive } from 'vue';
import _ from 'lodash-es';
import commentItem from '../components/detail/comment-item.vue';
const state = reactive({
id: 0, // 商品 SPU 编号
type: [
{ type: 0, name: '全部' },
{ type: 1, name: '好评' },
{ type: 2, name: '中评' },
{ type: 3, name: '差评' },
],
currentTab: 0, // 选中的 TAB
loadStatus: '',
pagination: {
list: [],
total: 0,
pageNo: 1,
pageSize: 8,
},
});
// 切换选项卡
function onTabsChange(e) {
state.currentTab = e.index;
// 加载列表
state.pagination.pageNo = 1;
state.pagination.list = [];
state.pagination.total = 0;
getList();
}
async function getList() {
// 加载列表
state.loadStatus = 'loading';
let res = await CommentApi.getCommentPage(
state.id,
state.pagination.pageNo,
state.pagination.pageSize,
state.type[state.currentTab].type,
);
if (res.code !== 0) {
return;
}
// 合并列表
state.pagination.list = _.concat(state.pagination.list, res.data.list);
state.pagination.total = res.data.total;
state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
}
// 加载更多
function loadMore() {
if (state.loadStatus === 'noMore') {
return;
}
state.pagination.pageNo++;
getList();
}
onLoad((options) => {
state.id = options.id;
getList();
});
// 上拉加载更多
onReachBottom(() => {
loadMore();
});
</script>
<style lang="scss" scoped>
.list-item {
padding: 32rpx 30rpx 20rpx 20rpx;
background: #fff;
.avatar {
width: 52rpx;
height: 52rpx;
border-radius: 50%;
}
.nickname {
font-size: 26rpx;
font-weight: 500;
color: #999999;
}
.create-time {
font-size: 24rpx;
font-weight: 500;
color: #c4c4c4;
}
.content-title {
font-size: 26rpx;
font-weight: 400;
color: #666666;
line-height: 42rpx;
}
.content-img {
width: 174rpx;
height: 174rpx;
}
.cicon-info-o {
font-size: 26rpx;
color: #c4c4c4;
}
.foot-title {
font-size: 24rpx;
font-weight: 500;
color: #999999;
}
}
.btn-box {
width: 100%;
height: 120rpx;
background: #fff;
border-top: 2rpx solid #eee;
}
.tab-btn {
width: 130rpx;
height: 62rpx;
background: #eeeeee;
border-radius: 31rpx;
font-size: 28rpx;
font-weight: 400;
color: #999999;
border: 1px solid #e5e5e5;
margin-right: 10rpx;
}
</style>
@@ -0,0 +1,94 @@
<!-- 商品评论项 -->
<template>
<view>
<!-- 用户评论 -->
<view class="user ss-flex ss-m-b-14">
<view class="ss-m-r-20 ss-flex">
<image class="avatar" :src="item.userAvatar"></image>
</view>
<view class="nickname ss-m-r-20">{{ item.userNickname }}</view>
<view class="">
<uni-rate :readonly="true" v-model="item.scores" size="18" />
</view>
</view>
<view class="content"> {{ item.content }} </view>
<view class="ss-m-t-24" v-if="item.picUrls?.length">
<scroll-view class="scroll-box" scroll-x scroll-anchoring>
<view class="ss-flex">
<view v-for="(picUrl, index) in item.picUrls" :key="picUrl" class="ss-m-r-10">
<su-image
class="content-img"
isPreview
:previewList="item.picUrls"
:current="index"
:src="picUrl"
:height="120"
:width="120"
mode="aspectFill"
/>
</view>
</view>
</scroll-view>
</view>
<!-- 商家回复 -->
<view class="ss-m-t-20 reply-box" v-if="item.replyTime">
<view class="reply-title">商家回复:</view>
<view class="reply-content">{{ item.replyContent }}</view>
</view>
</view>
</template>
<script setup>
const props = defineProps({
item: {
type: Object,
default() {},
},
});
</script>
<style lang="scss" scoped>
.avatar {
width: 52rpx;
height: 52rpx;
border-radius: 50%;
}
.nickname {
font-size: 26rpx;
font-weight: 500;
color: #999999;
}
.content {
width: 636rpx;
font-size: 26rpx;
font-weight: 400;
color: #333333;
}
.reply-box {
position: relative;
background: #f8f8f8;
border-radius: 8rpx;
padding: 16rpx;
}
.reply-title {
position: absolute;
left: 16rpx;
top: 16rpx;
font-weight: 400;
font-size: 26rpx;
line-height: 40rpx;
color: #333333;
}
.reply-content {
text-indent: 128rpx;
font-weight: 400;
font-size: 26rpx;
line-height: 40rpx;
color: #333333;
}
</style>
@@ -0,0 +1,99 @@
<template>
<su-fixed bottom placeholder :val="44">
<view>
<view v-for="activity in props.activityList" :key="activity.id">
<view
class="activity-box ss-p-x-38 ss-flex ss-row-between ss-col-center"
:class="activity.type === 1 ? 'seckill-box' : 'groupon-box'"
>
<view class="activity-title ss-flex">
<view class="ss-m-r-16">
<image
v-if="activity.type === 1"
:src="sheep.$url.static('/static/img/shop/goods/seckill-icon.png')"
class="activity-icon"
/>
<image
v-else-if="activity.type === 3"
:src="sheep.$url.static('/static/img/shop/goods/groupon-icon.png')"
class="activity-icon"
/>
</view>
<view>该商品正在参与{{ activity.name }}活动</view>
</view>
<button class="ss-reset-button activity-go" @tap="onActivity(activity)"> GO </button>
</view>
</view>
</view>
</su-fixed>
</template>
<script setup>
import sheep from '@/sheep';
const seckillBg = sheep.$url.css('/static/img/shop/goods/seckill-tip-bg.png');
const grouponBg = sheep.$url.css('/static/img/shop/goods/groupon-tip-bg.png');
const props = defineProps({
activityList: {
type: Array,
default() {
return [];
},
},
});
function onActivity(activity) {
const type = activity.type;
const typePath = type === 1 ? 'seckill' : type === 3 ? 'groupon' : undefined;
if (!typePath) {
return;
}
sheep.$router.go(`/pages/goods/${typePath}`, {
id: activity.id,
});
}
</script>
<style lang="scss" scoped>
.activity-box {
width: 100%;
height: 80rpx;
box-sizing: border-box;
margin-bottom: 10rpx;
.activity-title {
font-size: 26rpx;
font-weight: 500;
color: #ffffff;
line-height: 42rpx;
.activity-icon {
width: 38rpx;
height: 38rpx;
}
}
.activity-go {
width: 70rpx;
height: 32rpx;
background: #ffffff;
border-radius: 16rpx;
font-weight: 500;
color: #ff6000;
font-size: 24rpx;
line-height: normal;
}
}
//秒杀卡片
.seckill-box {
background: v-bind(seckillBg) no-repeat;
background-size: 100% 100%;
}
.groupon-box {
background: v-bind(grouponBg) no-repeat;
background-size: 100% 100%;
}
</style>
@@ -0,0 +1,35 @@
<template>
<!-- SKU 选择的提示框 -->
<detail-cell label="选择" :value="value" :theme="props.theme" />
</template>
<script setup>
import { computed } from 'vue';
import detailCell from './detail-cell.vue';
const props = defineProps({
modelValue: {
type: Array,
default() {
return [];
},
},
sku: {
type: Object,
},
theme: {
type: String,
default: '2',
},
});
const value = computed(() => {
if (!props.sku?.id) {
return '请选择商品规格';
}
let str = '';
props.sku.properties.forEach((property) => {
str += property.propertyName + ':' + property.valueName + ' ';
});
return str;
});
</script>
@@ -0,0 +1,64 @@
<!-- 商品详情:cell 组件 -->
<template>
<view class="detail-cell-wrap ss-flex ss-col-center ss-row-between theme-ai" @tap="onClick">
<view class="label-text" :class="{ c25: theme == '2' }">{{ label }}</view>
<view class="cell-content ss-line-1 ss-flex-1">{{ value }}</view>
<button class="ss-reset-button" v-if="props.label == '选择'">
<text class="_icon-forward right-forwrad-icon"></text>
</button>
</view>
</template>
<script setup>
/**
* 详情 cell
*
*/
const props = defineProps({
label: {
type: String,
default: '',
},
value: {
type: String,
default: '',
},
theme: {
type: String,
default: '2',
},
});
const emits = defineEmits(['click']);
// 点击
const onClick = () => {
emits('click');
};
</script>
<style lang="scss" scoped>
.detail-cell-wrap {
height: 90rpx;
padding: 0 32rpx;
// min-height: 60rpx;
.label-text {
font-size: 28rpx;
color: $dark-9;
margin-right: 38rpx;
}
.cell-content {
font-size: 28rpx;
font-weight: 500;
color: $dark-6;
}
.right-forwrad-icon {
font-size: 28rpx;
font-weight: 500;
color: #383838;
}
}
</style>
@@ -0,0 +1,106 @@
<!-- 商品评论的卡片 -->
<template>
<view class="detail-comment-card bg-white">
<view class="card-header ss-flex ss-col-center ss-row-between ss-p-b-30">
<view class="ss-flex ss-col-center">
<view class="line"></view>
<view class="title ss-m-l-20 ss-m-r-10">评价</view>
<view class="des">({{ state.total }})</view>
</view>
<view
class="ss-flex ss-col-center"
@tap="sheep.$router.go('/pages/goods/comment/list', { id: goodsId })"
v-if="state.commentList.length > 0"
>
<button class="ss-reset-button more-btn">查看全部</button>
<text class="cicon-forward" />
</view>
</view>
<!-- 评论列表 -->
<view class="card-content">
<view class="comment-box ss-p-y-30" v-for="item in state.commentList" :key="item.id">
<comment-item :item="item" />
</view>
<s-empty
v-if="state.commentList.length === 0"
paddingTop="0"
icon="/static/comment-empty.png"
text="期待您的第一个评价"
/>
</view>
</view>
</template>
<script setup>
import { reactive, onBeforeMount } from 'vue';
import sheep from '@/sheep';
import CommentApi from '@/sheep/api/product/comment';
import commentItem from './comment-item.vue';
const props = defineProps({
goodsId: {
type: [Number, String],
default: 0,
},
});
const state = reactive({
commentList: [], // 评论列表,只展示最近的 3 条
total: 0, // 总评论数
});
async function getComment(id) {
const { data } = await CommentApi.getCommentPage(id, 1, 3, 0);
state.commentList = data.list;
state.total = data.total;
}
onBeforeMount(() => {
getComment(props.goodsId);
});
</script>
<style lang="scss" scoped>
.detail-comment-card {
margin: 0 20rpx 20rpx 20rpx;
padding: 20rpx 20rpx 0 20rpx;
.card-header {
.line {
width: 6rpx;
height: 30rpx;
background: linear-gradient(180deg, var(--ui-BG-Main) 0%, var(--ui-BG-Main-gradient) 100%);
border-radius: 3rpx;
}
.title {
font-size: 30rpx;
font-weight: bold;
line-height: normal;
}
.des {
font-size: 24rpx;
color: $dark-9;
}
.more-btn {
font-size: 24rpx;
color: var(--ui-BG-Main);
line-height: normal;
}
.cicon-forward {
font-size: 24rpx;
line-height: normal;
color: var(--ui-BG-Main);
margin-top: 4rpx;
}
}
}
.comment-box {
border-bottom: 2rpx solid #eeeeee;
&:last-child {
border: none;
}
}
</style>
@@ -0,0 +1,50 @@
<template>
<view class="detail-content-card ss-p-b-20">
<view class="card-content">
<mp-html :content="content"></mp-html>
</view>
</view>
</template>
<script setup>
const props = defineProps({
content: {
type: String,
default: '',
},
});
</script>
<style lang="scss" scoped>
.detail-content-card {
.card-header {
.line {
width: 6rpx;
height: 30rpx;
background: linear-gradient(180deg, var(--ui-BG-Main) 0%, var(--ui-BG-Main-gradient) 100%);
border-radius: 3rpx;
}
.title {
font-size: 30rpx;
font-weight: bold;
}
.des {
font-size: 24rpx;
color: $dark-9;
}
.more-btn {
font-size: 24rpx;
color: var(--ui-BG-Main);
}
}
}
:deep() {
image {
display: block;
}
}
</style>
@@ -0,0 +1,257 @@
<!-- 商品详情:商品/评价/详情的 nav -->
<template>
<su-fixed alway :bgStyles="{ background: '#fff' }" :val="0" noNav opacity :placeholder="false">
<su-status-bar />
<view
class="ui-bar ss-flex ss-col-center ss-row-between ss-p-x-20"
:style="[{ height: sys_navBar - sys_statusBar + 'px' }]"
>
<!-- 左 -->
<view class="icon-box ss-flex">
<view class="icon-button icon-button-left ss-flex ss-row-center" @tap="onClickLeft">
<text class="sicon-back" v-if="hasHistory" />
<text class="sicon-home" v-else />
</view>
<view class="line"></view>
<view class="icon-button icon-button-right ss-flex ss-row-center" @tap="onClickRight">
<text class="sicon-more" />
</view>
</view>
<!-- 中 -->
<view class="detail-tab-card ss-flex-1" :style="[{ opacity: state.tabOpacityVal }]">
<view class="tab-box ss-flex ss-col-center ss-row-around">
<view
class="tab-item ss-flex-1 ss-flex ss-row-center ss-col-center"
v-for="item in state.tabList"
:key="item.value"
@tap="onTab(item)"
>
<view class="tab-title" :class="state.curTab === item.value ? 'cur-tab-title' : ''">
{{ item.label }}
</view>
<view v-show="state.curTab === item.value" class="tab-line"></view>
</view>
</view>
</view>
<!-- #ifdef MP -->
<view :style="[capsuleStyle]"></view>
<!-- #endif -->
</view>
</su-fixed>
</template>
<script setup>
import { reactive } from 'vue';
import { onPageScroll } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import throttle from '@/sheep/helper/throttle.js';
import { showMenuTools } from '@/sheep/hooks/useModal';
const sys_statusBar = sheep.$platform.device.statusBarHeight;
const sys_navBar = sheep.$platform.navbar;
const capsuleStyle = {
width: sheep.$platform.capsule.width + 'px',
height: sheep.$platform.capsule.height + 'px',
};
const state = reactive({
tabOpacityVal: 0,
curTab: 'goods',
tabList: [
{
label: '商品',
value: 'goods',
to: 'detail-swiper-selector',
},
{
label: '评价',
value: 'comment',
to: 'detail-comment-selector',
},
{
label: '详情',
value: 'detail',
to: 'detail-content-selector',
},
],
});
const emits = defineEmits(['clickLeft']);
const hasHistory = sheep.$router.hasHistory();
function onClickLeft() {
if (hasHistory) {
sheep.$router.back();
} else {
sheep.$router.go('/pages/index/index');
}
emits('clickLeft');
}
function onClickRight() {
showMenuTools();
}
let commentCard = {
top: 0,
bottom: 0,
};
function getCommentCardNode() {
return new Promise((res, rej) => {
uni
.createSelectorQuery()
.select('.detail-comment-selector')
.boundingClientRect((data) => {
if (data) {
commentCard.top = data.top;
commentCard.bottom = data.top + data.height;
res(data);
} else {
res(null);
}
})
.exec();
});
}
function onTab(tab) {
let scrollTop = 0;
if (tab.value === 'comment') {
scrollTop = commentCard.top - sys_navBar + 1;
} else if (tab.value === 'detail') {
scrollTop = commentCard.bottom - sys_navBar + 1;
}
uni.pageScrollTo({
scrollTop,
duration: 200,
});
}
onPageScroll((e) => {
state.tabOpacityVal = e.scrollTop > sheep.$platform.navbar ? 1 : e.scrollTop * 0.01;
if (commentCard.top === 0) {
throttle(() => {
getCommentCardNode();
}, 50);
}
if (e.scrollTop < commentCard.top - sys_navBar) {
state.curTab = 'goods';
} else if (
e.scrollTop >= commentCard.top - sys_navBar &&
e.scrollTop <= commentCard.bottom - sys_navBar
) {
state.curTab = 'comment';
} else {
state.curTab = 'detail';
}
});
</script>
<style lang="scss" scoped>
.icon-box {
box-shadow: 0px 0px 4rpx rgba(51, 51, 51, 0.08), 0px 4rpx 6rpx 2rpx rgba(102, 102, 102, 0.12);
border-radius: 30rpx;
width: 134rpx;
height: 56rpx;
margin-left: 8rpx;
border: 1px solid rgba(#fff, 0.4);
.line {
width: 2rpx;
height: 24rpx;
background: #e5e5e7;
}
.sicon-back {
font-size: 32rpx;
color: #000;
}
.sicon-home {
font-size: 32rpx;
color: #000;
}
.sicon-more {
font-size: 32rpx;
color: #000;
}
.icon-button {
width: 67rpx;
height: 56rpx;
&-left:hover {
background: rgba(0, 0, 0, 0.16);
border-radius: 30rpx 0px 0px 30rpx;
}
&-right:hover {
background: rgba(0, 0, 0, 0.16);
border-radius: 0px 30rpx 30rpx 0px;
}
}
}
.left-box {
position: relative;
width: 60rpx;
height: 60rpx;
display: flex;
justify-content: center;
align-items: center;
.circle {
position: absolute;
left: 0;
top: 0;
width: 60rpx;
height: 60rpx;
background: rgba(#fff, 0.6);
border: 1rpx solid #ebebeb;
border-radius: 50%;
box-sizing: border-box;
z-index: -1;
}
}
.right {
position: relative;
width: 60rpx;
height: 60rpx;
display: flex;
justify-content: center;
align-items: center;
.circle {
position: absolute;
left: 0;
top: 0;
width: 60rpx;
height: 60rpx;
background: rgba(#ffffff, 0.6);
border: 1rpx solid #ebebeb;
box-sizing: border-box;
border-radius: 50%;
z-index: -1;
}
}
.detail-tab-card {
width: 50%;
.tab-item {
height: 80rpx;
position: relative;
z-index: 11;
.tab-title {
font-size: 30rpx;
}
.cur-tab-title {
font-weight: $font-weight-bold;
}
.tab-line {
width: 60rpx;
height: 6rpx;
border-radius: 6rpx;
position: absolute;
left: 50%;
transform: translateX(-50%);
bottom: 10rpx;
background-color: var(--ui-BG-Main);
z-index: 12;
}
}
}
</style>
@@ -0,0 +1,40 @@
<!-- 秒杀商品:抢购进度 -->
<template>
<view class="ss-flex ss-col-center">
<view class="progress-title ss-m-r-10"> 已抢{{ percent }}% </view>
<view class="progress-box ss-flex ss-col-center">
<view class="progerss-active" :style="{ width: percent < 10 ? '10%' : percent + '%' }">
</view>
</view>
</view>
</template>
<script setup>
const props = defineProps({
percent: {
type: Number,
default: 0,
},
});
</script>
<style lang="scss" scoped>
.progress-title {
font-size: 20rpx;
font-weight: 500;
color: #ffffff;
}
.progress-box {
width: 168rpx;
height: 18rpx;
background: #f6f6f6;
border-radius: 9rpx;
}
.progerss-active {
height: 24rpx;
background: linear-gradient(86deg, #f60600, #d00500);
border-radius: 12rpx;
}
</style>
@@ -0,0 +1,177 @@
<template>
<view
class="skeleton-wrap"
:class="['theme-' + sys.mode, 'main-' + sys.theme, 'font-' + sys.fontSize]"
>
<view class="skeleton-banner"></view>
<view class="container-box">
<view class="container-box-strip title ss-m-b-58"></view>
<view class="container-box-strip ss-m-b-20"></view>
<view class="container-box-strip ss-m-b-20"></view>
<view class="container-box-strip w-364"></view>
</view>
<view class="container-box">
<view class="ss-flex ss-row-between ss-m-b-34">
<view class="container-box-strip w-380"></view>
<view class="circle"></view>
</view>
<view class="ss-flex ss-row-between ss-m-b-34">
<view class="container-box-strip w-556"></view>
<view class="circle"></view>
</view>
<view class="ss-flex ss-row-between">
<view class="container-box-strip w-556"></view>
<view class="circle"></view>
</view>
</view>
<view class="container-box">
<view class="container-box-strip w-198 ss-m-b-42"></view>
<view class="ss-flex">
<view class="circle ss-m-r-12"></view>
<view class="container-box-strip w-252"></view>
</view>
</view>
<su-fixed bottom placeholder bg="bg-white">
<view class="ui-tabbar-box">
<view class="foot ss-flex ss-col-center">
<view class="ss-m-r-54 ss-m-l-32">
<view class="rec ss-m-b-8"></view>
<view class="oval"></view>
</view>
<view class="ss-m-r-54">
<view class="rec ss-m-b-8"></view>
<view class="oval"></view>
</view>
<view class="ss-m-r-50">
<view class="rec ss-m-b-8"></view>
<view class="oval"></view>
</view>
<button class="ss-reset-button add-btn ui-Shadow-Main"></button>
<button class="ss-reset-button buy-btn ui-Shadow-Main"></button>
</view>
</view>
</su-fixed>
</view>
</template>
<script setup>
import { computed } from 'vue';
import sheep from '@/sheep';
const sys = computed(() => sheep.$store('sys'));
</script>
<style lang="scss" scoped>
@keyframes loading {
0% {
opacity: 0.5;
}
50% {
opacity: 1;
}
100% {
opacity: 0.5;
}
}
.skeleton-wrap {
width: 100%;
height: 100vh;
position: relative;
.skeleton-banner {
width: 100%;
height: calc(100vh - 882rpx);
background: #f4f4f4;
}
.container-box {
padding: 24rpx 18rpx;
margin: 14rpx 20rpx;
background: var(--ui-BG);
animation: loading 1.4s ease infinite;
.container-box-strip {
height: 40rpx;
background: #f3f3f1;
border-radius: 20rpx;
}
.title {
width: 470rpx;
height: 50rpx;
border-radius: 25rpx;
}
.w-364 {
width: 364rpx;
}
.w-380 {
width: 380rpx;
}
.w-556 {
width: 556rpx;
}
.w-198 {
width: 198rpx;
}
.w-252 {
width: 252rpx;
}
.circle {
width: 40rpx;
height: 40rpx;
background: #f3f3f1;
border-radius: 50%;
}
}
.ui-tabbar-box {
box-shadow: 0px -6px 10px 0px rgba(51, 51, 51, 0.2);
}
.foot {
height: 100rpx;
background: var(--ui-BG);
.rec {
width: 38rpx;
height: 38rpx;
background: #f3f3f1;
border-radius: 8rpx;
}
.oval {
width: 38rpx;
height: 22rpx;
background: #f3f3f1;
border-radius: 11rpx;
}
.add-btn {
width: 214rpx;
height: 72rpx;
font-weight: 500;
font-size: 28rpx;
border-radius: 40rpx 0 0 40rpx;
background-color: var(--ui-BG-Main-light);
color: var(--ui-BG-Main);
}
.buy-btn {
width: 214rpx;
height: 72rpx;
font-weight: 500;
font-size: 28rpx;
border-radius: 0 40rpx 40rpx 0;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
color: $white;
}
}
}
</style>
@@ -0,0 +1,166 @@
<!-- 商品详情的底部导航 -->
<template>
<su-fixed bottom placeholder bg="bg0">
<view class="ui-tabbar-box flex-center ju-between" style="background: #fff">
<view class="ui-tabbar ss-flex ss-col-center">
<view
class="detail-tabbar-item ss-flex ss-flex-col ss-row-center ss-col-center"
@tap="onCart"
>
<image class="item-icon" :src="$url + 'index/car1.png'" mode="aspectFit" />
<view class="item-title">购物车</view>
</view>
<view
v-if="collectIcon"
class="detail-tabbar-item ss-flex ss-flex-col ss-row-center ss-col-center"
@tap="onFavorite"
>
<block v-if="modelValue.favorite">
<image class="item-icon" :src="$url + 'index/collect_2.png'" mode="aspectFit" />
<view class="item-title">已收藏</view>
</block>
<block v-else>
<image class="item-icon" :src="$url + 'index/collect_3.png'" mode="aspectFit" />
<view class="item-title">收藏</view>
</block>
</view>
<!-- <view
v-if="shareIcon"
class="detail-tabbar-item ss-flex ss-flex-col ss-row-center ss-col-center"
@tap="showShareModal"
>
<image
class="item-icon"
:src="sheep.$url.static('/static/img/shop/goods/share.png')"
mode="aspectFit"
/>
<view class="item-title">分享</view>
</view> -->
</view>
<slot></slot>
</view>
</su-fixed>
</template>
<script setup>
/**
*
* 底部导航
*
* @property {String} bg - 背景颜色Class
* @property {String} ui - 自定义样式Class
* @property {Boolean} noFixed - 是否定位
* @property {Boolean} topRadius - 上圆角
*/
import { reactive } from 'vue';
import sheep from '@/sheep';
import { showShareModal } from '@/sheep/hooks/useModal';
import FavoriteApi from '@/sheep/api/product/favorite';
// 数据
const state = reactive({});
// 接收参数
const props = defineProps({
modelValue: {
type: Object,
default() {},
},
bg: {
type: String,
default: 'bg-white',
},
bgStyles: {
type: Object,
default() {},
},
ui: {
type: String,
default: '',
},
noFixed: {
type: Boolean,
default: false,
},
topRadius: {
type: Number,
default: 0,
},
collectIcon: {
type: Boolean,
default: true,
},
serviceIcon: {
type: Boolean,
default: true,
},
shareIcon: {
type: Boolean,
default: true,
},
});
async function onFavorite() {
// 情况一:取消收藏
if (props.modelValue.favorite) {
const { code } = await FavoriteApi.deleteFavorite(props.modelValue.id);
if (code !== 0) {
return;
}
sheep.$helper.toast('取消收藏');
props.modelValue.favorite = false;
// 情况二:添加收藏
} else {
const { code } = await FavoriteApi.createFavorite(props.modelValue.id);
if (code !== 0) {
return;
}
sheep.$helper.toast('收藏成功');
props.modelValue.favorite = true;
}
}
const onChat = () => {
sheep.$router.go('/pages/chat/index', {
id: props.modelValue.id,
});
};
const onCart = () => {
uni.switchTab({
url: '/pages/cart/cart',
});
};
</script>
<style lang="scss" scoped>
.ui-tabbar-box {
box-shadow: 0px -6px 10px 0px rgba(51, 51, 51, 0.2);
}
.ui-tabbar {
display: flex;
height: 50px;
.detail-tabbar-item {
width: 100rpx;
.item-icon {
width: 40rpx;
height: 40rpx;
}
.item-title {
font-size: 20rpx;
font-weight: 500;
line-height: 20rpx;
margin-top: 12rpx;
color: #333333;
}
}
}
.bg0 {
background: #ffffff !important;
}
</style>

Some files were not shown because too many files have changed in this diff Show More