luban-mall/pagesA/order/detail.vue

179 lines
4.7 KiB
Vue
Raw Normal View History

2022-07-08 08:15:29 +00:00
<template>
<view class="pad-b140">
<status-nav :ifReturn="true" navBarTitle="订单详情" :marginBottom="0"></status-nav>
<!-- 订单简介 -->
<view class="order-info-bg">
<view class="order-info">
<view class="flex">
<text>订单编号</text>
<text>{{orderDetail.coding}}</text>
</view>
<view class="flex">
<text>下单时间</text>
<text>{{orderDetail.created_at}}</text>
</view>
<view class="flex">
<text>订单状态</text>
<text>{{orderDetail.status_text}}</text>
</view>
</view>
</view>
<!-- 订单信息 -->
<view class="order-list">
<view class="order-item order-item-detail">
<view class="order-information">订单信息</view>
<view class="item-bg">
<view class="item flex" v-for="(item,index) in orderDetail.skus" :key="index" @tap="toDetail(item.spu_id,item.is_series)">
<view class="img"><image :src="item.spu_cover" mode="widthFix"></image></view>
<view class="txt">
<view class="title">{{item.spu_name}}</view>
<view class="specs clips2">规格{{item.custom_title}}</view>
<view class="price flex">
<text>{{$toolAll.tools.changeNum(parseInt(item.price))}}</text>
<view><text>x</text>{{item.num}}</view>
</view>
</view>
</view>
</view>
<view class="total-price total-price-detail flex">
<text>总价{{$toolAll.tools.changeNum(parseInt(orderDetail.original_price))}}</text>
</view>
</view>
</view>
<!-- 联系方式 -->
<view class="contact-info-bg">
<view class="contact-info">
<view class="title">联系方式</view>
<view class="name">
<text>{{orderDetail.contact}}</text>
<text>{{orderDetail.phone}}</text>
</view>
<view class="item">{{orderDetail.address}}</view>
<view class="item" v-if="orderDetail.remarks!==''">{{orderDetail.remarks}}</view>
</view>
</view>
<!-- 底部按钮 -->
<view class="shop-btns order-btns flex">
<view class="btn btn-grey" @tap="cancleEv" v-if="orderDetail.status == 'ordered'"></view>
<view class="btn" @tap="buyAgain" v-if="orderDetail.status == 'completed' || orderDetail.status == 'closed'"></view>
</view>
<!-- 客服btn -->
<customer-service></customer-service>
</view>
</template>
<script>
import statusNav from '@/components/status-navs/status-nav';
import customerService from '@/components/customer-service/customer-service.vue';
2022-07-13 08:04:38 +00:00
import {getCartNum,userInfoEv} from '@/jsFile/public-api.js';
import {mapState} from 'vuex'//引入mapState
2022-07-08 08:15:29 +00:00
export default {
components:{
statusNav,
customerService
},
data() {
return {
orderDetail:{}, //订单详情
flag:true,
ifLoading:false,
id:0, //订单id
}
},
onLoad(op) {
if(op.id !== ''){
this.id = op.id;
}
2022-07-12 10:07:08 +00:00
if(op.business_id){
this.$requst.post('/api/index/change-business',{business_id:op.business_id}).then(res=>{
if(res.code == 0){
this.getOrderDetail();
2022-07-13 08:04:38 +00:00
userInfoEv();
2022-07-12 10:07:08 +00:00
}
})
}else{
this.getOrderDetail();
2022-07-13 08:04:38 +00:00
userInfoEv();
2022-07-12 10:07:08 +00:00
}
2022-07-08 08:15:29 +00:00
},
// 分享到微信
onShareAppMessage() {
2022-07-11 10:35:14 +00:00
let path = uni.getStorageSync('page-path-options')+'?business_id='+uni.getStorageSync('business_id');
return {
path:path
}
2022-07-08 08:15:29 +00:00
},
// 分享到朋友圈
2022-07-11 10:35:14 +00:00
onShareTimeline(res){
let path = uni.getStorageSync('page-path-options')+'?business_id='+uni.getStorageSync('business_id');
return {
path:path
}
2022-07-08 08:15:29 +00:00
},
methods: {
// 查询订单详情
getOrderDetail(){
2022-07-14 02:00:23 +00:00
uni.showLoading({
title: '加载中'
});
2022-07-08 08:15:29 +00:00
this.$requst.get('/api/user/order-detail',{id:this.id}).then(res=>{
if(res.code==0){
this.orderDetail = res.data;
}
uni.hideLoading();
})
},
// 取消订单
cancleEv(){
let params = {
order_coding: this.orderDetail.coding //订单号
}
this.$requst.post('/api/order/cancel',params).then(res=>{
if(res.code==0) {
this.$toolAll.tools.showToast('取消订单成功(*^▽^*)');
uni.navigateTo({
url:'/pagesA/order/order'
})
} else {
this.$toolAll.tools.showToast(res.msg)
}
})
},
// 再次购买
buyAgain(index){
let buyList = [];
let newArr = this.orderDetail;
newArr.skus.forEach(item=>{
let obj = {
sku_coding: item.coding,
num: item.num
}
buyList.push(obj);
})
uni.setStorageSync('buyList',buyList);
uni.navigateTo({
url:'/pagesA/cart/settlement'
})
},
//去商品详情页
toDetail(id,type){
if(type == 0){
uni.navigateTo({
url:`/pagesA/shop/detail?id=${id}&source=shop`
})
}
if(type == 1){
uni.navigateTo({
url:`/pages/tabbar/kit/detail?id=${id}`
})
}
}
}
}
</script>
<style scoped>
</style>