<template>
<view class="order">
<view class="background">
<image src="../../static/background/background.jfif"></image>
</view>
<view class="order_item" v-for="(item,index) in orderList" :key="item.supplier_order_id" @click="navToOrderDetail(item.supplier_order_id)">
<view class="shop">
<image src="../../static/order-icon/shop.png"></image>
<view class="shop_name">{{item.super_user_name}}</view>
</view>
<view class="order_info">
<view>联系电话:{{item.super_phone}}</view>
<view>联系地址:{{item.super_address}}</view>
<view>订单时间:{{item.supplier_order_createdate | formatDate}}</view>
<view v-if="orderList[index].supplier_goods_price">交易价格:{{item.supplier_goods_price}}元</view>
<view v-if="orderList[index].supplier_goods_amount">交易数量:{{item.supplier_goods_amount}}</view>
</view>
<view class="line"></view>
</view>
</view>
</template>```
```javascript
<script>
export default {
data() {
return {
orderList: [],
}
},
methods: {
async getOrder() {
const res = await this.$myRequest({
url: '/order/getOrderBySupplierId',
method: 'POST',
data: JSON.stringify({
supplier_id: uni.getStorageSync('supplier_id')
})
})
this.orderList = res.data.data
for(let i=0;i<this.orderList.length;i++) {
let res2 = await this.$myRequest({
url: '/order/getSingleOrderBySupplierGoodsId',
method: 'POST',
data: JSON.stringify({
supplier_order_id: this.orderList[i].supplier_order_id
})
})
let orderDetail = res2.data.data
let order_all_price = 0
let order_all_amount = 0
for(let j=0;j<orderDetail.length;j++) {
order_all_price = order_all_price + orderDetail[j].supplier_goods_price * orderDetail[j].supplier_goods_amount
order_all_amount = order_all_amount + orderDetail[j].supplier_goods_amount
}
this.orderList[i].supplier_goods_price = order_all_price
this.orderList[i].supplier_goods_amount = order_all_amount
}
},
navToOrderDetail(supplier_order_id) {
uni.navigateTo({
url: '/pages/order/order-detail?supplier_order_id='+supplier_order_id
})
},
onPullDownRefresh() {
setTimeout(()=>{
this.getOrder(()=>{
uni.stopPullDownRefresh()
})
}, 500)
}
},
onLoad() {
this.getOrder()
}
}
</script>
<style lang="scss">
.order {
.background { // 背景图片
image {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: -1;
}
}
.order_item {
background-color: white;
.shop { // 商店
display: flex;
padding: 10rpx 30rpx 0 30rpx;
image { // 商铺图片
padding: 5rpx 15rpx 0 0;
width: 60rpx;
height: 60rpx;
}
.shop_name { // 商店名称
font-size: 45rpx;
line-height: 70rpx;
}
}
.order_info { // 联系电话、地址和订单生成时间
color: #555555;
padding: 0 30rpx 10rpx 30rpx;
font-size: 35rpx;
line-height: 60rpx;
}
.line { // 分割线
width: 750rpx;
height: 8rpx;
background: #eee;
}
}
}
</style>