Эх сурвалжийг харах

add 订单上传图片&加急费用

tea 3 сар өмнө
parent
commit
bec6b413f5

+ 10 - 0
kxmall-app-ui/pages.json

@@ -227,6 +227,16 @@
       "style": {
         "navigationBarTitleText": "订单详情"
       }
+    }, {
+      "path": "pages/order/complete",
+      "style": {
+        "navigationBarTitleText": "订单完成"
+      }
+    }, {
+      "path": "pages/order/upload",
+      "style": {
+        "navigationBarTitleText": "上传图片"
+      }
     }, {
       "path": "pages/order/refund",
       "style": {

+ 1 - 2
kxmall-app-ui/pages/address/list.vue

@@ -67,10 +67,9 @@ export default {
   methods: {
     //选择地址
     checkAddress(item) {
-      if (this.source == 1) {
+      if (this.source === 1) {
         //this.$api.prePage()获取上一页实例,在App.vue定义
         this.$api.prePage().addressData = item
-        this.$api.prePage().calcFreightPrice()
         uni.navigateBack()
       }
     },

+ 0 - 2
kxmall-app-ui/pages/cart/cart.vue

@@ -120,8 +120,6 @@
 							<view class="padding-left-xs lem-text-title"
 							style="color: #FC6620;font-weight: 500;">¥ {{total}}</view>
 						</view>
-						<view style="font-size: 20rpx;line-height: 36rpx;" class="lem-text-gray"
-						>已优惠:{{jian(yuanjia,total)}}元</view>
 					</view>
 					<button @click="createOrder" style="width: 240rpx;height: 84rpx;font-weight: 500;"
 					class="lem-btn round bg-green lem-text-xl ">提交订单</button>

+ 70 - 34
kxmall-app-ui/pages/order/create.vue

@@ -70,8 +70,8 @@
                                                 placeholder="请输入您的联系电话"></view>
       </view>
       <view class="distribution-list distribution-list-bottom"
-            :class="{ 'disabled': !hasAvailableCoupons }"
-            @click="hasAvailableCoupons ? toggleMask('show') : null"
+            :class="{ 'disabled': !hasCoupons }"
+            @click="hasCoupons ? toggleMask('show') : null"
             v-if="!orderReqeust.isIntegral">
         <view class="distribution-text">优惠券
           <!-- 新增最佳优惠标识 -->
@@ -79,9 +79,9 @@
             最佳优惠
           </view>
         </view>
-        <view class="distribution-price" :style="{ color: hasAvailableCoupons ? 'red' : '#999' }">
+        <view class="distribution-price" :style="{ color: hasCoupons ? 'red' : '#999' }">
           {{
-            orderReqeust.coupon ? "-¥" + orderReqeust.coupon.couponPrice : (hasAvailableCoupons ? '选择优惠券' : '暂无优惠券')
+            orderReqeust.coupon ? "-¥" + orderReqeust.coupon.couponPrice : (hasCoupons ? '选择优惠券' : '暂无优惠券')
           }}
         </view>
       </view>
@@ -93,12 +93,12 @@
       </view>
       
       <view class="distribution-list distribution-list-bottom" v-if="shippingType === 1">
-        <view class="distribution-text">加急费用(可选)</view>
-        <view class="distribution-price">
+        <view class="distribution-text" style="width: 250rpx">加急费用(可选)</view>
+        <view class="distribution-price" style="display: flex; align-items: center; justify-content: flex-end;flex:1; width: 430upx">
           <input type="number" v-model.number="orderReqeust.urgentFee"
                  placeholder="请输入加急费用"
-                 style="text-align: right;">
-          <text style="margin-left: 10rpx;">元</text>
+                 style="text-align: right; flex: 1; border: none; outline: none;">
+          <text style="margin-left: 5rpx;">元</text>
         </view>
       </view>
       
@@ -121,7 +121,7 @@
             
             <!-- 添加照片按钮 -->
             <view
-                v-if="orderReqeust.photos.length < 5"
+                v-if="orderReqeust.photos.length < 6"
                 class="photo-add-btn"
                 @click="choosePhoto"
             >
@@ -129,7 +129,7 @@
               <text class="photo-add-text">添加照片</text>
             </view>
           </view>
-          <view class="photo-tips">最多可上传5张照片</view>
+          <view class="photo-tips">最多可上传6张照片</view>
         </view>
       </view>
     </view>
@@ -167,13 +167,14 @@
         <view v-if="getAvailableCoupons().length === 0" class="no-coupon-tip">
           <text>暂无可用优惠券</text>
         </view>
-        <view @click="selectCoupon(item)"
-              v-if="(!item.categoryId && orderReqeust.totalPrice >= item.useMinPrice) || (item.categoryId && skuCategoryPriceMap[item.categoryId] && skuCategoryPriceMap[item.categoryId] > item.useMinPrice)"
-              class="coupon-item" v-for="(item,index) in couponList" :key="index">
+        <view @click="isCouponAvailable(item) ? selectCoupon(item) : null"
+              class="coupon-item" 
+              :class="{ 'coupon-disabled': !isCouponAvailable(item) }"
+              v-for="(item,index) in couponList" :key="index">
           <view class="con">
             <view class="left">
               <text class="title">{{ item.couponTitle }}</text>
-              <text class="time">有效期至{{ item.endTime | dateFormat }}</text>
+              <text class="time">有效期至{{ item.endTime || '-' }}</text>
             </view>
             <view class="right">
               <text class="price">{{ item.couponPrice }}</text>
@@ -184,6 +185,7 @@
             <view class="circle r"></view>
           </view>
           <text class="tips">{{ item.categoryTitle ? '限' + item.categoryTitle + '可用' : '全品类可用' }}</text>
+          <text class="info" v-if="item.id === bestCouponId && hasAvailableCoupons">最佳优惠</text>
         </view>
       </view>
     </view>
@@ -193,7 +195,7 @@
         <view class="price-content">
           <text>总计</text>
           <text class="price-content-money">
-            ¥{{ orderPriceData.actualPrice || 0 }}
+            ¥{{ orderPriceData.actualPrice || '-' }}
           </text>
           <text class="price-content-money" style="color: red" v-if="orderReqeust.isIntegral === 1"> +
             积分{{ orderReqeust.integral }}
@@ -201,7 +203,7 @@
         </view>
         <view class="price-preferential">
           <text>已优惠:</text>
-          <text>{{ jian(orderPriceData.productOriginalTotalPrice || 0, orderPriceData.actualPrice || 0) }}元</text>
+          <text>{{ orderPriceData.couponPrice || '0' }}元</text>
         </view>
       </view>
       <view class="submit" @click="submit">
@@ -242,6 +244,7 @@
 
 <script>
 import uniPopup from "@/components/uni-popup/uni-popup.vue"
+import {dateFormat} from "../../filters";
 
 export default {
   data() {
@@ -272,6 +275,7 @@ export default {
       maskState: 0, //优惠券面板显示状态
       couponList: [],
       hasAvailableCoupons: false, // 是否有可用优惠券
+      hasCoupons: false,
       urgentFeeTimer: null, // 加急费用防抖定时器
       orderPriceData: { // 订单价格数据
         productTotalPrice: 0,
@@ -352,8 +356,16 @@ export default {
     that.orderReqeust.totalPrice = totalPrice
     that.$api.request('get', 'coupon/app/getUserCoupons').then(res => {
       that.couponList = res.data
-      that.hasAvailableCoupons = that.getAvailableCoupons().length > 0
       this.findBestCoupon(); // 找出最佳优惠券
+      
+      if (that.bestCouponId) {
+        const baseIndex = that.couponList.findIndex(coupon => that.bestCouponId === coupon.id)
+        that.couponList.unshift(...that.couponList.splice(that.couponList.indexOf(baseIndex), 1));
+      }
+      
+      that.hasCoupons = res.data.length > 0
+      that.hasAvailableCoupons = that.getAvailableCoupons().length > 0
+
       // 初始化价格计算
       that.calculateOrderPrice();
     })
@@ -371,7 +383,6 @@ export default {
       if (res.data) {
         that.addressData = res.data
       }
-      that.calcFreightPrice()
     })
     
     if (that.orderReqeust.productList.length === 1 && that.orderReqeust.productList[0].groupShopId) {
@@ -398,6 +409,7 @@ export default {
     this.calcTime()
   },
   methods: {
+    dateFormat,
     findBestCoupon() {
       if (this.couponList.length > 0) {
         // 找出优惠力度最大的优惠券
@@ -411,9 +423,15 @@ export default {
     getAvailableCoupons() {
       return this.couponList.filter(item => {
         return (!item.categoryId && this.orderReqeust.totalPrice >= item.useMinPrice) ||
+            // 有categoryId 且 category 价格大于实际价格
             (item.categoryId && this.skuCategoryPriceMap[item.categoryId] && this.skuCategoryPriceMap[item.categoryId] > item.useMinPrice);
       });
     },
+    // 判断单个优惠券是否可用
+    isCouponAvailable(item) {
+      return (!item.categoryId && this.orderReqeust.totalPrice >= item.useMinPrice) ||
+          (item.categoryId && this.skuCategoryPriceMap[item.categoryId] && this.skuCategoryPriceMap[item.categoryId] > item.useMinPrice);
+    },
     // 计算订单价格
     calculateOrderPrice() {
       const that = this;
@@ -430,15 +448,7 @@ export default {
         })
         .catch(err => {
           console.error('计算订单价格失败:', err);
-          // 出错时使用默认值
-          that.orderPriceData = {
-            productTotalPrice: that.orderReqeust.totalPrice || 0,
-            productOriginalTotalPrice: that.orderReqeust.totalotPrice || 0,
-            freightPrice: that.orderReqeust.freightPrice || 0,
-            urgentFee: that.orderReqeust.urgentFee || 0,
-            couponPrice: that.orderReqeust.coupon ? that.orderReqeust.coupon.couponPrice : 0,
-            actualPrice: (that.orderReqeust.totalPrice || 0) - (that.orderReqeust.coupon ? that.orderReqeust.coupon.couponPrice : 0) + (that.orderReqeust.freightPrice || 0) + (that.orderReqeust.urgentFee || 0)
-          };
+          throw err
         });
     },
     showFreightMsg() {
@@ -510,7 +520,6 @@ export default {
     },
     addressType: function (index) {
       this.shippingType = index
-      this.calcFreightPrice()
     },
     //显示优惠券面板
     toggleMask(type) {
@@ -1026,7 +1035,7 @@ page {
   flex-direction: column;
   margin: 20upx 24upx;
   background: #fff;
-  
+  position: relative;
   .con {
     display: flex;
     align-items: center;
@@ -1045,7 +1054,12 @@ page {
       transform: scaleY(50%);
     }
   }
-  
+  .info {
+    position: absolute;
+    right: 20rpx;
+    bottom: 20rpx;
+    color: red;
+  }
   .left {
     display: flex;
     flex-direction: column;
@@ -1110,6 +1124,28 @@ page {
   }
 }
 
+/* 不可用优惠券置灰样式 */
+.coupon-disabled {
+  opacity: 0.5;
+  pointer-events: none;
+  
+  .title {
+    color: #999 !important;
+  }
+  
+  .time {
+    color: #ccc !important;
+  }
+  
+  .price {
+    color: #999 !important;
+  }
+  
+  .tips {
+    color: #ccc !important;
+  }
+}
+
 .address {
   padding: 36upx 30upx;
   background-color: #FFFFFF;
@@ -1449,8 +1485,8 @@ page {
 
 .photo-item {
   position: relative;
-  width: 120rpx; /* 固定正方形宽度 */
-  height: 120rpx; /* 固定正方形高度 */
+  width: 200rpx; /* 固定正方形宽度 */
+  height: 200rpx; /* 固定正方形高度 */
   margin-bottom: 20rpx; /* 行间距 */
 }
 
@@ -1481,8 +1517,8 @@ page {
 }
 
 .photo-add-btn {
-  width: 120rpx; /* 与photo-item保持一致 */
-  height: 120rpx; /* 与photo-item保持一致 */
+  width: 200rpx; /* 与photo-item保持一致 */
+  height: 200rpx; /* 与photo-item保持一致 */
   margin-bottom: 20rpx; /* 与photo-item保持一致的行间距 */
   border: 2rpx dashed #ccc;
   border-radius: 8rpx;

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 698 - 599
kxmall-app-ui/pages/order/detail.vue


+ 54 - 0
kxmall-rider-ui/main.js

@@ -5,6 +5,9 @@ import * as config from './config'
 
 const baseUrl = config.def().baseUrl
 Vue.config.productionTip = false
+Vue.prototype.$api = {
+  uploadImgByPath,
+};
 
 Vue.prototype.request = function(method, endpoint, token, data = {}) {
   let netWork = ''
@@ -95,6 +98,57 @@ Vue.prototype.dateFtt = function(fmt, date) {
   return fmt;
 }
 
+const uploadImgByPath = (filePath, successCallback, failCallback = undefined) => {
+  userInfo = uni.getStorageSync('userInfo');
+  var accessToken = userInfo ? userInfo.accessToken : '';
+  let baseUrl = config.def().baseUrl
+
+  uni.getImageInfo({
+    src: filePath,
+    success: image => {
+      console.log(image)
+      uni.showLoading({
+        title: '图片上传中',
+        mask: true
+      })
+      uni.uploadFile({
+        url: baseUrl + `/oss/app/upload`,
+        file: image,
+        filePath: image.path,
+        header: {
+          Authorization: 'Bearer ' + accessToken,
+        },
+        name: 'file',
+        success: res => {
+          if (successCallback) {
+            successCallback(JSON.parse(res.data).data.url)
+          }
+        },
+        fail: err => {
+          if (failCallback) {
+            failCallback(err)
+          } else {
+            uni.showToast({
+              title: '上传图片失败',
+              icon: 'none',
+              duration: 2000,
+            })
+          }
+        },
+        complete: res => {
+          uni.hideLoading()
+        },
+      })
+    },
+    fail: err => {
+      uni.showToast({
+        title: '获取图片信息失败',
+        icon: 'none',
+        duration: 2000,
+      })
+    },
+  })
+}
 
 App.mpType = 'app'
 

+ 7 - 5
kxmall-rider-ui/pages.json

@@ -1,11 +1,6 @@
 {
   "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
     {
-      "path": "pages/login/index",
-      "style": {
-        "navigationStyle": "custom"
-      }
-    }, {
       "path": "pages/login/login",
       "style": {
         "navigationStyle": "custom"
@@ -104,6 +99,13 @@
         "navigationBarBackgroundColor": "#FFFFFF",
         "enablePullDownRefresh": true
       }
+    },
+    {
+    	"path" : "pages/task/complete",
+    	"style" : 
+    	{
+    		"navigationBarTitleText" : ""
+    	}
     }
   ],
   "globalStyle": {

+ 111 - 0
kxmall-rider-ui/pages/task/complete.vue

@@ -0,0 +1,111 @@
+<template>
+  <view class="complete-page">
+    <view class="success-container">
+      <image class="success-image" src="/static/task/success.png" mode="widthFix" />
+      <view style="padding-top: 50upx; color: #1c84c6"> 订单已完成,多谢您的付出! </view>
+      
+      <view class="btn-group" style="padding-top: 200upx">
+        <view class="btn btn-primary " @click="goToHome">去首页</view>
+        <view class="btn btn-secondary" @click="uploadImage">去上传图片</view>
+      </view>
+    </view>
+  
+  </view>
+
+
+</template>
+
+<script>
+export default {
+  data() {
+    return {
+      riderOrderId: ''
+    }
+  },
+  onLoad(options) {
+    if (options.id) {
+      this.riderOrderId = options.id
+    }
+  },
+  methods: {
+    // 去首页
+    goToHome() {
+      uni.switchTab({
+        url: '/pages/task/task'
+      })
+    },
+    
+    // 上传图片
+    uploadImage() {
+      if (!this.riderOrderId) {
+        this.$api.msg('订单ID不存在')
+        return
+      }
+      
+      // 跳转到图片上传页面,带上订单ID
+      uni.redirectTo({
+        url: `/pages/order/order?id=${this.riderOrderId}`
+      })
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.complete-page {
+  min-height: 100vh;
+  background-color: #f8f8f8;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: center;
+  padding: 40upx;
+  box-sizing: border-box;
+}
+
+.success-container {
+  flex: 1;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  
+  .success-image {
+    width: 550upx;
+    height: 550upx;
+  }
+}
+
+.button-container {
+  width: 100%;
+  max-width: 600upx;
+}
+
+.btn {
+  flex: 1;
+  height: 88upx;
+  line-height: 88upx;
+  text-align: center;
+  border-radius: 44upx;
+  font-size: 32upx;
+  font-weight: 500;
+  
+  width: 500upx;
+  margin-top: 40upx;
+  margin-bottom: 60upx;
+  
+  &.btn-primary {
+    background-color: #007aff;
+    color: #fff;
+  }
+  
+  &.btn-secondary {
+    background-color: #fff;
+    color: #007aff;
+    border: 2upx solid #007aff;
+  }
+  
+  &:active {
+    opacity: 0.8;
+  }
+}
+</style>

+ 4 - 0
kxmall-rider-ui/pages/task/task.vue

@@ -465,6 +465,10 @@
             }
           })
         }
+        
+        uni.navigateTo({
+          url: `../task/complete?id=${id}`
+        })
       },
 
       // 获取各类任务列表统计数量

BIN
kxmall-rider-ui/static/task/success.png


Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно