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

624 lines
14 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<view class="page">
<view class="zcon">
<view class="ztip">
今日提成
</view>
<view class="ztxt">
{{commission}}
</view>
</view>
<view class="lcon">
<scroll-view class="scrolllist" scroll-with-animation>
<view class="tabicl" v-for="(item, index) in list" :key="index" :class="index==tabCurrentIndex?'cur':''" @tap="tabSelect" :data-id="index">
<view class="ptext">{{item.name}}</view>
<view class="pline"></view>
</view>
<view class="bcon">
<view class="bcell">
<view class="btip">订单笔数</view>
<view class="btxt">{{list[tabCurrentIndex].orderCount}}</view>
</view>
<view class="bcell">
<view class="btip">预计提成</view>
<view class="btxt"><text style="font-size: 26rpx;">¥</text>{{list[tabCurrentIndex].commission}}</view>
</view>
</view>
<view class="hcon">
<view class="hcell">客户名称</view>
<view class="hcell">课程名称</view>
<view class="hcell">成交金额</view>
<view class="hcell">类型</view>
<view class="hcell">购买数量</view>
</view>
</scroll-view>
<!-- 列表 -->
<swiper class="swiper-box" :duration="300" :current="tabCurrentIndex" @animationfinish="animationfinish">
<swiper-item class="swiper-item" v-for="tabItem in list" :key="tabItem.id">
<scroll-view scroll-y style="height: 100%;width: 100%;">
<view class="scell" v-if="tabItem.slist.length>0">
<view v-for="(item, index) in tabItem.slist" :key="index" class="oitem">
<view class="ocell">
{{item.studentName}}
</view>
<view class="ocell">
{{item.courseName}}
</view>
<view class="ocell">
{{item.receiptFee}}
</view>
<view class="ocell">
{{item.detailTag='1'?'新报':(item.detailTag='2'?'续报':'其他')}}
</view>
<view class="ocell">
{{item.buyCount}}
</view>
</view>
</view>
<uni-load-more v-if="tabItem.slist.length<1" iconType="circle" :status="tabItem.loadStatus" />
</scroll-view>
</swiper-item>
</swiper>
</view>
<!-- 是否登录 -->
<openlogin ref="loginId" @getPhoneNumber="getPhoneNumber"></openlogin>
</view>
</template>
<script>
import { myCache,getRemoteFile } from '../../utils/utils.js';
import openlogin from "../components/openlogin.vue";
export default {
components: {
openlogin
},
data() {
return {
openId:"",
phone:"",
userid:"",
orderCount: 0,
commission: 0,
tabCurrentIndex: 0,
scrollLeft: 0,//tabs
// 1今日2昨日3本月 4上月
list:[
{
id:1,
order_state:1,
value:"today",
orderCount: 0,
commission: 0,
loadStatus:'more', // 'noMore',
name:'今日',
slist:[
{
id:1,
name1:"金晓明",
name2:"精品小班课",
name3:"周卡",
name4:"990",
},
{
id:2,
name1:"金晓明",
name2:"精品小班课",
name3:"月卡",
name4:"1580",
},
{
id:3,
name1:"金晓明",
name2:"精品小班课",
name3:"年卡",
name4:"3390",
},
{
id:1,
name1:"金晓明",
name2:"精品小班课",
name3:"周卡",
name4:"990",
},
{
id:2,
name1:"金晓明",
name2:"精品小班课",
name3:"月卡",
name4:"1580",
},
{
id:3,
name1:"金晓明",
name2:"精品小班课",
name3:"年卡",
name4:"3390",
},
{
id:1,
name1:"金晓明",
name2:"精品小班课",
name3:"周卡",
name4:"990",
},
{
id:2,
name1:"金晓明",
name2:"精品小班课",
name3:"月卡",
name4:"1580",
},
{
id:3,
name1:"金晓明",
name2:"精品小班课",
name3:"年卡",
name4:"3390",
},
{
id:1,
name1:"金晓明",
name2:"精品小班课",
name3:"周卡",
name4:"990",
},
{
id:2,
name1:"金晓明",
name2:"精品小班课",
name3:"月卡",
name4:"1580",
},
{
id:3,
name1:"金晓明",
name2:"精品小班课",
name3:"年卡",
name4:"3390",
},
],
},
{
id:2,
order_state:2,
value:"yesterday",
orderCount: 0,
commission: 0,
loadStatus:'more', // 'noMore',
name:'昨日',
slist:[
{
id:1,
name1:"金晓明",
name2:"精品小班课",
name3:"周卡",
name4:"990",
},
{
id:2,
name1:"金晓明",
name2:"精品小班课",
name3:"月卡",
name4:"1580",
},
{
id:3,
name1:"金晓明",
name2:"精品小班课",
name3:"年卡",
name4:"3390",
},
],
},
{
id:3,
order_state:3,
value:"thisMonth",
orderCount: 0,
commission: 0,
loadStatus:'more', // 'more',
name:'本月',
slist:[
{
id:1,
name1:"金晓明",
name2:"精品小班课",
name3:"周卡",
name4:"990",
},
{
id:2,
name1:"金晓明",
name2:"精品小班课",
name3:"月卡",
name4:"1580",
},
{
id:3,
name1:"金晓明",
name2:"精品小班课",
name3:"年卡",
name4:"3390",
},
],
},
{
id:4,
order_state:4,
value:"lastMonth",
orderCount: 0,
commission: 0,
loadStatus:'more', // 'more',
name:'上月',
slist:[
{
id:1,
name1:"金晓明",
name2:"精品小班课",
name3:"周卡",
name4:"990",
},
{
id:2,
name1:"金晓明",
name2:"精品小班课",
name3:"月卡",
name4:"1580",
},
{
id:3,
name1:"金晓明",
name2:"精品小班课",
name3:"年卡",
name4:"3390",
},
],
},
],
};
},
onLoad(option) {
if(option.id||option.id==0){
if(parseInt(option.id)==0){
this.tabCurrentIndex=0;
}
else{
this.tabCurrentIndex=parseInt(option.id);
}
this.scrollLeft = (this.tabCurrentIndex - 1) * 60;
}
// 获取当前日期
// this.list[0].value=this.getDay(0);
// this.list[1].value=this.getDay(-1)
// this.list[2].value=this.getMonthDay(0)
// this.list[3].value=this.getMonthDay(-1)
// console.log(this.list[0].value,this.list[1].value,this.list[2].value,this.list[3].value);
// this.$forceUpdate();
},
onShow(option){
this.reset();
},
onReady(){
this.openId = myCache('openId');
var user = myCache('user');
this.userid = user.userid? user.userid:'';
this.phone = user.userphone;
if(this.userid==""||this.userid=="0"){
uni.navigateTo({
url: `/pages/login/login`
});
}
},
onPullDownRefresh() {
setTimeout(()=>{
uni.stopPullDownRefresh()
},100);
},
methods: {
getDay(day){
var today = new Date();
var targetday_milliseconds=today.getTime() + 1000*60*60*24*day;
today.setTime(targetday_milliseconds); //注意,这行是关键代码
var tYear = today.getFullYear();
var tMonth = today.getMonth();
tMonth = this.doHandleMonth(tMonth + 1);
var tDate = today.getDate();
tDate = this.doHandleMonth(tDate);
return tYear+"-"+tMonth+"-"+tDate;
},
getMonthDay(month){
var today = new Date();
today.setMonth(today.getMonth() + month);
var tYear = today.getFullYear();
var tMonth = today.getMonth();
tMonth = this.doHandleMonth(tMonth + 1);
var tDate = today.getDate();
tDate = this.doHandleMonth(tDate);
return tYear+"-"+tMonth;
},
doHandleMonth(month) {
var m = month;
if (month.toString().length == 1) {
m = "0" + month;
}
return m;
},
getPhoneNumber(e){
if(e.phone){
this.phone = e.phone
}
if(e.userid){
this.userid = e.userid
}
},
async getOrderList() {
if(this.list[this.tabCurrentIndex].loadStatus!=="noMore")
{
uni.showLoading({
title: '数据加载中...'
});
var para={
time: this.list[this.tabCurrentIndex].value
// time: "thisMonth"
}
const {data: res} = await uni.$http.post('/api/my/commissionTotal', para);
if(res&&res.data){
var data=res.data;
this.list[this.tabCurrentIndex].loadStatus="noMore";
this.list[this.tabCurrentIndex].slist=data.orderList;
this.list[this.tabCurrentIndex].commission=data.commission?data.commission:0;
this.list[this.tabCurrentIndex].orderCount=data.orderCount?data.orderCount:0;
if(this.tabCurrentIndex==0){
this.commission=data.commission?data.commission:0;
}
this.$forceUpdate();
}
else{
this.list[this.tabCurrentIndex].loadStatus="noMore";
this.list[this.tabCurrentIndex].slist=[];
this.list[this.tabCurrentIndex].commission=0;
this.list[this.tabCurrentIndex].orderCount=0;
this.$forceUpdate();
uni.showModal({
title: '提示',
content: res.message? res.message : '当前信息不存在..',
cancelText: '取消',
confirmText: '确定',
success: ress => {
// 返回
uni.navigateBack({
delta: 1
});
}
});
}
}
},
loadData(){
console.log('loadData');
// 加载
if(this.list[this.tabCurrentIndex].loadStatus=="more") {
this.list[this.tabCurrentIndex].loadStatus="loading";
setTimeout(() => {
this.getOrderList();
}, 300);
}
},
tabSelect(e) {
console.log(e)
this.tabCurrentIndex = e.currentTarget.dataset.id;
this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60;
// 重新加载 暂不需要加载
// this.list[this.tabCurrentIndex].loadStatus="more";
// this.list[this.tabCurrentIndex].slist=[];
this.loadData();
},
animationfinish({ detail: { current } }) {
this.tabCurrentIndex = current;
this.loadData();
},
gotoInfo(id){
// 订单详情
uni.navigateTo({
url: `/pages/book/bookinfo?id=${id}`
});
},
// 联系教练
gototeacher(item){
var data={
id:item.id,
name:"教练A"
}
// 联系教练
var data=encodeURIComponent(JSON.stringify(data));
uni.navigateTo({
url: `/pages/teacher/chat?data=${data}`
})
},
iflogin(){
this.openId = myCache('openId');
var user = myCache('user');
this.userid = user.userid? user.userid:'';
this.phone = user.userphone;
if(this.userid==""||this.userid=="0"||this.phone==""){
uni.navigateTo({
url: `/pages/login/login`
});
return false;
}
else{
return true;
}
},
reset(){
// 重新加载数据
this.list.forEach((cell,idx)=>{
this.list[idx].loadStatus='more';
this.list[idx].slist=[];
});
this.$forceUpdate();
this.loadData();
}
}
}
</script>
<style lang="less" scoped>
.page {
padding: 0;
position: relative;
background-image: url('@/static/image/bg.jpg');
background-attachment: fixed;
background-size: cover;
background-position: center center;
min-height: calc(100vh - var(--window-top) - var(--window-bottom));
}
.zcon{
padding: 0;
position: relative;
background: #6f8c6e;
padding: 30rpx;
margin: 30rpx;
height: 160rpx;
display: flex;
flex-direction: column;
border-radius: 20rpx;
.ztip{
font-size: 26rpx;
color: #fff;
margin-bottom: 5rpx;
}
.ztxt{
font-size: 40rpx;
color: #fff;
font-weight: 600;
}
}
.scrolllist{
height: 280rpx;
background: #fff;
white-space: nowrap;
width: 100%;
}
.bcon{
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
width: 100%;
.bcell{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 50%;
.btip{
color: #888;
font-size: 26rpx;
}
.btxt{
font-size: 40rpx;
font-weight: 600;
color:#000;
}
}
}
.tabicl{
width: 140rpx;
height: 80rpx;
line-height: 80rpx;
position: relative;
display: inline-block;
overflow: hidden;
margin-right: 20rpx;
}
.ptext{
font-size: 30rpx;
text-align: center;
color: #000;
font-weight: 600;
height: 75rpx;
}
.cur .ptext{
color: #89965f;
font-size: 33rpx;
font-weight: 600;
}
.cur .pline{
width: 40%;
height: 9rpx;
background: #89965f;
border-radius: 6rpx;
opacity: 1;
margin-left: 30%;
}
.hcon{
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
width: 100%;
padding-bottom: 10rpx;
margin-top: 10rpx;
border-top: 1rpx solid #e5e5e5;
border-bottom: 1rpx solid #e5e5e5;
}
.hcell{
width: 20%;
font-size: 26rpx;
font-weight: 600;
color: #000;
padding: 10rpx;
text-align: center;
}
.swiper-box {
flex: 1;
height: calc(100vh - var(--window-top) - 600rpx) !important;
}
.swiper-item {
height: 100%;
}
.lcon{
background: #fff;
padding: 30rpx;
margin: 30rpx;
border-radius: 20rpx;
}
.scell{
width: 100%;
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
.oitem{
display: flex;
flex-direction: row;
background-color: #FFFFFF;
width: 100%;
border-bottom: 1rpx solid #e5e5e5;
align-items: center;
justify-content: center;
.ocell{
width: 20%;
font-size: 26rpx;
color: #333;
padding: 10rpx 10rpx 15rpx;
text-align: center;
}
}
}
</style>