Files
lucky_shop/pages_order/list.vue
ZF sun 783c10fc62 refactor: 统一项目内国际化key的命名空间格式
本次提交对全项目的国际化调用进行了规范化重构:
1. 为中文/英文语言包新增了avatar和gender的别名映射,兼容旧有headImg/sex写法
2. 修正了lang.js中的注释路径错误
3. 将所有页面和组件内的$lang调用从短路径改为带业务模块前缀的完整命名空间路径,例如将$lang('title')改为$lang('article.list.title')
4. 优化了i18n-lazy.js的注释说明,补充了正确的key命名格式示例
5. 统一了分销、订单、会员等模块的国际化key层级,确保所有语言调用路径一致
2026-07-04 09:24:35 +08:00

473 lines
15 KiB
Vue

<template>
<view class="order-container" :style="themeColor">
<view class="cate-search">
<view class="search-box">
<input class="uni-input" maxlength="50" v-model="searchText" confirm-type="search"
:placeholder="$lang('order.list.searchPlaceholder')" @confirm="search()" @tap.stop="search()" />
<text class="iconfont icon-sousuo3" @tap.stop="search()"></text>
</view>
</view>
<view class="order-nav" v-if="storeToken">
<view v-for="(statusItem, statusIndex) in statusList" :key="statusIndex" class="uni-tab-item"
:id="statusItem.id" :data-current="statusIndex" @click="ontabtap">
<text class="uni-tab-item-title"
:class="statusItem.status == orderStatus ? 'uni-tab-item-title-active color-base-text' : ''">
{{ $lang('order.list.status.' + statusItem.status, statusItem.name) }}
</text>
</view>
</view>
<!-- #ifdef MP -->
<mescroll-uni ref="mescroll" @getData="getListData" top="176rpx" v-if="storeToken" :style="tabBarPagePaddingStyle">
<!-- #endif -->
<!-- #ifndef MP -->
<mescroll-uni ref="mescroll" @getData="getListData" top="196rpx" v-if="storeToken" :style="tabBarPagePaddingStyle">
<!-- #endif -->
<block slot="list">
<view class="order-list" v-if="orderList.length > 0">
<view class="order-item" v-for="(orderItem, orderIndex) in orderList" :key="orderIndex">
<view class="order-header"
:class="{ waitpay: orderStatus == 'waitpay' && orderItem.order_status == 0 }">
<!-- <view class="iconfont"
:class="$util.inArray(orderItem.order_id, mergePayOrder) == -1 ? 'icon-yuan_checkbox' : 'icon-yuan_checked color-base-text'"
@click="selectOrder(orderItem.order_id, orderItem.pay_money)"
v-if="orderStatus == 'waitpay' && orderItem.order_status == 0"></view> -->
<text class="order-no">{{ $lang('order.list.orderNo') }}{{ orderItem.order_no }}</text>
<text class="order-type-name">{{ orderItem.order_type_name }}</text>
<text class="status-name">{{ orderItem.order_status_name }}</text>
</view>
<view class="order-body" @click="orderDetail(orderItem)">
<block v-if="orderItem.order_goods.length == 1">
<view class="goods-wrap" v-for="(goodsItem, goodsIndex) in orderItem.order_goods"
:key="goodsIndex">
<view class="goods-img">
<image :src="$util.img(goodsItem.sku_image, { size: 'mid' })"
@error="imageError(orderIndex, goodsIndex)" mode="aspectFill"
:lazy-load="true" show-menu-by-longpress/>
</view>
<view class="goods-info">
<view class="pro-info">
<view class="goods-name" v-if="goodsItem.goods_class == 2">{{
goodsItem.goods_name }}</view>
<view class="goods-name" v-else>{{ goodsItem.sku_name }}</view>
<view class="sku" v-if="goodsItem.sku_spec_format">
<view class="goods-spec">
<block v-for="(x, i) in goodsItem.sku_spec_format" :key="i">
{{ x.spec_value_name }}
{{ i < goodsItem.sku_spec_format.length - 1 ? '; ' : '' }}
</block>
</view>
</view>
</view>
<!-- <view class="goods-sub-section">
<text class="goods-price">
<text class="unit price-style small">{{ $lang('common.currencySymbol') }}</text>
<text class="price-style large">{{ parseFloat(goodsItem.price).toFixed(2).split(".")[0] }}</text>
<text class="unit price-style small">.{{ parseFloat(goodsItem.price).toFixed(2).split(".")[1] }}</text>
</text>
<text class="goods-num">
<text class="iconfont icon-close"></text>
{{ goodsItem.num }}
</text>
</view> -->
<view class="goods-action"><!-- <view class="action-btn">加购物车</view> -->
</view>
</view>
</view>
</block>
<block v-else>
<view class="multi-order-goods">
<scroll-view scroll-x="true" class="scroll-view">
<view class="goods-wrap">
<view class="goods-img"
v-for="(goodsItem, goodsIndex) in orderItem.order_goods"
:key="goodsIndex">
<image :src="$util.img(goodsItem.sku_image, { size: 'mid' })"
@error="imageError(orderIndex, goodsIndex)" mode="aspectFill"
:lazy-load="true" show-menu-by-longpress/>
</view>
</view>
</scroll-view>
<view class="shade">
<image :src="$util.img('public/uniapp/order/order-shade.png')" show-menu-by-longpress></image>
</view>
</view>
</block>
</view>
<view class="order-footer">
<view class="order-base-info">
<view class="total">
<text class="font-size-sub">{{ $lang('order.list.totalGoods', { num: orderItem.goods_num }) }}</text>
<text class="align-right font-size-base">
{{ $lang('order.list.actualPayment') }}
<text class="font-size-base price-font">{{ $lang('common.currencySymbol')
}}{{ orderItem.order_money }}</text>
</text>
</view>
</view>
<view class="order-action" v-if="orderItem.action.length > 0">
<view class="order-time" v-if="orderItem.order_status == 0" id="action-date">
<image :src="$util.img('public/uniapp/order/time.png')" show-menu-by-longpress></image>
{{ $lang('order.list.remainingTime') }}
<uni-count-down :day="orderItem.discountTimeMachine.d"
:hour="orderItem.discountTimeMachine.h"
:minute="orderItem.discountTimeMachine.i"
:second="orderItem.discountTimeMachine.s" color="#FF4644"
splitorColor="#FF4644" />
</view>
<view class="order-box-btn"
v-if="evaluateConfig.evaluate_status == 1 && orderItem.is_evaluate == 1"
@click="operation('memberOrderEvaluation', orderItem)">
<text v-if="orderItem.evaluate_status == 0">{{ $lang('order.list.evaluate') }}</text>
<text v-else-if="orderItem.evaluate_status == 1">{{ $lang('order.list.review') }}</text>
</view>
<view class="order-box-btn"
:class="{ 'color-base-border color-base-bg': operationItem.action == 'orderPay' }"
v-for="(operationItem, operationIndex) in orderItem.action"
:key="operationIndex" @click="operation(operationItem.action, orderItem)">
{{ operationItem.title }}
</view>
</view>
<view class="order-action"
v-else-if="orderItem.action.length == 0 && orderItem.is_evaluate == 1 && evaluateConfig.evaluate_status == 1">
<view class="order-box-btn" v-if="orderItem.is_evaluate == 1"
@click="operation('memberOrderEvaluation', orderItem)">
<text v-if="orderItem.evaluate_status == 0">{{ $lang('order.list.evaluate') }}</text>
<text v-else-if="orderItem.evaluate_status == 1">{{ $lang('order.list.review') }}</text>
</view>
</view>
<view class="order-action" v-else>
<view class="order-box-btn" @click="orderDetail(orderItem)">{{ $lang('order.list.viewDetail') }}</view>
</view>
</view>
</view>
</view>
<view v-else><ns-empty :isIndex="false" :text="$lang('order.list.emptyTips')"></ns-empty></view>
</block>
<!--#ifndef MP -->
</mescroll-uni>
<!--#endif -->
<!-- <view class="order-batch-action" :class="{ 'bottom-safe-area': isIphoneX }" v-if="mergePayOrder.length">
<view class="action-btn color-base-text color-base-border" @click="mergePay()">合并付款</view>
</view> -->
<!-- 选择支付方式弹窗 -->
<ns-payment ref="choosePaymentPopup"></ns-payment>
<ns-payment ref="choosePaymentMergePopup"></ns-payment>
<!-- #ifdef MP -->
</mescroll-uni>
<!-- #endif -->
<ns-login ref="login"></ns-login>
<loading-cover ref="loadingCover"></loading-cover>
<!-- 底部tabBar -->
<view id="tab-bar">
<diy-bottom-nav></diy-bottom-nav>
</view>
</view>
</template>
<script>
import orderMethod from './public/js/orderMethod.js';
export default {
data() {
return {
scrollInto: '',
orderStatus: 'all',
statusList: [],
orderList: [],
contentText: {},
mergePayOrder: [],
isIphoneX: false,
evaluateConfig: {
evaluate_audit: 1,
evaluate_show: 0,
evaluate_status: 1
},
orderData: {},
payMoney: 0,
payMoneyMerge: 0,
order_id: 0,
searchText: "",
pageText: "",
payConfig: null,
isTradeManaged: false // 检测微信小程序是否已开通发货信息管理服务
};
},
mixins: [orderMethod],
onLoad(option) {
if (option.status) this.orderStatus = option.status;
if (option.order_id) this.order_id = option.order_id;
},
onShow() {
if (!this.storeToken) {
this.redirectTologinOnShowLifecycle('/pages_order/list?status=' + this.orderStatus);
return;
}
this.isIphoneX = this.$util.uniappIsIPhoneX();
this.getEvaluateConfig();
this.getOrderStatus();
if (this.$refs.mescroll) this.$refs.mescroll.refresh();
},
onUnload() {
if (!this.storeToken && this.$refs.login) this.$refs.login.cancelCompleteInfo();
},
methods: {
ontabtap(e) {
let index = e.target.dataset.current || e.currentTarget.dataset.current;
this.orderStatus = this.statusList[index].status;
if (this.orderStatus == '') this.mergePayOrder = [];
this.$refs.loadingCover.show();
this.$refs.mescroll.refresh();
},
getListData(mescroll) {
this.$api.sendRequest({
url: '/api/order/lists',
data: {
page: mescroll.num,
page_size: mescroll.size,
order_status: this.orderStatus,
order_id: this.order_id,
searchText: this.pageText
},
success: res => {
let newArr = [];
let msg = res.message;
let auto_close = 0
if (res.code == 0 && res.data) {
newArr = res.data.list;
auto_close = res.data.auto_close;
this.payConfig = res.data.pay_config;
this.isTradeManaged = res.data.is_trade_managed;
} else {
this.$util.showToast({
title: msg
});
}
mescroll.endSuccess(newArr.length);
//设置列表数据
if (mescroll.num == 1) {
this.orderList = []; //如果是第一页需手动制空列表
this.order_id = 0
}
this.orderList = this.orderList.concat(newArr); //追加新数据
let date = (Date.parse(new Date())) / 1000
this.orderList.forEach(v => {
v.discountTimeMachine = this.$util.countDown((v.create_time + auto_close) - date);
v.order_goods.forEach(vo => {
if (vo.sku_spec_format) {
try {
vo.sku_spec_format = JSON.parse(vo.sku_spec_format);
} catch (e) {
vo.sku_spec_format = vo.sku_spec_format;
}
} else {
vo.sku_spec_format = [];
}
});
});
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
},
fail: res => {
mescroll.endErr();
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
}
});
},
/**
* 获取订单状态
*/
getOrderStatus() {
this.statusList = [{
status: 'all',
name: this.$lang('order.list.status.all'),
id: 'status_0'
},
{
status: 'waitpay',
name: this.$lang('order.list.status.waitpay'),
id: 'status_1'
},
{
status: 'waitsend',
name: this.$lang('order.list.status.waitsend'),
id: 'status_2'
},
{
status: 'waitconfirm',
name: this.$lang('order.list.status.waitconfirm'),
id: 'status_3'
},
{
status: 'waitrate',
name: this.$lang('order.list.status.waitrate'),
id: 'status_4'
},
/*{
status: 'wait_use',
name: '待使用',
id: 'status_4'
}*/
];
},
operation(action, orderData) {
let index = this.status;
switch (action) {
case 'orderPay': // 支付
this.orderData = orderData;
this.payMoney = parseFloat(orderData.pay_money);
this.orderPay(orderData);
break;
case 'orderClose': //关闭
this.orderClose(orderData.order_id, () => {
this.$refs.mescroll.refresh();
});
break;
case 'memberTakeDelivery': //收货
this.orderData = orderData;
this.orderData.pay_config = {};
this.orderData.pay_config.mch_id = this.payConfig.mch_id;
this.orderData.is_trade_managed = this.isTradeManaged;
this.orderDelivery(this.orderData, () => {
this.$refs.mescroll.refresh();
});
break;
case 'trace': //查看物流
this.$util.redirectTo('/pages_tool/order/logistics', {
order_id: orderData.order_id
});
break;
case 'memberOrderEvaluation': //评价
this.$util.redirectTo('/pages_tool/order/evaluate', {
order_id: orderData.order_id
});
break;
case 'memberVirtualTakeDelivery':
this.orderData = orderData;
this.orderData.pay_config = {};
this.orderData.pay_config.mch_id = this.payConfig.mch_id;
this.orderData.is_trade_managed = this.isTradeManaged;
this.orderVirtualDelivery(this.orderData, () => {
this.$refs.mescroll.refresh();
});
break;
}
},
orderDetail(data) {
switch (parseInt(data.order_type)) {
case 2:
// 自提订单
this.$util.redirectTo('/pages_order/detail_pickup', {
order_id: data.order_id
});
break;
case 3:
// 本地配送订单
this.$util.redirectTo('/pages_order/detail_local_delivery', {
order_id: data.order_id
});
break;
case 4:
// 虚拟订单
this.$util.redirectTo('/pages_tool/order/detail_virtual', {
order_id: data.order_id
});
break;
default:
this.$util.redirectTo('/pages_order/detail', {
order_id: data.order_id
});
break;
}
},
/**
* 选择订单
* @param {Object} orderId
*/
selectOrder(orderId, pay_money) {
if (this.$util.inArray(orderId, this.mergePayOrder) != -1) {
this.mergePayOrder.splice(this.$util.inArray(orderId, this.mergePayOrder), 1);
this.payMoneyMerge -= parseFloat(pay_money);
} else {
this.payMoneyMerge += parseFloat(pay_money);
this.mergePayOrder.push(orderId);
}
},
/**
* 合并支付
*/
mergePay() {
if (this.mergePayOrder.length) {
this.$api.sendRequest({
url: '/api/order/pay',
data: {
order_ids: this.mergePayOrder.toString()
},
success: res => {
if (res.code >= 0) {
this.$refs.choosePaymentMergePopup.getPayInfo(res.data);
} else {
this.$util.showToast({
title: res.message
});
}
}
});
}
},
imageError(orderIndex, goodsIndex) {
this.orderList[orderIndex].order_goods[goodsIndex].sku_image = this.$util.getDefaultImage().goods;
this.$forceUpdate();
},
getEvaluateConfig() {
this.$api.sendRequest({
url: '/api/goodsevaluate/config',
success: res => {
if (res.code == 0) {
var data = res.data;
this.evaluateConfig = data;
}
}
});
},
search() {
this.pageText = this.searchText;
this.$refs.mescroll.refresh();
}
},
computed: {
mpOrderList() {
if (!this.orderList[this.status]) return;
return this.orderList[this.status].list || [];
}
},
watch: {
storeToken: function (nVal, oVal) {
if (nVal) {
this.$refs.mescroll.refresh();
}
}
}
};
</script>
<style lang="scss">
@import './public/css/list.scss';
</style>
<style lang="scss" scoped>
::v-deep .uni-page {
overflow: hidden;
}
::v-deep .mescroll-upwarp {
padding-bottom: 100rpx;
}
</style>