Browse Source

更新评价页面的图片上传功能

Xfy
徐飞洋 4 weeks ago
parent
commit
c393b0352f
  1. 13
      pages/evaluate2/index.js
  2. 25
      pages/evaluate2/index.wxml
  3. 26
      pages/evaluate2/index.wxss
  4. 7
      pages/evaluate2/spec-detail.js
  5. 21
      pages/evaluate2/spec-detail.wxml

13
pages/evaluate2/index.js

@ -1,6 +1,7 @@
Page({
data: {
productName: '',
category: '',
specifications: [],
loading: false,
error: '',
@ -21,6 +22,7 @@ Page({
},
onLoad(options) {
let productName = '';
let category = '';
// 首先检查URL参数
if (options.productName) {
productName = options.productName;
@ -33,8 +35,14 @@ Page({
}
}
// 获取分类信息
category = wx.getStorageSync('selectedCategory') || '';
if (productName) {
this.setData({ productName: productName });
this.setData({
productName: productName,
category: category
});
this.loadSpecifications(productName);
} else {
// 如果没有商品名称参数,跳转到商品列表页面
@ -472,8 +480,9 @@ Page({
const specItem = e.currentTarget.dataset.spec;
console.log('点击的规格项:', specItem);
console.log('传递的价格:', specItem.finalPriceText);
console.log('传递的分类:', this.data.category);
wx.navigateTo({
url: `/pages/evaluate2/spec-detail?productName=${encodeURIComponent(this.data.productName)}&specification=${encodeURIComponent(specItem.name)}&price=${encodeURIComponent(specItem.finalPriceText)}`
url: `/pages/evaluate2/spec-detail?productName=${encodeURIComponent(this.data.productName)}&specification=${encodeURIComponent(specItem.name)}&price=${encodeURIComponent(specItem.finalPriceText)}&category=${encodeURIComponent(this.data.category)}`
});
});
},

25
pages/evaluate2/index.wxml

@ -1,12 +1,10 @@
<view class="container">
<!-- 头部导航栏 -->
<view class="header">
<view class="header-content" style="display: block; box-sizing: border-box; height: 124rpx; width: 740rpx">
<text class="title">规格选择</text>
</view>
</view>
<view class="content" style="width: 612rpx; height: 1622rpx; display: block; box-sizing: border-box">
<view class="content" style="width: 525rpx; display: flex; box-sizing: content-box">
<!-- 加载中状态 -->
<view wx:if="{{loading}}" class="loading">
<view class="loading-spinner"></view>
@ -24,24 +22,25 @@
</view>
<!-- 商品信息 -->
<view wx:else class="product-card" style="display: block; box-sizing: border-box; width: 525rpx">
<view wx:else class="product-card">
<view class="product-info-container">
<view class="product-info-row">
<text class="product-label">商品名称</text>
<button bindtap="goBackToProductList" class="btn-back" style="width: 172rpx; display: flex; box-sizing: border-box; left: 0rpx; top: 0rpx; height: 87rpx">
<text class="btn-back-icon">←</text>
<view class="product-name-container">
<text class="product-label">商品名称:</text>
<text class="product-name" style="position: relative; left: 20rpx; top: 0rpx; width: 0rpx">{{productName}}</text>
</view>
<button bindtap="goBackToProductList" class="btn-back" style="width: 200rpx; left: 47rpx; top: 1rpx; position: relative">
<text class="btn-back-text">更换商品</text>
</button>
</view>
<text class="product-name">{{productName}}</text>
</view>
</view>
<!-- 规格列表 -->
<view wx:if="{{!loading && !error && specifications.length > 0}}" class="spec-section">
<view class="section-header" style="width: 525rpx; display: flex; box-sizing: border-box; left: 0rpx; top: 0rpx">
<view class="section-header">
<text class="section-title">可用规格</text>
<text class="section-count">{{specifications.length}}个</text>
</view>
<view class="spec-list">
<view
@ -50,7 +49,7 @@
class="spec-item"
data-spec="{{item}}"
bindtap="goToSpecDetail"
style="width: 525rpx; height: 90rpx; display: flex; box-sizing: border-box">
style="width: 612rpx; display: flex; box-sizing: border-box">
<text class="spec-name">{{item.name}}</text>
</view>
</view>
@ -62,7 +61,7 @@
</view>
<!-- 无规格提示 -->
<view wx:if="{{!loading && !error && specifications.length === 0}}" class="empty-state" style="height: 600rpx; display: flex; box-sizing: border-box">
<view wx:if="{{!loading && !error && specifications.length === 0}}" class="empty-state">
<view class="empty-icon">📋</view>
<text class="empty-text">该商品暂无可用规格</text>
<button bindtap="goBackToProductList" class="btn-secondary">返回商品列表</button>

26
pages/evaluate2/index.wxss

@ -29,6 +29,10 @@
.content {
flex: 1;
padding: 16rpx;
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
}
/* 加载状态 */
@ -166,6 +170,8 @@
border-radius: 12rpx;
padding: 32rpx;
margin-bottom: 24rpx;
width: 100%;
max-width: 600rpx;
}
.product-info-container {
@ -182,11 +188,18 @@
box-sizing: border-box;
}
.product-name-container {
display: flex;
align-items: center;
flex: 1;
gap: 8rpx;
}
.product-label {
font-size: 24rpx;
color: #666;
font-weight: 500;
flex: 1;
white-space: nowrap;
}
.product-name {
@ -195,9 +208,8 @@
color: #333;
line-height: 1.4;
word-break: break-word;
margin-top: 12rpx;
padding: 12rpx 0;
border-top: 1rpx solid #e0e0e0;
flex: 1;
text-align: center;
}
/* 规格列表区域 */
@ -211,6 +223,8 @@
align-items: center;
margin-bottom: 24rpx;
padding: 0 8rpx;
width: 100%;
max-width: 600rpx;
}
.section-title {
@ -235,6 +249,8 @@
display: flex;
flex-direction: column;
gap: 16rpx;
width: 100%;
max-width: 600rpx;
}
/* 规格项 */
@ -247,6 +263,8 @@
display: flex;
align-items: center;
justify-content: center;
width: 100%;
max-width: 600rpx;
}
.spec-name {

7
pages/evaluate2/spec-detail.js

@ -1,6 +1,7 @@
Page({
data: {
productName: '',
category: '',
specification: '',
price: 0,
quantity: 1,
@ -12,6 +13,7 @@ Page({
console.log('接收到的参数:', options);
// 即使参数不完整,也要尝试获取并设置
const productName = options.productName ? decodeURIComponent(options.productName) : '';
const category = options.category ? decodeURIComponent(options.category) : '';
const specification = options.specification ? decodeURIComponent(options.specification) : '';
let price = 0;
@ -21,10 +23,11 @@ Page({
price = parseFloat(decodedPrice) || 0;
}
console.log('解析后的参数:', { productName, specification, price });
console.log('解析后的参数:', { productName, category, specification, price });
this.setData({
productName: productName,
category: category,
specification: specification,
price: price,
totalPrice: 0 // 初始时总价为0,不显示
@ -81,6 +84,7 @@ Page({
// 由于spec-detail页面的数据是通过URL参数传递的,这里可以重新获取参数并设置数据
const options = this.options || {};
const productName = options.productName ? decodeURIComponent(options.productName) : '';
const category = options.category ? decodeURIComponent(options.category) : '';
const specification = options.specification ? decodeURIComponent(options.specification) : '';
let price = 0;
@ -91,6 +95,7 @@ Page({
this.setData({
productName: productName,
category: category,
specification: specification,
price: price,
totalPrice: 0 // 初始时总价为0,不显示

21
pages/evaluate2/spec-detail.wxml

@ -1,8 +1,4 @@
<view class="page-container">
<!-- 头部导航栏 -->
<view class="page-header">
<text class="header-title">{{productName || '规格详情'}}</text>
</view>
<!-- 主要内容区域 -->
<view class="main-content">
@ -10,19 +6,24 @@
<view class="info-card">
<text class="card-subtitle">规格信息</text>
<view class="info-row">
<text class="info-label">规格</text>
<text class="info-value">{{specification}}</text>
<text class="info-label">分类</text>
<text class="info-value">{{category}}</text>
</view>
<view class="info-row">
<text class="info-label">单价</text>
<text class="info-value price">¥{{price || 0}}</text>
<text class="info-label">名称</text>
<text class="info-value">{{productName}}</text>
</view>
<view class="info-row">
<text class="info-label">规格</text>
<text class="info-value">{{specification}}</text>
</view>
<text class="info-hint">您已选择此规格进行估价</text>
</view>
<!-- 数量设置卡片 -->
<view class="control-card">
<text class="card-subtitle">数设置</text>
<text class="card-subtitle">数设置</text>
<view class="quantity-box">
<button bindtap="decreaseQuantity" class="quantity-btn minus" style="width: 180rpx; display: flex; box-sizing: border-box; left: 0rpx; top: 0rpx">-</button>
<input style="width: 420rpx; display: block; box-sizing: border-box"
@ -48,7 +49,7 @@
<text class="result-label">预估总价</text>
<text class="result-value">¥{{totalPrice}}</text>
</view>
<text class="result-hint">此价格为预估价格,实际价格可能会有所变动</text>
<text class="result-hint">此价格为预估价格,仅供参考,解释权归又鸟蛋平台,实际价格可能会有所变动</text>
</view>
<!-- 返回按钮 -->

Loading…
Cancel
Save