Commit d41c75b0 by chenwq

fix(validReferralCount): 修复编辑页参数传递与数据初始化问题

- 修改导航参数传递方式,使用 JSON.stringify 传递完整对象而非仅 merchantId
- 修复编辑页面数据初始化逻辑,确保组件正确接收更新后的数据
- 修复有效引荐数空值判断逻辑,使用严格相等运算符
- 优化图片上传状态管理,添加加载状态防止重复上传
- 根据提交状态动态设置页面标题(编辑/查看)
1 parent 991ddfcc
...@@ -10,7 +10,7 @@ Component({ ...@@ -10,7 +10,7 @@ Component({
value: {}, value: {},
observer(newVal) { observer(newVal) {
if (newVal) { if (newVal) {
this.initData(newVal) this.initData(this.data.item)
} }
} }
} }
...@@ -25,7 +25,7 @@ Component({ ...@@ -25,7 +25,7 @@ Component({
3: '单延保' 3: '单延保'
}, },
isRemarkRequired: false, isRemarkRequired: false,
fileList: [], // For uploader fileList: [],
fileMaxLen: 15 fileMaxLen: 15
}, },
...@@ -111,7 +111,7 @@ Component({ ...@@ -111,7 +111,7 @@ Component({
let { fileList, fileMaxLen } = _this.data let { fileList, fileMaxLen } = _this.data
getApp().globalData.isChoosingMedia = true getApp().globalData.isChoosingMedia = true
wx.chooseMedia({ wx.chooseMedia({
count: fileMaxLen - fileList.length, count: fileMaxLen - fileList?.length,
sizeType: ['original'], sizeType: ['original'],
mediaType: ['image'], mediaType: ['image'],
complete() { complete() {
...@@ -121,6 +121,9 @@ Component({ ...@@ -121,6 +121,9 @@ Component({
}, },
success(res) { success(res) {
wx.showLoading({ title: '上传中' }) wx.showLoading({ title: '上传中' })
_this.setData({
loadingFlag: true
})
const uploadImages = async tempFiles => { const uploadImages = async tempFiles => {
try { try {
for (const item of tempFiles) { for (const item of tempFiles) {
...@@ -150,9 +153,12 @@ Component({ ...@@ -150,9 +153,12 @@ Component({
} }
} }
} catch (error) { } catch (error) {
wx.showToast({ title: '上传失败,请重试', icon: 'none' }) wx.$util.showToast("上传失败,请重试")
} finally { } finally {
wx.hideLoading() wx.hideLoading()
_this.setData({
loadingFlag: false
})
} }
} }
uploadImages(res?.tempFiles) uploadImages(res?.tempFiles)
...@@ -181,7 +187,6 @@ Component({ ...@@ -181,7 +187,6 @@ Component({
this.updateImageUrls(fileList) this.updateImageUrls(fileList)
}, },
// Sync fileList to item.imageUrls
updateImageUrls(fileList) { updateImageUrls(fileList) {
const urls = fileList.map(file => file.fileUrl).join(',') const urls = fileList.map(file => file.fileUrl).join(',')
this.setData({ this.setData({
...@@ -197,7 +202,7 @@ Component({ ...@@ -197,7 +202,7 @@ Component({
if (effectiveReferralCountDTOS && effectiveReferralCountDTOS.length > 0) { if (effectiveReferralCountDTOS && effectiveReferralCountDTOS.length > 0) {
for (const dto of effectiveReferralCountDTOS) { for (const dto of effectiveReferralCountDTOS) {
const val = dto.effectiveReferralCount const val = dto.effectiveReferralCount
if (val == null || val == undefined || val == '') { if (val == null || val == undefined || val === '') {
wx.showToast({ wx.showToast({
title: `${dto.brandName}交车数有效引荐数未填`, title: `${dto.brandName}交车数有效引荐数未填`,
icon: 'none' icon: 'none'
......
...@@ -16,9 +16,12 @@ Page({ ...@@ -16,9 +16,12 @@ Page({
*/ */
onLoad(options) { onLoad(options) {
this.setData({ this.setData({
routerParams: options routerParams: JSON.parse(options.info)
}); });
console.log(options, 'options----') // 提交状态:0-未提交 1-已提交
wx.setNavigationBarTitle({
title: this.data.routerParams.submitStatus ? '查看门店引荐数' : '编辑门店引荐数'
})
this.getDetail(); this.getDetail();
}, },
...@@ -28,7 +31,7 @@ Page({ ...@@ -28,7 +31,7 @@ Page({
if (item.status == 0) { if (item.status == 0) {
if (item.effectiveReferralCountDTOS && item.effectiveReferralCountDTOS.length) { if (item.effectiveReferralCountDTOS && item.effectiveReferralCountDTOS.length) {
item.effectiveReferralCountDTOS.forEach(k => { item.effectiveReferralCountDTOS.forEach(k => {
k.effectiveReferralCount = k.deliveryCount || '0' k.effectiveReferralCount = (k.deliveryCount || 0) + ''
}) })
} }
} }
......
...@@ -168,8 +168,8 @@ Page({ ...@@ -168,8 +168,8 @@ Page({
console.log(target) console.log(target)
wx.navigateTo({ wx.navigateTo({
url: url:
"/packageWorkspace/pages/validReferralCount/referraCountEdit/referraCountEdit?merchantId=" + "/packageWorkspace/pages/validReferralCount/referraCountEdit/referraCountEdit?info=" +
target.merchantId, JSON.stringify(target),
}); });
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!