| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538 |
- <template>
- <view class="container">
- <view class="navbar">
- <view v-for="(item, index) in navList" :key="index" class="nav-item" @click="navChoose(index)" :class="{ navC: index == navIc }">{{ item.text }}</view>
- </view>
- <!-- 订单列表 -->
- <swiper :current="navIc" class="swiper-box" duration="300" @change="changeTab" :style="{ height: maxheight }">
- <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
- <scroll-view scroll-y="true" class="scroll-y">
- <view class="order-item" @click="goToOrderDetail(i)" v-for="i in tabItem.orderList" :key="i.id">
- <view class="i-td">
- <view class="td-left">订单编号:{{ i.order_id }}</view>
- <view class="td-right">{{ i.stateTip }}</view>
- </view>
- <view class="goods-box" v-for="(item, index) in i.cartInfo">
- <view class="goods-left flex">
- <image class="goods-img" :src="item.productInfo.image || '../../static/error/errorImage.jpg'"></image>
- <view class="goods-name">
- <view class="p clamp2">{{ item.productInfo.store_name }}</view>
- <view class="span">{{ i.shipping_type == 1 ? '送货上门' : '到店自提' }}</view>
- </view>
- </view>
- <view class="goods-price">
- <view class="">¥{{ price(item.productInfo.attrInfo.price) }}</view>
- <view class="num">x{{ item.cart_num }}</view>
- <br />
- </view>
- </view>
- <view class="i-td">
- <view class="td-left"></view>
- <view class="i-bottom">
- 共计{{ i.total_num }}件商品
- <text>合计 ¥{{ i.pay_price }}</text>
- ( {{ i.pay_postage * 1 > 0 ? '含物流费用¥' + i.pay_postage * 1 : '免邮' }})
- </view>
- </view>
- <view class="btn-box" v-if="tabItem.state == 0">
- <view class="btn" @click.stop="qxzf(i)">取消支付</view>
- <view class="btn" @click.stop="ljzf(i)">立即支付</view>
- </view>
- <view class="btn-box" v-if="tabItem.state == 1">
- <view class="btn" @click.stop="sqth(i)" v-if="i.store_id != 0 && !i.is_virtual">申请退款</view>
- <view class="btn" @click.stop="sqth(i)" v-if="i.store_id == 0 && i.gift_uid == 0 && !i.is_virtual">申请退款</view>
- <view v-if="i.shipping_type == 2">
- <view class="btn" @click.stop="showCode(i)" v-if="i.gift_uid == 0 || i.gift_uid == userInfo.uid">查看券码</view>
- </view>
- </view>
- <view class="btn-box" v-if="tabItem.state == 2">
- <!-- <view v-if="i.shipping_type == 1" class="btn-look">查看物流</view> -->
- <view v-if="i.shipping_type == 1" class="btn" @click.stop="orderTake(i, index)">确认收货</view>
- <view v-if="i.shipping_type == 2">
- <view class="btn" @click.stop="showCode(i)" v-if="i.gift_uid == 0 || i.gift_uid == userInfo.uid">查看券码</view>
- </view>
- </view>
- </view>
- </scroll-view>
- </swiper-item>
- </swiper>
- </view>
- </template>
- <script>
- import { orderList, orderCancel, orderDel, orderTake } from '@/api/order.js';
- import { mapState, mapMutations } from 'vuex';
- export default {
- computed: {
- ...mapState('user', ['userInfo'])
- },
- onReady(res) {
- var _this = this;
- uni.getSystemInfo({
- success: resu => {
- const query = uni.createSelectorQuery();
- query.select('.swiper-box').boundingClientRect();
- query.exec(function(res) {
- _this.maxheight = resu.windowHeight - res[0].top + 'px';
- console.log('打印页面的剩余高度', _this.height);
- });
- },
- fail: res => {}
- });
- },
- data() {
- return {
- maxheight: '',
- navIc: 0,
- navList: [
- {
- state: 0,
- text: '待付款',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: 1,
- text: '待发货',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: 2,
- text: '待收货',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: 3,
- text: '已完成',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: -1,
- text: '退款中',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: -2,
- text: '已退款',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- }
- ]
- };
- },
- onShow() {
- this.navList = [
- {
- state: 0,
- text: '待付款',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: 1,
- text: '待发货',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: 2,
- text: '待收货',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: 3,
- text: '已完成',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: -1,
- text: '退款中',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: -2,
- text: '已退款',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- }
- ];
- this.loadData();
- },
- methods: {
- navChoose(index) {
- this.navIc = index;
- this.loadData();
- },
- price(price) {
- return (price * 1).toFixed(2);
- },
- //swiper 切换
- changeTab(e) {
- this.navIc = e.target.current;
- this.loadData('tabChange');
- },
- //获取订单列表
- loadData(source) {
- //这里是将订单挂载到tab列表下
- let index = this.navIc;
- let navItem = this.navList[index];
- let state = navItem.state;
- if (source === 'tabChange' && navItem.loaded === true) {
- //tab切换只有第一次需要加载数据
- return;
- }
- if (navItem.loadingType === 'loading') {
- //防止重复加载
- return;
- }
- if (navItem.loadingType === 'noMore') {
- //防止重复加载
- return;
- }
- // 修改当前对象状态为加载中
- navItem.loadingType = 'loading';
- orderList({
- type: state,
- page: navItem.page,
- limit: navItem.limit
- })
- .then(({ data }) => {
- console.log(data);
- let arr = data.map(e => {
- console.log(e, 123456);
- let b = this.orderStateExp(e.status);
- e.stateTip = b.stateTip;
- e.stateTipColor = b.stateTipColor;
- return e;
- });
- navItem.orderList = navItem.orderList.concat(arr);
- navItem.page++;
- if (navItem.limit == 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);
- });
- },
- orderTake(item, index) {
- let obj = this;
- uni.showModal({
- title: '是否确认收货?',
- success: res => {
- if (res.confirm) {
- orderTake({
- uni: item.order_id
- })
- .then(e => {
- obj.navList[obj.navIc].orderList.splice(index, 1);
- uni.showToast({
- title: '收货成功'
- });
- })
- .catch(e => {
- console.log(e);
- });
- } else if (res.cancel) {
- console.log('取消');
- }
- }
- });
- },
- //跳转到订单详情
- goToOrderDetail(e) {
- uni.navigateTo({
- url: '/pages/order/orderDetail?id=' + e.order_id
- });
- },
- showCode(e) {
- uni.navigateTo({
- url: '/pages/order/verifyCode?id=' + e.order_id
- });
- },
- orderStateExp(state) {
- let stateTip = '',
- stateTipColor = '#fa436a';
- switch (+state) {
- case 0:
- stateTip = '待发货';
- break;
- case 1:
- stateTip = '待收货';
- break;
- case 2:
- stateTip = '已完成';
- break;
- case 3:
- stateTip = '待评价';
- break;
- case 4:
- stateTip = '已完成';
- stateTipColor = '#901b21';
- break;
- case 9:
- stateTip = '订单已关闭';
- stateTipColor = '#909399';
- break;
- //更多自定义
- }
- return {
- stateTip,
- stateTipColor
- };
- },
- qxzf(item) {
- uni.showModal({
- title: '订单取消',
- content: '是否取消订单?',
- success: e => {
- if (e.confirm) {
- uni.showLoading({
- title: '请稍后'
- });
- orderCancel({ id: item.order_id })
- .then(e => {
- uni.showToast({
- title: '取消成功',
- duration: 2000,
- position: 'top'
- });
- })
- .catch(e => {
- console.log(e);
- });
- //取消订单后删除待付款中该项
- let list = this.navList[this.navIc].orderList;
- let index = list.findIndex(val => val.id === item.id);
- index !== -1 && list.splice(index, 1);
- uni.hideLoading();
- }
- }
- });
- },
- ljzf(e) {
- let yajin = 0;
- e.cartInfo.forEach(item => {
- console.log(item.deposit);
- yajin += item.deposit * 1;
- });
- console.log(yajin);
- uni.navigateTo({
- url: '/pages/money/pay?type=1&ordid=' + e.order_id + '&money=' + (e.pay_price * 1 + yajin)
- });
- },
- sqth(i) {
- uni.navigateTo({
- url: '/pages/order/orderRefund?id=' + i.order_id
- });
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- page {
- min-height: 100%;
- height: auto;
- background: #f8f1f2;
- }
- .container {
- width: 100%;
- min-height: 100%;
- height: auto;
- position: fixed;
- .navbar {
- position: relative;
- z-index: 10;
- margin: 20rpx;
- display: flex;
- border-radius: 40rpx;
- background-color: #ee2f72;
- .nav-item {
- margin: 0 10rpx;
- text-align: center;
- flex: 1;
- color: #ffffff;
- font-size: 28rpx;
- margin: 10rpx;
- line-height: 60rpx;
- }
- .navC {
- background-color: #ffffff;
- color: #ee2f72;
- line-height: 60rpx;
- border-radius: 50rpx;
- }
- }
- .tab-content,
- .scroll-y {
- height: 100%;
- }
- .order-item {
- display: grid;
- margin-bottom: 20rpx;
- }
- .btn-box {
- border-top: 1px solid #f2f2f2;
- height: 100rpx;
- width: 100%;
- padding-right: 20rpx;
- background-color: #ffffff;
- display: flex;
- justify-content: flex-end;
- align-items: center;
- .btn {
- margin-left: 10rpx;
- width: 144rpx;
- height: 55rpx;
- border: 1px solid #ee2f72;
- border-radius: 28rpx;
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #ee2f72;
- line-height: 55rpx;
- text-align: center;
- }
- .btn-look {
- margin-left: 10rpx;
- width: 144rpx;
- height: 55rpx;
- border: 1px solid #ebebeb;
- border-radius: 28rpx;
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #999999;
- line-height: 55rpx;
- text-align: center;
- }
- }
- .i-td {
- display: flex;
- justify-content: space-between;
- background-color: #ffffff;
- padding: 20rpx;
- color: #999999;
- font-size: 25rpx;
- .i-bottom {
- span {
- margin: 0 10rpx;
- b {
- font-size: 28rpx;
- color: #4f4f4f;
- }
- }
- }
- }
- .goods-box {
- height: 100%;
- display: flex;
- justify-content: space-between;
- background-color: #f7f7f7;
- padding: 20rpx;
- .goods-left {
- align-items: flex-start;
- .goods-img {
- width: 160rpx;
- height: 160rpx;
- }
- .goods-name {
- margin: 10rpx 40rpx;
- color: #666666;
- font-size: 30rpx;
- .p {
- max-width: 300rpx;
- margin-bottom: 10rpx;
- }
- .span {
- width: 120rpx;
- background-color: #ffeae5;
- color: #fd5b23;
- text-align: center;
- font-size: 24rpx;
- padding: 5rpx;
- border-radius: 5rpx;
- }
- }
- }
- .goods-price {
- margin: 10rpx 0;
- text-align: right;
- display: grid;
- color: #999999;
- font-size: 24rpx;
- position: relative;
- b {
- color: #ee2f72;
- font-size: 35rpx;
- }
- .num {
- position: absolute;
- bottom: 20rpx;
- right: 10rpx;
- }
- }
- }
- }
- </style>
|