Commit 6abaf8f2 by 岑成威

fix: 订单拦截

1 parent a10bed0d
...@@ -544,6 +544,14 @@ module.exports = { ...@@ -544,6 +544,14 @@ module.exports = {
getUserScene(data) { getUserScene(data) {
return api.post("dj.api.smartcarlife.scene.config.getUserScene", data); return api.post("dj.api.smartcarlife.scene.config.getUserScene", data);
}, },
/** 保存用户最近选择场景 */
saveUserScene(data) {
return api.post("dj.api.smartcarlife.scene.recent.saveUserScene", data);
},
/** 查询用户最近选择场景 */
getRecentUserScene(data) {
return api.post("dj.api.smartcarlife.scene.recent.getUserScene", data);
},
fetchApiConfig(bucketName, systemSource = "dj") { fetchApiConfig(bucketName, systemSource = "dj") {
return api.post( return api.post(
"dj.api.script.common.aliyun.oss.acs.sts.credentials/1.0.0?bucketName=" + "dj.api.script.common.aliyun.oss.acs.sts.credentials/1.0.0?bucketName=" +
......
...@@ -479,12 +479,18 @@ Component({ ...@@ -479,12 +479,18 @@ Component({
// 过滤选中的商户和员工 // 过滤选中的商户和员工
// let merchantListObj = merchantList. // let merchantListObj = merchantList.
let filter = selesList.find((item) => item.active); let filter = selesList.find((item) => item.active);
let filterMerchant = merchantList.find((item) => item.active); let filterMerchant =
merchantList.find((item) => item.active) || merchantList?.[0];
console.log(filter, "filter"); console.log(filter, "filter");
if (!filter) { if (!filter) {
wx.$util.showToast(subTitle); wx.$util.showToast(subTitle);
return; return;
} }
// 门店必须有值:否则会导致后续商品接口 merchantId 为空
if (!filterMerchant) {
wx.$util.showToast(title || "请选择合作门店");
return;
}
if (form) { if (form) {
this.assignment(type, filter) this.assignment(type, filter)
......
...@@ -94,13 +94,15 @@ Component({ ...@@ -94,13 +94,15 @@ Component({
vinValid: true, vinValid: true,
createAllGoodsFlag: 1, createAllGoodsFlag: 1,
showSceneSelect: false, showSceneSelect: false,
sceneColumns: [] sceneColumns: [],
sceneDefaultIndex: 0
}, },
lifetimes: { lifetimes: {
attached() { async attached() {
this.getEmployee() this.getEmployee()
this.getShopMerchantPointConfig() this.getShopMerchantPointConfig()
await this.prefillRecentScene()
this.getUserSceneList() this.getUserSceneList()
// 没有才走获取档案接口逻辑修改配置,有是必填优先及更高 // 没有才走获取档案接口逻辑修改配置,有是必填优先及更高
// 在createOrderCarQuotationSimple 页面做逻辑判断 // 在createOrderCarQuotationSimple 页面做逻辑判断
...@@ -113,6 +115,28 @@ Component({ ...@@ -113,6 +115,28 @@ Component({
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
async prefillRecentScene() {
const userInfo = wx.$util.getUserInfo() || {}
const thisPage = wx.$router.getPageInstance()
const orderInfo = thisPage?.data?.orderInfo || {}
if (orderInfo?.baseSceneCode) return
try {
const res = await commonApi.getRecentUserScene({
sceneType: String(userInfo.sceneType ?? ''),
phone: userInfo.phone
})
const recent = res?.code == 0 ? res?.data : null
const baseSceneCode = recent?.baseSceneCode || ''
if (!baseSceneCode) return
thisPage.setData({
'orderInfo.baseSceneCode': baseSceneCode,
'orderInfo.sceneType': recent?.sceneType
}, () => {
// recent 场景回显后,主动触发一次商品池刷新(内部会调用 getSelectOrderGoodsList)
thisPage.resetGoods && thisPage.resetGoods()
})
} catch (e) {}
},
getUserSceneList() { getUserSceneList() {
const userInfo = wx.$util.getUserInfo() || {} const userInfo = wx.$util.getUserInfo() || {}
commonApi commonApi
...@@ -122,12 +146,27 @@ Component({ ...@@ -122,12 +146,27 @@ Component({
}) })
.then(res => { .then(res => {
const list = res?.code == 0 && res?.data?.length ? res.data : [] const list = res?.code == 0 && res?.data?.length ? res.data : []
const sceneColumns = list.map(item => ({
...item,
name: item.name || item.staffName
}))
const thisPage = wx.$router.getPageInstance()
const orderInfo = thisPage?.data?.orderInfo || {}
const code = orderInfo?.baseSceneCode || ''
const idx = code
? sceneColumns.findIndex(s => s.baseSceneCode == code)
: 0
const currentScene = code && idx >= 0 ? sceneColumns[idx] : null
this.setData({ this.setData({
sceneColumns: list.map(item => ({ sceneColumns,
...item, sceneDefaultIndex: idx >= 0 ? idx : 0
name: item.name || item.staffName
}))
}) })
if (currentScene) {
thisPage.setData({
'orderInfo.baseSceneName': currentScene.name || '',
'orderInfo.sceneType': currentScene.sceneType
})
}
}) })
.catch(() => { .catch(() => {
this.setData({ this.setData({
...@@ -143,10 +182,19 @@ Component({ ...@@ -143,10 +182,19 @@ Component({
onConfirmSceneSelect(e) { onConfirmSceneSelect(e) {
const scene = e.detail.value || {} const scene = e.detail.value || {}
const thisPage = wx.$router.getPageInstance() const thisPage = wx.$router.getPageInstance()
const userInfo = wx.$util.getUserInfo() || {}
thisPage.setData({ thisPage.setData({
'orderInfo.baseSceneCode': scene.baseSceneCode || '', 'orderInfo.baseSceneCode': scene.baseSceneCode || '',
'orderInfo.baseSceneName': scene.name || scene.staffName || '' 'orderInfo.baseSceneName': scene.name || scene.staffName || ''
}) })
scene.baseSceneCode &&
commonApi
.saveUserScene({
baseSceneCode: scene.baseSceneCode,
sceneType: userInfo.sceneType,
phone: userInfo.phone
})
.catch(() => {})
// 切换场景后,重新按场景拉取可选商品 // 切换场景后,重新按场景拉取可选商品
thisPage.resetGoods && thisPage.resetGoods() thisPage.resetGoods && thisPage.resetGoods()
this.setData({ this.setData({
......
...@@ -88,6 +88,7 @@ ...@@ -88,6 +88,7 @@
title="场景名称" title="场景名称"
bind:cancel="onCloseSceneSelect" bind:cancel="onCloseSceneSelect"
columns="{{ sceneColumns }}" columns="{{ sceneColumns }}"
default-index="{{ sceneDefaultIndex }}"
value-key="name" value-key="name"
bind:confirm="onConfirmSceneSelect" bind:confirm="onConfirmSceneSelect"
/> />
......
...@@ -39,6 +39,39 @@ Component({ ...@@ -39,6 +39,39 @@ Component({
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
async tryClear4logCacheOnce() {
// 某些调试/日志组件会把日志写到 USER_DATA_PATH/4log,文件过大时会触发
// writeFile:fail the maximum size of the file storage limit is exceeded
// 进而导致选图/上传等流程异常。这里做一次兜底清理,不影响正常业务。
if (this.__cleared4logOnce) return
this.__cleared4logOnce = true
const fs = wx.getFileSystemManager()
const baseDir = `${wx.env.USER_DATA_PATH}/4log`
const safeReaddir = dirPath =>
new Promise(resolve => {
fs.readdir({
dirPath,
success: res => resolve(res?.files || []),
fail: () => resolve([])
})
})
const safeUnlink = filePath =>
new Promise(resolve => {
fs.unlink({
filePath,
complete: () => resolve()
})
})
const files = await safeReaddir(baseDir)
if (!files.length) return
// 只删除该目录下的文件(不递归删子目录,避免误删)
await Promise.all(
files.map(name => safeUnlink(`${baseDir}/${name}`))
)
},
noScroll() { }, noScroll() { },
close() { close() {
let thisPage = wx.$router.getPageInstance() let thisPage = wx.$router.getPageInstance()
...@@ -66,37 +99,68 @@ Component({ ...@@ -66,37 +99,68 @@ Component({
}) })
}, },
// 上传付款凭证 // 上传付款凭证
upLoad(event) { async upLoad(event) {
let _this = this let _this = this
let { payVoucherList } = _this.data let { payVoucherList } = _this.data
const { file } = event.detail const { file } = event.detail
let tempFiles = file?.url let tempFiles = file?.url
if (!tempFiles) return wx.$util.showToast('请选择图片')
let imgType = tempFiles.split('.')[1] let imgType = tempFiles.split('.')[1]
let type = imgType == 'unknown' ? 'jpg' : imgType let type = imgType == 'unknown' ? 'jpg' : imgType
wx.getFileSystemManager().readFile({
filePath: tempFiles, //选择图片返回的相对路径 const fs = wx.getFileSystemManager()
encoding: 'base64', //编码格式 const readBase64 = () =>
success(_res) { new Promise((resolve, reject) => {
wx.$util.showLoading('上传中...') fs.readFile({
api filePath: tempFiles,
.uploadImg({ encoding: 'base64',
file: `${type}@${_res.data}` success: res => resolve(res?.data),
}) fail: err => reject(err)
.then(img => { })
wx.$util.hideLoading() })
console.log(img)
let { code, data, message } = img try {
if (code == 0) { wx.$util.showLoading('上传中...')
payVoucherList.push({ url: data }) const base64 = await readBase64()
_this.setData({ const img = await api.uploadImg({
payVoucherList file: `${type}@${base64}`
}) })
} else { wx.$util.hideLoading()
wx.$util.showToast(message) const { code, data, message } = img || {}
} if (code == 0) {
payVoucherList.push({ url: data })
_this.setData({ payVoucherList })
} else {
wx.$util.showToast(message || '上传失败')
}
} catch (err) {
wx.$util.hideLoading()
const msg = err?.errMsg || ''
// 本地存储满:尝试清理日志缓存后重试一次
if (msg.includes('maximum size of the file storage limit is exceeded')) {
await this.tryClear4logCacheOnce()
try {
wx.$util.showLoading('上传中...')
const base64 = await readBase64()
const img = await api.uploadImg({
file: `${type}@${base64}`
}) })
wx.$util.hideLoading()
const { code, data, message } = img || {}
if (code == 0) {
payVoucherList.push({ url: data })
_this.setData({ payVoucherList })
return
}
wx.$util.showToast(message || '上传失败')
return
} catch (err2) {
wx.$util.hideLoading()
}
} }
}) wx.$util.showToast(msg || '读取图片失败,请稍后重试')
}
}, },
// 删除上传 // 删除上传
deletePayVoucher(e) { deletePayVoucher(e) {
......
...@@ -218,6 +218,10 @@ Component({ ...@@ -218,6 +218,10 @@ Component({
{ {
text: '组合付款', text: '组合付款',
value: 5 value: 5
},
{
text: '内部结算',
value: 6
} }
], ],
orderTypeName: '正常订单', orderTypeName: '正常订单',
......
...@@ -21,11 +21,19 @@ const checkRequired = function (obj, formRule) { ...@@ -21,11 +21,19 @@ const checkRequired = function (obj, formRule) {
let item = formRule[attr] let item = formRule[attr]
let requirObj = item.find(k => k.required == true) let requirObj = item.find(k => k.required == true)
let validFn = item.find(k => k.validator) let validFn = item.find(k => k.validator)
if (requirObj && !obj[attr]) { if (requirObj) {
const value = obj[attr]
// 客户来源(salesType)允许数值 0;其他字段沿用原有 !value 判空逻辑
const isEmpty =
attr === 'salesType'
? value === undefined || value === null || value === ''
: !value
if (isEmpty) {
return { return {
...requirObj, ...requirObj,
attr attr
} }
}
} }
if (validFn) { if (validFn) {
let validObj = validFn.validator({}, obj[attr]) let validObj = validFn.validator({}, obj[attr])
......
...@@ -1077,6 +1077,12 @@ Page({ ...@@ -1077,6 +1077,12 @@ Page({
return item; return item;
} }
); );
// 缓存详情返回的“原始”商品列表(后续等按场景拉到商品池后再做一次回显映射)
this._rawDetailVdQuotationGoodsList = wx.$util.deepClone(
tableInfo.vdQuotationGoodsList || []
);
// 标记:等待商品池(selectOrderGoods.list)回来后再做一次回显映射(主要用于多规格商品)
this._pendingEchoFromDetail = true;
wx.hideLoading(); wx.hideLoading();
if (code == 0) { if (code == 0) {
tableInfo.vdQuotationGoodsList = tableInfo.vdQuotationGoodsList.reduce( tableInfo.vdQuotationGoodsList = tableInfo.vdQuotationGoodsList.reduce(
...@@ -1242,6 +1248,11 @@ Page({ ...@@ -1242,6 +1248,11 @@ Page({
// this.getQuotationInfo() // this.getQuotationInfo()
// 判断有没有勾选商品,有的话调用一下 // 判断有没有勾选商品,有的话调用一下
orderInfo.vdQuotationGoodsList.length && this.totalFee(); orderInfo.vdQuotationGoodsList.length && this.totalFee();
// 编辑态:详情回显后如果已有场景编码,则按场景重新拉取商品列表并回显
const { orderInfo: newOrderInfo, id: currentId } = this.data;
if (currentId && newOrderInfo?.baseSceneCode) {
this.getQuotationInfo(true);
}
} }
}) })
.catch((err) => {}); .catch((err) => {});
...@@ -1401,7 +1412,11 @@ Page({ ...@@ -1401,7 +1412,11 @@ Page({
this.setData({ this.setData({
["orderInfo.vdQuotationGoodsList"]: [], ["orderInfo.vdQuotationGoodsList"]: [],
["orderInfo.quotationGoodsInfoList"]: [], ["orderInfo.quotationGoodsInfoList"]: [],
["orderInfo.total"]: "",
}); });
// 切换场景时:清空详情回显缓存,避免商品池回来后把旧商品“重建回显”
this._rawDetailVdQuotationGoodsList = [];
this._pendingEchoFromDetail = false;
const { orderInfo } = this.data const { orderInfo } = this.data
// 未选择场景名称时,不拉取商品列表(对齐精品升级逻辑) // 未选择场景名称时,不拉取商品列表(对齐精品升级逻辑)
if (!orderInfo?.baseSceneCode) return if (!orderInfo?.baseSceneCode) return
...@@ -1575,9 +1590,150 @@ Page({ ...@@ -1575,9 +1590,150 @@ Page({
} }
return ele; return ele;
}); });
this.setData({ this.setData(
quotationGoodsList: data, {
}); quotationGoodsList: data,
},
() => {
// 编辑态:先拿详情、再按场景拉商品池;商品池回来后再把详情里的“原始 vdQuotationGoodsList”
// 映射成前端可渲染结构(尤其是多规格商品需要靠 specificationGoodsMap 做回显)
if (
id &&
this._pendingEchoFromDetail &&
this._rawDetailVdQuotationGoodsList &&
this._rawDetailVdQuotationGoodsList.length
) {
const quotationGoodsList = this.data.quotationGoodsList || [];
const rebuilt = this._rawDetailVdQuotationGoodsList.reduce(
(pre, item) => {
// 普通商品
if (
!item.packageName &&
!item.packageId &&
!item.specificationsValue
) {
let obj = {
...item,
basePrice: undefined,
upgradeGoodsId: item.goodsId,
merchantGoodsId: item.goodsId,
price: item.price,
goodsPrice: item.price,
finalPrice: item.finalPrice,
minSellPrice: quotationGoodsList?.find(
(val) =>
val?.goods?.merchantGoodsId ==
item.goodsId
)?.goods?.minSellPrice,
validMinSellPrice: quotationGoodsList?.find(
(val) =>
val?.goods?.merchantGoodsId ==
item.goodsId
)?.goods?.validMinSellPrice,
};
pre.push({
goodsFlag: 1,
goods: obj,
packageGoods: null,
});
}
// 套餐
if (item.packageName || item.packageId) {
let obj = {
...item,
basePrice: undefined,
upgradeGoodsId: item.goodsId,
upgradeGoodsId: item.goodsId,
price: item.price,
goodsPrice: item.price,
finalPrice: item.finalPrice,
minSellPrice: quotationGoodsList
?.find(
(val) =>
val.packageGoods?.goodsList
?.length &&
val.packageGoods?.packageCode ==
item?.packageId
)
?.packageGoods?.goodsList?.find(
(subV) =>
subV.merchantGoodsId ==
item.goodsId
)?.minSellPrice,
validMinSellPrice: quotationGoodsList
?.find(
(val) =>
val.packageGoods?.goodsList
?.length &&
val.packageGoods?.packageCode ==
item?.packageId
)
?.packageGoods?.goodsList?.find(
(subV) =>
subV.merchantGoodsId ==
item.goodsId
)?.validMinSellPrice,
};
let index = pre.findIndex((ele) => {
if (ele.packageGoods) {
return (
ele.packageGoods.packageId ==
item.packageId
);
}
});
if (index != -1) {
pre[index].packageGoods.goodsList.push(obj);
pre[index].price = NP.plus(
pre[index].price,
obj.price
);
} else {
pre.push({
goods: null,
goodsFlag: 3,
price: item.price,
packageGoods: {
...item,
goodsPrice: item.price,
finalPrice: item.finalPrice,
packageCode: item.packageId,
goodsList: [
{
...obj,
},
],
},
});
}
}
// 多规格商品(靠商品池映射)
if (
!item.packageName &&
!item.packageId &&
item.specificationsValue
) {
let specificdata =
this.handleSpecificationsEcho(item);
pre = pre.concat(specificdata);
}
return pre;
},
[]
);
this._pendingEchoFromDetail = false;
this.setData(
{
["orderInfo.vdQuotationGoodsList"]: rebuilt,
},
() => {
rebuilt.length && this.totalFee();
}
);
}
}
);
// debugger // debugger
setTimeout(() => { setTimeout(() => {
wx.hideLoading(); wx.hideLoading();
......
...@@ -497,7 +497,8 @@ Component({ ...@@ -497,7 +497,8 @@ Component({
2: '打折策略', 2: '打折策略',
3: '买赠策略', 3: '买赠策略',
4: '冲量活动', 4: '冲量活动',
5: '组合付款' 5: '组合付款',
6: '内部结算'
} }
// 1: '审批中', // 1: '审批中',
// 2: '审批中', // 2: '审批中',
......
...@@ -257,7 +257,7 @@ ...@@ -257,7 +257,7 @@
</block> </block>
<block wx:if="{{ !staffUuid&&isOrder }}"> <block wx:if="{{ !staffUuid&&isOrder }}">
<view <view
wx:if="{{ item.orderStatus == '-1' || item.orderStatus == '0' }}" wx:if="{{ item.orderStatus == '0' }}"
class="order-btn" class="order-btn"
bindtap="handleClickBtn" bindtap="handleClickBtn"
data-target="{{ item }}" data-target="{{ item }}"
......
...@@ -68,7 +68,26 @@ Page({ ...@@ -68,7 +68,26 @@ Page({
} }
], ],
showSceneSelect: false, showSceneSelect: false,
sceneColumns: [] sceneColumns: [],
sceneDefaultIndex: 0
},
async prefillRecentScene() {
const userInfo = this.data.userInfo || wx.$util.getUserInfo() || {}
const currentCode = this.data.orderObj?.baseSceneCode || ''
if (currentCode) return
try {
const res = await commonApi.getRecentUserScene({
sceneType: String(userInfo.sceneType ?? ''),
phone: userInfo.phone
})
const recent = res?.code == 0 ? res?.data : null
const baseSceneCode = recent?.baseSceneCode || ''
if (!baseSceneCode) return
this.setData({
'orderObj.baseSceneCode': baseSceneCode,
'orderObj.sceneType': recent?.sceneType
})
} catch (e) {}
}, },
/**设置日期 */ /**设置日期 */
setTimeList(dateNum) { setTimeList(dateNum) {
...@@ -105,10 +124,11 @@ Page({ ...@@ -105,10 +124,11 @@ Page({
this.setTimeList(date) this.setTimeList(date)
}, },
onLoad: function (res) { onLoad: async function (res) {
this.setTimeList() this.setTimeList()
this.handlerUserInfo() this.handlerUserInfo()
this.getGoodsProduct() this.getGoodsProduct()
await this.prefillRecentScene()
this.getUserSceneList() this.getUserSceneList()
}, },
...@@ -155,11 +175,24 @@ Page({ ...@@ -155,11 +175,24 @@ Page({
}) })
.then(res => { .then(res => {
const list = res?.code == 0 && res?.data?.length ? res.data : [] const list = res?.code == 0 && res?.data?.length ? res.data : []
const sceneColumns = list.map(item => ({
...item,
name: item.name || item.staffName
}))
const code = this.data.orderObj?.baseSceneCode || ''
const idx = code
? sceneColumns.findIndex(s => s.baseSceneCode == code)
: 0
const currentScene = code && idx >= 0 ? sceneColumns[idx] : null
this.setData({ this.setData({
sceneColumns: list.map(item => ({ sceneColumns,
...item, sceneDefaultIndex: idx >= 0 ? idx : 0,
name: item.name || item.staffName ...(currentScene
})) ? {
'orderObj.baseSceneName': currentScene.name || '',
'orderObj.sceneType': currentScene.sceneType
}
: {})
}) })
}) })
.catch(() => { .catch(() => {
...@@ -175,12 +208,21 @@ Page({ ...@@ -175,12 +208,21 @@ Page({
}, },
onConfirmSceneSelect(e) { onConfirmSceneSelect(e) {
const scene = e.detail.value || {} const scene = e.detail.value || {}
const userInfo = this.data.userInfo || wx.$util.getUserInfo() || {}
this.setData({ this.setData({
showSceneSelect: false, showSceneSelect: false,
'orderObj.baseSceneCode': scene.baseSceneCode || '', 'orderObj.baseSceneCode': scene.baseSceneCode || '',
'orderObj.baseSceneName': scene.name || scene.staffName || '', 'orderObj.baseSceneName': scene.name || scene.staffName || '',
'orderObj.sceneType': scene.sceneType 'orderObj.sceneType': scene.sceneType
}) })
scene.baseSceneCode &&
commonApi
.saveUserScene({
baseSceneCode: scene.baseSceneCode,
sceneType: userInfo.sceneType,
phone: userInfo.phone
})
.catch(() => {})
}, },
handlerUserInfo() { handlerUserInfo() {
let userInfo = wx.$util.getUserInfo() let userInfo = wx.$util.getUserInfo()
......
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
title="场景名称" title="场景名称"
bind:cancel="onCloseSceneSelect" bind:cancel="onCloseSceneSelect"
columns="{{ sceneColumns }}" columns="{{ sceneColumns }}"
default-index="{{ sceneDefaultIndex }}"
value-key="name" value-key="name"
bind:confirm="onConfirmSceneSelect" bind:confirm="onConfirmSceneSelect"
/> />
......
...@@ -264,7 +264,8 @@ const checkStudyTask = () => { ...@@ -264,7 +264,8 @@ const checkStudyTask = () => {
api.checkStudyTaskAPI().then(res => { api.checkStudyTaskAPI().then(res => {
wx.hideLoading() wx.hideLoading()
const modal = initModal() const modal = initModal()
if (modal && res.data.lockOrder&&res.data?.lockReason !== '2') { const shouldLock = !!res?.data?.lockOrder && res?.data?.lockReason !== '2'
if (modal && shouldLock) {
modal.open({ modal.open({
title: '未完成学习任务,暂不能开单', title: '未完成学习任务,暂不能开单',
type: 'permission', type: 'permission',
...@@ -273,7 +274,7 @@ const checkStudyTask = () => { ...@@ -273,7 +274,7 @@ const checkStudyTask = () => {
res.data?.lockReason == '0' ? '我的课程-待学习' : '我的任务' res.data?.lockReason == '0' ? '我的课程-待学习' : '我的任务'
}) })
} }
resolve(res.data.lockOrder) resolve(shouldLock)
}) })
}) })
} }
......
...@@ -717,7 +717,8 @@ Page({ ...@@ -717,7 +717,8 @@ Page({
2: '打折策略', 2: '打折策略',
3: '买赠策略', 3: '买赠策略',
4: '冲量活动', 4: '冲量活动',
5: '组合付款' 5: '组合付款',
6: '内部结算'
} }
e.djOrderTypeText = djOrderTypeMap[e.djOrderType] || '' e.djOrderTypeText = djOrderTypeMap[e.djOrderType] || ''
......
...@@ -252,7 +252,8 @@ const checkStudyTask = () => { ...@@ -252,7 +252,8 @@ const checkStudyTask = () => {
wx.hideLoading() wx.hideLoading()
const modal = initModal() const modal = initModal()
// res.data.lockOrder = true // res.data.lockOrder = true
if (modal && res.data.lockOrder&&res.data?.lockReason !== '2') { const shouldLock = !!res?.data?.lockOrder && res?.data?.lockReason !== '2'
if (modal && shouldLock) {
modal.open({ modal.open({
title: '未完成学习任务,暂不能开单', title: '未完成学习任务,暂不能开单',
type: 'permission', type: 'permission',
...@@ -261,7 +262,7 @@ const checkStudyTask = () => { ...@@ -261,7 +262,7 @@ const checkStudyTask = () => {
res.data?.lockReason == '0' ? '我的课程-待学习' : '我的任务' res.data?.lockReason == '0' ? '我的课程-待学习' : '我的任务'
}) })
} }
resolve(res.data.lockOrder) resolve(shouldLock)
}) })
}) })
} }
......
...@@ -184,6 +184,11 @@ module.exports = { ...@@ -184,6 +184,11 @@ module.exports = {
return api.post('dj.api.smartcarlife.scene.recent.saveUserScene', data) return api.post('dj.api.smartcarlife.scene.recent.saveUserScene', data)
}, },
/** 查询用户最近选择场景 */
getRecentUserScene(data) {
return api.post('dj.api.smartcarlife.scene.recent.getUserScene', data)
},
/** 根据订单更新技师信息 */ /** 根据订单更新技师信息 */
updateTechnicianInfo(data) { updateTechnicianInfo(data) {
return api.post('dj.api.smartcarlife.order.updateTechnicianInfo', data) return api.post('dj.api.smartcarlife.order.updateTechnicianInfo', data)
......
...@@ -7,7 +7,6 @@ import { checkStudyTask, checkAbnormalOrder } from '~/store/ModalToQueueControl' ...@@ -7,7 +7,6 @@ import { checkStudyTask, checkAbnormalOrder } from '~/store/ModalToQueueControl'
const app = getApp() const app = getApp()
let toastList = { let toastList = {
employeeName: '销售顾问不能为空', employeeName: '销售顾问不能为空',
baseSceneCode: '场景名称不能为空',
subShopMerchantId: '二级流量方不能为空', subShopMerchantId: '二级流量方不能为空',
customerName: '车主姓名不能为空', customerName: '车主姓名不能为空',
customerPhone: '手机号不能为空', customerPhone: '手机号不能为空',
...@@ -38,11 +37,15 @@ Page({ ...@@ -38,11 +37,15 @@ Page({
userInfo: {}, userInfo: {},
showSceneSelect: false, showSceneSelect: false,
sceneColumns: [], sceneColumns: [],
sceneDefaultIndex: 0,
notUpgradeOrderList: [ notUpgradeOrderList: [
{ {
customerName: '', customerName: '',
customerPhone: '', customerPhone: '',
customerSex: 1, customerSex: 1,
baseSceneCode: '',
baseSceneName: '',
sceneType: '',
confirmIndex: false confirmIndex: false
} }
// { // {
...@@ -73,6 +76,81 @@ Page({ ...@@ -73,6 +76,81 @@ Page({
}, },
selectCustomIndex: 0 selectCustomIndex: 0
}, },
async prefillRecentScene() {
const freshUserInfo = wx.$util.getUserInfo() || {}
const userInfo =
(this.data.userInfo && Object.keys(this.data.userInfo).length
? this.data.userInfo
: freshUserInfo) || {}
try {
const res = await api.getRecentUserScene({
sceneType: String(userInfo.sceneType || ''),
phone: userInfo.phone
})
const recent = res?.code == 0 ? res?.data : null
const baseSceneCode = recent?.baseSceneCode || ''
if (!baseSceneCode) return
const list = this.ensureNotUpgradeOrderList()
const next = list.map(item =>
item?.baseSceneCode
? item
: { ...item, baseSceneCode, sceneType: recent?.sceneType }
)
this.setData({
userInfo,
notUpgradeOrderList: next
})
} catch (e) {}
},
ensureNotUpgradeOrderList() {
const list = this.data.notUpgradeOrderList
if (Array.isArray(list)) {
this.__lastValidNotUpgradeOrderList = list
return list
}
const normalized = []
if (list && typeof list === 'object') {
Object.keys(list).forEach(k => {
const item = list[k]
if (item && typeof item === 'object') normalized.push(item)
})
}
// 如果当前值是对象(比如被错误 setData 成了 map),优先从当前值还原,避免丢失最新填写/选择的数据
if (normalized.length) {
this.setData({
notUpgradeOrderList: normalized
})
this.__lastValidNotUpgradeOrderList = normalized
return normalized
}
// 如果曾经有过有效数组,回滚到最近一次有效值,避免“突然变 1 条”
if (Array.isArray(this.__lastValidNotUpgradeOrderList)) {
this.setData({
notUpgradeOrderList: this.__lastValidNotUpgradeOrderList
})
return this.__lastValidNotUpgradeOrderList
}
if (!normalized.length) {
normalized.push({
customerName: '',
customerPhone: '',
customerSex: 1,
baseSceneCode: '',
baseSceneName: '',
sceneType: '',
confirmIndex: false
})
}
this.setData({
notUpgradeOrderList: normalized
})
this.__lastValidNotUpgradeOrderList = normalized
return normalized
},
routerBack() { routerBack() {
wx.$router.back() wx.$router.back()
}, },
...@@ -97,9 +175,12 @@ Page({ ...@@ -97,9 +175,12 @@ Page({
let customer = { let customer = {
customerName: '', customerName: '',
customerPhone: '', customerPhone: '',
customerSex: 1 customerSex: 1,
baseSceneCode: '',
baseSceneName: '',
sceneType: ''
} }
let { notUpgradeOrderList } = this.data let notUpgradeOrderList = this.ensureNotUpgradeOrderList()
notUpgradeOrderList.push(customer) notUpgradeOrderList.push(customer)
this.setData({ this.setData({
notUpgradeOrderList notUpgradeOrderList
...@@ -178,7 +259,7 @@ Page({ ...@@ -178,7 +259,7 @@ Page({
}, },
delBtn(e) { delBtn(e) {
let ind = e.currentTarget.dataset.ind let ind = e.currentTarget.dataset.ind
let { notUpgradeOrderList } = this.data let notUpgradeOrderList = this.ensureNotUpgradeOrderList()
notUpgradeOrderList.splice(ind, 1) notUpgradeOrderList.splice(ind, 1)
this.setData({ this.setData({
...@@ -218,7 +299,8 @@ Page({ ...@@ -218,7 +299,8 @@ Page({
// console.log(e) // console.log(e)
//开始触摸时 重置所有删除 //开始触摸时 重置所有删除
this.data.notUpgradeOrderList.forEach(item => { const notUpgradeOrderList = this.ensureNotUpgradeOrderList()
notUpgradeOrderList.forEach(item => {
item.isTouchMove = false item.isTouchMove = false
item.confirmIndex = false item.confirmIndex = false
}) })
...@@ -226,12 +308,12 @@ Page({ ...@@ -226,12 +308,12 @@ Page({
this.setData({ this.setData({
startX: e.changedTouches[0].clientX, startX: e.changedTouches[0].clientX,
startY: e.changedTouches[0].clientY, startY: e.changedTouches[0].clientY,
notUpgradeOrderList: this.data.notUpgradeOrderList notUpgradeOrderList
}) })
}, },
//滑动事件处理 //滑动事件处理
touchmove: function (e) { touchmove: function (e) {
let { notUpgradeOrderList } = this.data let notUpgradeOrderList = this.ensureNotUpgradeOrderList()
// 为1就不能再删除了 // 为1就不能再删除了
if (notUpgradeOrderList.length == 1) return if (notUpgradeOrderList.length == 1) return
...@@ -288,13 +370,13 @@ Page({ ...@@ -288,13 +370,13 @@ Page({
...(e.detail || {}) ...(e.detail || {})
} }
let { showName, index } = payload let { showName, index } = payload
if (showName === 'showSceneSelect') {
this.getUserSceneList()
}
this.setData({ this.setData({
[showName]: true, [showName]: true,
selectCustomIndex: index selectCustomIndex: index
}) })
if (showName === 'showSceneSelect') {
this.getUserSceneList()
}
}, },
async getUserSceneList() { async getUserSceneList() {
const freshUserInfo = wx.$util.getUserInfo() || {} const freshUserInfo = wx.$util.getUserInfo() || {}
...@@ -313,19 +395,28 @@ Page({ ...@@ -313,19 +395,28 @@ Page({
...item, ...item,
name: item.name || item.staffName name: item.name || item.staffName
})) }))
const { orderObj } = this.data const { notUpgradeOrderList, selectCustomIndex } = this.data
const currentCustomer = notUpgradeOrderList?.[selectCustomIndex] || {}
const currentScene = const currentScene =
orderObj.baseSceneCode && currentCustomer.baseSceneCode &&
sceneColumns.find( sceneColumns.find(
item => item.baseSceneCode == orderObj.baseSceneCode item => item.baseSceneCode == currentCustomer.baseSceneCode
) )
const currentIndex = currentCustomer.baseSceneCode
? sceneColumns.findIndex(
item => item.baseSceneCode == currentCustomer.baseSceneCode
)
: 0
this.setData({ this.setData({
userInfo, userInfo,
sceneColumns, sceneColumns,
sceneDefaultIndex: currentIndex >= 0 ? currentIndex : 0,
...(currentScene ...(currentScene
? { ? {
'orderObj.baseSceneName': currentScene.name || '', [`notUpgradeOrderList[${selectCustomIndex}].baseSceneName`]:
'orderObj.sceneType': currentScene.sceneType currentScene.name || '',
[`notUpgradeOrderList[${selectCustomIndex}].sceneType`]:
currentScene.sceneType
} }
: {}) : {})
}) })
...@@ -344,17 +435,29 @@ Page({ ...@@ -344,17 +435,29 @@ Page({
onConfirmSceneSelect(e) { onConfirmSceneSelect(e) {
const scene = e.detail.value || {} const scene = e.detail.value || {}
const userInfo = this.data.userInfo || wx.$util.getUserInfo() || {} const userInfo = this.data.userInfo || wx.$util.getUserInfo() || {}
const list = this.ensureNotUpgradeOrderList()
const rawIndex = this.data.selectCustomIndex
const selectCustomIndex =
typeof rawIndex === 'number' ? rawIndex : Number(rawIndex)
const safeIndex =
Number.isFinite(selectCustomIndex) && list[selectCustomIndex]
? selectCustomIndex
: 0
this.setData({ this.setData({
showSceneSelect: false, showSceneSelect: false,
'orderObj.baseSceneCode': scene.baseSceneCode || '', [`notUpgradeOrderList[${safeIndex}].baseSceneCode`]:
'orderObj.baseSceneName': scene.name || scene.staffName || '', scene.baseSceneCode || '',
'orderObj.sceneType': scene.sceneType [`notUpgradeOrderList[${safeIndex}].baseSceneName`]:
scene.name || scene.staffName || '',
[`notUpgradeOrderList[${safeIndex}].sceneType`]: scene.sceneType
}, () => {
this.__lastValidNotUpgradeOrderList = this.data.notUpgradeOrderList
}) })
scene.baseSceneCode && scene.baseSceneCode &&
api api
.saveUserScene({ .saveUserScene({
baseSceneCode: scene.baseSceneCode, baseSceneCode: scene.baseSceneCode,
sceneType: scene.sceneType, sceneType: userInfo.sceneType,
phone: userInfo.phone phone: userInfo.phone
}) })
.catch(() => {}) .catch(() => {})
...@@ -364,10 +467,15 @@ Page({ ...@@ -364,10 +467,15 @@ Page({
let { value } = e.detail let { value } = e.detail
let { name, index } = e.currentTarget.dataset let { name, index } = e.currentTarget.dataset
console.log(name, index) console.log(name, index)
if (!notUpgradeOrderList?.[index]?.customerSex) {
notUpgradeOrderList[index].customerSex = 1
}
// [`notUpgradeOrderList.${index}.${name}`]: // [`notUpgradeOrderList.${index}.${name}`]:
notUpgradeOrderList[index][name] = value notUpgradeOrderList[index][name] = value
this.setData({ this.setData({
notUpgradeOrderList notUpgradeOrderList
}, () => {
this.__lastValidNotUpgradeOrderList = this.data.notUpgradeOrderList
}) })
}, },
...@@ -456,7 +564,8 @@ Page({ ...@@ -456,7 +564,8 @@ Page({
if (abnormalOrderCheck) return false if (abnormalOrderCheck) return false
this.checkPhoneUseConfig() this.checkPhoneUseConfig()
let { type } = i.currentTarget.dataset let { type } = i.currentTarget.dataset
let { orderObj, notUpgradeOrderList, dateObj } = this.data let { orderObj, dateObj } = this.data
let notUpgradeOrderList = this.ensureNotUpgradeOrderList()
let key = this.checkRequired(orderObj) let key = this.checkRequired(orderObj)
// debugger // debugger
...@@ -472,6 +581,9 @@ Page({ ...@@ -472,6 +581,9 @@ Page({
if (!notUpgradeOrderList[index].customerName) { if (!notUpgradeOrderList[index].customerName) {
return this.showToast(`请输入第${index + 1}位客户姓名`) return this.showToast(`请输入第${index + 1}位客户姓名`)
} }
if (!notUpgradeOrderList[index].baseSceneCode) {
return this.showToast(`请选择第${index + 1}位客户场景名称`)
}
if (!phoneRex.test(notUpgradeOrderList[index].customerPhone)) { if (!phoneRex.test(notUpgradeOrderList[index].customerPhone)) {
this.showToast(`请输入第${index + 1}位客户正确的手机号`) this.showToast(`请输入第${index + 1}位客户正确的手机号`)
return return
...@@ -489,8 +601,8 @@ Page({ ...@@ -489,8 +601,8 @@ Page({
if (type == 'success') { if (type == 'success') {
orderObj.preliminaryOrders = (notUpgradeOrderList || []).map(item => ({ orderObj.preliminaryOrders = (notUpgradeOrderList || []).map(item => ({
...item, ...item,
baseSceneCode: orderObj.baseSceneCode, baseSceneCode: item.baseSceneCode,
sceneType: orderObj.sceneType sceneType: item.sceneType
})) }))
} else { } else {
orderObj.notUpgradeOrderList = notUpgradeOrderList orderObj.notUpgradeOrderList = notUpgradeOrderList
...@@ -547,7 +659,7 @@ Page({ ...@@ -547,7 +659,7 @@ Page({
// 导入动态校验字段 // 导入动态校验字段
// console.log(requiredList) ...requiredList, // console.log(requiredList) ...requiredList,
let { requiredList } = this.data let { requiredList } = this.data
let target = [...requiredList, 'employeeName', 'baseSceneCode'] let target = [...requiredList, 'employeeName']
try { try {
target.map(key => { target.map(key => {
...@@ -561,7 +673,8 @@ Page({ ...@@ -561,7 +673,8 @@ Page({
return false return false
}, },
checkPhoneUseConfig() { checkPhoneUseConfig() {
let { phoneShow, orderObj, notUpgradeOrderList } = this.data let { phoneShow, orderObj } = this.data
let notUpgradeOrderList = this.ensureNotUpgradeOrderList()
if (phoneShow && orderObj.merchantName && orderObj.employeeName) { if (phoneShow && orderObj.merchantName && orderObj.employeeName) {
// && !orderObj.customer.customerPhone // && !orderObj.customer.customerPhone
// let list = phoneShow.shopMerchantPhoneList // let list = phoneShow.shopMerchantPhoneList
...@@ -641,7 +754,7 @@ Page({ ...@@ -641,7 +754,7 @@ Page({
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (res) { onLoad: async function (res) {
this.setTimeList() this.setTimeList()
console.log(res) console.log(res)
const userInfo = wx.$util.getUserInfo() || {} const userInfo = wx.$util.getUserInfo() || {}
...@@ -649,6 +762,7 @@ Page({ ...@@ -649,6 +762,7 @@ Page({
userInfo userInfo
}) })
res && this.initOPtions(res) res && this.initOPtions(res)
await this.prefillRecentScene()
this.getUserSceneList() this.getUserSceneList()
}, },
/** /**
......
...@@ -59,24 +59,6 @@ ...@@ -59,24 +59,6 @@
</block> </block>
</gl-cell> </gl-cell>
</view> </view>
<view class="baseSceneCode" >
<gl-cell
border
valueAlign="right"
label="场景名称"
requiredAfter
labelWidth="var(--fontSize140)"
required
haveArrow
bindclick="showPopup"
data-show-name="showSceneSelect"
placeholder="点击选择"
>
<block wx:if="{{ orderObj.baseSceneName }}">
<view class="between">{{orderObj.baseSceneName}}</view>
</block>
</gl-cell>
</view>
<view class="subShopMerchantId" wx:if="{{isShowSubShopMerchant}}"> <view class="subShopMerchantId" wx:if="{{isShowSubShopMerchant}}">
<gl-cell <gl-cell
border border
...@@ -157,22 +139,41 @@ ...@@ -157,22 +139,41 @@
data-name="customerName" data-name="customerName"
always-embed></input> always-embed></input>
</gl-cell> </gl-cell>
<view class="baseSceneCode">
<gl-cell
border
valueAlign="right"
label="场景名称"
requiredAfter
labelWidth="var(--fontSize140)"
required
haveArrow
bindclick="showPopup"
data-show-name="showSceneSelect"
data-index="{{ind}}"
placeholder="点击选择"
>
<block wx:if="{{ li.baseSceneName }}">
<view class="between">{{li.baseSceneName}}</view>
</block>
</gl-cell>
</view>
<gl-cell <gl-cell
border border
label="性别" label="性别"
valueAlign="right" valueAlign="right"
labelWidth="var(--fontSize140)"> labelWidth="var(--fontSize140)">
<view class="gender-box"> <view class="gender-box">
<view class="block text-center {{li.customerSex==1?'':'right'}}" /> <view class="block text-center {{(li.customerSex||1)==1?'':'right'}}" />
<view <view
class="male text-center {{li.customerSex == 1?'active':''}}" class="male text-center {{(li.customerSex||1) == 1?'active':''}}"
bindtap="changeGender" bindtap="changeGender"
data-index="{{ind}}" data-index="{{ind}}"
data-gender="1"> data-gender="1">
男 男
</view> </view>
<view <view
class="woman text-center {{li.customerSex == 2?'active':''}}" class="woman text-center {{(li.customerSex||1) == 2?'active':''}}"
bindtap="changeGender" bindtap="changeGender"
data-index="{{ind}}" data-index="{{ind}}"
data-gender="2"> data-gender="2">
...@@ -309,6 +310,7 @@ ...@@ -309,6 +310,7 @@
title="场景名称" title="场景名称"
bind:cancel="onCloseSceneSelect" bind:cancel="onCloseSceneSelect"
columns="{{ sceneColumns }}" columns="{{ sceneColumns }}"
default-index="{{ sceneDefaultIndex }}"
value-key="name" value-key="name"
bind:confirm="onConfirmSceneSelect" bind:confirm="onConfirmSceneSelect"
/> />
......
...@@ -129,6 +129,7 @@ Page({ ...@@ -129,6 +129,7 @@ Page({
isErrorOrder: false, isErrorOrder: false,
isAlreadyExistOrder: false, isAlreadyExistOrder: false,
showTips: false, showTips: false,
sceneDefaultIndex: 0,
associateOrderType: false, associateOrderType: false,
tipsProps: { tipsProps: {
tipsText: '该门店产生异常订单,请点击补录!', tipsText: '该门店产生异常订单,请点击补录!',
...@@ -471,6 +472,29 @@ Page({ ...@@ -471,6 +472,29 @@ Page({
// console.log(type) // console.log(type)
wx.$router.go(`ocr?type=${type}`) wx.$router.go(`ocr?type=${type}`)
}, },
async prefillRecentScene() {
const freshUserInfo = wx.$util.getUserInfo() || {}
const userInfo =
(this.data.userInfo && Object.keys(this.data.userInfo).length
? this.data.userInfo
: freshUserInfo) || {}
const currentCode = this.data.orderObj?.baseSceneCode || ''
if (currentCode) return
try {
const res = await api.getRecentUserScene({
sceneType: String(userInfo.sceneType || ''),
phone: userInfo.phone
})
const recent = res?.code == 0 ? res?.data : null
const baseSceneCode = recent?.baseSceneCode || ''
if (!baseSceneCode) return
this.setData({
userInfo,
'orderObj.baseSceneCode': baseSceneCode,
'orderObj.sceneType': recent?.sceneType
})
} catch (e) {}
},
showPopup(e) { showPopup(e) {
console.log(e) console.log(e)
let { let {
...@@ -533,19 +557,41 @@ Page({ ...@@ -533,19 +557,41 @@ Page({
...item, ...item,
name: item.name || item.staffName name: item.name || item.staffName
})) }))
const currentScene = sceneColumns.find( const currentCode = this.data.orderObj?.baseSceneCode || ''
item => item.baseSceneCode == this.data.orderObj.baseSceneCode const currentIndex = currentCode
? sceneColumns.findIndex(item => item.baseSceneCode == currentCode)
: 0
const currentScene =
currentCode && currentIndex >= 0 ? sceneColumns[currentIndex] : null
this.setData(
{
userInfo,
sceneColumns,
sceneDefaultIndex: currentIndex >= 0 ? currentIndex : 0,
...(currentScene
? {
'orderObj.baseSceneName': currentScene.name || '',
'orderObj.sceneType': currentScene.sceneType
}
: {})
},
() => {
// recent.getUserScene 可能只回 baseSceneCode,sceneType 需要在这里通过列表匹配后才能拿到
const { orderObj } = this.data
if (
currentScene &&
orderObj?.merchantId &&
orderObj?.userId &&
orderObj?.baseSceneCode
) {
this.getOrderBaseGoodsList(orderObj.merchantId, currentScene.sceneType)
this.getSelectOrderGoodsList(
orderObj.merchantId,
currentScene.sceneType
)
}
}
) )
this.setData({
userInfo,
sceneColumns,
...(currentScene
? {
'orderObj.baseSceneName': currentScene.name || '',
'orderObj.sceneType': currentScene.sceneType
}
: {})
})
} catch (e) { } catch (e) {
this.setData({ this.setData({
sceneColumns: [] sceneColumns: []
...@@ -569,6 +615,17 @@ Page({ ...@@ -569,6 +615,17 @@ Page({
'orderObj.userId': last.userId || '', 'orderObj.userId': last.userId || '',
'orderObj.employeeName': last.employeeName || '' 'orderObj.employeeName': last.employeeName || ''
}) })
// 注意:sceneType 需要以“当前选中场景”为准;若 recent 只回 baseSceneCode,则等 getUserSceneList 匹配后再触发
const nextOrderObj = this.data.orderObj || {}
if (nextOrderObj?.merchantId && nextOrderObj?.baseSceneCode) {
// 尝试直接用已存在的 sceneType;没有的话交给 getUserSceneList() 的回调触发
if (nextOrderObj.sceneType !== undefined && nextOrderObj.sceneType !== null && nextOrderObj.sceneType !== '') {
this.getOrderBaseGoodsList(nextOrderObj.merchantId, nextOrderObj.sceneType)
this.getSelectOrderGoodsList(nextOrderObj.merchantId, nextOrderObj.sceneType)
} else {
this.getUserSceneList()
}
}
} catch (e) {} } catch (e) {}
}, },
onCloseSceneSelect() { onCloseSceneSelect() {
...@@ -588,7 +645,7 @@ Page({ ...@@ -588,7 +645,7 @@ Page({
scene.baseSceneCode && scene.baseSceneCode &&
api.saveUserScene({ api.saveUserScene({
baseSceneCode: scene.baseSceneCode, baseSceneCode: scene.baseSceneCode,
sceneType: scene.sceneType, sceneType: userInfo.sceneType,
phone: userInfo.phone phone: userInfo.phone
}).catch(() => {}) }).catch(() => {})
const { orderObj } = this.data const { orderObj } = this.data
...@@ -1242,6 +1299,7 @@ Page({ ...@@ -1242,6 +1299,7 @@ Page({
console.log('setOrderObj', options) console.log('setOrderObj', options)
// debugger // debugger
wx.$util.showLoading('加载中...') wx.$util.showLoading('加载中...')
const prevOrderObj = this.data.orderObj || {}
let orderObj = {} let orderObj = {}
Object.keys(options).map(e => { Object.keys(options).map(e => {
if (options[e] != null && options[e] != undefined) { if (options[e] != null && options[e] != undefined) {
...@@ -1255,6 +1313,24 @@ Page({ ...@@ -1255,6 +1313,24 @@ Page({
} }
}) })
// 保留“进入页面通过 recent.getUserScene 预填”的场景信息,避免选择门店/销售顾问时被覆盖丢失
if (!orderObj.baseSceneCode && prevOrderObj.baseSceneCode) {
orderObj.baseSceneCode = prevOrderObj.baseSceneCode
}
if (!orderObj.baseSceneName && prevOrderObj.baseSceneName) {
orderObj.baseSceneName = prevOrderObj.baseSceneName
}
if (
(orderObj.sceneType === undefined ||
orderObj.sceneType === null ||
orderObj.sceneType === '') &&
prevOrderObj.sceneType !== undefined &&
prevOrderObj.sceneType !== null &&
prevOrderObj.sceneType !== ''
) {
orderObj.sceneType = prevOrderObj.sceneType
}
// 兼容处理 orderType 赋值给 djOrderType // 兼容处理 orderType 赋值给 djOrderType
if (orderObj.djOrderType === undefined || orderObj.djOrderType === null) { if (orderObj.djOrderType === undefined || orderObj.djOrderType === null) {
if (orderObj.orderType !== undefined && orderObj.orderType !== null) { if (orderObj.orderType !== undefined && orderObj.orderType !== null) {
...@@ -1408,7 +1484,7 @@ Page({ ...@@ -1408,7 +1484,7 @@ Page({
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: async function (options) {
// 2:防抖 (Debounce) 处理 // 2:防抖 (Debounce) 处理
// 建议:对于触发价格重算的输入事件(如 inputDiscountValue),引入防抖机制。 // 建议:对于触发价格重算的输入事件(如 inputDiscountValue),引入防抖机制。
// 收益:避免用户快速输入时频繁调用 setGoodsTotal 和 setData,提升输入流畅度。 // 收益:避免用户快速输入时频繁调用 setGoodsTotal 和 setData,提升输入流畅度。
...@@ -1431,6 +1507,7 @@ Page({ ...@@ -1431,6 +1507,7 @@ Page({
if (options.orderCode) { if (options.orderCode) {
this.onRoute(options) this.onRoute(options)
} }
await this.prefillRecentScene()
this.getUserSceneList() this.getUserSceneList()
this.prefillLastSeller() this.prefillLastSeller()
// 添加埋点 // 添加埋点
...@@ -1534,7 +1611,8 @@ Page({ ...@@ -1534,7 +1611,8 @@ Page({
api api
.getSelectOrderGoodsList({ .getSelectOrderGoodsList({
merchantId, merchantId,
sceneType: sceneType ?? 1 sceneType: sceneType ?? 1,
baseSceneCode: orderObj?.baseSceneCode || ''
}) })
.then(result => { .then(result => {
let { code, data, message } = result let { code, data, message } = result
...@@ -1658,6 +1736,7 @@ Page({ ...@@ -1658,6 +1736,7 @@ Page({
.getOrderBaseGoodsList({ .getOrderBaseGoodsList({
merchantId, merchantId,
sceneType, sceneType,
baseSceneCode: orderObj?.baseSceneCode || '',
upradeFlag: selectPayType ? 'N' : 'Y' upradeFlag: selectPayType ? 'N' : 'Y'
}) })
.then(res => { .then(res => {
......
...@@ -891,6 +891,7 @@ value="{{ orderObj.remark }}" ...@@ -891,6 +891,7 @@ value="{{ orderObj.remark }}"
title="场景名称" title="场景名称"
bind:cancel="onCloseSceneSelect" bind:cancel="onCloseSceneSelect"
columns="{{ sceneColumns }}" columns="{{ sceneColumns }}"
default-index="{{ sceneDefaultIndex }}"
value-key="name" value-key="name"
bind:confirm="onConfirmSceneSelect" bind:confirm="onConfirmSceneSelect"
/> />
......
...@@ -55,24 +55,6 @@ ...@@ -55,24 +55,6 @@
</block> </block>
</gl-cell> </gl-cell>
</view> </view>
<view class="baseSceneCode">
<gl-cell
border
valueAlign="right"
label="场景名称"
requiredAfter
labelWidth="var(--fontSize140)"
required
haveArrow
bindclick="showPopup"
data-show-name="showSceneSelect"
placeholder="点击选择"
>
<block wx:if="{{ orderObj.baseSceneName }}">
<view class="between">{{orderObj.baseSceneName}}</view>
</block>
</gl-cell>
</view>
<view class="subShopMerchantId" wx:if="{{ isShowSubShopMerchant }}"> <view class="subShopMerchantId" wx:if="{{ isShowSubShopMerchant }}">
<gl-cell <gl-cell
border border
...@@ -157,6 +139,25 @@ ...@@ -157,6 +139,25 @@
disabled="{{ orderObj.orderSource == 5 }}" disabled="{{ orderObj.orderSource == 5 }}"
></input> ></input>
</gl-cell> </gl-cell>
<view class="baseSceneCode">
<gl-cell
border
valueAlign="right"
label="场景名称"
requiredAfter
labelWidth="var(--fontSize140)"
required
haveArrow
bindclick="showPopup"
data-show-name="showSceneSelect"
data-index="{{ ind }}"
placeholder="点击选择"
>
<block wx:if="{{ li.baseSceneName }}">
<view class="between">{{li.baseSceneName}}</view>
</block>
</gl-cell>
</view>
<gl-cell border label="性别" valueAlign="right" labelWidth="var(--fontSize140)"> <gl-cell border label="性别" valueAlign="right" labelWidth="var(--fontSize140)">
<view class="gender-box"> <view class="gender-box">
<view class="block text-center {{ li.customer.customerSex==1?'':'right' }}" /> <view class="block text-center {{ li.customer.customerSex==1?'':'right' }}" />
...@@ -751,6 +752,7 @@ ...@@ -751,6 +752,7 @@
title="场景名称" title="场景名称"
bind:cancel="onCloseSceneSelect" bind:cancel="onCloseSceneSelect"
columns="{{ sceneColumns }}" columns="{{ sceneColumns }}"
default-index="{{ sceneDefaultIndex }}"
value-key="name" value-key="name"
bind:confirm="onConfirmSceneSelect" bind:confirm="onConfirmSceneSelect"
/> />
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!