| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663 |
- <template>
- <view class="content">
- <view class="navbar">
- <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">
- {{ item.text }}
- <view class="dian" v-if="tabCurrentIndex != index && item.content != 0">{{ item.content }}</view>
- </view>
- </view>
- <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
- <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
- <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
- <!-- 空白页 -->
- <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
- <!-- 订单列表 -->
- <view class="order-item" v-for="(item, index) in tabItem.orderList">
- <view class="order-top flex">
- <view class="order-top-left">
- <image class="order-top-left-image" src="../../static/img/order5.png" mode=""></image>
- <view class="order-top-left-font">订单信息</view>
- </view>
- <view class="order-top-right">{{ item.after_sales == 1 ? '申请售后' : item.after_sales == 2 ? '售后成功' : tabItem.text }}</view>
- </view>
- <view class="order-info flex">
- <view class="order-info-left">委托时间:</view>
- <view class="order-info-right">{{ item.time }}</view>
- </view>
- <view class="order-info flex">
- <view class="order-info-left">订单类型:</view>
- <view class="order-info-right">{{ item.type == 2 ? '代办' : '陪诊' }}</view>
- </view>
- <view class="order-info flex">
- <view class="order-info-left">医院:</view>
- <view class="order-info-right">{{ item.hospital }}</view>
- </view>
- <view class="order-info flex">
- <view class="order-info-left">预约人:</view>
- <view class="order-info-right">{{ item.name }}</view>
- </view>
- <view class="order-info flex" v-if="item.type == 2">
- <view class="order-info-left">代办类型:</view>
- <view class="order-info-right">{{ item.catename }}</view>
- </view>
- <view class="order-info flex" v-if="item.type == 1">
- <view class="order-info-left">陪诊类型:</view>
- <view class="order-info-right">{{ item.catename }}</view>
- </view>
- <view class="order-info flex" v-if="item.type == 1">
- <view class="order-info-left">陪诊服务:</view>
- <view class="order-info-right">{{ item.servicename }}</view>
- </view>
- <view class="order-info flex" v-if="item.issm == 2">
- <view class="order-info-left">接送地址:</view>
- <view class="order-info-right">{{ item.transfer_address }}</view>
- </view>
- <view class="order-info flex">
- <view class="order-info-left">备注:</view>
- <view class="order-info-right">{{ item.remarks || '无' }}</view>
- </view>
- <view class="order-btn-box" v-if="tabCurrentIndex == 0">
- <view class="order-btn" @click="qxorder(item)">
- <image class="order-btn-icon" src="../../static/img/order3.png" mode=""></image>
- <view class="order-btn-font">取消订单</view>
- </view>
- </view>
- <view class="ordering" v-if="tabCurrentIndex == 1">
- <view class="order-info flex">
- <view class="order-info-left">接单人:</view>
- <view class="order-info-right">{{ item.receiving.name }}</view>
- </view>
- <view class="order-info flex">
- <view class="order-info-left">接单人电话:</view>
- <view class="order-info-right">{{ item.receiving.phone }}</view>
- </view>
- <view class="ordering-btn flex" @click="call(item)">
- <image class="ordering-btn-icon" src="../../static/img/order4.png" mode=""></image>
- <view class="ordering-btn-font">立即联系</view>
- </view>
- </view>
- <view class="ordering" v-if="tabCurrentIndex == 2">
- <view class="order-info flex">
- <view class="order-info-left">接单人:</view>
- <view class="order-info-right">{{ item.receiving.name }}</view>
- </view>
- <view class="order-info flex">
- <view class="order-info-left">接单人电话:</view>
- <view class="order-info-right">{{ item.receiving.phone }}</view>
- </view>
- <view class="order-info flex">
- <view class="order-info-left">照片:</view>
- <view class="order-info-picture">
- <view class="order-info-picture-item" v-for="(itm, inx) in item.images"><image :src="itm" mode=""></image></view>
- </view>
- </view>
- <view class="ordering-btnbox">
- <view class="ordering-btnbox-left" @click="navTo('/pages/order/evaluate?unique=' + item.id)">
- <image class="ordering-btnbox-left-icon" src="../../static/img/order1.png" mode=""></image>
- <view class="ordering-btnbox-left-font">{{ item.after_sales == 1 ? '查看售后' : '申请售后' }}</view>
- </view>
- <view class="ordering-btnbox-right" @click="accomplish(item)"><view class="ordering-btnbox-right-font">确认完成</view></view>
- </view>
- </view>
- <view class="ordering" v-if="tabCurrentIndex == 3">
- <view class="order-info flex">
- <view class="order-info-left">接单人:</view>
- <view class="order-info-right">{{ item.receiving.name }}</view>
- </view>
- <view class="order-info flex">
- <view class="order-info-left">接单人电话:</view>
- <view class="order-info-right">{{ item.receiving.phone }}</view>
- </view>
- <view class="order-info flex">
- <view class="order-info-left">照片:</view>
- <view class="order-info-picture">
- <view class="order-info-picture-item" v-for="(itm, inx) in item.images"><image :src="itm" mode=""></image></view>
- </view>
- </view>
- <view class="order-btn-box">
- <view class="order-btn" @click="navTo('/pages/order/evaluate?unique=' + item.id)">
- <image class="order-btn-icon" src="../../static/img/order1.png" mode=""></image>
- <view class="order-btn-font">{{ item.after_sales == 1 ? '查看售后' : '申请售后' }}</view>
- </view>
- </view>
- </view>
- </view>
- <uni-load-more :status="tabItem.loadingType"></uni-load-more>
- </scroll-view>
- </swiper-item>
- </swiper>
- </view>
- </template>
- <script>
- import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
- import { mapState, mapMutations } from 'vuex';
- import empty from '@/components/empty';
- import { orderList, orderCancel, orderDel, orderTake, confirmation } from '@/api/order.js';
- import { getTime } from '@/utils/rocessor.js';
- import { saveUrl, interceptor } from '@/utils/loginUtils.js';
- export default {
- components: {
- uniLoadMore,
- empty
- },
- computed: {
- ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
- },
- data() {
- return {
- tabCurrentIndex: 0,
- navList: [
- {
- state: 0,
- text: '待接单',
- loadingType: 'more',
- content: 0,
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: 1,
- text: '进行中',
- loadingType: 'more',
- content: 0,
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: 2,
- text: '待确认',
- loadingType: 'more',
- content: 0,
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: 3,
- text: '已完成',
- loadingType: 'more',
- content: 0,
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- }
- ]
- };
- },
- onShow() {
- this.navList = [
- {
- state: 0,
- text: '待接单',
- loadingType: 'more',
- content: 0,
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: 1,
- text: '进行中',
- loadingType: 'more',
- content: 0,
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: 2,
- text: '待确认',
- loadingType: 'more',
- content: 0,
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: 3,
- text: '已完成',
- loadingType: 'more',
- content: 0,
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- }
- ];
- this.tabCurrentIndex = 0;
- if (!this.hasLogin) {
- // 保存地址
- saveUrl();
- // 登录拦截
- interceptor();
- } else {
- this.loadData();
- this.shul();
- }
- },
- onLoad(options) {},
- // #ifdef APP-PLUS || H5
- onBackPress(e) {
- uni.switchTab({
- url: '/pages/user/my'
- });
- return true;
- },
- // #endif
- filters: {
- moneyNum(value) {
- return +value;
- }
- },
- methods: {
- call(item) {
- console.log(item.receiving.phone);
- uni.makePhoneCall({
- phoneNumber: item.receiving.phone //仅为示例
- });
- },
- shul() {
- orderList({
- status: 0
- }).then(({ data }) => {
- this.navList[0].content = data.count;
- });
- orderList({
- status: 1
- }).then(({ data }) => {
- this.navList[1].content = data.count;
- });
- orderList({
- status: 2
- }).then(({ data }) => {
- this.navList[2].content = data.count;
- });
- },
- // 完成
- accomplish(opt) {
- const obj = this;
- uni.showModal({
- title: '提示',
- content: '是否确认订单成功',
- success: function(res) {
- if (res.confirm) {
- confirmation({}, opt.id).then(e => {
- uni.showToast({
- title: '确认订单成功',
- icon: 'success',
- duration: 2000
- });
- obj.loadData('shua');
- });
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- });
- },
- // 转换金额为数字
- moneyNum(value) {
- return +value;
- },
- navTo(url) {
- uni.navigateTo({
- url
- });
- },
- // 取消订单
- qxorder(opt) {
- const obj = this;
- uni.showModal({
- title: '提示',
- content: '是否取消订单',
- success: function(res) {
- if (res.confirm) {
- orderCancel({}, opt.id).then(e => {
- uni.showToast({
- title: '取消订单成功',
- icon: 'success',
- duration: 2000
- });
- obj.loadData('shua');
- });
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- });
- },
- //获取订单列表
- loadData(source) {
- //这里是将订单挂载到tab列表下
- let index = this.tabCurrentIndex;
- let navItem = this.navList[index];
- let state = navItem.state;
- if (source === 'shua') {
- navItem.loaded = false;
- navItem.page = 1;
- navItem.limit = 10;
- navItem.loadingType = 'more';
- navItem.orderList = [];
- }
- if (source === 'tabChange' && navItem.loaded === true) {
- //tab切换只有第一次需要加载数据
- return;
- }
- if (navItem.loadingType === 'loading') {
- //防止重复加载
- return;
- }
- if (navItem.loadingType === 'noMore') {
- //防止重复加载
- return;
- }
- // 修改当前对象状态为加载中
- navItem.loadingType = 'loading';
- orderList({
- status: state,
- page: navItem.page,
- limit: navItem.limit
- })
- .then(({ data }) => {
- data.data.forEach(e => {
- if (e.remarks == undefined || e.remarks == 'undefined') {
- e.remarks = '无';
- }
- let key = Object.keys(e.cate);
- let name = '';
- key.forEach(e => {
- if (name == '') {
- name = name + e;
- } else {
- name = name + '/' + e;
- }
- });
- e.catename = name;
- let key1 = Object.keys(e.service);
- let name1 = '';
- e.issm = 1;
- key1.forEach(es => {
- console.log(e);
- if (es == '上门接送') {
- e.issm = 2;
- }
- if (name1 == '') {
- name1 = name1 + es;
- } else {
- name1 = name1 + '/' + es;
- }
- });
- e.servicename = name1;
- e.time = getTime(e.time);
- });
- navItem.orderList = navItem.orderList.concat(data.data);
- navItem.page++;
- if (navItem.limit == data.data.length) {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- navItem.loadingType = 'more';
- return;
- } else {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- navItem.loadingType = 'noMore';
- }
- uni.hideLoading();
- this.$set(navItem, 'loaded', true);
- })
- .catch(e => {
- console.log(e);
- });
- },
- //swiper 切换
- changeTab(e) {
- this.tabCurrentIndex = e.target.current;
- this.loadData('tabChange');
- },
- //顶部tab点击
- tabClick(index) {
- this.tabCurrentIndex = index;
- }
- }
- };
- </script>
- <style lang="scss">
- page,
- .content {
- background: $page-color-base;
- height: 100%;
- }
- .swiper-box {
- height: calc(100% - 40px);
- }
- .list-scroll-content {
- height: 100%;
- }
- .navbar {
- display: flex;
- height: 40px;
- padding: 0 5px;
- background: #fff;
- box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
- position: relative;
- z-index: 10;
- .nav-item {
- position: relative;
- flex: 1;
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100%;
- font-size: 15px;
- color: $font-color-dark;
- position: relative;
- .dian {
- position: absolute;
- top: 20rpx;
- right: 18rpx;
- width: 30rpx;
- height: 30rpx;
- border-radius: 50%;
- background-color: red;
- color: #ffffff;
- font-size: 24rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- &.current {
- color: $base-color;
- &:after {
- content: '';
- position: absolute;
- left: 50%;
- bottom: 0;
- transform: translateX(-50%);
- width: 44px;
- height: 0;
- border-bottom: 2px solid $base-color;
- }
- }
- }
- }
- .uni-swiper-item {
- height: auto;
- }
- .order-item {
- width: 702rpx;
- background: #ffffff;
- box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
- border-radius: 20rpx;
- margin: 20rpx auto 0;
- padding: 24rpx;
- .order-top-left {
- display: flex;
- align-items: center;
- .order-top-left-image {
- width: 32rpx;
- height: 37rpx;
- }
- .order-top-left-font {
- margin-left: 10rpx;
- font-size: 30rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #333333;
- }
- }
- .order-top-right {
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #ff6f0f;
- }
- .order-info {
- margin-top: 24rpx;
- align-items: flex-start;
- .order-info-left {
- width: 200rpx;
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #666666;
- }
- .order-info-right {
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #333333;
- }
- .order-info-picture {
- display: flex;
- justify-content: flex-end;
- .order-info-picture-item {
- width: 130rpx;
- height: 130rpx;
- margin-left: 10rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- }
- }
- .order-btn-box {
- display: flex;
- justify-content: flex-end;
- .order-btn {
- margin-top: 34rpx;
- align-items: center;
- display: flex;
- justify-content: center;
- width: 181rpx;
- height: 63rpx;
- border: 1rpx solid #c9c9c9;
- border-radius: 15rpx;
- .order-btn-icon {
- width: 38rpx;
- height: 38rpx;
- }
- .order-btn-font {
- margin-left: 7rpx;
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #666666;
- }
- }
- }
- .ordering {
- margin-top: 30rpx;
- padding: 30rpx 0 10rpx;
- border-top: 1px solid #eaeced;
- .ordering-btn {
- display: flex;
- justify-content: center;
- margin: 38rpx auto 0;
- width: 566rpx;
- height: 74rpx;
- background: #24a17d;
- border-radius: 15rpx;
- .ordering-btn-icon {
- width: 32rpx;
- height: 34rpx;
- }
- .ordering-btn-font {
- margin-left: 14rpx;
- font-size: 30rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #ffffff;
- }
- }
- .ordering-btnbox {
- margin-top: 40rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .ordering-btnbox-left {
- display: flex;
- flex-direction: column;
- align-items: center;
- line-height: 1;
- .ordering-btnbox-left-icon {
- width: 42rpx;
- height: 42rpx;
- }
- .ordering-btnbox-left-font {
- margin-top: 10rpx;
- font-size: 20rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #666666;
- }
- }
- .ordering-btnbox-right {
- display: flex;
- justify-content: center;
- align-items: center;
- width: 556rpx;
- height: 74rpx;
- background: #24a17d;
- border-radius: 15rpx;
- .ordering-btnbox-right-font {
- font-size: 30rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #ffffff;
- }
- }
- }
- }
- }
- /* load-more */
- .uni-load-more {
- display: flex;
- flex-direction: row;
- height: 80rpx;
- align-items: center;
- justify-content: center;
- }
- @-webkit-keyframes load {
- 0% {
- opacity: 1;
- }
- 100% {
- opacity: 0.2;
- }
- }
- </style>
|