20260227-1
This commit is contained in:
28
fix_merchant_id.py
Normal file
28
fix_merchant_id.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import re
|
||||
|
||||
# Read the file
|
||||
with open('pages/mall/consumer/product-detail.uvue', 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# Find and replace the selectedItem object
|
||||
# Looking for the pattern with quantity as the last property
|
||||
old_pattern = r"(const selectedItem = \{[^}]+quantity: this\.quantity as number)\s*\}"
|
||||
|
||||
new_text = r"""\1,
|
||||
merchant_id: this.product.merchant_id ?? '',
|
||||
shop_id: this.product.merchant_id ?? '',
|
||||
shop_name: this.merchant?.shop_name ?? ''
|
||||
}"""
|
||||
|
||||
# Check if pattern exists
|
||||
if 'quantity: this.quantity as number' in content and 'selectedItem' in content:
|
||||
content = re.sub(old_pattern, new_text, content, flags=re.DOTALL)
|
||||
print("Pattern found and replaced!")
|
||||
else:
|
||||
print("Pattern not found!")
|
||||
|
||||
# Write back
|
||||
with open('pages/mall/consumer/product-detail.uvue', 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
|
||||
print("File updated successfully!")
|
||||
Reference in New Issue
Block a user