|
|
- <template>
- <view class="page">
- <!-- 导航栏 -->
- <navbar title="订单详情 " leftClick @leftClick="navigateBack" bgColor="#019245"
- color="#fff" />
-
- <!-- 店铺信息 -->
- <view class="shop-info">
- <view class="shop-header">
- <image class="shop-logo" :src="teamLeader.spotImage" mode="aspectFill"></image>
- <view class="shop-name-container">
- <text class="shop-name"> {{ teamLeader.spotName }} </text>
- <view class="shop-address">
- <view style="padding-top: 7rpx;">
- <!-- 需要置顶 -->
- <uv-icon name="map-fill" color="#019245" size="28rpx"></uv-icon>
- </view>
- <text class="address-text">{{ teamLeader.area }} {{ teamLeader.address }}</text>
- </view>
- <view class="shop-phone">
- <view style="padding-top: 7rpx;">
- <!-- 需要置顶 -->
- <uv-icon name="phone-fill" color="#019245" size="28rpx"></uv-icon>
- </view>
- <text class="phone-text">{{teamLeader.phone}}</text>
- </view>
- </view>
- </view>
- </view>
-
- <view class="order-status">
- <!-- 商品列表 -->
- <view class="food-list">
- <view class="food-item" v-for="(food, index) in showedFoods" :key="food.id">
- <image class="food-image" :src="food.goods.image" mode="aspectFill" />
- <view class="food-info">
- <text class="food-name">{{food.goods.title}}</text>
- <view class="food-sold">
- <uv-icon name="bag" size="28rpx"></uv-icon>
- <text>已售出 {{ food.goods.sales }}单</text>
- </view>
- <text class="food-price"> <text style="font-size: 20rpx;">¥</text> {{food.goods.price}}</text>
- <text class="food-count">×{{food.num}}</text>
- </view>
- </view>
- <view class="expand-more" @tap="showAllFoods = !showAllFoods" v-if="orderDetail.goodsList.length > 3">
- <text>{{showAllFoods ? '收起' : '展开'}} (共{{orderDetail.goodsList.length}}个)</text>
- <uv-icon :name="showAllFoods ? 'arrow-up' : 'arrow-down'" size="28rpx"></uv-icon>
- </view>
- </view>
-
-
- <!-- 订单信息 -->
- <view class="order-info">
- <view class="info-item">
- <text class="info-label">合计:</text>
- <text class="info-value price">¥{{ orderDetail.priceAll }}</text>
- </view>
- <view class="info-item" v-if="this.orderDetail.status != '-1'" >
- <text class="info-label">创建时间:</text>
- <text class="info-value">{{ orderDetail.createTime }}</text>
- </view>
- <view class="info-item" v-if="this.orderDetail.status != '-1'">
- <text class="info-label">订单编号:</text>
- <text class="info-value">{{orderDetail.id}}</text>
- </view>
- </view>
- </view>
- <view class="discount-info-container">
- <!-- 优惠信息 -->
- <view class="discount-info" @click="gotoCoupon">
- <view class="discount-header">
- <text>优惠</text>
- </view>
- <view class="discount-item">
- <view class="discount-left">
- <image src="@/static/image/券.webp" mode="aspectFill" class="coupon-icon" />
- <view>新用户立减</view>
- </view>
- <text class="discount-amount">-¥{{ orderDetail.pricePreferential || 0 }}</text>
- </view>
- </view>
-
- <!-- 备注 -->
- <view class="remark-section">
- <view class="remark-header">
- <text>备注</text>
- </view>
- <view class="remark-content">
- <input v-if="orderStatus === '0'" type="text" v-model="orderDetail.remark"
- placeholder="请输入您要备注的内容" placeholder-style="font-size: 28rpx" />
- <text v-else>{{orderDetail.remark || '无备注信息'}}</text>
- </view>
- </view>
- </view>
-
- <!-- 支付方式 -->
- <uv-radio-group v-model="payMethod" v-if="orderStatus === '0' || orderStatus === '-1'">
- <view class="payment-methods">
- <view class="payment-item">
- <uv-icon name="weixin-circle-fill" size="70rpx" color="#019245" />
- <text class="payment-name">微信支付</text>
- <uv-radio activeColor="#019245" size="40rpx" name="0" />
- </view>
- <view class="payment-item">
- <uv-icon name="red-packet" size="70rpx" color="#019245" />
- <text class="payment-name">账户余额<text class="balance-text">(余额: ¥{{ userInfo.balance }})</text></text>
- <uv-radio activeColor="#019245" size="40rpx" name="1" />
- </view>
- </view>
- </uv-radio-group>
-
- <!-- 底部支付栏 -->
- <view class="bottom-bar">
- <view class="total-section">
- <text class="total-label">共{{ orderDetail.goodsList.length || 0 }}个,<text style="color: black;">合计</text> </text>
- <text class="total-price">¥{{ orderDetail.pricePay || cartPay }}</text>
- </view>
- <view class="pay-button" @tap="handlePay" v-if="orderStatus === '0' || orderStatus === '-1'">立即下单</view>
- <view class="pay-button" @tap="handlePay" v-if="orderStatus === '2'">立即取餐</view>
- </view>
- </view>
- </template>
-
- <script>
- import navbar from '@/components/base/navbar.vue'
- import { mapState } from 'vuex'
- export default {
- components: {
- navbar
- },
- data() {
- return {
- id: '',
- payMethod: '0',
- showAllFoods: false,
- orderStatus: '',
- orderDetail: { },
- cartDiscount: 0,
- teamLeader: {}
- }
- },
- computed: {
- ...mapState(['cartData']),
- showedFoods() {
- return this.showAllFoods ? this.orderDetail.goodsList : this.orderDetail.goodsList.slice(0, 3)
- },
-
- cartPay() {
- return this.orderDetail.priceAll - this.cartDiscount
- },
- orderStatus() {
- return this.orderDetail.status
- },
- // 格式为 goodId,goodNum;goodId2,goodsNum
- goodss() {
- return this.orderDetail.goodsList.map(item => {
- return `${item.id},${item.num},${item.goods.price * item.num}`
- }).join(';')
- }
-
- },
- onLoad(options) {
- // 如果是购物车调过来的结账页面
- if (options.status === 'cart') {
- this.showCartData()
- // 独一无二代表购物车的状态
- this.orderStatus = '-1'
- }
- else if (options.id) {
- this.getOrderDetail(options.id)
- }
- },
- methods: {
- // 返回上一页
- navigateBack() {
- uni.navigateBack()
- },
- // 如果是购物车结账页面
- showCartData() {
- this.$api('queryMyLeader', {}, res => {
- if (res.code === 200) {
- this.teamLeader = res.result
- }
- })
- this.orderDetail.goodsList = this.cartData.sendData
- this.orderDetail.priceAll = this.cartData.priceAll
- this.orderDetail.status = '-1'
- },
- // 获取订单详情
- getOrderDetail(id) {
- this.id = id
- this.$api('queryMemberOrderList', {
- id: this.id
- }, res => {
- if (res.code === 200) {
- this.orderDetail = res.result.records[0]
- }
- })
- },
-
- // 处理支付
- handlePay() {
- uni.showLoading({
- title: '支付处理中...'
- })
-
- // 正常订单调用支付接口
- if(this.orderStatus === '0'){
- this.$api('payOrder',{
- id: this.id,
- payMethod: this.payMethod
- }, res => {
- uni.hideLoading()
- console.log('res', res);
- })
-
- }
- // 购物车调用创造订单接口
- else if(this.orderStatus === '-1'){
- this.$api('createOrder',{
- priceAll: this.orderDetail.priceAll,
- pricePay: this.orderDetail.priceAll - 0,
- pricePreferential: 0,
- payType: this.payMethod,
- leaderId: this.teamLeader.id,
- goodss: this.goodss
- }, res => {
- uni.hideLoading()
- console.log('res', res);
- if(res.code === 200){
- }
- })
- }
- },
-
- // 去优惠页面
- gotoCoupon() {
- this.$utils.navigateTo({
- url: '/pages_order/mine/coupon?isUseinOrder=true'
- })
- }
- }
- }
- </script>
-
- <style lang="scss" scoped>
- .page {
- background-color: #f5f5f5;
- min-height: 100vh;
- padding-bottom: 120rpx;
- }
-
- .status-bar {
- background-color: #019245;
- padding: 30rpx;
- color: #fff;
- font-size: 32rpx;
- font-weight: 500;
- }
-
- .shop-info {
- background-color: #fff;
- margin: 20rpx;
- border-radius: 16rpx;
- padding: 20rpx;
-
- .shop-header {
- display: flex;
- align-items: center;
- // background-color: red;
-
- .shop-logo {
- width: 150rpx;
- height: 150rpx;
- // border-radius: 10rpx;
- margin-right: 20rpx;
- }
-
- .shop-name-container {
- flex: 1;
-
- .shop-name {
- font-size: 30rpx;
- font-weight: 500;
- margin-bottom: 10rpx;
- display: block;
- }
-
-
- .shop-address, .shop-phone {
- display: flex;
- align-items: start;
- font-size: 24rpx;
- color: $uni-color-third;
- margin-top: 8rpx;
-
- .address-text, .phone-text {
- margin-left: 8rpx;
- width: 80%;
- white-space: wrap;
- // overflow: hidden;
- // text-overflow: ellipsis;
- }
- }
- .shop-address-top{
- display: flex;
- align-items: start;
- background-color: red;
- // gap: 10rpx;
- }
- }
- }
- }
- .order-status{
- background-color: #fff;
- margin: 20rpx;
- border-radius: 16rpx;
- padding: 20rpx;
-
- .food-list {
- // gap: 20rpx;
- // background-color: #019245;
- .food-item {
- display: flex;
- margin-bottom: 20rpx;
- // background-color: red;
-
- .food-image {
- width: 120rpx;
- height: 120rpx;
- // border-radius: 10rpx;
- margin-right: 20rpx;
- }
-
- .food-info {
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- position: relative;
- .food-name {
- font-size: 28rpx;
- font-weight: 500;
- }
-
- .food-sold {
- display: flex;
- align-items: center;
- font-size: 24rpx;
- color: $uni-color-third;
- }
-
- .food-price {
- font-size: 28rpx;
- color: #f00;
- }
- .food-count {
- color: black;
- position: absolute;
- bottom: 50%;
- right: 0;
- }
- }
- }
-
- .expand-more {
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 20rpx 0 0;
- font-size: 24rpx;
- color: $uni-color-third;
- }
- }
- .order-info {
- padding-top: 20rpx;
- .info-item {
- display: flex;
- justify-content: space-between;
- margin-bottom: 15rpx;
- font-size: 26rpx;
-
- .info-label {
- color: black;
- }
-
- .info-value {
- color: #333;
-
- &.price {
- color: #f00;
- font-weight: 500;
- }
- }
- }
- }
- }
-
-
- .discount-info-container {
- background-color: #fff;
- margin: 20rpx;
- border-radius: 16rpx;
- padding: 20rpx;
- display: flex;
- flex-direction: column;
- gap: 40rpx;
- }
- .discount-info {
- display: flex;
- align-items: center;
- justify-content: space-between;
- .discount-header {
- font-size: 28rpx;
- }
-
- .discount-item {
- display: flex;
- justify-content: space-between;
- align-items: center;
- gap: 20rpx;
- .discount-left {
- display: flex;
- align-items: center;
- gap: 10rpx;
- .coupon-icon {
- width: 36rpx;
- height: 36rpx;
- margin-top: 6rpx;
- }
- }
-
- .discount-amount {
- color: #f00;
- font-weight: 500;
- }
- }
- }
-
- .remark-section {
- display: flex;
- // flex-direction: column;
- gap: 40rpx;
- // background-color: red;
- align-items: center;
-
- .remark-header {
- font-size: 28rpx;
- // font-weight: 500;
- }
-
- .remark-content {
- font-size: 26rpx;
- color: black;
- min-height: 60rpx;
- display: flex;
- align-items: center;
- }
- }
-
- .payment-methods {
- background-color: #fff;
- width: 100%;
- margin: 20rpx;
- border-radius: 16rpx;
- padding: 20rpx;
- display: flex;
- flex-direction: column;
- gap: 20rpx;
- .payment-item {
- display: flex;
- align-items: center;
- padding: 20rpx 0;
- border-bottom: 1rpx solid #f5f5f5;
-
- &:last-child {
- border-bottom: none;
- }
-
- .payment-name {
- flex: 1;
- margin-left: 20rpx;
- font-size: 28rpx;
-
- .balance-text {
- font-size: 24rpx;
- color: $uni-color-third;
- margin-left: 10rpx;
- }
- }
- }
- }
-
- .bottom-bar {
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- height: 100rpx;
- background-color: #fff;
- display: flex;
- align-items: center;
- padding: 0 30rpx;
- box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
-
- .total-section {
- flex: 1;
-
- .total-label {
- font-size: 26rpx;
- color: $uni-color-third;
- }
-
- .total-price {
- font-size: 32rpx;
- color: #f00;
- margin-left: 10rpx;
- }
- }
-
- .pay-button {
- width: 240rpx;
- height: 80rpx;
- background-color: #019245;
- color: #fff;
- font-size: 30rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: 40rpx;
- }
- }
- </style>
|