| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- // 权重大的在前面显示 基础是-1在最后
- import i18n from '../i18n';
- const merchantStatusMap = new Map([
- [
- 'NOT_RECEIVED',
- {
- name: i18n.t('dai-shang-jia-jie-dan'),
- sort: 0,
- type: 'merchant',
- nowImgType: 'merchant',
- },
- ],
- [
- 'RECEIVED',
- {
- name: i18n.t('shang-jia-yi-jie-dan'),
- sort: 0,
- type: 'merchant',
- nowImgType: 'merchant',
- },
- ],
- [
- 'REJECTED',
- {
- name: i18n.t('shang-jia-yi-tui-dan'),
- sort: 2,
- type: 'merchant',
- },
- ],
- [
- 'COMPLETED',
- {
- name: i18n.t('yi-wan-cheng'),
- sort: -1,
- type: 'merchant',
- },
- ],
- ]);
- const orderStatusMap = new Map([
- [
- 'UNPAID',
- {
- name: i18n.t('ding-dan-wei-zhi-fu'),
- sort: 1,
- type: 'order',
- },
- ],
- [
- 'PAID',
- {
- name: i18n.t('yong-hu-yi-zhi-fu'),
- sort: -1,
- type: 'order',
- },
- ],
- [
- 'RATED',
- {
- name: i18n.t('dai-ping-jia'),
- sort: 0,
- type: 'order',
- },
- ],
- [
- 'CANCELLED',
- {
- name: i18n.t('ding-dan-yi-qu-xiao'),
- sort: 2,
- type: 'order',
- },
- ],
- [
- 'REFUNDED_PENDING',
- {
- name: i18n.t('shen-qing-tui-kuan-zhong'),
- sort: 2,
- type: 'order',
- isRefund: true,
- },
- ],
- [
- 'REFUNDING',
- {
- name: i18n.t('tui-kuan-zhong'),
- sort: 2,
- type: 'order',
- isRefund: true,
- },
- ],
- [
- 'REFUNDED',
- {
- name: i18n.t('yi-tui-kuan'),
- sort: 2,
- type: 'order',
- isRefund: true,
- },
- ],
- [
- 'COMPLETED',
- {
- name: i18n.t('yi-wan-cheng'),
- sort: 2,
- type: 'order',
- },
- ],
- ]);
- const RiderStatusMap = new Map([
- [
- 'NOT_RECEIVED',
- {
- name: i18n.t('dai-qi-shou-jie-dan'),
- sort: -1,
- type: 'rider',
- },
- ],
- [
- 'RECEIVED',
- {
- name: i18n.t('qi-shou-yi-jie-dan'),
- sort: 1,
- type: 'rider',
- nowImgType: 'rider',
- },
- ],
- [
- 'TAKE_MEAL',
- {
- name: i18n.t('qi-shou-yi-qu-can'),
- sort: 1,
- type: 'rider',
- nowImgType: 'rider',
- },
- ],
- [
- 'MEAL_DELIVERY',
- {
- name: i18n.t('ding-dan-zheng-zai-pei-song-zhong'),
- sort: 1,
- type: 'rider',
- nowImgType: 'rider',
- },
- ],
- [
- 'CARRY_OUT',
- {
- name: i18n.t('ding-dan-yi-song-da'),
- sort: 1,
- type: 'rider',
- },
- ],
- ]);
- const payMap = new Map([
- [
- 'ALI_PAY',
- {
- name: i18n.t('zhi-fu-bao'),
- icon: 'alipay-square',
- iconColor: 'blue500',
- },
- ],
- [
- 'CASH_DELIVERY',
- {
- name: i18n.t('huo-dao-fu-kuan'),
- icon: 'wallet',
- iconColor: 'green500',
- },
- ],
- [
- 'CREDIT_CARD',
- {
- name: i18n.t('xin-yong-ka'),
- icon: 'creditcard',
- iconColor: 'red500',
- },
- ],
- ]);
- function getStatusInfo(orderInfo) {
- const statusList = [];
- if (orderInfo.status) {
- statusList.push(orderStatusMap.get(orderInfo.status));
- }
- if (orderInfo.merchantStatus) {
- statusList.push(merchantStatusMap.get(orderInfo.merchantStatus));
- }
- if (orderInfo.riderStatus) {
- statusList.push(RiderStatusMap.get(orderInfo.riderStatus));
- }
- console.log(statusList);
- if (statusList.length > 0) {
- return statusList.sort((a, b) => {
- return b.sort - a.sort;
- })[0];
- } else {
- return {
- name: i18n.t('ding-dan-xiang-qing'),
- };
- }
- }
- function getGoodsInfo(orderGoodsSpecs) {
- const info = {
- list: orderGoodsSpecs,
- };
- if (orderGoodsSpecs.length > 0) {
- info.num = orderGoodsSpecs.reduce((pre, cur) => {
- return pre + cur.num;
- }, 0);
- info.name = orderGoodsSpecs[0].goods.name;
- }
- return info;
- }
- const reasonMap = new Map([
- ['UNABLE_TO_DELIVER', { name: i18n.t('dang-qian-ding-dan-wu-fa-pei-song') }],
- [
- 'DELIVERY_TIME_IS_TOO_LONG',
- { name: i18n.t('pei-song-shi-jian-tai-chang') },
- ],
- ['ADDRESS_IS_INCORRECT', { name: i18n.t('di-zhi-tian-xie-cuo-wu') }],
- [
- 'MERCHANT_CANNOT_DELIVER',
- { name: i18n.t('shang-jia-wu-fa-song-da-lian-xi-wo-qu-xiao') },
- ],
- [
- 'MERCHANT_OUT_OF_STOCK',
- { name: i18n.t('shang-jia-que-huo-da-yang-lian-xi-wo-qu-xiao') },
- ],
- [
- 'FORGOT_TO_USE_THE_RED_ENVELOPE',
- { name: i18n.t('wang-ji-shi-yong-hong-bao') },
- ],
- ['FORGET_ABOUT_STAPLE_FOOD', { name: i18n.t('wang-dian-zhu-shi') }],
- [
- 'RIDER_CONTACT_ME_TO_CANCEL',
- { name: i18n.t('qi-shou-lian-xi-wo-qu-xiao') },
- ],
- ['MORE_POINTS', { name: i18n.t('dian-duo-le-dian-cuo-le-lou-dian-le') }],
- [
- 'RIDER_CANNOT_REACH_USER',
- { name: i18n.t('lin-shi-you-shi-bu-xiang-yao-le') },
- ],
- ['OTHER', { name: i18n.t('qi-ta-yuan-yin') }],
- ]);
- export {
- merchantStatusMap,
- orderStatusMap,
- RiderStatusMap,
- payMap,
- getStatusInfo,
- getGoodsInfo,
- reasonMap,
- };
|