Commit 6b2f4c18 by cen Committed by chenwq1

fix: 修改订单类型

1 parent ea45ecf9
......@@ -23,6 +23,8 @@ export default {
methods: {
async getList () {
const params = this.params
let flag = null
let hasStorage = !!(uni && uni.$storage && uni.$storage.get)
// 默认支持所有订单类型
let data = [
{ name: '正常订单', value: '1' },
......@@ -34,9 +36,52 @@ export default {
// 基于门店配置控制是否只允许“正常订单”
try {
const flag = uni?.$storage?.get && uni.$storage.get('createAllGoodsFlag')
// createAllGoodsFlag = 0:只能选择正常订单
if (flag === 0 || flag === '0') {
// 1)优先从本地缓存读取(CreateOrder / EquityCreateOrder 入口会写入)
if (hasStorage) {
const rawFlag = uni.$storage.get('createAllGoodsFlag')
if (rawFlag !== undefined && rawFlag !== null) {
flag = String(rawFlag)
}
}
// 2)本地没有时,实时调轻改/权益配置接口兜底一次(避免先打开弹窗再拿到配置的竞态)
if (flag === null) {
const userInfo = hasStorage ? uni.$storage.get('userInfo') : null
// merchantId 来源:userInfo > 父组件传入的 data(如 orderObj).merchantId > params.merchantId
const merchantId =
(userInfo && (userInfo.shopMerchantId || userInfo.merchantId)) ||
(this.data && this.data.merchantId) ||
(params && params.merchantId)
if (merchantId) {
// 轻改接口
if (uni?.$api?.boutiqueApi?.getShopMerchantPointConfig) {
try {
const res = await uni.$api.boutiqueApi.getShopMerchantPointConfig({ merchantId })
if (res && res.createAllGoodsFlag !== undefined && res.createAllGoodsFlag !== null) {
flag = String(res.createAllGoodsFlag)
uni.$storage.set('createAllGoodsFlag', res.createAllGoodsFlag)
}
} catch (err) {
console.warn('fetch createAllGoodsFlag failed in OrderTypePopup (boutique)', err)
}
}
// 若轻改未返回 createAllGoodsFlag,再试权益接口(同一弹窗可能用于权益页)
if (flag === null && uni?.$api?.equityApi?.getShopMerchantPointConfig) {
try {
const res = await uni.$api.equityApi.getShopMerchantPointConfig({ merchantId })
if (res && res.createAllGoodsFlag !== undefined && res.createAllGoodsFlag !== null) {
flag = String(res.createAllGoodsFlag)
uni.$storage.set('createAllGoodsFlag', res.createAllGoodsFlag)
}
} catch (err) {
console.warn('fetch createAllGoodsFlag failed in OrderTypePopup (equity)', err)
}
}
}
}
// 3)有 flag 且不为 1 时,只允许“正常订单”
if (flag !== null && flag !== '1') {
data = [{ name: '正常订单', value: '1' }]
}
} catch (e) {
......@@ -44,6 +89,8 @@ export default {
console.warn('read createAllGoodsFlag failed', e)
}
// 打开弹窗时输出:当前 createAllGoodsFlag 值、本次展示的订单类型
console.log('[OrderTypePopup] createAllGoodsFlag:', flag, '| 订单类型:', (data || []).map(i => i.name).join('、'))
this.updateParams(params, data || [])
},
initData (list) {
......
const target = ['ip', 'dev', 'uat', 'prod', 'beta']
const index = 2
const index = 1
/**
*
0本地
......
......@@ -947,7 +947,7 @@ export default {
// 单商品
const sellPrice = parseFloat(e.goods.sellPrice || 0)
const number = parseInt(e.goods.number || 1)
const finalPrice = e.goods.finalPrice !== undefined && e.goods.finalPrice !== null && !isNaN(parseFloat(e.goods.finalPrice)) ? parseFloat(e.goods.finalPrice) : this.calculateFinalPrice(e.goods, sellPrice, number, obj.orderTypeCode)
const finalPrice = this.calculateFinalPrice(e.goods, sellPrice, number, obj.orderTypeCode)
const discountFields = this.calculateDiscountFields(e.goods, sellPrice, number, obj.orderTypeCode)
const unitFinalPrice = finalPrice / number
subGoodsList.push({
......@@ -968,7 +968,7 @@ export default {
e.packageGoods.goodsList.forEach(g => {
const sellPrice = parseFloat(g.sellPrice || 0)
const number = parseInt(e.packageGoods.number || 1)
const finalPrice = g.finalPrice !== undefined && g.finalPrice !== null && !isNaN(parseFloat(g.finalPrice)) ? parseFloat(g.finalPrice) : this.calculateFinalPrice(g, sellPrice, number, obj.orderTypeCode)
const finalPrice = this.calculateFinalPrice(g, sellPrice, number, obj.orderTypeCode)
const discountFields = this.calculateDiscountFields(g, sellPrice, number, obj.orderTypeCode)
const unitFinalPrice = finalPrice / number
subGoodsList.push({
......@@ -992,7 +992,7 @@ export default {
const goods = e.multipleSpecificationsGoods.goods
const sellPrice = parseFloat(goods.sellPrice || 0)
const number = parseInt(e.multipleSpecificationsGoods.number || 1)
const finalPrice = goods.finalPrice !== undefined && goods.finalPrice !== null && !isNaN(parseFloat(goods.finalPrice)) ? parseFloat(goods.finalPrice) : this.calculateFinalPrice(goods, sellPrice, number, obj.orderTypeCode)
const finalPrice = this.calculateFinalPrice(goods, sellPrice, number, obj.orderTypeCode)
const discountFields = this.calculateDiscountFields(goods, sellPrice, number, obj.orderTypeCode)
const unitFinalPrice = finalPrice / number
subGoodsList.push({
......
......@@ -686,6 +686,10 @@ export default {
// deliveryCell.hidden = false
// }
}
// 订单类型配置:createAllGoodsFlag = 1 显示全部类型;0 仅正常订单
if (res.createAllGoodsFlag !== undefined && res.createAllGoodsFlag !== null) {
uni.$storage.set('createAllGoodsFlag', res.createAllGoodsFlag)
}
},
// 判断二级流量方
async getSubShopMerchantList (merchantId) {
......
<template>
<view class="detail-box">
<view class="nav-bar">
<view
class="back"
@click="backPage"
>
<uni-icons
type="left"
:size="20"
color="#000"
></uni-icons>
<view class="back" @click="backPage">
<uni-icons type="left" :size="20" color="#000"></uni-icons>
</view>
<view class="title">展业工具</view>
</view>
......@@ -17,23 +10,9 @@
<view class="detail-left">
<view class="common-title">展业</view>
<view class="content">
<image
class="banner"
src="../../../assets/images/common/tool_banner.png"
mode="scaleToFill"
/>
<image class="banner" src="../../../assets/images/common/tool_banner.png" mode="scaleToFill" />
<template v-if="toolComponentName === 'DailyReport'">
<uni-calendar
ref="calendar"
:clearDate="false"
:endDate="endDate"
:showMonth="false"
@monthSwitch="currentMonth = `${$event.year}-${$event.month}`"
@change="currentDate = $event.fulldate"
backgroundColor="transparent"
:selected="selectedDays"
:date="currentDate"
/>
<uni-calendar ref="calendar" :clearDate="false" :endDate="endDate" :showMonth="false" @monthSwitch="currentMonth = `${$event.year}-${$event.month}`" @change="currentDate = $event.fulldate" backgroundColor="transparent" :selected="selectedDays" :date="currentDate" />
</template>
<template v-else-if="toolComponentName === 'WageAppeal'">
<MonthCalendar @confirm="confirmMonth"></MonthCalendar>
......@@ -44,49 +23,24 @@
</view>
</view>
<view class="detail-right">
<component
:is="toolComponentName"
@jump="jump"
:transmission-of-data="transmissionOfData"
:currentDate="currentDate"
:currentMonth="currentMonth"
:lastMonth="lastMonth"
@setCalendarSelected="selectedDays = $event"
:enterType="enterType"
/>
<component :is="toolComponentName" @jump="jump" :transmission-of-data="transmissionOfData" :currentDate="currentDate" :currentMonth="currentMonth" :lastMonth="lastMonth" @setCalendarSelected="selectedDays = $event" :enterType="enterType" />
</view>
</view>
<NoticePopup
ref="notice"
title="重要提示"
text="当前页面暂未保存,是否确认退出"
type="warning"
></NoticePopup>
<NoticePopup ref="notice" title="重要提示" text="当前页面暂未保存,是否确认退出" type="warning"></NoticePopup>
<!-- 学习中心权限弹窗 -->
<StudyPopup :show.sync="showStudyPermissionPopup" title="" :width="848" :height="870" :topImage="require('@/assets/images/common/warning-notice.png')" :topImageWidth="848" :topImageHeight="248" style="overflow: hidden">
<StudyCenterPermissionPopup :lockReason="lockReason" @confirm="handleStudyPermissionConfirm" />
</StudyPopup>
<!-- 异常订单锁单弹窗,样式与车险工具页保持一致 -->
<ErrorOrderPopup
:show.sync="showErrorOrderPopup"
title=""
:width="848"
:height="870"
:topImage="require('@/assets/images/common/warning-notice.png')"
:topImageWidth="848"
:topImageHeight="248"
style="overflow: hidden"
>
<ErrorOrderPopup :show.sync="showErrorOrderPopup" title="" :width="848" :height="870" :topImage="require('@/assets/images/common/warning-notice.png')" :topImageWidth="848" :topImageHeight="248" style="overflow: hidden">
<view>
<view class="error-order-title">异常订单提醒</view>
<view class="error-order-content">存在{{ abnormalOrderCount }} 条异常订单未处理,请尽快处理!</view>
</view>
<template #footer>
<view class="flex justify-between error-order-footer">
<view class="footer-btn sure flex-1" @click="showErrorOrderPopup = false">
好的
</view>
<view class="footer-btn sure flex-1" @click="showErrorOrderPopup = false">好的</view>
</view>
</template>
</ErrorOrderPopup>
......@@ -129,7 +83,7 @@ export default {
MonthCalendar,
ErrorOrderPopup
},
data () {
data() {
return {
toolComponentName: '',
transmissionOfData: null,
......@@ -143,10 +97,10 @@ export default {
// 异常订单锁单弹窗
showErrorOrderPopup: false,
abnormalOrderCount: 0,
enterType: '',
enterType: ''
}
},
onLoad (options) {
onLoad(options) {
if (options.componentName) this.toolComponentName = options.componentName
if (options.currentDate) this.setCurrentDate(options.currentDate)
if (options.enterType) this.enterType = options.enterType
......@@ -167,20 +121,20 @@ export default {
}
})
},
onUnload () {
onUnload() {
uni.$off('showErrorOrderPopup')
},
methods: {
setCurrentDate (currentDate) {
setCurrentDate(currentDate) {
this.currentDate = currentDate
this.currentMonth = dayjs(currentDate).format('YYYY-MM')
},
async entranceClick (item) {
if(this.toolComponentName == item.name) return
async entranceClick(item) {
if (this.toolComponentName == item.name) return
const noInterceptPage = ['DailyReport']
// 原禁止提单inspectionOfProhibitionBill方法被替换getLimitRecord
// if (!noInterceptPage.includes(item.name) && ((await this.checkDailyReport()) || (await this.inspectionOfProhibitionBill()))) return
if (!noInterceptPage.includes(item.name) && ((await this.checkDailyReport()))) return
if (!noInterceptPage.includes(item.name) && (await this.checkDailyReport())) return
// 提示去学习中心弹窗
const res = await this.getLimitRecord()
if (res.lockOrder) {
......@@ -229,11 +183,11 @@ export default {
// 打开弹窗
this.$refs.notice.open()
},
backPage () {
backPage() {
uni.navigateBack()
},
// name:跳转组件名,val:跳转参数
jump (name, val) {
jump(name, val) {
this.toolComponentName = name
console.log(this.toolComponentName, val)
if (val) {
......@@ -254,7 +208,7 @@ export default {
// 确认选择的月份
confirmMonth(month) {
this.lastMonth = month
},
}
}
}
</script>
......@@ -305,8 +259,8 @@ export default {
.error-order-title {
text-align: center;
color: #333333;
font-size: toRpx(40);
font-weight: 500;
font-size: toRpx(40);
font-weight: 500;
}
.error-order-content {
text-align: center;
......@@ -319,7 +273,7 @@ export default {
margin-top: toRpx(64);
margin-bottom: toRpx(48);
width: 100%;
.cancel{
.cancel {
height: toRpx(88);
border-radius: toRpx(64);
opacity: 1;
......@@ -331,7 +285,7 @@ export default {
font-size: toRpx(32);
font-weight: 400;
}
.sure{
.sure {
height: toRpx(88);
border-radius: toRpx(64);
opacity: 1;
......
......@@ -44,5 +44,6 @@ export const STORAGE_OBJECTKEY = {
studyCenterPermission: 'studyCenterPermission',
caseInfo: 'caseInfo',
boutique_YQorderSetting: 'boutique_YQorderSetting',
sessionId:'sessionId'
sessionId: 'sessionId',
createAllGoodsFlag: 'createAllGoodsFlag'
}
......@@ -232,10 +232,11 @@ const decimal = (num, fixed) => {
/** 向上取整,保留 fixed 位小数(默认2位),用于商品价格、总价等 */
const ceilDecimal = (num, fixed = 2) => {
const n = Number(num)
if (isNaN(n)) return 0
if (isNaN(n) || n === 0) return 0
const pow = Math.pow(10, fixed)
// 避免浮点误差导致的边界问题(如 1.005、256.693 等)
return Math.ceil((n + Number.EPSILON) * pow) / pow
// 先乘 pow 再减极小量后 ceil,避免 1.01 等已整步长的数被浮点误差多进一位成 1.02
const tolerance = 1e-10
return Math.ceil((n * pow) - tolerance) / pow
}
const setPrice = price => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!