mrr.sj.front/pages/syr/home.vue

991 lines
23 KiB
Vue
Raw Normal View History

2026-03-24 11:45:13 +08:00
<template>
<view class="syrAdmin">
<view v-show="currentIndex == 0" class="artisan-page">
<view class="bg">
<!-- 顶部导航栏 -->
<custom-navbar title="共享手艺人" :show-back="true" title-color="#000000"
backgroundColor="transparent"></custom-navbar>
<!-- 头像信息区 -->
<view class="profile-section">
<view class="profile-info">
<image class="avatar" v-if="userInfo.head_photo" :src="userInfo.head_photo" mode="aspectFill">
</image>
<view class="info-content">
<view class="name">{{ userInfo.name }}</view>
<view class="welcome">欢迎使用美融融手艺人</view>
</view>
</view>
<view class="center-btn" @click="goRoleMy">
<view class="center-text"> 个人中心</view>
<image class="center_icon" src="@/static/images/icons/right_gray.png" />
</view>
</view>
</view>
<view class="switch-section">
<view class="center-btn">
<text class="switch-tip" @click="goMoreSetting">更多接单设置</text>
<image class="center_icon" src="@/static/images/icons/right_gray2.png" />
</view>
<view class="switch-box" @click="handleSwitchChange()"
:class="{ disswitch: userInfo.order_taking == 2 }">
<text class="switch-text" v-if="userInfo.order_taking == 1">接单</text>
<view class="switch-yuan"></view>
<text class="switch-text" v-if="userInfo.order_taking == 2">不接单</text>
</view>
</view>
<!-- 订单类型 -->
<view class="order-class" :style="{paddingBottom:count != 0?`40rpx`:`40rpx`}">
<view class="order-types">
<view class="order-type-item" @click="searchTypeOrder(0)" :class="{ active: typeId == 0 }">
<text class="type-name">用户订单</text>
<view class="active-line" :style="{ visibility: typeId == 0 ? 'visible' : 'hidden' }"></view>
</view>
<view class="order-type-item" @click="searchTypeOrder(3)" :class="{ active: typeId == 3 }">
<text class="type-name">自营订单</text>
<view class="active-line" :style="{ visibility: typeId == 3 ? 'visible' : 'hidden' }"></view>
</view>
<view class="order-type-item" @click="searchTypeOrder(1)" :class="{ active: typeId == 1 }">
<text class="type-name">商家订单</text>
<view class="active-line" :style="{ visibility: typeId == 1 ? 'visible' : 'hidden' }"></view>
</view>
<view class="order-type-item" @click="searchTypeOrder(2)" :class="{ active: typeId == 2 }">
<text class="type-name">工时订单</text>
<view class="active-line" :style="{ visibility: typeId == 2 ? 'visible' : 'hidden' }"></view>
</view>
</view>
<scroll-view class="order-state" scroll-x="true" scroll-with-animation>
<view class="order-state-item" @click="handleOrderState(2)" :class="{ active: stateOrder == 2 }">
<text class="state-name">待接单: {{ ordernum.djd }}</text>
</view>
<view class="order-state-item" @click="handleOrderState(3, 0)" :class="{ active: stateOrder == 3 }">
<text class="state-name">待开始:{{ ordernum.dfw }}</text>
</view>
<view class="order-state-item" @click="handleOrderState(4)" :class="{ active: stateOrder == 4 }">
<text class="state-name">待完成:{{ ordernum.dwc }}</text>
</view>
</scroll-view>
</view>
<!-- 订单列表 -->
<view class="order-list" v-if="count != 0">
<view class="order_item" v-for="(item, i) in orderList" :key="item.id">
<OrderCard v-if="typeId != 2" :dataItem="item" :typeId="typeId" @cancel="cancelOrder($event, item)"
@accept="confirmOrder($event, item)" @start="startOrder($event, item)"
@done="endOrder($event, item)" @goOrderDetail="goOrderDetail" />
<WorkHourOrderCard v-else :showState="false" :dataItem="item" :typeId="typeId"
@cancel="cancelOrder($event, item)" @accept="confirmOrder($event, item)"
@start="startOrder($event, item)" @done="endOrder($event, item)" @goOrderDetail="goOrderDetail">
</WorkHourOrderCard>
</view>
</view>
<view class="nothings-box" v-else>
<text class="nothings-text">暂无数据...</text>
</view>
<serviceCodeInput :show="showInput" @close="showInput = false" @confirm="onConfirm" />
</view>
<MyPage v-show="currentIndex == 1"></MyPage>
<MyTabBar @change="changeIndex" :tabList="tabList" :currentIndex="currentIndex"></MyTabBar>
</view>
</template>
<script>
import request from "../../utils/request";
import MyPage from "./my.vue";
import {
debounce
} from "../../utils/debounce";
import serviceCodeInput from "@/components/service-code-input/service-code-input.vue";
import _public from "../../utils/public";
import MyTabBar from "@/components/MyTabBar.vue";
import OrderCard from "./components/orderCard.vue";
import WorkHourOrderCard from "./manHour/components/orderCard.vue";
export default {
components: {
serviceCodeInput,
MyTabBar,
MyPage,
OrderCard,
WorkHourOrderCard,
},
data() {
return {
clickType: false, //点击状态,防止连续点击
tabList: [{
text: "首页",
selectedIcon: "/static/images/tabbar/home_icon_active.png",
icon: "/static/images/tabbar/home_icon_dis.png",
},
{
text: "我的",
selectedIcon: "/static/images/tabbar/my_icon_active.png",
icon: "/static/images/tabbar/my_icon_dis.png",
},
],
currentIndex: 0,
noClick: true, //防止重复点击状态
userInfo: {},
typeId: 0, // 0 用户订单 1 工位订单
stateOrder: 2, // 2 等待确认 3 待服务 4 待完成
days: null, // 今天0明天1后天2
ordernum: {},
orderList: [],
handelOrder: {},
showInput: false,
timeRange: "7days",
count: 0,
isLoad: true, //加载完成
page: 1,
limit: 10,
urlList: [{
ordernum: "/syr/getyhordernum",
weChatRefund: "/syr/yhwechatrefund",
aliRefund: "/syr/yhalirefund",
startOrder: "/syr/yhstartserver",
endOrder: "/syr/yhendserver",
sureOrder: "/syr/yhordersure",
list: "/syr/syrgetyhorder",
},
{
ordernum: "/syr/getsjordernum",
weChatRefund: "/syr/sjwechatrefund",
aliRefund: "/syr/sjalirefund",
startOrder: "/syr/sjstartserver",
endOrder: "/syr/sjendserver",
sureOrder: "/syr/sjordersure",
list: "/syr/syrgetsjorder",
},
{
ordernum: "/syr/workHourOrder/orderNum",
weChatRefund: "/syr/workHourOrder/weChatRefund",
aliRefund: "/syr/workHourOrder/aliRefund",
startOrder: "/syr/workHourOrder/start",
endOrder: "/syr/workHourOrder/end",
sureOrder: "/syr/workHourOrder/sure",
list: "/syr/workHourOrder/list",
},
{
ordernum: "/syr/orderSelf/orderNum",
weChatRefund: "/syr/orderSelf/weChatRefund",
aliRefund: "/syr/orderSelf/aliRefund",
startOrder: "/syr/orderSelf/start",
endOrder: "/syr/orderSelf/end",
sureOrder: "/syr/orderSelf/sure",
list: "/syr/orderSelf/list",
},
],
chartOpts: {
2026-06-02 11:39:23 +08:00
color: ["#FF4767"],
2026-03-24 11:45:13 +08:00
padding: [15, 15, 0, 15],
enableScroll: false,
legend: false,
xAxis: {
gridType: "solid",
gridColor: "#F0F0F0",
fontColor: "#999999",
rotateLabel: false,
},
yAxis: {
gridType: "dash",
splitNumber: 4,
gridColor: "#F0F0F0",
fontColor: "#999999",
format: "value",
},
extra: {
line: {
type: "straight",
width: 2,
},
},
},
};
},
async onPullDownRefresh() {
await this.getOrderNumber();
this.getOrderList();
},
async onLoad() {
// 获取状态栏高度
const systemInfo = uni.getSystemInfoSync();
const userInfo = await request.post("/user/getuser", {
type: 2
});
this.userInfo = userInfo.data;
this.getOrderNumber();
this.getOrderList();
},
async onReachBottom() {
console.log("onReachBottom");
if (this.count <= this.page * this.limit || !this.isLoad) {
return;
}
this.page++;
this.getOrderList(false);
},
methods: {
//getProfileLoding获取上个页面返回后调用提示
async getProfileLoding(title) {
setTimeout(() => {
uni.showToast({
title: "保存成功",
duration: 1000,
});
}, 300);
let {
data
} = await request.post("/user/getuser", {
type: 3,
});
//存储商家地址
uni.setStorageSync("shopdependency", data.dependency);
},
changeIndex(index) {
console.log(index);
this.currentIndex = index;
},
syrorsjordertaking() {
request
.post("/syr/syrordertaking", {
syrid: this.userInfo.id,
order_taking: this.userInfo.order_taking,
})
.then((result) => {
request.post("/user/getuser", {
type: 2
}).then((result) => {
this.userInfo.order_taking = result.data.order_taking;
});
});
},
getOrderNumber() {
const url = this.urlList[this.typeId].ordernum;
let data = {
syrid: this.userInfo.id,
syr_id: this.userInfo.id,
};
if (url) {
request.post(url, data).then((res) => {
this.ordernum = res.data;
});
}
},
getOrderList(isRefresh = true) {
this.isLoad = false;
if (isRefresh) {
this.page = 1;
this.limit = 10;
this.orderList = [];
}
let url = this.urlList[this.typeId].list;
let data = {
syrid: this.userInfo.id,
state: this.stateOrder,
};
if (this.typeId == 2) {
data = {
state: this.stateOrder,
limit: 50,
page: 1,
};
}
request
.post(url, data)
.then((res) => {
if (isRefresh) {
if (this.typeId == 2 || this.typeId == 3) {
this.orderList = res.data.list;
this.count = res.data.count;
return;
}
this.orderList = res.data;
this.count = res.count;
} else {
if (this.typeId == 2 || this.typeId == 3) {
this.orderList = [...this.orderList, ...res.data.list];
this.count = res.data.count;
return;
}
this.orderList = [...this.orderList, ...res.data];
this.count = res.count;
}
})
.finally(() => {
this.isLoad = true;
uni.stopPullDownRefresh();
});
},
handleSwitchChange(e) {
if (this.noClick) {
// 第一次点击
this.noClick = false;
this.orderSwitch = e;
if (this.userInfo.order_taking == 1) {
this.userInfo.order_taking = 2;
} else if (this.userInfo.order_taking == 2) {
this.userInfo.order_taking = 1;
}
this.syrorsjordertaking();
setTimeout(() => {
this.noClick = true;
}, 1000);
}
},
goRoleMy() {
uni.$uv.throttle(() => {
this.currentIndex = 1;
}, 500)
// uni.redirectTo({
// url: "/pages/syr/my",
// });
},
goMoreSetting() {
uni.navigateTo({
url: "/pages/artisan/unavailable-time",
});
},
// 去订单详情
goOrderDetail(item) {
let path = "";
if (this.typeId == 0) {
path = "/pages/syr/userorder-detail?id=" + item.id;
} else if (this.typeId == 1) {
path = "/pages/syr/shoporder-detail?id=" + item.id;
} else if (this.typeId == 2) {
path = `/pages/shop/SellerDetail?id=${item.id}&identity=1`;
} else if (this.typeId == 3) {
path = `/pages/syr/userorder-detail?id=${item.id}&serviceType=2`;
}
uni.navigateTo({
url: path,
});
},
// 报名入口
goToCompetition() {},
switchTimeRange(range) {
this.timeRange = range;
},
// 处理不同类型订单的点击
searchTypeOrder(type) {
this.typeId = type;
this.stateOrder = 2;
this.days = null;
this.getOrderNumber();
this.getOrderList();
},
// 处理不同订单状态的点击
handleOrderState(type, days) {
this.stateOrder = type;
// if (type == 3) {
// this.days = days;
// } else {
// this.days = null;
// }
this.getOrderList();
},
// 取消订单
cancelOrder(e, order) {
uni.showModal({
title: "取消订单",
content: "确定要取消该订单吗?(订单取消后,支付金额将原路退回)",
success: (res) => {
if (res.confirm) {
// TODO: 取消订单
let data = {
orderNo: order.number,
amount: order.pay_money,
syrid: this.userInfo.id,
};
let url = "";
if (order.pay_kind == 1) {
url = "";
} else if (order.pay_kind == 2) {
url = this.urlList[this.typeId].weChatRefund;
} else if (order.pay_kind == 3) {
url = this.urlList[this.typeId].aliRefund;
}
console.log(data, url);
if (this.clickType) {
return
}
this.clickType = true
request
.post(url, data)
.then((res) => {
console.log("取消订单返回结果", res);
if (res.state == 1 || res.code == 1 || res.code == 200) {
uni.showToast({
title: "取消成功!",
icon: "none",
});
this.getOrderNumber();
this.getOrderList();
} else {
uni.showToast({
title: res.msg,
icon: "none",
});
}
})
.catch((err) => {
console.log(err);
}).finally(() => {
this.clickType = false
});
}
},
});
},
// 确认接单
confirmOrder(e, order) {
const url = this.urlList[this.typeId].sureOrder;
if (this.clickType) {
return
}
this.clickType = true
request
.post(url, {
syrid: this.userInfo.id,
id: order.id
})
.then((res) => {
uni.showToast({
title: "已接单",
icon: "none",
});
this.getOrderNumber();
this.getOrderList();
}).finally(() => {
this.clickType = false
});
},
// 开始服务
startOrder(e, order) {
this.showInput = true;
this.handelOrder = order;
},
// 输入完成
onConfirm(code) {
this.showInput = false;
const url = this.urlList[this.typeId].startOrder;
if (this.clickType) {
return
}
this.clickType = true
request
.post(url, {
id: this.handelOrder.id,
server_code: code,
syrid: this.userInfo.id,
})
.then((res) => {
console.log(res);
if (res.state == 1 || res.code == 200) {
uni.showToast({
title: res.msg,
icon: "none",
});
this.getOrderNumber();
this.getOrderList();
} else if (res.state == 2 || res.code == 500) {
uni.showToast({
title: res.msg,
icon: "none",
});
}
this.handelOrder = {};
}).finally(() => {
this.clickType = false
});
},
// 完成服务
endOrder: debounce(function(e, order) {
const url = this.urlList[this.typeId].endOrder;
if (this.clickType) {
return
}
this.clickType = true
request
.post(url, {
id: order.id,
syrid: this.userInfo.id
})
.then((res) => {
if (res.state == 1 || res.code == 200) {
uni.showToast({
title: res.msg,
icon: "none",
});
this.getOrderNumber();
this.getOrderList();
}
}).finally(() => {
this.clickType = false
});
}, 500),
},
};
</script>
<style lang="less">
page {
background-color: #fafafa;
padding-bottom: 40rpx;
}
.artisan-page {
/* min-height: 100vh; */
position: relative;
padding-bottom: 110rpx;
}
.artisan-page::before {
content: "";
position: fixed;
top: 0;
left: 0;
right: 0;
height: 580rpx !important;
background-image: url("/static/images/bg.png");
background-size: cover;
background-position: center top;
background-repeat: no-repeat;
z-index: 1;
}
.bg {
position: relative;
}
.bg::before {
content: "";
position: fixed;
top: 0;
left: 0;
right: 0;
height: 272rpx !important;
/* #ifdef APP-PLUS || MP-WEIXIN */
height: calc(272rpx + var(--status-bar-height)) !important;
/* #endif */
background-image: url("/static/images/bg.png");
background-size: cover;
background-position: center top;
background-repeat: no-repeat;
z-index: 999;
}
.profile-section,
.switch-section,
.order-class,
.order-list,
.nothings-box {
position: relative;
z-index: 99;
}
.profile-section {
position: fixed;
top: 88rpx;
left: 0;
right: 0;
height: 184rpx;
/* background-color: transparent; */
z-index: 999;
display: flex;
flex-flow: row nowrap;
justify-content: space-between;
align-items: center;
padding: 0 24rpx;
}
.profile-info {
display: flex;
flex-flow: row nowrap;
justify-content: flex-start;
align-items: center;
}
.avatar {
width: 96rpx;
height: 96rpx;
border-radius: 50rpx;
margin-right: 24rpx;
background-color: #333333;
border: 4rpx solid #ffffff;
}
.name {
font-size: 36rpx;
font-weight: 500;
color: #000000;
}
.welcome {
margin-top: 8rpx;
font-size: 22rpx;
color: #999999;
}
.center-text {
font-weight: 500;
font-size: 28rpx;
color: #666666;
line-height: 32rpx;
text-align: right;
font-style: normal;
}
.switch-section {
margin: 184rpx 24rpx 32rpx;
height: 82rpx;
display: flex;
flex-flow: row nowrap;
justify-content: space-between;
align-items: center;
font-size: 28rpx;
border-radius: 14rpx;
padding: 0 32rpx;
box-shadow: 0 4rpx 16rpx 0 rgba(210, 213, 224, 0.5);
background-image: url('/static/images/shop/jdBj.png');
background-size: cover;
/* 确保图片覆盖整个屏幕 */
background-repeat: no-repeat;
/* 防止图片重复 */
background-position: center center;
/* 图片居中显示 */
}
.switch-box {
/* width: 126rpx; */
height: 52rpx;
line-height: 52rpx;
border-radius: 26rpx;
2026-06-02 11:39:23 +08:00
background-color: #FF4767;
2026-03-24 11:45:13 +08:00
display: flex;
flex-flow: row nowrap;
justify-content: center;
align-items: center;
padding: 0 6rpx;
}
.switch-text {
font-size: 24rpx;
padding: 0 12rpx;
color: #ffffff;
}
.switch-yuan {
width: 40rpx;
height: 40rpx;
border-radius: 20rpx;
background-color: #fff;
}
.switch-box.disswitch {
background-color: rgba(0, 0, 0, 0.1);
}
.switch-box.disswitch .switch-yuan {
margin-left: 0;
}
.switch-tip {
font-weight: 400;
font-size: 28rpx;
color: #333333;
line-height: 37rpx;
text-align: left;
font-style: normal;
}
.order-class {
width: 750rpx;
overflow: hidden;
padding-bottom: 20rpx;
margin: 36rpx 0 0;
border-radius: 28rpx 28rpx 28rpx 28rpx;
background-color: #fff;
.order-types {
margin: 0 30rpx;
height: 49px;
display: flex;
justify-content: flex-start;
border-bottom: 1px solid rgba(255, 225, 225, 0.2);
align-items: center;
flex-wrap: nowrap;
column-gap: 58rpx;
border-bottom: 3rpx solid #f6f5f5;
.order-type-item {
display: flex;
flex-flow: column nowrap;
justify-content: center;
align-items: center;
margin-top: 0;
transition: all 0.3s ease;
.type-name {
font-weight: 500;
font-size: 32rpx;
color: #666666;
white-space: nowrap;
line-height: 45rpx;
font-style: normal;
}
}
.order-type-item.active {
position: relative;
background-color: #fff;
.type-name {
color: #333333;
}
}
}
}
.active-line {
width: 70rpx;
height: 6rpx;
border-radius: 4rpx;
2026-06-02 11:39:23 +08:00
background-color: #FF4767;
2026-03-24 11:45:13 +08:00
position: absolute;
bottom: -10rpx;
z-index: 99;
}
.order-state {
width: 726rpx;
display: flex;
flex-flow: row nowrap;
justify-content: flex-start;
align-items: center;
margin-top: 24rpx;
padding: 0 24rpx;
gap: 16rpx;
/* H5 必须添加以下属性 */
/* #ifdef H5 */
white-space: nowrap;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
/* iOS平滑滚动 */
/* #endif */
}
scroll-view .uni-scroll-view-content {
display: flex !important;
flex-flow: row nowrap !important;
justify-content: flex-start !important;
align-items: center !important;
/* H5 需要添加 */
/* #ifdef H5 */
width: max-content !important;
min-width: 100% !important;
/* #endif */
}
.order-state-item {
width: 218rpx;
height: 72rpx;
background: #f2f2f2;
border-radius: 20rpx;
margin-right: 28rpx;
display: flex;
align-items: center;
justify-content: center;
/* #ifdef H5 */
display: inline-block;
vertical-align: middle;
/* #endif */
}
.state-name {
margin: 12rpx 0;
}
.state-name,
.state-count,
.state-date {
font-weight: 400;
font-size: 28rpx;
line-height: 40rpx;
text-align: left;
font-style: normal;
/* #ifdef H5 */
text-align: center;
display: block;
/* #endif */
}
.order-state-item.active {
2026-06-02 11:39:23 +08:00
background: linear-gradient(43deg, #f52540 0%, #FF4767 100%);
2026-03-24 11:45:13 +08:00
}
.order-state-item.active .state-name,
.order-state-item.active .state-count,
.order-state-item.active .state-date {
color: #fff;
font-weight: 500;
}
.order-list {
background-color: #fafafa;
border-radius: 28rpx 28rpx 0 0;
padding-top: 24rpx;
margin-top: -40rpx;
padding-bottom: 80rpx;
}
.order-item {
background-color: #ffffff;
border-radius: 16rpx;
padding: 32rpx;
margin: 0 24rpx 24rpx;
box-shadow: 0 8rpx 16rpx 0 rgba(210, 213, 224, 0.5);
}
.order-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8rpx;
}
.service-name {
font-size: 28rpx;
color: #333333;
font-weight: 500;
flex: 1;
}
.order-info {
margin-bottom: 32rpx;
display: flex;
flex-flow: column nowrap;
justify-content: center;
align-items: flex-start;
}
.address,
.service-time,
.order-number {
flex: 1;
font-size: 24rpx;
color: #666666;
}
.order-footer {
display: flex;
justify-content: space-between;
align-items: center;
}
.order-actions {
padding-top: 32rpx;
border-top: 1rpx solid rgba(0, 0, 0, 0.05);
display: flex;
flex-flow: row nowrap;
justify-content: flex-end;
align-items: center;
gap: 24rpx;
}
.action-btn {
/* width: 96rpx;
height: 40rpx; */
padding: 8rpx 12rpx;
display: flex;
justify-content: center;
align-items: center;
border-radius: 6rpx;
}
.action-btn.cancel,
.action-btn.confirm {
border: 1rpx solid rgba(51, 51, 51, 0.12);
box-sizing: border-box;
}
.action-btn.cancel .action-text,
.action-btn.confirm .action-text {
font-size: 28rpx;
color: #333333;
font-weight: 400;
}
.action-btn.verify {
border: 1rpx solid rgba(252, 67, 124, 0.12);
box-sizing: border-box;
}
.action-btn.verify .action-text {
font-size: 28rpx;
2026-06-02 11:39:23 +08:00
color: #FF4767;
2026-03-24 11:45:13 +08:00
}
.nothings-box {
display: flex;
flex-flow: row nowrap;
justify-content: center;
align-items: center;
padding: 280rpx 0 0;
}
.nothings-text {
font-size: 32rpx;
font-weight: 500;
color: #999999;
text-align: center;
font-style: italic;
}
/* APP适配 */
/* #ifdef APP-PLUS */
.nav-bar {
padding-top: 0;
}
.profile-section {
top: calc(var(--status-bar-height) + 88) rpx;
}
/* #endif */
/* 小程序适配 */
/* #ifdef MP-WEIXIN */
.nav-bar {
padding-top: constant(safe-area-inset-top);
padding-top: env(safe-area-inset-top);
}
.profile-section {
top: calc(var(--status-bar-height) + 88rpx);
}
/* #endif */
.center-btn {
display: flex;
align-items: center;
.center_icon {
width: 12rpx;
height: 24rpx;
margin-left: 16rpx;
}
}
</style>