| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458 |
- <template>
- <view class="app-main app-content">
- <view class="express-form-container">
- <!-- 订单信息显示 -->
- <view class="order-info-section" v-if="orderInfo">
- <view class="section-title">
- 订单信息
- <button class="admin-button-com mini-btn" @click="goToModifyPage" style="float: right;">修改</button>
- </view>
- <view class="info-item">
- <text class="label">下单客户:</text>
- <text class="value">{{ orderInfo.customName }}</text>
- </view>
- <view class="info-item">
- <text class="label">下单手机:</text>
- <text class="value">{{ orderInfo.bookMobile }}</text>
- </view>
- <view class="info-item">
- <text class="label">订单编号:</text>
- <text class="value">{{ orderInfo.orderSn }}</text>
- </view>
- <view class="info-item">
- <text class="label">收货姓名:</text>
- <text class="value">{{ expressForm.user_name }}</text>
- </view>
- <view class="info-item">
- <text class="label">手机号码:</text>
- <text class="value">{{ expressForm.user_phone }}</text>
- </view>
- <view class="info-item">
- <text class="label">详细地址:</text>
- <view class="value-container">
- <text class="value">{{orderInfo.address}}{{orderInfo.floor}}</text>
- <view v-if="orderInfo.fullAddress!=orderInfo.showAddress && orderInfo.showAddress!=''" class="secondary-address">
- <text style="color:#a7a0a0;">{{ orderInfo.showAddress }}</text>
- </view>
- </view>
- </view>
- </view>
- <!-- 包裹信息 -->
- <view class="form-section">
- <view class="section-title">商品信息</view>
- <view class="form-item">
- <text class="item-label">商品数量</text>
- <view class="item-value">
- <input class="item-input" type="number" v-model="expressForm.packageNum" placeholder="请输入包裹数量" />
- </view>
- </view>
- <view class="form-item required">
- <text class="item-label">商品重量</text>
- <view class="item-value">
- <input class="item-input" type="digit" v-model="expressForm.weight" placeholder="公斤" @focus="expressForm.weight=''" />
- </view>
- </view>
- <view class="form-item">
- <text class="item-label">配送费用</text>
- <view class="item-value">
- <text class="fee-text">¥{{ deliveryFee }}</text>
- </view>
- </view>
- </view>
- <!-- 操作按钮 -->
- <view class="button-section" style="display: flex; justify-content: center; gap: 50rpx;">
- <button class="admin-button-com blue big" @click="queryDeliveryFee">
- 查运费
- </button>
- <button class="admin-button-com blue big" style="padding: 0 30rpx; display: flex; align-items: center; justify-content: center;" @click="submitExpress">提交</button>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { getStoreFee, createExpressOrder } from '@/api/shop-express'
- import { getDetail } from '@/api/order'
- export default {
- name: 'ExpressCreate',
- data() {
- return {
- orderId: '',
- orderInfo: null,
- // 配送表单数据
- expressForm: {
- packageNum: 1,
- price: 0,
- weight:'',
- user_name: '',
- user_phone: '',
- user_lng: 0,
- user_lat: 0,
- user_address: '',
- note: ''
- },
- cargo: {
- name: '',
- price: 0,
- type: 0,
- num: 0,
- },
- // 配送费用
- deliveryFee: 0,
- refreshPage:0
- }
- },
- onLoad(options) {
- if (options.orderId) {
- this.orderId = options.orderId
- }
- //返回上一页时刷新
- let pages = getCurrentPages();
- let prevPage = pages[ pages.length - 2 ];
- prevPage.$vm.refreshPage = 1
- },
- onShow() {
- if(this.orderId){
- this.getOrderDetail()
- } else {
- setTimeout(() => {
- this.getOrderDetail()
- }, 100)
- }
- if(this.refreshPage == 1){
- this.getOrderDetail()
- this.refreshPage = 0
- }
- },
- methods: {
- init(){},
- /**
- * 跳转到修改订单页面
- */
- goToModifyPage() {
- uni.navigateTo({
- url: `/admin/order/modify?id=${this.orderId}`
- })
- },
- /**
- * 获取订单详情
- */
- async getOrderDetail() {
- const res = await getDetail({ id: this.orderId })
- if (res.code === 1) {
- this.orderInfo = res.data
- this.expressForm.weight = res.data.weight?parseFloat(res.data.weight):0
- this.expressForm.price = res.data.prePrice || 0
- // 自动填充收货信息
- this.expressForm.user_name = res.data.receiveUserName || res.data.bookName || ''
- this.expressForm.user_phone = res.data.receiveMobile || res.data.bookMobile || ''
- this.expressForm.user_address = res.data.dist + res.data.address + res.data.floor
- this.expressForm.user_lng = res.data.long || 0
- this.expressForm.user_lat = res.data.lat || 0
- }
- },
- /**
- * 查询配送运费
- */
- async queryDeliveryFee() {
- // 验证必填字段
- if (!this.expressForm.weight || Number(this.expressForm.weight) <= 0) {
- this.$msg('请输入重量')
- return
- }
- if (!this.expressForm.user_name) {
- this.$msg('收货人姓名不能为空')
- return
- }
- if (!this.expressForm.user_phone) {
- this.$msg('收货人手机号不能为空')
- return
- }
- if (!this.expressForm.user_address) {
- this.$msg('收货地址不能为空')
- return
- }
- const data = {
- orderId: this.orderId,
- price: this.expressForm.price,
- weight: Number(this.expressForm.weight),
- packageNum: this.expressForm.packageNum,
- user_name: this.expressForm.user_name,
- user_phone: this.expressForm.user_phone,
- user_address: this.expressForm.user_address,
- user_lng: this.expressForm.user_lng,
- user_lat: this.expressForm.user_lat
- }
- const res = await getStoreFee(data)
- if (res.code === 1) {
- const deliveryFee = res.data.est_fee || '0'
- this.deliveryFee = deliveryFee/100.0
- this.$msg('运费查询成功')
- }
- },
- /**
- * 提交配送订单
- */
- async submitExpress() {
- // 验证必填字段
- if (!this.expressForm.weight || Number(this.expressForm.weight) <= 0) {
- this.$msg('请输入重量')
- return
- }
- if (!this.expressForm.user_name) {
- this.$msg('收货人姓名不能为空')
- return
- }
- if (!this.expressForm.user_phone) {
- this.$msg('收货人手机号不能为空')
- return
- }
- if (!this.expressForm.user_address) {
- this.$msg('收货地址不能为空')
- return
- }
- this.$util.confirmModal({content: '确认呼叫跑腿?'}, async () => {
- const data = {
- orderId: this.orderId,
- weight: Number(this.expressForm.weight),
- packageNum: this.expressForm.packageNum,
- user_name: this.expressForm.user_name,
- user_phone: this.expressForm.user_phone,
- user_address: this.expressForm.user_address,
- user_lng: this.expressForm.user_lng,
- user_lat: this.expressForm.user_lat,
- note: this.expressForm.note
- }
- const res = await createExpressOrder(data)
- if (res.code === 1) {
- this.$msg('提交成功')
- // 返回订单列表页面
- setTimeout(() => {
- uni.navigateBack()
- }, 1500)
- }
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .app-content {
- padding: 20upx;
- background-color: #f5f5f5;
- min-height: 100vh;
- }
- .express-form-container {
- max-width: 750upx;
- margin: 0 auto;
- }
- .order-info-section {
- background: white;
- border-radius: 12upx;
- padding: 30upx;
- margin-bottom: 20upx;
- .info-item {
- display: flex;
- align-items: center;
- margin-bottom: 20upx;
-
- &:last-child {
- margin-bottom: 0;
- }
- .label {
- width: 150upx;
- color: #666;
- font-size: 28upx;
- }
- .value-container {
- flex: 1;
- }
- .value {
- color: black;
- font-size: 28upx;
- }
- .secondary-address {
- margin-top: 10upx;
- font-size: 28upx;
- }
- }
- }
- .form-section {
- background: white;
- border-radius: 12upx;
- padding: 30upx;
- margin-bottom: 20upx;
- }
- .section-title {
- font-size: 32upx;
- font-weight: bold;
- color: #333;
- margin-bottom: 30upx;
- padding-bottom: 20upx;
- border-bottom: 2upx solid #eee;
- }
- .section-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 30upx;
- padding-bottom: 20upx;
- border-bottom: 2upx solid #eee;
- .title {
- font-size: 32upx;
- font-weight: bold;
- color: #333;
- }
- }
- .form-item {
- display: flex;
- align-items: flex-start;
- margin-bottom: 20upx;
-
- &:last-child {
- margin-bottom: 0;
- }
- &.required .item-label::after {
- content: '*';
- color: #ff4d4f;
- margin-left: 4upx;
- }
- .item-label {
- width: 140upx;
- color: #333;
- font-size: 28upx;
- padding-top: 16upx;
- flex-shrink: 0;
- }
- .item-value {
- flex: 1;
- display: flex;
- align-items: center;
- min-height: 80upx;
- .fee-text {
- color: #ff2842;
- font-weight: bold;
- font-size: 36upx;
- line-height: 80upx;
- }
- }
- .item-input {
- width: 100%;
- height: 80upx;
- line-height: 80upx;
- border: 2upx solid #eee;
- border-radius: 8upx;
- padding: 0 20upx;
- font-size: 28upx;
- background: #fff;
- &:focus {
- border-color: #007aff;
- }
- }
- .item-textarea {
- flex: 1;
- max-height: 150upx;
- min-height: 80upx;
- border: 2upx solid #eee;
- border-radius: 8upx;
- padding: 20upx;
- font-size: 28upx;
- background: #fff;
- &.large {
- min-height: 160upx;
- }
- &:focus {
- border-color: #007aff;
- }
- }
- }
- .fee-display {
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 30upx;
- background: #f0f9ff;
- border-radius: 12upx;
- border: 1upx solid #09C567;
- .fee-label {
- font-size: 32upx;
- color: #333;
- font-weight: bold;
- }
- .fee-amount {
- font-size: 36upx;
- color: #ff4d4f;
- font-weight: bold;
- margin-left: 20upx;
- }
- }
- .button-section {
- margin-top: 40upx;
- display: flex;
- gap: 20upx;
- }
- .express-button {
- flex: 1;
- height: 88upx;
- line-height: 88upx;
- border-radius: 12upx;
- font-size: 32upx;
- font-weight: bold;
- border: none;
-
- &.query-button {
- background: #f0f9ff;
- color: #09C567;
- border: 2upx solid #09C567;
- &:disabled {
- background: #f5f5f5;
- color: #ccc;
- border-color: #ddd;
- }
- }
- &.submit-button {
- background: #09C567;
- color: white;
- &:disabled {
- background: #ccc;
- }
- }
- }
- </style>
|