Files
sykl-sm/pages/order/index.vue

400 lines
12 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="content">
<view class="header">
<view class="tabs">
<view class="item" :class="{'show': listType == ''}" @click="onTabs('')">全部</view>
<view class="item" :class="{'show': listType == 'unpay'}" @click="onTabs('unpay')">待支付</view>
<view class="item" :class="{'show': listType == 'paid'}" @click="onTabs('paid')">待发货</view>
<view class="item" :class="{'show': listType == 'delivered'}" @click="onTabs('delivered')">已发货</view>
<view class="item" :class="{'show': listType == 'signed'}" @click="onTabs('signed')">已签收</view>
</view>
</view>
<view class="order" v-if="orderArr.length > 0">
<view class="While order-list" v-for="(item, index) in orderArr" :key="index">
<view class="order-top">
<view class="order-top-number">{{ item.order_no }}</view>
<view class="order-top-tips">{{ item.state }}</view>
</view>
<view class="order-name" v-for="(goodItem, index) in item.items" :key="index">
<!-- <image class="order-img" :src="goodItem.sku.cover" mode="aspectFill"></image> -->
<!-- 先默认固定图 -->
<image class="order-img" src="@/static/imgs/photo.png" mode="widthFix"></image>
<view class="order-goods">
<view class="order-label">
<view class="nowrap order-label-name">
{{ goodItem.sku.goods_name }}
</view>
<view class="order-label-price">
{{ goodItem.sku.price }}
</view>
</view>
<view class="order-specs">
x{{ goodItem.qty }}
</view>
</view>
</view>
<view class="order-text">
<view class="order-time">下单时间{{ item.created_at }}</view>
<!-- <view class="order-price">合计金额<text class="red">{{ item.amount }}</text></view> -->
</view>
<view class="order-btn">
<!-- <view class="order-btn-atn" @click="$Router.push({name: 'OrderDetails', params: { orderNo: item.order_no, listType: listType}})">订单详情</view> -->
<view class="order-btn-atn" v-if="item.can.pay" @click="cancel(item.order_no)">取消支付</view>
<view class="order-btn-atn active" v-if="item.can.pay" @click="$Router.push({name: 'indexPay', params: { orderNo: item.order_no, total: item.total }})">去支付</view>
<view class="order-btn-atn active" v-if="item.can.sign" @click="signcel(item.order_no)">签收</view>
</view>
</view>
<view class="pagesLoding" v-if="lodingStats">
<block v-if="page.has_more">
<image class="pagesLodingIcon" src="/static/icons/refresh_loding.gif" mode="widthFix"></image>加载中...
</block>
<block v-else>
没有更多了~
</block>
</view>
</view>
<view class="pack-center pages-hint" v-else>
<image src="/static/imgs/coupon_null.png"></image>
<view>暂无数据</view>
</view>
</view>
</template>
<script>
const jweixin = require('jweixin-module');
import { donationPay } from '@/apis/interfaces/mall'
import { orders, goodsSign, goodsCancel } from '@/apis/interfaces/user'
export default {
data() {
return {
listType : '', //unpay待付款paid待发货delivered已发货signed已签收
orderArr : [], //订单列表
page : {}, //分页信息
lodingStats : false //加载状态
}
},
onLoad() {
this.listType = this.$Route.query.listType
// 获取省市区列表
this.ordersInfo();
},
methods: {
// 商品详情数据
ordersInfo(page) {
orders({
state: this.listType,
page : page || 1
}).then(res => {
let listArr = this.orderArr,
newData = []
if(page == 1 || page == undefined) listArr = []
newData = listArr.concat(res.data)
this.orderArr = newData
this.page = res.page
this.lodingStats= false
uni.stopPullDownRefresh()
}).catch(err => {
uni.showToast({
title: err.message,
icon: "none"
})
})
},
// 状态筛选
onTabs(val){
if(this.listType === val) return
this.listType = val
// 商品详情数据
this.page = {};
this.ordersInfo();
},
// 支付
stockForm(order_no) {
// 微信支付
donationPay(order_no, {
type : 'mp',
openid: ''
}).then(res => {
let wxConfig = JSON.parse(res.wechat)
jweixin.config({
appId: wxConfig.appId,
debug: false,
jsApiList: ['chooseWXPay'],
signature: wxConfig.signature,
nonceStr: wxConfig.nonceStr,
timestamp: wxConfig.timestamp,
})
jweixin.ready(() => {
jweixin.chooseWXPay({
timestamp: wxConfig.timeStamp,
nonceStr: wxConfig.nonceStr,
package: wxConfig.package,
signType: wxConfig.signType,
paySign: wxConfig.paySign,
success: payRes => {
uni.showToast({
title: '支付成功',
icon: 'none'
})
this.disabled = true
setTimeout(()=>{
this.$Router.replace({ name: 'OrderIndex', params: { listType: 'paid' }});
},1000)
},
fail: payfail => {
uni.showToast({
title: '取消支付',
icon: 'none'
})
this.disabled = true
setTimeout(()=>{
this.$Router.replace({ name: 'OrderIndex', params: { listType: 'unpay' }});
},1000)
}
});
});
}).catch(err => {
uni.showToast({
title: err.message,
icon: "none"
})
})
},
// 取消订单
cancel(e) {
uni.showModal({
title: '订单提示',
content: '是否取消订单支付',
confirmColor: '#8b64fd',
showCancel:false,
success: res=> {
goodsCancel(e).then(CancelRes => {
// 获取订单列表
this.ordersInfo();
}).catch(err => {
uni.showToast({
title: err.message,
icon: "none"
})
})
}
})
},
// 签收订单
signcel(e) {
uni.showModal({
title: '订单提示',
content: '是否签收订单',
confirmColor: '#8b64fd',
showCancel:false,
success: res=> {
goodsSign(e).then(CancelRes => {
// 获取订单列表
this.ordersInfo();
}).catch(err => {
uni.showToast({
title: err.message,
icon: "none"
})
})
}
})
},
// 页面相关事件处理函数--监听用户下拉动作
onPullDownRefresh() {
// 获取账变记录
this.logsList();
},
// 上拉加载
onReachBottom(){
this.lodingStats = true
let pageNumber = this.page.current
if(this.page.has_more){
pageNumber++
// 获取账变记录
this.logsList(pageNumber);
}
}
}
}
</script>
<style lang="scss" scoped>
page {
background-color: #f3f4f6;
}
.content{
overflow: hidden;
background: #f3f4f6;
padding: 30rpx;
box-sizing: border-box;
}
.While {
border-radius: 10rpx;
margin-bottom: 30rpx;
background-color: #FFFFFF;
padding: 0 30rpx;
box-sizing: border-box;
box-shadow: 0 0 10rpx rgba($color: #000000, $alpha: .05);
}
.order {
margin-top: 90rpx;
}
.order-top {
line-height: 90rpx;
box-sizing: border-box;
display: flex;
font-size: 28rpx;
border-bottom: 2rpx #f2f2f2 solid;
.order-top-number {
flex: 1;
}
.order-top-tips {
font-size: 26rpx;
color: #eb504c;
}
}
.order-name {
padding: 20rpx 0;
box-sizing: border-box;
position: relative;
.order-img {
width: 90rpx;
height: 90rpx;
margin-right: 20rpx;
border-radius: 10rpx;
}
.order-goods {
position: absolute;
width: 100%;
left: 0;
top: 0;
padding: 20rpx 20rpx 20rpx 110rpx;
box-sizing: border-box;
.order-label {
display: flex;
font-size: 30rpx;
margin-bottom: 15rpx;
.order-label-name {
flex: 1;
margin-right: 30rpx;
}
.order-label-price {
font-weight: 600;
}
}
.order-specs {
font-size: 24rpx;
color: #919191;
display: flex;
text {
display: inline-block;
flex: 1;
}
}
}
}
.order-text {
font-size: 28rpx;
line-height: 40rpx;
display: flex;
padding-bottom: 20rpx;
border-top: 2rpx solid #f2f2f2;
border-bottom: 2rpx solid #f2f2f2;
padding-top: 20rpx;
.order-time {
color: #919191;
font-size: 26rpx;
flex: 1;
}
.order-price {
text {
font-weight: 600;
color: #1d37e2;
}
}
}
.order-btn {
text-align: right;
padding: 30rpx 0;
box-sizing: border-box;
position: relative;
.order-btn-atn {
border: 2rpx solid #f2f2f2;
border-radius: 40rpx;
padding: 0 30rpx;
height: 52rpx;
line-height: 52rpx;
color: #767676;
display: inline-block;
margin-left: 15rpx;
font-size: 24rpx;
&.active {
color: #1d37e2;
border-color: #bfc5ff;
}
}
}
// tabs
.header{
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 99;
.tabs{
display: flex;
justify-content: space-around;
background: white;
padding: 15rpx 0;
font-size: $title-size-lg;
color: $text-gray;
.item{
height: 60rpx;
line-height: 60rpx;
&.show{
color: #1d37e2;
border-bottom: solid 4rpx #1d37e2;
}
}
}
// 类型
.tabs-type{
display: flex;
padding: 20rpx 30rpx;
background: white;
.item{
font-size: $title-size-sm;
height: 46rpx;
line-height: 46rpx;
border-radius: 23rpx;
padding: 0 ($padding - 10);
background: white;
margin-right: $margin/2;
color: $text-gray;
&.show{
background-color:#1d37e2;
color: #1d37e2;
}
}
}
}
</style>