Commit f9e2d711 by 宋冰琦

修改订单详情获取方式

parent bc760195
......@@ -5,6 +5,11 @@
<script>
import Store from '@/store';
export default {
globalData: {
statusBarHeight: 0, // 状态导航栏高度
navHeight: 0, // 总体高度
navigationBarHeight: 0, // 导航栏高度(标题栏高度)
},
onLaunch: function () {
Store.commit('setAuthorization', uni.getStorageSync('Authorization'))
Store.commit('setUserInfo', uni.getStorageSync('userInfo'))
......@@ -19,6 +24,20 @@ export default {
uni.setStorage({ key: 'BottomSafeHeight', data: BottomSafeHeight });
}
})
// 状态栏高度
this.globalData.statusBarHeight = uni.getSystemInfoSync().statusBarHeight
// #ifdef MP-WEIXIN
// 获取微信胶囊的位置信息 width,height,top,right,left,bottom
const custom = wx.getMenuButtonBoundingClientRect()
// 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
this.globalData.navigationBarHeight = custom.height + (custom.top - this.globalData.statusBarHeight) * 2
// console.log("导航栏高度:"+this.globalData.navigationBarHeight)
// 总体高度 = 状态栏高度 + 导航栏高度
this.globalData.navHeight = this.globalData.navigationBarHeight + this.globalData.statusBarHeight
// #endif
},
onShow: function () {
},
......
<template>
<div class="pages">
<div class="order_status">
<view class="topBar" :style="{'padding-top':statusBarHeight+'px','height':navigationBarHeight+'px'}">
<u-icon @click="goBack" name="arrow-left" color="#000000" size="20"></u-icon>
<view class="tabTitle" :style="{'line-height':navigationBarHeight+'px'}">订单详情</view>
</view>
<div class="order_status" :style="{'margin-top':(statusBarHeight+navigationBarHeight+13)+'px'}">
<view class="status_text">订单状态:{{ orderStatusText }}</view>
<view class="tips">
<view v-if="orderInfo.state == 7">为保持口感,请尽快引用哦~</view>
......@@ -117,12 +122,25 @@ import Order from '@/request/order';
import QRCode from '@/utils/qrCode'
import Menu from '@/request/menu';
import Utils from '@/utils/utils'
import { systemInfo } from '@/utils/mixin.js'
import { $EventBus } from "@/utils/EventBus";
export default {
onLoad() {
const resData = uni.getStorageSync('orderInfo');
this.orderInfo = resData
mixins: [systemInfo],
async onLoad(option) {
this.getSystemInfo()
let oId = 0
// 从订阅消息进入
this.option = JSON.stringify(option)
const { orderId } = option
if(orderId){
oId = orderId
}else{
oId = uni.getStorageSync('orderId');
}
// return
const {data = {}} = await Order.getOrderDetail({orderId:oId})
this.orderInfo = data?.data
const isBuild = ['4', '5'].indexOf(this.orderInfo.state) >= 0;
if (isBuild) {
new QRCode('myQrcode', {
......@@ -147,13 +165,16 @@ export default {
}
},
methods: {
goBack(){
uni.switchTab({ url: '/pages/order/order' })
},
async oneMoreOrder(item) {
uni.removeStorageSync('shopCarInfo');
$EventBus.$emit('updateCar');
const numObj = {}
const { id, shopId, orderDetails } = item;
orderDetails.forEach(item => {
orderDetails[item.skuId] = item.num
orderDe = tails[item.skuId] = item.num
})
const { data } = await Order.moreOrder({ orderId: id, shopId });
if(!data || !data.data){
......@@ -212,7 +233,7 @@ export default {
computed: {
totalNum() {
let totalNum = 0;
const {orderDetails} = this.orderInfo
const {orderDetails=[]} = this.orderInfo
orderDetails.forEach(item => {
totalNum += parseInt(item.num);
})
......@@ -279,7 +300,10 @@ export default {
default:
return ''
}
}
},
userms() {
return this.$store.getters.Authorization;
},
}
}
</script>
......@@ -288,6 +312,23 @@ export default {
.pages {
padding-top: 1rpx;
padding-bottom: 30rpx;
.topBar{
position: fixed;
padding:0rpx 34rpx;
width: 100%;
background: white;
display: flex;
justify-content: flex-start;
align-items: center;
.tabTitle{
font-size: 26rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
text-align: center;
width: 79%;
color: #333333
}
}
}
.order_status {
......
......@@ -74,7 +74,7 @@
<div class="price">总优惠¥{{ reduction }}</div>
</div> -->
</div>
<view v-if="userms" class="payment" @click="messageAndSave"></view>
<view v-if="userms" class="payment" @click="messageAndSave">付款</view>
<button v-if="!userms" class="payment" style="border-radius: 0;" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"></button>
</div>
<show-toast ref="toast"/>
......@@ -554,8 +554,13 @@ export default {
.payment {
width: 200rpx;
height: 100%;
background: url('@/static/imgs/fukuan.png') center center no-repeat;
background-size: 100%;
background: #0050F6;
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFFFFF;
line-height: 100rpx;
text-align: center;
}
}
</style>
\ No newline at end of file
......@@ -62,6 +62,7 @@
"path": "pages/orderInfo/index",
"style": {
"navigationBarTitleText": "订单详情",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
}
......
......@@ -209,7 +209,8 @@ export default {
}
},
openInfo(data) {
uni.setStorageSync('orderInfo', data);
const { id } = data
uni.setStorageSync('orderId', id);
let url = '/orderSubPackage/pages/orderInfo/index'
uni.navigateTo({ url })
},
......
......@@ -60,9 +60,7 @@ export default {
// 删除购物车数据后重新放回购物车
uni.setStorageSync('shopCarInfo', []);
$EventBus.$emit('updateCar');
const {data} = await Order.getMyOrder()
const {rows} = data
uni.setStorageSync('orderInfo', rows[0]);
uni.setStorageSync('orderId', data.orderId);
let url = '/orderSubPackage/pages/orderInfo/index'
uni.navigateTo({ url })
}
......@@ -76,9 +74,7 @@ export default {
});
uni.setStorageSync('shopCarInfo', []);
$EventBus.$emit('updateCar');
const {data} = await Order.getMyOrder()
const {rows} = data
uni.setStorageSync('orderInfo', rows[0]);
uni.setStorageSync('orderId', data.orderId);
let url = '/orderSubPackage/pages/orderInfo/index'
uni.navigateTo({ url })
},
......
......@@ -105,5 +105,14 @@ export default {
// uni.showToast({ title: '服务器错误', icon: 'none' })
console.log('服务器错误');
});
},
getOrderDetail(params) {
return uni.$u.http
.get(`/order/${params.orderId}`)
.then((res) => res)
.catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' })
console.log('服务器错误');
});
}
};
export const systemInfo = {
data: () => ({
statusBarHeight: 0,
navigationBarHeight: 0,
navHeight: 0,
windowHeight: 0, // 可使用窗口高度
}),
methods: {
// 获取设备信息
getSystemInfo() {
this.statusBarHeight = getApp().globalData.statusBarHeight;
this.navigationBarHeight = getApp().globalData.navigationBarHeight;
this.windowHeight = uni.getSystemInfoSync().windowHeight;
this.navHeight = getApp().globalData.navHeight;
},
},
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment