优化细节问题

This commit is contained in:
Gao xiaosong
2021-04-18 15:28:14 +08:00
parent 829daf1f61
commit 7333043a4f
10 changed files with 863 additions and 904 deletions

View File

@ -4,7 +4,7 @@
<view class="picTxt acea-row row-between-wrapper">
<view class="text">
<view class="name">订单信息</view>
<view>累计订单{{ orderData.orderCount || 0 }} 总消费{{orderData.sumPrice || 0 }}</view>
<view>累计订单{{ orderData.orderCount || 0 }} 总消费{{ orderData.sumPrice || 0 }}</view>
</view>
</view>
</view>
@ -31,13 +31,10 @@
</view>
</view>
<view class="list">
<view class="item" v-for="(order,orderListIndex) in orderList" :key="orderListIndex">
<view class="item" v-for="(order, orderListIndex) in orderList" :key="orderListIndex">
<view class="title acea-row row-between-wrapper">
<view class="acea-row row-middle">
<span
class="sign cart-color acea-row row-center-wrapper"
v-if="order.combinationId > 0"
>拼团</span>
<span class="sign cart-color acea-row row-center-wrapper" v-if="order.combinationId > 0">拼团</span>
<span class="sign cart-color acea-row row-center-wrapper" v-if="order.seckillId > 0">秒杀</span>
<span class="sign cart-color acea-row row-center-wrapper" v-if="order.bargainId > 0">砍价</span>
<span class="sign cart-color acea-row row-center-wrapper" v-if="order.storeId > 0">门店</span>
@ -46,24 +43,15 @@
<view class="font-color-red">{{ getStatus(order) }}</view>
</view>
<view @click="goOrderDetails(order)">
<view
class="item-info acea-row row-between row-top"
v-for="(cart,cartInfoIndex) in order.cartInfo"
:key="cartInfoIndex"
>
<view class="item-info acea-row row-between row-top" v-for="(cart, cartInfoIndex) in order.cartInfo" :key="cartInfoIndex">
<view class="pictrue">
<image
:src="cart.productInfo.image"
@click.stop="
$yrouter.push({ path: '/pages/shop/GoodsCon/index',query:{id:cart.productInfo.id} })
"
v-if="cart.combinationId === 0 && cart.bargainId === 0 &&cart.seckillId === 0"
/>
<image :src="cart.productInfo.image" @click.stop="$yrouter.push({ path: '/pages/shop/GoodsCon/index', query: { id: cart.productInfo.id } })" v-if="cart.combinationId === 0 && cart.bargainId === 0 && cart.seckillId === 0" />
<image
:src="cart.productInfo.image"
@click.stop="
$yrouter.push({
path: '/pages/activity/GroupDetails/index',query:{id:cart.combinationId}
path: '/pages/activity/GroupDetails/index',
query: { id: cart.combinationId },
})
"
v-else-if="cart.combinationId > 0"
@ -72,7 +60,8 @@
:src="cart.productInfo.image"
@click.stop="
$yrouter.push({
path: '/pages/activity/DargainDetails/index',query:{id:cart.bargainId}
path: '/pages/activity/DargainDetails/index',
query: { id: cart.bargainId },
})
"
v-else-if="cart.bargainId > 0"
@ -81,7 +70,8 @@
:src="cart.productInfo.image"
@click.stop="
$yrouter.push({
path: '/pages/activity/SeckillDetails/index',query:{id:cart.seckillId}
path: '/pages/activity/SeckillDetails/index',
query: { id: cart.seckillId },
})
"
v-else-if="cart.seckillId > 0"
@ -90,16 +80,8 @@
<view class="text acea-row row-between">
<view class="name line2">{{ cart.productInfo.storeName }}</view>
<view class="money">
<view v-if="order.payType!='integral'">
¥{{
cart.productInfo.attrInfo
? cart.productInfo.attrInfo.price
: cart.productInfo.price
}}
</view>
<view v-if="order.payType=='integral'">
{{order.payIntegral}}积分
</view>
<view v-if="order.payType != 'integral'"> ¥{{ cart.productInfo.attrInfo ? cart.productInfo.attrInfo.price : cart.productInfo.price }} </view>
<view v-if="order.payType == 'integral'"> {{ order.payIntegral }}积分 </view>
<view>x{{ cart.cartNum }}</view>
</view>
</view>
@ -107,8 +89,8 @@
</view>
<view class="totalPrice">
共{{ order.cartInfo.length || 0 }}件商品,总金额
<text class="money font-color-red" v-if="order.payType!='integral'">¥{{ order.payPrice }}</text>
<text class="money font-color-red" v-if="order.payType=='integral'">{{order.payIntegral}}积分</text>
<text class="money font-color-red" v-if="order.payType != 'integral'">¥{{ order.payPrice }}</text>
<text class="money font-color-red" v-if="order.payType == 'integral'">{{ order.payIntegral }}积分</text>
</view>
<view class="bottom acea-row row-right row-middle">
<template v-if="order._status._type == 0">
@ -150,32 +132,17 @@
</view>
</template>
<script>
import { getOrderData, getOrderList } from "@/api/order";
import {
cancelOrderHandle,
payOrderHandle,
takeOrderHandle
} from "@/libs/order";
import Loading from "@/components/Loading";
import Payment from "@/components/Payment";
import DataFormat from "@/components/DataFormat";
import { mapGetters } from "vuex";
import { isWeixin, dataFormat } from "@/utils";
import { getOrderData, getOrderList } from '@/api/order'
import { cancelOrderHandle, payOrderHandle, takeOrderHandle } from '@/libs/order'
import Loading from '@/components/Loading'
import Payment from '@/components/Payment'
import DataFormat from '@/components/DataFormat'
import { mapGetters } from 'vuex'
import { isWeixin, dataFormat } from '@/utils'
const STATUS = [
"待付款",
"待发货",
"待收货",
"待评价",
"已完成",
"",
"",
"",
"",
"待付款"
];
const STATUS = ['待付款', '待发货', '待收货', '待评价', '已完成', '', '', '', '', '待付款']
const NAME = "MyOrder";
const NAME = 'MyOrder'
export default {
name: NAME,
@ -183,139 +150,137 @@ export default {
return {
offlinePayStatus: 2,
orderData: {},
type: "",
type: '',
page: 1,
limit: 20,
loaded: false,
loading: false,
orderList: [],
pay: false,
payType: ["yue", "weixin"],
from: this.$deviceType
};
payType: ['yue', 'weixin'],
from: this.$deviceType,
}
},
components: {
Loading,
Payment,
DataFormat
DataFormat,
},
computed: mapGetters(["userInfo"]),
computed: mapGetters(['userInfo']),
onShow: function() {
console.log(this);
this.type = parseInt(this.$yroute.query.type) || 0;
this.changeType(this.type);
this.getOrderData();
this.getOrderList();
console.log(this)
this.type = parseInt(this.$yroute.query.type) || 0
this.changeType(this.type)
this.getOrderData()
this.getOrderList()
},
onHide: function() {
this.orderList = [];
this.page = 1;
this.limit = 20;
this.loaded = false;
this.loading = false;
this.orderList = []
this.page = 1
this.limit = 20
this.loaded = false
this.loading = false
},
methods: {
goLogistics(order) {
this.$yrouter.push({
path: "/pages/order/Logistics/index",
query: { id: order.orderId }
});
path: '/pages/order/Logistics/index',
query: { id: order.orderId },
})
},
goOrderDetails(order) {
this.$yrouter.push({
path: "/pages/order/OrderDetails/index",
query: { id: order.orderId }
});
path: '/pages/order/OrderDetails/index',
query: { id: order.orderId },
})
},
dataFormat,
setOfflinePayStatus: function(status) {
var that = this;
that.offlinePayStatus = status;
var that = this
that.offlinePayStatus = status
if (status === 1) {
if (that.payType.indexOf("offline") < 0) {
that.payType.push("offline");
if (that.payType.indexOf('offline') < 0) {
that.payType.push('offline')
}
}
},
getOrderData() {
getOrderData().then(res => {
this.orderData = res.data;
});
this.orderData = res.data
})
},
takeOrder(order) {
takeOrderHandle(order.orderId).finally(() => {
this.reload();
this.getOrderData();
});
this.reload()
this.getOrderData()
})
},
reload() {
this.changeType(this.type);
this.changeType(this.type)
},
changeType(type) {
this.type = type;
this.orderList = [];
this.page = 1;
this.loaded = false;
this.loading = false;
this.getOrderList();
this.type = type
this.orderList = []
this.page = 1
this.loaded = false
this.loading = false
this.getOrderList()
},
getOrderList() {
if (this.loading || this.loaded) return;
this.loading = true;
const { page, limit, type } = this;
if (this.loading || this.loaded) return
this.loading = true
const { page, limit, type } = this
getOrderList({
page,
limit,
type
type,
}).then(res => {
this.orderList = this.orderList.concat(res.data);
this.page++;
this.loaded = res.data.length < this.limit;
this.loading = false;
});
this.orderList = this.orderList.concat(res.data)
this.page++
this.loaded = res.data.length < this.limit
this.loading = false
})
},
getStatus(order) {
return STATUS[order._status._type];
return STATUS[order._status._type]
},
cancelOrder(order) {
cancelOrderHandle(order.orderId)
.then(() => {
this.getOrderData();
this.orderList.splice(this.orderList.indexOf(order), 1);
this.getOrderData()
this.orderList.splice(this.orderList.indexOf(order), 1)
})
.catch(() => {
this.reload();
});
this.reload()
})
},
paymentTap: function(order) {
var that = this;
if (
!(order.combinationId > 0 || order.bargainId > 0 || order.seckillId > 0)
) {
that.setOfflinePayStatus(order.offlinePayStatus);
var that = this
if (!(order.combinationId > 0 || order.bargainId > 0 || order.seckillId > 0)) {
that.setOfflinePayStatus(order.offlinePayStatus)
}
this.pay = true;
this.pay = true
this.toPay = type => {
payOrderHandle(order.orderId, type, that.from)
.then(() => {
const type = parseInt(this.$yroute.query.type) || 0;
that.changeType(type);
that.getOrderData();
const type = parseInt(this.$yroute.query.type) || 0
that.changeType(type)
that.getOrderData()
})
.catch(() => {
const type = parseInt(that.$yroute.query.type) || 0;
that.changeType(type);
that.getOrderData();
});
};
const type = parseInt(that.$yroute.query.type) || 0
that.changeType(type)
that.getOrderData()
})
}
},
toPay() {}
toPay() {},
},
mounted() {},
onReachBottom() {
!this.loading && this.getOrderList();
}
};
!this.loading && this.getOrderList()
},
}
</script>
<style scoped lang="less">