小程序产品库完成
This commit is contained in:
210
src/mods/AppOrderList/AppOrderList.vue
Normal file
210
src/mods/AppOrderList/AppOrderList.vue
Normal file
@@ -0,0 +1,210 @@
|
||||
<template>
|
||||
<div class="order">
|
||||
<div class="order-item" v-for="(item, index) in list" :key="index" hover-class="text-hover"
|
||||
@click="$linkTo('./orderInfo?id=' + item.id)">
|
||||
<div class="order-item__imgs">
|
||||
<scroll-view scroll-x>
|
||||
<image v-for="(goods, index) in item.merchandiseList" :key="index"
|
||||
:src="JSON.parse(goods.merchandisePhoto)[0].url"/>
|
||||
</scroll-view>
|
||||
<div class="order-item__imgs--right">
|
||||
<div class="top">
|
||||
<span>{{ item.orderIntegral }}</span>
|
||||
<i>积分</i>
|
||||
</div>
|
||||
<p>共{{ item.total }}件</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="order-item__footer">
|
||||
<span :style="{color: $dict.getColor('integralOrderStatus', item.orderStatus)}">{{
|
||||
$dict.getLabel('integralOrderStatus', item.orderStatus)
|
||||
}}</span>
|
||||
<div class="order-item__footer--btn" v-if="item.orderStatus === '0'" @click.stop="cancel(item.id)">取消订单</div>
|
||||
</div>
|
||||
</div>
|
||||
<AiEmpty v-if="!list.length"/>
|
||||
<!-- <div class="loading" style="margin-top:20px">
|
||||
<u-loadmore :status="loadingStatus" />
|
||||
</div> -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: "AppOrderList",
|
||||
appName: "超市订单",
|
||||
data() {
|
||||
return {
|
||||
list: [],
|
||||
current: 0,
|
||||
loadingStatus: 'loadmore'
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.$dict.load(['integralOrderStatus']).then(() => {
|
||||
this.getList()
|
||||
})
|
||||
uni.$on('update', () => {
|
||||
this.reset()
|
||||
})
|
||||
},
|
||||
|
||||
methods: {
|
||||
reset() {
|
||||
this.loadingStatus = 'loadmore'
|
||||
this.current = 0
|
||||
this.$loading()
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.getList()
|
||||
})
|
||||
},
|
||||
|
||||
cancel(id) {
|
||||
this.$loading()
|
||||
this.$instance.post(`/app/appvillagerintegralshoporder/overOrderForWx?orderId=${id}`).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.$toast('取消成功')
|
||||
this.reset()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
getTotal(arr) {
|
||||
let total = 0
|
||||
arr.forEach(item => {
|
||||
total = total + item.merchandiseNumber
|
||||
})
|
||||
|
||||
return total
|
||||
},
|
||||
|
||||
getList() {
|
||||
if (this.loadingStatus === 'loading' || this.loadingStatus === 'nomore') return
|
||||
|
||||
this.loadingStatus = 'loading'
|
||||
this.$instance.post(`/app/appvillagerintegralshoporder/listForWx?current=${this.current + 1}&size=10`).then(res => {
|
||||
if (res.code === 0) {
|
||||
if (this.current === 0) {
|
||||
this.list = []
|
||||
}
|
||||
|
||||
const data = res.data.records.map(item => {
|
||||
item.total = this.getTotal(item.merchandiseList)
|
||||
|
||||
return item
|
||||
})
|
||||
this.list.push(...data)
|
||||
this.current = this.current + 1
|
||||
this.loadingStatus = 'loadmore'
|
||||
if (!res.data.records.length || res.data.records.length < 10) {
|
||||
this.loadingStatus = 'nomore'
|
||||
}
|
||||
} else {
|
||||
this.loadingStatus = 'loadmore'
|
||||
}
|
||||
}).catch(() => {
|
||||
this.loadingStatus = 'loadmore'
|
||||
})
|
||||
},
|
||||
|
||||
toDetail(id) {
|
||||
this.$linkTo(`./newsDetail?id=${id}&areaId=${this.areaId}`)
|
||||
}
|
||||
},
|
||||
|
||||
onReachBottom() {
|
||||
this.getList(this.areaId)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.order {
|
||||
padding: 30px 0;
|
||||
}
|
||||
|
||||
.order-item {
|
||||
width: 686px;
|
||||
margin: 0px auto32px;
|
||||
background: #FFFFFF;
|
||||
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.02);
|
||||
border-radius: 8px;
|
||||
|
||||
.order-item__imgs--right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
width: 144px;
|
||||
height: 160px;
|
||||
background: rgba(255, 255, 255, 0.98);
|
||||
|
||||
.top {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
color: #4185F5;
|
||||
font-size: 40px i {
|
||||
padding-left: 4px;
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
p {
|
||||
color: #ADADAD;
|
||||
font-size: 26px;
|
||||
}
|
||||
}
|
||||
|
||||
.order-item__footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 112px;
|
||||
padding: 024px span {
|
||||
color: #3078E1;
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.order-item__footer--btn {
|
||||
width: 160px;
|
||||
height: 56px;
|
||||
line-height: 56px;
|
||||
text-align: center;
|
||||
color: #666666;
|
||||
font-size: 26px;
|
||||
background: #FFFFFF;
|
||||
border-radius: 32px;
|
||||
border: 1px solid #CCCCCC;
|
||||
}
|
||||
}
|
||||
|
||||
.order-item__imgs {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
height: 208px;
|
||||
padding: 0 0 024px;
|
||||
border-bottom: 1px solid #DDDDDD;
|
||||
|
||||
scroll-view {
|
||||
flex: 1;
|
||||
height: 160px;
|
||||
font-size: 0;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
image {
|
||||
flex-shrink: 1;
|
||||
width: 160px;
|
||||
height: 160px;
|
||||
margin-right: 10px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #DDDDDD;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
234
src/mods/AppOrderList/orderInfo.vue
Normal file
234
src/mods/AppOrderList/orderInfo.vue
Normal file
@@ -0,0 +1,234 @@
|
||||
<template>
|
||||
<div class="order" v-if="pageShow">
|
||||
<h2>订单{{ $dict.getLabel('integralOrderStatus', info.orderStatus) }}</h2>
|
||||
<p>{{ info.createTime }}</p>
|
||||
<div class="order-info">
|
||||
<div class="order-top">
|
||||
<div class="goods-item" v-for="(item, index) in info.merchandiseList" :key="index">
|
||||
<image :src="JSON.parse(item.merchandisePhoto)[0].url"/>
|
||||
<div class="goods-item__middle">
|
||||
<h2>{{ item.merchandiseName }}</h2>
|
||||
<p>{{ item.merchandiseNumber }}件</p>
|
||||
</div>
|
||||
<div class="goods-item__right">
|
||||
<span>{{ item.costIntegral * item.merchandiseNumber }}</span>
|
||||
<i>积分</i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="order-bottom">
|
||||
<div class="order-bottom__top">
|
||||
<div class="left">
|
||||
<span>总数量 </span>
|
||||
<i>{{ total }}</i>
|
||||
<span>件</span>
|
||||
</div>
|
||||
<div class="right">
|
||||
<span>共消耗</span>
|
||||
<i>{{ info.orderIntegral }}</i>
|
||||
<em>积分</em>
|
||||
</div>
|
||||
</div>
|
||||
<div class="order-bottom__bottom" v-if="info.orderStatus === '0'">
|
||||
<div></div>
|
||||
<span @click="cancel">取消订单</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
info: {},
|
||||
id: '',
|
||||
total: 0,
|
||||
pageShow: false
|
||||
}
|
||||
},
|
||||
|
||||
onLoad(query) {
|
||||
this.id = query.id
|
||||
this.getInfo()
|
||||
},
|
||||
|
||||
methods: {
|
||||
getInfo() {
|
||||
this.$loading()
|
||||
this.$instance.post(`/app/appvillagerintegralshoporder/queryDetailByIdForWx?id=${this.id}`).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.info = res.data
|
||||
this.total = this.getTotal(res.data.merchandiseList)
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.pageShow = true
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
getTotal(arr) {
|
||||
let total = 0
|
||||
arr.forEach(item => {
|
||||
total = total + item.merchandiseNumber
|
||||
})
|
||||
|
||||
return total
|
||||
},
|
||||
|
||||
cancel() {
|
||||
this.$loading()
|
||||
this.$instance.post(`/app/appvillagerintegralshoporder/overOrderForWx?orderId=${this.id}`).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.$toast('取消成功')
|
||||
uni.$emit('update')
|
||||
this.getInfo()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.order {
|
||||
padding: 48px 32px;
|
||||
|
||||
& > h2 {
|
||||
margin-bottom: 8px;
|
||||
color: #333333;
|
||||
font-size: 40px;
|
||||
}
|
||||
|
||||
.order-bottom {
|
||||
.order-bottom__bottom {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 120px span {
|
||||
width: 160px;
|
||||
height: 56px;
|
||||
line-height: 56px;
|
||||
text-align: center;
|
||||
color: #666666;
|
||||
font-size: 26px;
|
||||
background: #FFFFFF;
|
||||
border-radius: 32px;
|
||||
border: 1px solid #CCCCCC;
|
||||
}
|
||||
}
|
||||
|
||||
.order-bottom__top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 120px;
|
||||
|
||||
& > div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.right {
|
||||
align-items: baseline;
|
||||
|
||||
span {
|
||||
color: #333333;
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
i {
|
||||
position: relative;
|
||||
top: 2px;
|
||||
padding: 08px;
|
||||
color: #FA4A51;
|
||||
font-size: 40px;
|
||||
}
|
||||
|
||||
em {
|
||||
color: #FA4A51;
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.left {
|
||||
span {
|
||||
color: #999999;
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
i {
|
||||
padding: 04px;
|
||||
color: #333333;
|
||||
font-size: 28px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
& > p {
|
||||
color: #999999;
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.order-info {
|
||||
margin-top: 48px;
|
||||
padding: 24px 24px 0;
|
||||
background: #fff;
|
||||
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.02);
|
||||
border-radius: 8px;
|
||||
|
||||
.order-top {
|
||||
border-bottom: 1px solid #DDDDDD;
|
||||
}
|
||||
|
||||
.goods-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 24px;
|
||||
|
||||
.goods-item__right {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
|
||||
span {
|
||||
margin-right: 4px;
|
||||
color: #4185F5;
|
||||
font-size: 40px;
|
||||
}
|
||||
|
||||
i {
|
||||
color: #4185F5;
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.goods-item__middle {
|
||||
flex: 1;
|
||||
|
||||
h2 {
|
||||
line-height: 1.3;
|
||||
color: #333333;
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 20px;
|
||||
color: #ADADAD;
|
||||
font-size: 26px;
|
||||
}
|
||||
}
|
||||
|
||||
image {
|
||||
width: 160px;
|
||||
height: 160px;
|
||||
margin-right: 24px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #DDDDDD;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user