Commit f9e2d711 by 宋冰琦

修改订单详情获取方式

parent bc760195
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
<script> <script>
import Store from '@/store'; import Store from '@/store';
export default { export default {
globalData: {
statusBarHeight: 0, // 状态导航栏高度
navHeight: 0, // 总体高度
navigationBarHeight: 0, // 导航栏高度(标题栏高度)
},
onLaunch: function () { onLaunch: function () {
Store.commit('setAuthorization', uni.getStorageSync('Authorization')) Store.commit('setAuthorization', uni.getStorageSync('Authorization'))
Store.commit('setUserInfo', uni.getStorageSync('userInfo')) Store.commit('setUserInfo', uni.getStorageSync('userInfo'))
...@@ -19,6 +24,20 @@ export default { ...@@ -19,6 +24,20 @@ export default {
uni.setStorage({ key: 'BottomSafeHeight', data: BottomSafeHeight }); 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 () { onShow: function () {
}, },
......
<template> <template>
<div class="pages"> <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="status_text">订单状态:{{ orderStatusText }}</view>
<view class="tips"> <view class="tips">
<view v-if="orderInfo.state == 7">为保持口感,请尽快引用哦~</view> <view v-if="orderInfo.state == 7">为保持口感,请尽快引用哦~</view>
...@@ -117,12 +122,25 @@ import Order from '@/request/order'; ...@@ -117,12 +122,25 @@ import Order from '@/request/order';
import QRCode from '@/utils/qrCode' import QRCode from '@/utils/qrCode'
import Menu from '@/request/menu'; import Menu from '@/request/menu';
import Utils from '@/utils/utils' import Utils from '@/utils/utils'
import { systemInfo } from '@/utils/mixin.js'
import { $EventBus } from "@/utils/EventBus"; import { $EventBus } from "@/utils/EventBus";
export default { export default {
onLoad() { mixins: [systemInfo],
const resData = uni.getStorageSync('orderInfo'); async onLoad(option) {
this.orderInfo = resData 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; const isBuild = ['4', '5'].indexOf(this.orderInfo.state) >= 0;
if (isBuild) { if (isBuild) {
new QRCode('myQrcode', { new QRCode('myQrcode', {
...@@ -147,13 +165,16 @@ export default { ...@@ -147,13 +165,16 @@ export default {
} }
}, },
methods: { methods: {
goBack(){
uni.switchTab({ url: '/pages/order/order' })
},
async oneMoreOrder(item) { async oneMoreOrder(item) {
uni.removeStorageSync('shopCarInfo'); uni.removeStorageSync('shopCarInfo');
$EventBus.$emit('updateCar'); $EventBus.$emit('updateCar');
const numObj = {} const numObj = {}
const { id, shopId, orderDetails } = item; const { id, shopId, orderDetails } = item;
orderDetails.forEach(item => { orderDetails.forEach(item => {
orderDetails[item.skuId] = item.num orderDe = tails[item.skuId] = item.num
}) })
const { data } = await Order.moreOrder({ orderId: id, shopId }); const { data } = await Order.moreOrder({ orderId: id, shopId });
if(!data || !data.data){ if(!data || !data.data){
...@@ -212,7 +233,7 @@ export default { ...@@ -212,7 +233,7 @@ export default {
computed: { computed: {
totalNum() { totalNum() {
let totalNum = 0; let totalNum = 0;
const {orderDetails} = this.orderInfo const {orderDetails=[]} = this.orderInfo
orderDetails.forEach(item => { orderDetails.forEach(item => {
totalNum += parseInt(item.num); totalNum += parseInt(item.num);
}) })
...@@ -279,7 +300,10 @@ export default { ...@@ -279,7 +300,10 @@ export default {
default: default:
return '' return ''
} }
} },
userms() {
return this.$store.getters.Authorization;
},
} }
} }
</script> </script>
...@@ -288,6 +312,23 @@ export default { ...@@ -288,6 +312,23 @@ export default {
.pages { .pages {
padding-top: 1rpx; padding-top: 1rpx;
padding-bottom: 30rpx; 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 { .order_status {
......
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
<div class="price">总优惠¥{{ reduction }}</div> <div class="price">总优惠¥{{ reduction }}</div>
</div> --> </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> <button v-if="!userms" class="payment" style="border-radius: 0;" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"></button>
</div> </div>
<show-toast ref="toast"/> <show-toast ref="toast"/>
...@@ -554,8 +554,13 @@ export default { ...@@ -554,8 +554,13 @@ export default {
.payment { .payment {
width: 200rpx; width: 200rpx;
height: 100%; height: 100%;
background: url('@/static/imgs/fukuan.png') center center no-repeat; background: #0050F6;
background-size: 100%; font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFFFFF;
line-height: 100rpx;
text-align: center;
} }
} }
</style> </style>
\ No newline at end of file
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
"path": "pages/orderInfo/index", "path": "pages/orderInfo/index",
"style": { "style": {
"navigationBarTitleText": "订单详情", "navigationBarTitleText": "订单详情",
"navigationStyle": "custom",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
} }
......
...@@ -209,7 +209,8 @@ export default { ...@@ -209,7 +209,8 @@ export default {
} }
}, },
openInfo(data) { openInfo(data) {
uni.setStorageSync('orderInfo', data); const { id } = data
uni.setStorageSync('orderId', id);
let url = '/orderSubPackage/pages/orderInfo/index' let url = '/orderSubPackage/pages/orderInfo/index'
uni.navigateTo({ url }) uni.navigateTo({ url })
}, },
......
...@@ -60,9 +60,7 @@ export default { ...@@ -60,9 +60,7 @@ export default {
// 删除购物车数据后重新放回购物车 // 删除购物车数据后重新放回购物车
uni.setStorageSync('shopCarInfo', []); uni.setStorageSync('shopCarInfo', []);
$EventBus.$emit('updateCar'); $EventBus.$emit('updateCar');
const {data} = await Order.getMyOrder() uni.setStorageSync('orderId', data.orderId);
const {rows} = data
uni.setStorageSync('orderInfo', rows[0]);
let url = '/orderSubPackage/pages/orderInfo/index' let url = '/orderSubPackage/pages/orderInfo/index'
uni.navigateTo({ url }) uni.navigateTo({ url })
} }
...@@ -76,9 +74,7 @@ export default { ...@@ -76,9 +74,7 @@ export default {
}); });
uni.setStorageSync('shopCarInfo', []); uni.setStorageSync('shopCarInfo', []);
$EventBus.$emit('updateCar'); $EventBus.$emit('updateCar');
const {data} = await Order.getMyOrder() uni.setStorageSync('orderId', data.orderId);
const {rows} = data
uni.setStorageSync('orderInfo', rows[0]);
let url = '/orderSubPackage/pages/orderInfo/index' let url = '/orderSubPackage/pages/orderInfo/index'
uni.navigateTo({ url }) uni.navigateTo({ url })
}, },
......
...@@ -105,5 +105,14 @@ export default { ...@@ -105,5 +105,14 @@ export default {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '服务器错误', icon: 'none' })
console.log('服务器错误'); 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