first commit
This commit is contained in:
@@ -0,0 +1,840 @@
|
||||
<template>
|
||||
|
||||
<view v-if="isLoading" class="skeleton-container" style="padding-top: 80rpx;">
|
||||
<!-- 统计数据区域骨架 -->
|
||||
<view class="skeleton-stats-section">
|
||||
<view class="skeleton-stat-item">
|
||||
<view class="skeleton-stat-label"></view>
|
||||
<view class="skeleton-stat-value"></view>
|
||||
</view>
|
||||
<view class="skeleton-stat-item">
|
||||
<view class="skeleton-stat-label"></view>
|
||||
<view class="skeleton-stat-value"></view>
|
||||
</view>
|
||||
<view class="skeleton-stat-item">
|
||||
<view class="skeleton-stat-label"></view>
|
||||
<view class="skeleton-stat-value"></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 接单按钮骨架 -->
|
||||
<view class="skeleton-action-section">
|
||||
<view class="skeleton-accept-btn"></view>
|
||||
</view>
|
||||
|
||||
<!-- 标签栏骨架 -->
|
||||
<view class="skeleton-tab-bar">
|
||||
<view class="skeleton-tab-item">
|
||||
<view class="skeleton-tab-text"></view>
|
||||
</view>
|
||||
<view class="skeleton-tab-item">
|
||||
<view class="skeleton-tab-text"></view>
|
||||
</view>
|
||||
<view class="skeleton-tab-item">
|
||||
<view class="skeleton-tab-text"></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 任务列表骨架 -->
|
||||
<view class="skeleton-task-list">
|
||||
<!-- 任务卡片骨架 -->
|
||||
<view class="skeleton-task-section" v-for="i in 3" :key="i">
|
||||
<!-- 高价单标签骨架 -->
|
||||
<view class="skeleton-tag-row">
|
||||
<view class="skeleton-high-price-tag"></view>
|
||||
<view class="skeleton-phone-btn"></view>
|
||||
</view>
|
||||
|
||||
<!-- 商家信息骨架 -->
|
||||
<view class="skeleton-merchant-info">
|
||||
<view class="skeleton-merchant-name"></view>
|
||||
<view class="skeleton-distance"></view>
|
||||
</view>
|
||||
|
||||
<!-- 地址信息骨架 -->
|
||||
<view class="skeleton-address-info">
|
||||
<view class="skeleton-address-text"></view>
|
||||
</view>
|
||||
|
||||
<!-- 价格和取餐时间骨架 -->
|
||||
<view class="skeleton-price-time-row">
|
||||
<view class="skeleton-pickup-code"></view>
|
||||
<view class="skeleton-pickup-time"></view>
|
||||
</view>
|
||||
|
||||
<!-- 立即抢单按钮骨架 -->
|
||||
<view class="skeleton-grab-btn"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 实际内容 -->
|
||||
<view v-else class="rider-home" style="padding-top: 60rpx;">
|
||||
<!-- 统计数据区域 -->
|
||||
<view class="stats-section">
|
||||
<view class="stat-item">
|
||||
<text class="stat-label">今日收入</text>
|
||||
<text class="stat-value income">¥{{userData.dayAmount.toFixed(2)}}</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-label">已完成</text>
|
||||
<text class="stat-value completed">{{userData.dayOrderCount}}单</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-label">配送中</text>
|
||||
<text class="stat-value ongoing">{{ userData.takeOrderCount }}单</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 接单按钮 -->
|
||||
<view class="action-section">
|
||||
<up-button :disabled='riderInfo.status===0' type="primary" shape="circle" size="default"
|
||||
class="accept-orders-btn"
|
||||
@click="toggleAcceptOrders">{{ riderInfo.status==0?'审核中':(riderInfo.isOnline == 0 ? '已下线' : '已上线') }}</up-button>
|
||||
</view>
|
||||
|
||||
<view class="tab-bar">
|
||||
<view v-for="(tab, index) in tabs" :key="index" class="tab-item" :class="{ active: activeTab === index }"
|
||||
@click="switchTab(index)">
|
||||
<text class="tab-text">{{ tab }}</text>
|
||||
<view v-if="activeTab === index" class="active-line"></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="riderInfo.status==1" class="" style="padding: 0 30rpx;">
|
||||
<!-- -->
|
||||
<view v-for="(orderItem,orderIndex) in orderList " @click="gopage(orderItem.orderId)" :key="orderIndex"
|
||||
class="task-section">
|
||||
<!-- 高价单标签 -->
|
||||
<view class="" style="display: flex; align-items: center; justify-content: space-between;">
|
||||
|
||||
<view class="high-price-tag"
|
||||
:style="{'border':activeTab==0?'1rpx solid #FF7875':(activeTab==1?'1rpx solid #52C41A':'1rpx solid #FAAD14'),'color':activeTab==0?'#FF7875':(activeTab==1?'#52C41A':'#FAAD14') }"
|
||||
style="background-color: #fff;">
|
||||
<text class="high-price-text">{{activeTab==0? '新订单':(activeTab==1? '待取单':'配送中')}}</text>
|
||||
</view>
|
||||
<view class="" @click.stop="call(orderItem.phone)" style="display: flex; align-items: baseline;">
|
||||
<up-icon name="phone" color="var(--nav-mian)" size="20"></up-icon>
|
||||
<text style="margin-left: 10rpx; color: var(--nav-mian); ">拨打商家</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 商家信息 -->
|
||||
<view class="merchant-info">
|
||||
<text class="merchant-name">{{ orderItem.storeName }}</text>
|
||||
<text v-if="activeTab==1" class="distance">{{ distance(orderItem.distance) }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 地址信息 -->
|
||||
<view class="address-info">
|
||||
<up-icon name="map" color="#999" size="24rpx" />
|
||||
<text class="address-text"> {{orderItem.address }}</text>
|
||||
<!-- <text v-if="activeTab!==0" class="address-text">共3件商品</text> -->
|
||||
</view>
|
||||
<!-- 商品次数-->
|
||||
<!-- <view class="address-info">
|
||||
<text class="address-text">共3件商品</text>
|
||||
<view class="">
|
||||
<text class="price">¥5.50</text>
|
||||
<text style="color: var(--nav-mian); font-weight: 600; margin-left: 10rpx; ">/单</text>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<!-- 价格和取餐时间 -->
|
||||
<view class="price-time-row">
|
||||
<view v-if="activeTab==1" class="">
|
||||
<text style="font-size: 30rpx; font-weight: 600; color: #1890FF; ">取件码: </text>
|
||||
<text
|
||||
style="color: var(--nav-mian); font-weight: 600; margin-left: 10rpx; ">{{orderItem.pickCode }}</text>
|
||||
</view>
|
||||
<view v-if="activeTab!==1" class="">
|
||||
<text class="address-text">据您{{ distance(orderItem.distance) }}</text>
|
||||
</view>
|
||||
<view class="pickup-time">
|
||||
<up-icon name="clock" :color="activeTab==0?'#FAAD14':'#FF0000'" size="16" />
|
||||
<text class="time-text"
|
||||
:style="{'color':activeTab==0?'#FAAD14':'#FF0000'}">{{ orderItem.makeTime.split(' ').length==2?'预计'+orderItem.makeTime.split(' ')[1]+'送达':orderItem.makeTime }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 立即抢单按钮 -->
|
||||
|
||||
<view class="" style="display: flex; ">
|
||||
<view class="" style="width: 100%;"
|
||||
@click.stop="activeTab==0?takeOrder(orderItem.orderId):pickFood(orderItem.orderId)">
|
||||
<button type="primary" :color="activeTab==0?'#1890FF':'#52C41A'" size="large"
|
||||
class="grab-btn">{{ activeTab==0?'立即接单':(activeTab==1?'我已取餐':'确认送达')}}</button>
|
||||
</view>
|
||||
<view class="" style="width: 20rpx;" v-if="activeTab!=0">
|
||||
|
||||
</view>
|
||||
<view style="width: 100%;" v-if="activeTab!=0"
|
||||
@click.stop="Service.GoPage('/pages/order/orderMap?orderId='+orderItem.orderId)" class="">
|
||||
<button type="primary" color="#1890FF" class="grab-btn">{{activeTab==1?'导航取餐':'导航送餐'}}</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<up-loadmore :status="status" />
|
||||
</view>
|
||||
|
||||
<view v-if="riderInfo.status==0"
|
||||
style=" margin-top: 20rpx; text-align: center; font-weight: bold; font-size: 34rpx;" class="">
|
||||
信息审核中·请等待审核
|
||||
</view>
|
||||
<view v-if="riderInfo.status==-1"
|
||||
style=" margin-top: 20rpx; text-align: center; font-weight: bold; font-size: 34rpx;" class="">
|
||||
申请骑手完善信息·解锁后续功能
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
<view class="" style="width: 100%; height: 60rpx; ">
|
||||
|
||||
</view>
|
||||
<view class="" v-if="riderInfo.status === -1" style=" display: flex; align-items: center; justify-content: space-between; gap: 20rpx; position: fixed; bottom: 0; left: 0; width: 100%; background-color: #fff; padding: 20rpx; " >
|
||||
<button @click="Service.GoPage('/pages/my/completeData')" class="confirm-button">申请骑手</button>
|
||||
<button @click=" retrunLogin()" class="confirm-button">切换账号</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { Service } from '@/Service/Service';
|
||||
import { CNRiderDataService } from '@/Service/CN/CNRiderDataService'
|
||||
import { CNRiderOrderService } from '@/Service/CN/CNRiderOrderService'
|
||||
|
||||
// 加载状态
|
||||
const isLoading = ref(true);
|
||||
let status = ref('nomore')
|
||||
let page = ref(1)
|
||||
|
||||
let userData = ref({
|
||||
dayAmount: 0,
|
||||
dayOrderCount: 0,
|
||||
takeOrderCount: 0
|
||||
})
|
||||
|
||||
const tabs = ['新订单', '待取货', '配送中']
|
||||
const activeTab = ref(0)
|
||||
let riderInfo = ref<any>({})
|
||||
|
||||
let orderList = ref<Array<any>>([])
|
||||
|
||||
let a = ref(1)
|
||||
|
||||
onLoad(() => {
|
||||
uni.$on(`newOrder`, (data) => {
|
||||
a.value++
|
||||
console.log('消息推送1', a.value);
|
||||
newOrder()
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
onShow(() => {
|
||||
getData()
|
||||
getOrderData()
|
||||
})
|
||||
|
||||
// 有新订单
|
||||
const newOrder = () => {
|
||||
if (activeTab.value == 0) {
|
||||
getOrderData()
|
||||
}
|
||||
}
|
||||
|
||||
const getData = () => {
|
||||
CNRiderDataService.GetRiderHomeInfo().then(res => {
|
||||
isLoading.value = false
|
||||
riderInfo.value = res.data.riderInfo
|
||||
userData.value = res.data
|
||||
if (res.data.riderInfo.status === -1) {
|
||||
uni.hideTabBar()
|
||||
}else{
|
||||
uni.showTabBar()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
const getOrderData = () => {
|
||||
status.value = 'loadmore'
|
||||
page.value = 1
|
||||
orderList.value = []
|
||||
getOrderList()
|
||||
}
|
||||
|
||||
|
||||
//获取订单
|
||||
const getOrderList = () => {
|
||||
if (status.value == 'nomore' || status.value == 'loading') {
|
||||
return
|
||||
}
|
||||
status.value == 'loadmore'
|
||||
|
||||
if (activeTab.value == 0) {
|
||||
CNRiderOrderService.GetRiderOrderList(page.value).then(res => {
|
||||
if(res.code==0){
|
||||
orderList.value = [...orderList.value, ...res.data.list]
|
||||
status.value = res.data.list == 10 ? 'loadmore' : 'nomore'
|
||||
page.value++
|
||||
}
|
||||
})
|
||||
} else {
|
||||
CNRiderOrderService.GetRiderTakeOrderList(activeTab.value == 1 ? 0 : 1, page.value).then(res => {
|
||||
if(res.code==0){
|
||||
orderList.value = [...orderList.value, ...res.data.list]
|
||||
status.value = res.data.list == 10 ? 'loadmore' : 'nomore'
|
||||
page.value++
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 接单
|
||||
const takeOrder = (orderId : string) => {
|
||||
CNRiderOrderService.RiderTakeOrder(orderId).then(res => {
|
||||
if (res.data) {
|
||||
activeTab.value = 1
|
||||
getOrderData()
|
||||
getData()
|
||||
} else {
|
||||
Service.Msg(res.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
// 取餐
|
||||
const pickFood = (orderId : string) => {
|
||||
CNRiderOrderService.UpdateRiderOrderTake(orderId, activeTab.value).then(res => {
|
||||
if (res.data) {
|
||||
getOrderData()
|
||||
getData()
|
||||
} else {
|
||||
Service.Msg(res.msg)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 切换标签
|
||||
const switchTab = (index : number) => {
|
||||
activeTab.value = index
|
||||
getOrderData()
|
||||
}
|
||||
|
||||
// 切换接单状态
|
||||
const toggleAcceptOrders = () => {
|
||||
CNRiderDataService.UpdateRiderOnline().then(res => {
|
||||
if (res.data) {
|
||||
getData()
|
||||
} else {
|
||||
Service.Msg(res.msg)
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
// 距离计算
|
||||
const distance = (item : any) => {
|
||||
if (item < 0) {
|
||||
return Number(item * 100).toFixed(2) + 'm'
|
||||
} else {
|
||||
return Number(item).toFixed(2) + 'km'
|
||||
}
|
||||
}
|
||||
|
||||
// 拨打电话
|
||||
const call = (e : string) => {
|
||||
uni.makePhoneCall({
|
||||
phoneNumber: e
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 页面跳转
|
||||
const gopage = (id) => {
|
||||
if (activeTab.value == 0) {
|
||||
Service.GoPage('/pages/order/grabOrder?orderId=' + id)
|
||||
} else {
|
||||
Service.GoPage('/pages/order/orderDetail?orderId=' + id + '&type=' + activeTab.value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const retrunLogin=()=>{
|
||||
Service.OffUserToken()
|
||||
Service.GoPageDelse('/pages/my/login')
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
page {
|
||||
background-color: #F6f6f6;
|
||||
}
|
||||
|
||||
.confirm-button {
|
||||
width: 100%;
|
||||
height: 90rpx;
|
||||
background-color: #1677ff;
|
||||
color: #fff;
|
||||
font-size: 34rpx;
|
||||
font-weight: 600;
|
||||
border-radius: 45rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.confirm-button:active {
|
||||
background-color: #0958d9;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 统计数据区域 */
|
||||
.stats-section {
|
||||
background-color: #ffffff;
|
||||
margin: 20rpx;
|
||||
border-radius: 16rpx;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
padding: 30rpx 0;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 28rpx;
|
||||
color: #666666;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.income {
|
||||
color: var(--nav-diluted);
|
||||
}
|
||||
|
||||
.completed {
|
||||
color: var(--nav-vice);
|
||||
}
|
||||
|
||||
.ongoing {
|
||||
color: #FF9500;
|
||||
}
|
||||
|
||||
/* 接单按钮 */
|
||||
.action-section {
|
||||
margin: 0 20rpx;
|
||||
}
|
||||
|
||||
.accept-orders-btn {
|
||||
width: 100%;
|
||||
height: 90rpx;
|
||||
font-size: 32rpx;
|
||||
background-color: #52C41A;
|
||||
}
|
||||
|
||||
|
||||
/* 顶部标签栏 */
|
||||
.tab-bar {
|
||||
margin-top: 20rpx;
|
||||
display: flex;
|
||||
background-color: #FFFFFF;
|
||||
padding: 20rpx 0 0;
|
||||
border-bottom: 1rpx solid #E5E5E5;
|
||||
width: 100vw;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 20rpx 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tab-text {
|
||||
font-size: 28rpx;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.tab-item.active .tab-text {
|
||||
color: var(--nav-mian);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.active-line {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 110rpx;
|
||||
height: 6rpx;
|
||||
background-color: var(--nav-mian);
|
||||
border-radius: 3rpx;
|
||||
}
|
||||
|
||||
|
||||
.task-section {
|
||||
margin-top: 20rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: #fff;
|
||||
border-radius: 20rpx;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
|
||||
/* 标签样式 */
|
||||
.high-price-tag {
|
||||
width: fit-content;
|
||||
background-color: #FF7875;
|
||||
color: #FFFFFF;
|
||||
padding: 5rpx 20rpx;
|
||||
border-radius: 20rpx;
|
||||
font-size: 24rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.status-tag {
|
||||
position: absolute;
|
||||
top: 20rpx;
|
||||
left: 20rpx;
|
||||
padding: 5rpx 20rpx;
|
||||
border-radius: 20rpx;
|
||||
font-size: 24rpx;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.status-tag.pending {
|
||||
background-color: #4CD964;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.status-tag.delivering {
|
||||
background-color: #FF9500;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
/* 右侧操作按钮 */
|
||||
.right-action {
|
||||
position: absolute;
|
||||
top: 20rpx;
|
||||
right: 20rpx;
|
||||
}
|
||||
|
||||
.call-btn {
|
||||
padding: 5rpx 15rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 36rpx;
|
||||
}
|
||||
|
||||
/* 信息展示 */
|
||||
.merchant-info {
|
||||
margin-top: 20rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.merchant-name {
|
||||
font-size: 34rpx;
|
||||
font-weight: 600;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.distance {
|
||||
font-size: 28rpx;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.address-info {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
margin-top: 15rpx;
|
||||
}
|
||||
|
||||
.address-text {
|
||||
margin-left: 10rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666666;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* 价格和时间 */
|
||||
.price-time-row {
|
||||
margin-top: 20rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.price {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: #FF3B30;
|
||||
}
|
||||
|
||||
.pickup-code {
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.pickup-time {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
.time-text {
|
||||
margin-left: 8rpx;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
/* 按钮样式 */
|
||||
.grab-btn {
|
||||
margin-top: 25rpx;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
}
|
||||
|
||||
.grab-btn {
|
||||
background-color: #007AFF;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* uview组件样式覆盖 */
|
||||
::v-deep .u-button--primary {
|
||||
background-color: var(--nav-vice);
|
||||
border-color: var(--nav-vice);
|
||||
}
|
||||
|
||||
::v-deep .u-button--mini {
|
||||
background-color: var(--nav-mian);
|
||||
border-color: var(--nav-mian);
|
||||
}
|
||||
|
||||
|
||||
/* 骨架屏样式 */
|
||||
.skeleton-container {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
/* 统计数据区域骨架 */
|
||||
.skeleton-stats-section {
|
||||
background-color: #ffffff;
|
||||
margin: 0 20rpx;
|
||||
border-radius: 16rpx;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
padding: 30rpx 0;
|
||||
}
|
||||
|
||||
.skeleton-stat-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.skeleton-stat-label {
|
||||
width: 120rpx;
|
||||
height: 28rpx;
|
||||
background-color: #e6e6e6;
|
||||
border-radius: 8rpx;
|
||||
margin-bottom: 10rpx;
|
||||
animation: skeleton-loading 1.5s infinite;
|
||||
}
|
||||
|
||||
.skeleton-stat-value {
|
||||
width: 150rpx;
|
||||
height: 36rpx;
|
||||
background-color: #e6e6e6;
|
||||
border-radius: 8rpx;
|
||||
animation: skeleton-loading 1.5s infinite;
|
||||
}
|
||||
|
||||
/* 接单按钮骨架 */
|
||||
.skeleton-action-section {
|
||||
margin: 20rpx;
|
||||
}
|
||||
|
||||
.skeleton-accept-btn {
|
||||
width: 100%;
|
||||
height: 90rpx;
|
||||
background-color: #e6e6e6;
|
||||
border-radius: 8rpx;
|
||||
animation: skeleton-loading 1.5s infinite;
|
||||
}
|
||||
|
||||
/* 标签栏骨架 */
|
||||
.skeleton-tab-bar {
|
||||
display: flex;
|
||||
background-color: #ffffff;
|
||||
padding: 20rpx 0 0;
|
||||
border-bottom: 1rpx solid #e5e5e5;
|
||||
}
|
||||
|
||||
.skeleton-tab-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 20rpx 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.skeleton-tab-text {
|
||||
width: 100rpx;
|
||||
height: 28rpx;
|
||||
background-color: #e6e6e6;
|
||||
border-radius: 8rpx;
|
||||
animation: skeleton-loading 1.5s infinite;
|
||||
}
|
||||
|
||||
/* 任务列表骨架 */
|
||||
.skeleton-task-list {
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
|
||||
.skeleton-task-section {
|
||||
margin-top: 20rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: #fff;
|
||||
border-radius: 20rpx;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
/* 标签骨架 */
|
||||
.skeleton-tag-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.skeleton-high-price-tag {
|
||||
width: 120rpx;
|
||||
height: 30rpx;
|
||||
background-color: #e6e6e6;
|
||||
border-radius: 20rpx;
|
||||
animation: skeleton-loading 1.5s infinite;
|
||||
}
|
||||
|
||||
.skeleton-phone-btn {
|
||||
width: 150rpx;
|
||||
height: 30rpx;
|
||||
background-color: #e6e6e6;
|
||||
border-radius: 8rpx;
|
||||
animation: skeleton-loading 1.5s infinite;
|
||||
}
|
||||
|
||||
/* 商家信息骨架 */
|
||||
.skeleton-merchant-info {
|
||||
margin-top: 20rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.skeleton-merchant-name {
|
||||
width: 200rpx;
|
||||
height: 34rpx;
|
||||
background-color: #e6e6e6;
|
||||
border-radius: 8rpx;
|
||||
animation: skeleton-loading 1.5s infinite;
|
||||
}
|
||||
|
||||
.skeleton-distance {
|
||||
width: 80rpx;
|
||||
height: 28rpx;
|
||||
background-color: #e6e6e6;
|
||||
border-radius: 8rpx;
|
||||
animation: skeleton-loading 1.5s infinite;
|
||||
}
|
||||
|
||||
/* 地址信息骨架 */
|
||||
.skeleton-address-info {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
margin-top: 15rpx;
|
||||
}
|
||||
|
||||
.skeleton-address-text {
|
||||
width: 100%;
|
||||
height: 28rpx;
|
||||
background-color: #e6e6e6;
|
||||
border-radius: 8rpx;
|
||||
animation: skeleton-loading 1.5s infinite;
|
||||
}
|
||||
|
||||
/* 价格和时间骨架 */
|
||||
.skeleton-price-time-row {
|
||||
margin-top: 20rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.skeleton-pickup-code {
|
||||
width: 150rpx;
|
||||
height: 30rpx;
|
||||
background-color: #e6e6e6;
|
||||
border-radius: 8rpx;
|
||||
animation: skeleton-loading 1.5s infinite;
|
||||
}
|
||||
|
||||
.skeleton-pickup-time {
|
||||
width: 200rpx;
|
||||
height: 30rpx;
|
||||
background-color: #e6e6e6;
|
||||
border-radius: 8rpx;
|
||||
animation: skeleton-loading 1.5s infinite;
|
||||
}
|
||||
|
||||
/* 按钮骨架 */
|
||||
.skeleton-grab-btn {
|
||||
margin-top: 25rpx;
|
||||
height: 80rpx;
|
||||
background-color: #e6e6e6;
|
||||
border-radius: 40rpx;
|
||||
animation: skeleton-loading 1.5s infinite;
|
||||
}
|
||||
|
||||
/* 骨架屏动画 */
|
||||
@keyframes skeleton-loading {
|
||||
0% {
|
||||
background-color: #e6e6e6;
|
||||
}
|
||||
|
||||
50% {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
100% {
|
||||
background-color: #e6e6e6;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,392 @@
|
||||
import { HttpRequest, StoreAssist, UploadAssist, ResultData } from '@/common/Common';
|
||||
import { BaseConfig } from './BaseConfig';
|
||||
export class Service extends BaseConfig {
|
||||
|
||||
|
||||
// 获取是否后台
|
||||
static getIsHede () {
|
||||
let isHede = this.GetStorageCache('isHede')
|
||||
if (isHede == null || isHede == '') {
|
||||
return false;
|
||||
} else {
|
||||
return isHede;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//获取API地址
|
||||
static ApiUrl(path : string) {
|
||||
return `${this.servesUrl}${path}`;
|
||||
}
|
||||
|
||||
//获取图片地址
|
||||
static GetpayImg(path : string) {
|
||||
if (path.startsWith('http') || path.startsWith('https')) {
|
||||
return path;
|
||||
} else {
|
||||
return `${this.payuploadUrl}${path}`;
|
||||
}
|
||||
}
|
||||
|
||||
//获取图标地址
|
||||
static GetIconImg(path : string) {
|
||||
return path
|
||||
if (path.startsWith('http') || path.startsWith('https')) {
|
||||
return path;
|
||||
} else {
|
||||
return `${this.imgUrl}${path}`;
|
||||
}
|
||||
}
|
||||
|
||||
//获取图片地址
|
||||
static GetMateUrlByImg(path : string) {
|
||||
return path
|
||||
if (path.startsWith('http') || path.startsWith('https')) {
|
||||
return path;
|
||||
} else {
|
||||
return `${this.imgUrl}${path}`;
|
||||
}
|
||||
}
|
||||
//获取音视频地址
|
||||
static GetMateUrlByMedia(path : string) {
|
||||
if (path.startsWith('http') || path.startsWith('https')) {
|
||||
return path;
|
||||
} else {
|
||||
return `${this.mediaUrl}${path}`;
|
||||
}
|
||||
}
|
||||
//获取登录账号token
|
||||
static GetUserToken() {
|
||||
return Service.GetStorageCache('token');
|
||||
}
|
||||
// 获取登录状态
|
||||
static GetUserIsLogin() {
|
||||
var token = this.GetUserToken();
|
||||
if (token == null || token == '') {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//设置登录账户Token
|
||||
static SetUserToken(token : string) {
|
||||
this.SetStorageCache('token', token);
|
||||
}
|
||||
//清理登录账户Token
|
||||
static OffUserToken() {
|
||||
Service.DelStorageCache('token');
|
||||
uni.$emit('ImComOff', 'user');
|
||||
this.ClearUserStateData();
|
||||
}
|
||||
//获取登录账号状态信息
|
||||
static GetUserStateData() {
|
||||
return Service.GetStorageCache('StateDomain');
|
||||
}
|
||||
//设置当前登录账号状态信息
|
||||
static SetUserStateData() {
|
||||
return Service.GetStorageCache('StateDomain');
|
||||
}
|
||||
//清理当前登录账号状态信息
|
||||
static ClearUserStateData() {
|
||||
Service.DelStorageCache('StateDomain');
|
||||
}
|
||||
|
||||
|
||||
//获取当前客户端ID
|
||||
static GetUserClientId() {
|
||||
return this.GetStorageCache('ClientId');
|
||||
}
|
||||
//保存当前客户端ID
|
||||
static SetUserClientId(clientId: string) {
|
||||
this.SetStorageCache('ClientId', clientId);
|
||||
}
|
||||
|
||||
|
||||
//获取缓存
|
||||
static GetStorageCache(key : string) {
|
||||
return StoreAssist.Get(key);
|
||||
}
|
||||
//删除缓存
|
||||
static DelStorageCache(key : string) {
|
||||
StoreAssist.Delete(key);
|
||||
}
|
||||
//设置缓存
|
||||
static SetStorageCache(key : string, data : any) {
|
||||
StoreAssist.Set(key, data);
|
||||
}
|
||||
|
||||
/*****以下是基础方法调用与拦截器*****/
|
||||
|
||||
static Request(url : string, method : 'GET' | 'POST' | 'PUT' | undefined, data : object | any) {
|
||||
const token = Service.GetUserToken();
|
||||
|
||||
const _url = Service.ApiUrl(url);
|
||||
var result = HttpRequest.RequestWithToken(_url, method, token, data).then((retResult : any) => {
|
||||
if (retResult.statusCode == '200') {
|
||||
var obj = retResult.data;
|
||||
if (obj.code == 401) {
|
||||
//过期
|
||||
this.OffUserToken();
|
||||
// this.Msg('登录过期,请重新登录')
|
||||
this.GoPage('/pages/my/login')
|
||||
return Promise.reject();
|
||||
} else if (obj.code == 40101) {
|
||||
//失效
|
||||
this.OffUserToken();
|
||||
this.GoPageDelse('/pages/mine/login/login');
|
||||
return Promise.reject();
|
||||
} else if (obj.code == 1004) {
|
||||
//资源不存在
|
||||
this.GoPageDelse('/pages/AppSet/404/404');
|
||||
return Promise.reject();
|
||||
// return new ResultData(-1, '', '');
|
||||
} else if (obj.code == 40188) {
|
||||
//无权限
|
||||
|
||||
this.GoPageDelse('/pages/AppSet/40188/40188');
|
||||
return Promise.reject();
|
||||
// return new ResultData(-1, '', '');
|
||||
} else if (obj.code == 1008) {
|
||||
//业务提示
|
||||
return new ResultData(obj.code, obj.msg, obj.data);
|
||||
} else {
|
||||
return new ResultData(obj.code, obj.msg, obj.data);
|
||||
}
|
||||
} else {
|
||||
return new ResultData(-1, '', '');
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
/*****以下是腾讯云oss上传*****/
|
||||
static UpLoadMedia(code : string, fileName : string, desire : string, path : string) {
|
||||
var result = this.Request(this.uploadUrl, 'GET', { code, fileName, desire }).then((retResult) => {
|
||||
if (retResult.code == 0) {
|
||||
var upOk = UploadAssist.Upload(retResult.data.url, path, retResult.data.cosData).then((upRet : any) => {
|
||||
if (upRet.statusCode == 200) {
|
||||
const retData : any = { code: retResult.data.code, file: retResult.data.file, cache: retResult.data.cache };
|
||||
return new ResultData(0, '上传成功!', retData);
|
||||
} else {
|
||||
this.Msg('上传失败!');
|
||||
return new ResultData(-1, '', '');
|
||||
}
|
||||
});
|
||||
return upOk;
|
||||
} else {
|
||||
this.Msg('上传失败!');
|
||||
return new ResultData(-1, retResult.msg,retResult.data);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/***********消息操作**************/
|
||||
static Msg(message : any, icon ?: any) : void {
|
||||
if (icon != null) {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: icon
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static Alert(msg : string, cb ?: any) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: msg,
|
||||
showCancel: false,
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
cb && cb();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
static LoadIng(text : any) : void {
|
||||
uni.showLoading({
|
||||
title: text,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
|
||||
static LoadClose() : void {
|
||||
uni.hideLoading();
|
||||
}
|
||||
|
||||
/**********跳转操作*********/
|
||||
|
||||
|
||||
static GoPageTab(path : string) : void {
|
||||
uni.switchTab({
|
||||
url: path
|
||||
});
|
||||
}
|
||||
|
||||
/**********跳转操作*********/
|
||||
static GoPage(path : string) : void {
|
||||
uni.navigateTo({
|
||||
url: path, //跳转的页面
|
||||
success: function (res) {
|
||||
// 通过eventChannel向被打开页面传送数据
|
||||
}
|
||||
});
|
||||
}
|
||||
/**********跳转并删除当前页面操作*********/
|
||||
static GoPageDelse(path : string) : void {
|
||||
uni.redirectTo({
|
||||
url: path //跳转的页面
|
||||
});
|
||||
}
|
||||
|
||||
/**********返回上一页*********/
|
||||
static GoPageBack() : void {
|
||||
uni.navigateBack({ delta: 1 });
|
||||
}
|
||||
|
||||
/*****获取图片base64*****/
|
||||
static UpLoadMediaBase64(path : string) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
uni.uploadFile({
|
||||
url: 'http://cloud.pccsh.com/DefUp/UploadFileImgBase64', //仅为示例,非真实的接口地址
|
||||
filePath: path,
|
||||
name: 'file',
|
||||
success: (uploadFileRes) => {
|
||||
resolve(uploadFileRes);
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/*****获取图片位置信息*****/
|
||||
//获取时间戳
|
||||
static GetTimeSpan(milliSecond : number) {
|
||||
return Date.now() + milliSecond;
|
||||
}
|
||||
|
||||
// 时间戳处理
|
||||
static formatDate(time : any, type : number) : string {
|
||||
const date = new Date(time);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,所以加1,并用0填充
|
||||
const day = String(date.getDate()).padStart(2, '0'); // 用0填充
|
||||
const hours = String(date.getHours()).padStart(2, '0'); // 用0填充
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0'); // 用0填充
|
||||
const seconds = String(date.getSeconds()).padStart(2, '0'); // 用0填充
|
||||
if (type == 0) {
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||
}
|
||||
else if (type == 1) {
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}`;
|
||||
} else if (type == 2) {
|
||||
return `${year}-${month}-${day}`;
|
||||
} else if (type == 3) {
|
||||
return `${hours}:${minutes}`;
|
||||
} else if (type == 4) {
|
||||
return `${year}${month}${day}`;
|
||||
}
|
||||
|
||||
else {
|
||||
return `${hours}:${minutes}`;
|
||||
}
|
||||
}
|
||||
|
||||
/*****节流*****/
|
||||
static throttle(fn: () => void, time: number) {
|
||||
let canRun: boolean = true;
|
||||
return function () {
|
||||
if (!canRun) return;
|
||||
canRun = false;
|
||||
setTimeout(() => {
|
||||
fn(); //可以不执行
|
||||
canRun = true;
|
||||
}, time);
|
||||
};
|
||||
}
|
||||
/*****防抖*****/
|
||||
static debounce<T extends (...args: any[]) => void>(fn: T, time: number): (...args: Parameters<T>) => void {
|
||||
let timerId: NodeJS.Timeout | null = null;
|
||||
|
||||
return (...args: Parameters<T>) => {
|
||||
if (timerId) {
|
||||
clearTimeout(timerId);
|
||||
}
|
||||
|
||||
timerId = setTimeout(() => {
|
||||
fn(...args); // 执行传入的函数
|
||||
timerId = null; // 清除定时器ID
|
||||
}, time);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 普通图片上传
|
||||
static uploadH5(path, dic, callback) {
|
||||
console.log(this.payuploadUrl,'xxx')
|
||||
uni.uploadFile({
|
||||
url: this.payuploadUrl+'/Upload/Upload',
|
||||
method: "POST",
|
||||
header: {
|
||||
'Authorization': 'Bearer ' + Service.GetUserToken(),
|
||||
},
|
||||
formData: {
|
||||
"path": dic,
|
||||
},
|
||||
filePath: path,
|
||||
name: 'file',
|
||||
success: (data) => {
|
||||
let info = data.data
|
||||
callback(info)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建并显示一条本地推送通知 (手机顶部栏消息)
|
||||
*
|
||||
* @param {string} title - 通知的标题
|
||||
* @param {string} content - 通知的主要内容
|
||||
* @param {Record<string, any>} [payload] - (可选) 附带的业务数据。用户点击通知时,可以在 App 启动时获取到。
|
||||
*/
|
||||
|
||||
|
||||
public static createLocalPush(
|
||||
title: string,
|
||||
content: string,
|
||||
payload?: string,
|
||||
): void {
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
console.log('准备创建本地推送:', { title, content, payload });
|
||||
|
||||
// 消息的配置对象
|
||||
const options = {
|
||||
cover: false, // 是否覆盖上一次的通知。设为 false 则不覆盖,多条通知会并列显示。
|
||||
title: title,
|
||||
vibrate:['100', '200', '300']
|
||||
};
|
||||
|
||||
// 调用 plus.push.createMessage API
|
||||
plus.push.createMessage(content, payload, options);
|
||||
|
||||
// #endif
|
||||
|
||||
// #ifndef APP-PLUS
|
||||
console.warn('本地推送功能仅在 App 端支持。');
|
||||
// #endif
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user