20260227-1
This commit is contained in:
50
fix_merchant_id2.py
Normal file
50
fix_merchant_id2.py
Normal file
@@ -0,0 +1,50 @@
|
||||
import re
|
||||
|
||||
# Read the file
|
||||
with open('pages/mall/consumer/product-detail.uvue', 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# Find the exact text to replace
|
||||
old_text = '''const selectedItem = {
|
||||
id: this.selectedSkuId,
|
||||
product_id: this.product.id,
|
||||
sku_id: this.selectedSkuId,
|
||||
product_name: this.product.name,
|
||||
product_image: (sku != null && sku.image_url != null) ? sku!.image_url : this.product.images[0],
|
||||
sku_specifications: sku != null ? sku!.specifications : {},
|
||||
price: parseFloat((sku != null ? sku!.price : this.product.price).toString()).toFixed(2) as string,
|
||||
quantity: this.quantity as number
|
||||
}'''
|
||||
|
||||
new_text = '''const selectedItem = {
|
||||
id: this.selectedSkuId,
|
||||
product_id: this.product.id,
|
||||
sku_id: this.selectedSkuId,
|
||||
product_name: this.product.name,
|
||||
product_image: (sku != null && sku.image_url != null) ? sku!.image_url : this.product.images[0],
|
||||
sku_specifications: sku != null ? sku!.specifications : {},
|
||||
price: parseFloat((sku != null ? sku!.price : this.product.price).toString()).toFixed(2) as string,
|
||||
quantity: this.quantity as number,
|
||||
merchant_id: this.product.merchant_id ?? '',
|
||||
shop_id: this.product.merchant_id ?? '',
|
||||
shop_name: this.merchant?.shop_name ?? ''
|
||||
}'''
|
||||
|
||||
if old_text in content:
|
||||
content = content.replace(old_text, new_text)
|
||||
print("Found and replaced!")
|
||||
else:
|
||||
print("Old text not found, trying alternative...")
|
||||
# Try with tab characters
|
||||
old_text_alt = old_text.replace(' ', '\t\t\t')
|
||||
if old_text_alt in content:
|
||||
content = content.replace(old_text_alt, new_text.replace(' ', '\t\t\t'))
|
||||
print("Found with tabs and replaced!")
|
||||
else:
|
||||
print("Still not found")
|
||||
|
||||
# Write back
|
||||
with open('pages/mall/consumer/product-detail.uvue', 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
|
||||
print("Done!")
|
||||
Reference in New Issue
Block a user