Browse Source

扩展地区选择功能,添加完整的中国省市区列表

pull/1/head
SwTt29 3 months ago
parent
commit
2a0d89f1e3
  1. 476
      pages/seller/index.js
  2. 66
      pages/seller/index.wxml
  3. 116
      pages/seller/index.wxss

476
pages/seller/index.js

@ -23,17 +23,24 @@ Page({
showYolkSelectModal: false, // 控制蛋黄选择弹窗显示 showYolkSelectModal: false, // 控制蛋黄选择弹窗显示
selectedNameIndex: -1, // 商品名称弹窗中选中的索引 selectedNameIndex: -1, // 商品名称弹窗中选中的索引
selectedYolkIndex: -1,//蛋黄弹窗中选中的索引, selectedYolkIndex: -1,//蛋黄弹窗中选中的索引,
// 商品名称选项列表 // 商品名称选项列表
productNameOptions: ['罗曼粉', '伊莎粉', '罗曼灰', '海蓝灰', '海蓝褐', '绿壳', '粉一', '粉二', '粉八', '京粉1号', '京红', '京粉6号', '京粉3号', '农大系列', '黑鸡土蛋', '双黄蛋', '大午金凤', '黑凤'], productNameOptions: ['罗曼粉', '伊莎粉', '罗曼灰', '海蓝灰', '海蓝褐', '绿壳', '粉一', '粉二', '粉八', '京粉1号', '京红', '京粉6号', '京粉3号', '农大系列', '黑鸡土蛋', '双黄蛋', '大午金凤', '黑凤'],
// 蛋黄选项 // 蛋黄选项
yolkOptions: ['红心', '黄心', '双色'], yolkOptions: ['红心', '黄心', '双色'],
// 规格选项 // 规格选项
specOptions: ['格子装', '散托', '不限规格','净重47+', '净重46-47', '净重45-46', '净重44-45', '净重43-44', '净重42-43', '净重41-42', '净重40-41', '净重39-40', '净重38-39', '净重37-39','净重37-38' , '净重36-38', '净重36-37', '净重35-36', '净重34-35', '净重33-34', '净重32-33', '净重32-34', '净重31-32', '净重30-35', '净重30-34', '净重30-32', '净重30-31', '净重29-31', '净重29-30', '净重28-29', '净重28以下', '毛重52以上', '毛重50-51', '毛重48-49', '毛重47-48', '毛重46-47', '毛重45-47', '毛重45-46', '毛重44-45', '毛重43-44', '毛重42-43', '毛重41-42', '毛重40-41', '毛重38-39', '毛重36-37', '毛重34-35', '毛重32-33', '毛重30-31', '毛重30以下'], specOptions: ['格子装', '散托', '不限规格', '净重47+', '净重46-47', '净重45-46', '净重44-45', '净重43-44', '净重42-43', '净重41-42', '净重40-41', '净重39-40', '净重38-39', '净重37-39', '净重37-38', '净重36-38', '净重36-37', '净重35-36', '净重34-35', '净重33-34', '净重32-33', '净重32-34', '净重31-32', '净重30-35', '净重30-34', '净重30-32', '净重30-31', '净重29-31', '净重29-30', '净重28-29', '净重28以下', '毛重52以上', '毛重50-51', '毛重48-49', '毛重47-48', '毛重46-47', '毛重45-47', '毛重45-46', '毛重44-45', '毛重43-44', '毛重42-43', '毛重41-42', '毛重40-41', '毛重38-39', '毛重36-37', '毛重34-35', '毛重32-33', '毛重30-31', '毛重30以下'],
// 规格搜索相关变量 // 规格搜索相关变量
specSearchKeyword: '', // 创建货源弹窗中的规格搜索关键词 specSearchKeyword: '', // 创建货源弹窗中的规格搜索关键词
editSpecSearchKeyword: '', // 编辑货源弹窗中的规格搜索关键词 editSpecSearchKeyword: '', // 编辑货源弹窗中的规格搜索关键词
filteredSpecOptions: [], // 过滤后的规格选项数组 filteredSpecOptions: [], // 过滤后的规格选项数组
filteredEditSpecOptions: [], // 编辑货源过滤后的规格选项数组 filteredEditSpecOptions: [], // 编辑货源过滤后的规格选项数组
// 地区选择相关变量
showRegionSelectModal: false, // 控制地区选择弹窗显示
currentRegionMode: 'create', // 当前地区选择模式:create 或 edit
regionOptions: ['北京', '上海', '天津', '重庆', '河北', '石家庄', '唐山', '秦皇岛', '邯郸', '邢台', '保定', '张家口', '承德', '沧州', '廊坊', '衡水', '山西', '太原', '大同', '阳泉', '长治', '晋城', '朔州', '晋中', '运城', '忻州', '临汾', '吕梁', '内蒙古', '呼和浩特', '包头', '乌海', '赤峰', '通辽', '鄂尔多斯', '呼伦贝尔', '巴彦淖尔', '乌兰察布', '兴安盟', '锡林郭勒盟', '阿拉善盟', '辽宁', '沈阳', '大连', '鞍山', '抚顺', '本溪', '丹东', '锦州', '营口', '阜新', '辽阳', '盘锦', '铁岭', '朝阳', '葫芦岛', '吉林', '长春', '吉林', '四平', '辽源', '通化', '白山', '松原', '白城', '延边朝鲜族自治州', '黑龙江', '哈尔滨', '齐齐哈尔', '鸡西', '鹤岗', '双鸭山', '大庆', '伊春', '佳木斯', '七台河', '牡丹江', '黑河', '绥化', '大兴安岭地区', '江苏', '南京', '无锡', '徐州', '常州', '苏州', '南通', '连云港', '淮安', '盐城', '扬州', '镇江', '泰州', '宿迁', '浙江', '杭州', '宁波', '温州', '嘉兴', '湖州', '绍兴', '金华', '衢州', '舟山', '台州', '丽水', '安徽', '合肥', '芜湖', '蚌埠', '淮南', '马鞍山', '淮北', '铜陵', '安庆', '黄山', '滁州', '阜阳', '宿州', '六安', '亳州', '池州', '宣城', '福建', '福州', '厦门', '莆田', '三明', '泉州', '漳州', '南平', '龙岩', '宁德', '江西', '南昌', '景德镇', '萍乡', '九江', '新余', '鹰潭', '赣州', '吉安', '宜春', '抚州', '上饶', '山东', '济南', '青岛', '淄博', '枣庄', '东营', '烟台', '潍坊', '济宁', '泰安', '威海', '日照', '临沂', '德州', '聊城', '滨州', '菏泽', '河南', '郑州', '开封', '洛阳', '平顶山', '安阳', '鹤壁', '新乡', '焦作', '濮阳', '许昌', '漯河', '三门峡', '南阳', '商丘', '信阳', '周口', '驻马店', '湖北', '武汉', '黄石', '十堰', '宜昌', '襄阳', '鄂州', '荆门', '孝感', '荆州', '黄冈', '咸宁', '随州', '恩施土家族苗族自治州', '湖南', '长沙', '株洲', '湘潭', '衡阳', '邵阳', '岳阳', '常德', '张家界', '益阳', '郴州', '永州', '怀化', '娄底', '湘西土家族苗族自治州', '广东', '广州', '深圳', '珠海', '汕头', '佛山', '韶关', '湛江', '肇庆', '江门', '茂名', '惠州', '梅州', '汕尾', '河源', '阳江', '清远', '东莞', '中山', '潮州', '揭阳', '云浮', '广西', '南宁', '柳州', '桂林', '梧州', '北海', '防城港', '钦州', '贵港', '玉林', '百色', '贺州', '河池', '来宾', '崇左', '海南', '海口', '三亚', '三沙', '儋州', '四川', '成都', '自贡', '攀枝花', '泸州', '德阳', '绵阳', '广元', '遂宁', '内江', '乐山', '南充', '眉山', '宜宾', '广安', '达州', '雅安', '巴中', '资阳', '阿坝藏族羌族自治州', '甘孜藏族自治州', '凉山彝族自治州', '贵州', '贵阳', '六盘水', '遵义', '安顺', '毕节', '铜仁', '黔西南布依族苗族自治州', '黔东南苗族侗族自治州', '黔南布依族苗族自治州', '云南', '昆明', '曲靖', '玉溪', '保山', '昭通', '丽江', '普洱', '临沧', '楚雄彝族自治州', '红河哈尼族彝族自治州', '文山壮族苗族自治州', '西双版纳傣族自治州', '大理白族自治州', '德宏傣族景颇族自治州', '怒江傈僳族自治州', '迪庆藏族自治州', '西藏', '拉萨', '日喀则', '昌都', '林芝', '山南', '那曲', '阿里', '陕西', '西安', '铜川', '宝鸡', '咸阳', '渭南', '延安', '汉中', '榆林', '安康', '商洛', '甘肃', '兰州', '嘉峪关', '金昌', '白银', '天水', '武威', '张掖', '平凉', '酒泉', '庆阳', '定西', '陇南', '临夏回族自治州', '甘南藏族自治州', '青海', '西宁', '海东', '海北藏族自治州', '黄南藏族自治州', '海南藏族自治州', '果洛藏族自治州', '玉树藏族自治州', '海西蒙古族藏族自治州', '宁夏', '银川', '石嘴山', '吴忠', '固原', '中卫', '新疆', '乌鲁木齐', '克拉玛依', '吐鲁番', '哈密', '阿克苏地区', '喀什地区', '和田地区', '昌吉回族自治州', '博尔塔拉蒙古自治州', '巴音郭楞蒙古自治州', '克孜勒苏柯尔克孜自治州', '伊犁哈萨克自治州', '塔城地区', '阿勒泰地区', '石河子', '阿拉尔', '图木舒克', '五家渠', '北屯', '铁门关', '双河', '可克达拉', '昆玉', '胡杨河', '新星'], // 地区选项列表(包含中国大部分省市区)
regionSearchKeyword: '', // 创建货源弹窗中的地区搜索关键词
editRegionSearchKeyword: '', // 编辑货源弹窗中的地区搜索关键词
filteredRegionOptions: [], // 过滤后的地区选项数组
newSupply: { newSupply: {
name: '', // 品种 name: '', // 品种
price: '', price: '',
@ -47,7 +54,8 @@ Page({
imageUrls: [] // 图片URL数组,支持多张图片 imageUrls: [] // 图片URL数组,支持多张图片
}, },
newSupplyRegionArray: [], // 新创建货源的省市区数组 newSupplyRegionArray: [], // 新创建货源的省市区数组
editSupplyRegionArray: [], // 编辑货源的省市区数组, editSupplyRegionArray: [], // 编辑货源的省市区数组
selectedRegionIndex: -1, // 地区弹窗中选中的地区索引
editSupply: { editSupply: {
yolkIndex: 0, yolkIndex: 0,
specIndex: 0 specIndex: 0
@ -139,7 +147,7 @@ Page({
filteredSpecOptions: this.data.specOptions, filteredSpecOptions: this.data.specOptions,
filteredEditSpecOptions: this.data.specOptions filteredEditSpecOptions: this.data.specOptions
}); });
// 尝试从本地存储加载草稿数据 // 尝试从本地存储加载草稿数据
const draftData = wx.getStorageSync('newSupplyDraft'); const draftData = wx.getStorageSync('newSupplyDraft');
if (draftData) { if (draftData) {
@ -148,7 +156,7 @@ Page({
}); });
console.log('从本地存储加载了草稿数据'); console.log('从本地存储加载了草稿数据');
} }
console.log('卖家页面onLoad执行完毕'); console.log('卖家页面onLoad执行完毕');
}, },
@ -352,7 +360,7 @@ Page({
// 页面不是初次显示,正常加载数据 // 页面不是初次显示,正常加载数据
this.loadSupplies(); this.loadSupplies();
} }
// 更新自定义tabBar状态 // 更新自定义tabBar状态
if (typeof this.getTabBar === 'function' && this.getTabBar()) { if (typeof this.getTabBar === 'function' && this.getTabBar()) {
this.getTabBar().setData({ this.getTabBar().setData({
@ -1175,10 +1183,10 @@ Page({
try { try {
const res = await API.uploadUserInfo(uploadData) const res = await API.uploadUserInfo(uploadData)
console.log('用户信息上传成功:', res) console.log('用户信息上传成功:', res)
// 入驻成功后,将用户类型设置为seller // 入驻成功后,将用户类型设置为seller
API.updateUserType('seller'); API.updateUserType('seller');
return res return res
} catch (err) { } catch (err) {
console.error('用户信息上传失败:', err) console.error('用户信息上传失败:', err)
@ -1236,22 +1244,22 @@ Page({
// 显示添加货源弹窗 // 显示添加货源弹窗
showAddSupply(e) { showAddSupply(e) {
console.log('点击创建新货源按钮'); console.log('点击创建新货源按钮');
// 阻止事件冒泡,防止触发父元素的点击事件 // 阻止事件冒泡,防止触发父元素的点击事件
if (e && e.stopPropagation) { if (e && e.stopPropagation) {
e.stopPropagation(); e.stopPropagation();
} }
// 从本地存储加载之前保存的货源数据 // 从本地存储加载之前保存的货源数据
const savedSupply = wx.getStorageSync('newSupplyDraft') || { name: '', price: '', minOrder: '', yolk: '', spec: '', imageUrls: [] }; const savedSupply = wx.getStorageSync('newSupplyDraft') || { name: '', price: '', minOrder: '', yolk: '', spec: '', imageUrls: [] };
// 直接显示创建货源弹窗,无需登录验证 // 直接显示创建货源弹窗,无需登录验证
this.setData({ this.setData({
showImagePreview: false, showImagePreview: false,
showModal: true, showModal: true,
newSupply: savedSupply newSupply: savedSupply
}); });
// 锁定页面滚动 // 锁定页面滚动
this.disablePageScroll(); this.disablePageScroll();
}, },
@ -1316,7 +1324,7 @@ Page({
const newSupply = this.data.newSupply const newSupply = this.data.newSupply
newSupply[field] = value newSupply[field] = value
this.setData({ newSupply }) this.setData({ newSupply })
// 实时保存到本地存储 // 实时保存到本地存储
wx.setStorageSync('newSupplyDraft', newSupply); wx.setStorageSync('newSupplyDraft', newSupply);
}, },
@ -1338,7 +1346,7 @@ Page({
onNewSupplyRegionChange(e) { onNewSupplyRegionChange(e) {
const regionArray = e.detail.value const regionArray = e.detail.value
const region = regionArray.join(' ') const region = regionArray.join(' ')
this.setData({ this.setData({
newSupplyRegionArray: regionArray, newSupplyRegionArray: regionArray,
newSupply: { newSupply: {
@ -1346,7 +1354,7 @@ Page({
region: region region: region
} }
}) })
// 实时保存到本地存储 // 实时保存到本地存储
wx.setStorageSync('newSupplyDraft', this.data.newSupply); wx.setStorageSync('newSupplyDraft', this.data.newSupply);
}, },
@ -1355,7 +1363,7 @@ Page({
onEditSupplyRegionChange(e) { onEditSupplyRegionChange(e) {
const regionArray = e.detail.value const regionArray = e.detail.value
const region = regionArray.join(' ') const region = regionArray.join(' ')
this.setData({ this.setData({
editSupplyRegionArray: regionArray, editSupplyRegionArray: regionArray,
editSupply: { editSupply: {
@ -1364,7 +1372,7 @@ Page({
} }
}) })
}, },
// 处理蛋黄选择变更 // 处理蛋黄选择变更
onYolkChange(e) { onYolkChange(e) {
const index = e.detail.value const index = e.detail.value
@ -1374,24 +1382,24 @@ Page({
'newSupply.yolk': yolk 'newSupply.yolk': yolk
}) })
}, },
// 处理规格选择变更 - 现在直接打开自定义弹窗 // 处理规格选择变更 - 现在直接打开自定义弹窗
onSpecChange(e) { onSpecChange(e) {
// 由于我们使用自定义弹窗,这个函数现在只需要打开弹窗即可 // 由于我们使用自定义弹窗,这个函数现在只需要打开弹窗即可
this.openSpecSelectModal({ currentTarget: { dataset: { mode: 'create' } } }); this.openSpecSelectModal({ currentTarget: { dataset: { mode: 'create' } } });
}, },
// 处理编辑模式下的蛋黄选择变更 // 处理编辑模式下的蛋黄选择变更
onEditYolkChange(e) { onEditYolkChange(e) {
console.warn('此方法已弃用,请使用openYolkSelectModal替代'); console.warn('此方法已弃用,请使用openYolkSelectModal替代');
}, },
// 处理编辑模式下的规格选择变更 - 现在直接打开自定义弹窗 // 处理编辑模式下的规格选择变更 - 现在直接打开自定义弹窗
onEditSpecChange(e) { onEditSpecChange(e) {
// 由于我们使用自定义弹窗,这个函数现在只需要打开弹窗即可 // 由于我们使用自定义弹窗,这个函数现在只需要打开弹窗即可
this.openSpecSelectModal({ currentTarget: { dataset: { mode: 'edit' } } }); this.openSpecSelectModal({ currentTarget: { dataset: { mode: 'edit' } } });
}, },
// 商品名称选择变化处理 // 商品名称选择变化处理
onNameChange(e) { onNameChange(e) {
const index = e.detail.value const index = e.detail.value
const productName = this.data.productNameOptions[index] const productName = this.data.productNameOptions[index]
@ -1410,7 +1418,7 @@ Page({
const userId = wx.getStorageSync('userId'); const userId = wx.getStorageSync('userId');
const openid = wx.getStorageSync('openid'); const openid = wx.getStorageSync('openid');
const userInfo = wx.getStorageSync('userInfo'); const userInfo = wx.getStorageSync('userInfo');
if (!userId || !openid || !userInfo) { if (!userId || !openid || !userInfo) {
console.log('用户未登录,显示登录提示'); console.log('用户未登录,显示登录提示');
// 登录前保存当前表单数据到本地存储 // 登录前保存当前表单数据到本地存储
@ -1433,7 +1441,7 @@ Page({
}); });
return; return;
} }
const { name, price, minOrder, yolk, spec, region, imageUrls } = this.data.newSupply const { name, price, minOrder, yolk, spec, region, imageUrls } = this.data.newSupply
if (!name || !price || !minOrder || !yolk) { if (!name || !price || !minOrder || !yolk) {
wx.showToast({ title: '请填写完整信息', icon: 'none', duration: 2000 }) wx.showToast({ title: '请填写完整信息', icon: 'none', duration: 2000 })
@ -1448,22 +1456,22 @@ Page({
.then(response => { .then(response => {
const userInfoRes = response.data; const userInfoRes = response.data;
console.log('获取用户信息成功:', userInfoRes) console.log('获取用户信息成功:', userInfoRes)
// 检查partnerstatus字段 // 检查partnerstatus字段
const partnerStatus = userInfoRes.partnerstatus || 'pending' const partnerStatus = userInfoRes.partnerstatus || 'pending'
console.log('用户合作状态:', partnerStatus) console.log('用户合作状态:', partnerStatus)
if (partnerStatus !== 'approved') { if (partnerStatus !== 'approved') {
throw new Error('partnerstatus_not_approved') throw new Error('partnerstatus_not_approved')
} }
// 第一步:先创建商品(不带图片) // 第一步:先创建商品(不带图片)
const productData = { const productData = {
productName: name, productName: name,
price: price, // 保留原始字符串,不进行数字转换 price: price, // 保留原始字符串,不进行数字转换
quantity: Number(minOrder), quantity: Number(minOrder),
grossWeight: this.data.newSupply.grossWeight && this.data.newSupply.grossWeight !== '' ? this.data.newSupply.grossWeight : "", grossWeight: this.data.newSupply.grossWeight && this.data.newSupply.grossWeight !== '' ? this.data.newSupply.grossWeight : "",
yolk: yolk, yolk: yolk,
specification: spec || '', specification: spec || '',
region: region || '', // 【新增】添加地区字段 region: region || '', // 【新增】添加地区字段
@ -1472,7 +1480,7 @@ Page({
} }
console.log('第一步:准备创建商品,数据:', productData) console.log('第一步:准备创建商品,数据:', productData)
// 更新加载提示 // 更新加载提示
wx.showLoading({ title: '正在创建商品...', mask: true }) wx.showLoading({ title: '正在创建商品...', mask: true })
@ -1519,10 +1527,10 @@ Page({
showModal: false, showModal: false,
newSupply: { name: '', price: '', minOrder: '', yolk: '', spec: '', imageUrls: [] } newSupply: { name: '', price: '', minOrder: '', yolk: '', spec: '', imageUrls: [] }
}) })
// 清除本地存储的草稿数据 // 清除本地存储的草稿数据
wx.removeStorageSync('newSupplyDraft'); wx.removeStorageSync('newSupplyDraft');
this.enablePageScroll() this.enablePageScroll()
// 重新加载数据 // 重新加载数据
@ -1785,106 +1793,106 @@ Page({
return Promise.reject(err); return Promise.reject(err);
}) })
.then(() => { .then(() => {
// 【关键修复】准备商品数据 - 确保包含地区字段 // 【关键修复】准备商品数据 - 确保包含地区字段
const productData = { const productData = {
productName: editSupply.name, productName: editSupply.name,
price: editSupply.price, // 保留原始字符串,不进行数字转换 price: editSupply.price, // 保留原始字符串,不进行数字转换
quantity: Number(editSupply.minOrder), quantity: Number(editSupply.minOrder),
grossWeight: editSupply.grossWeight !== undefined && editSupply.grossWeight !== null && editSupply.grossWeight !== '' ? editSupply.grossWeight : "", grossWeight: editSupply.grossWeight !== undefined && editSupply.grossWeight !== null && editSupply.grossWeight !== '' ? editSupply.grossWeight : "",
yolk: editSupply.yolk, yolk: editSupply.yolk,
specification: editSupply.spec || '', specification: editSupply.spec || '',
region: editSupply.region || '', // 【重要】确保地区字段传递 region: editSupply.region || '', // 【重要】确保地区字段传递
imageUrls: editSupply.imageUrls || [], imageUrls: editSupply.imageUrls || [],
created_at: new Date().toISOString(), created_at: new Date().toISOString(),
status: autoPublishAfterEdit ? 'pending_review' : '' status: autoPublishAfterEdit ? 'pending_review' : ''
}; };
console.log('【调试】准备提交的商品数据:', { console.log('【调试】准备提交的商品数据:', {
productData: productData, productData: productData,
hasRegion: !!productData.region, hasRegion: !!productData.region,
regionValue: productData.region regionValue: productData.region
}); });
// 判断是编辑现有商品还是创建新商品
if (editSupply.serverProductId) {
// 编辑现有商品
productData.productId = editSupply.serverProductId;
console.log('【调试】调用API.editProduct,商品ID:', editSupply.serverProductId);
// 【关键修复】使用正确的API调用格式 // 判断是编辑现有商品还是创建新商品
const requestData = { if (editSupply.serverProductId) {
openid: openid, // 编辑现有商品
productId: editSupply.serverProductId, productData.productId = editSupply.serverProductId;
product: {
productName: productData.productName, console.log('【调试】调用API.editProduct,商品ID:', editSupply.serverProductId);
price: productData.price,
quantity: productData.quantity, // 【关键修复】使用正确的API调用格式
grossWeight: productData.grossWeight, const requestData = {
yolk: productData.yolk, openid: openid,
specification: productData.specification, productId: editSupply.serverProductId,
region: productData.region, // 【重要】确保在product对象中传递地区字段 product: {
imageUrls: productData.imageUrls productName: productData.productName,
}, price: productData.price,
status: productData.status || '' quantity: productData.quantity,
}; grossWeight: productData.grossWeight,
yolk: productData.yolk,
specification: productData.specification,
region: productData.region, // 【重要】确保在product对象中传递地区字段
imageUrls: productData.imageUrls
},
status: productData.status || ''
};
console.log('【调试】最终发送的请求数据:', requestData); console.log('【调试】最终发送的请求数据:', requestData);
// 直接使用wx.request调用,避免API封装层的问题 // 直接使用wx.request调用,避免API封装层的问题
wx.request({ wx.request({
url: API.BASE_URL + '/api/product/edit', url: API.BASE_URL + '/api/product/edit',
method: 'POST', method: 'POST',
data: requestData, data: requestData,
success: (res) => { success: (res) => {
console.log('【调试】编辑商品成功响应:', res); console.log('【调试】编辑商品成功响应:', res);
wx.hideLoading(); wx.hideLoading();
this.setData({ showEditModal: false }); this.setData({ showEditModal: false });
this.enablePageScroll(); this.enablePageScroll();
wx.showToast({ title: '更新成功', duration: 2000 }); wx.showToast({ title: '更新成功', duration: 2000 });
// 重新加载数据 // 重新加载数据
setTimeout(() => { setTimeout(() => {
this.loadSupplies(); this.loadSupplies();
}, 100); }, 100);
}, },
fail: (err) => { fail: (err) => {
console.error('【调试】编辑商品失败:', err); console.error('【调试】编辑商品失败:', err);
wx.hideLoading(); wx.hideLoading();
wx.showToast({ title: '保存失败,请重试', icon: 'none', duration: 2000 }); wx.showToast({ title: '保存失败,请重试', icon: 'none', duration: 2000 });
} }
}); });
} else { } else {
// 创建新商品并提交审核 // 创建新商品并提交审核
// 调用添加商品接口 // 调用添加商品接口
wx.request({ wx.request({
url: API.BASE_URL + '/api/product/add', url: API.BASE_URL + '/api/product/add',
method: 'POST', method: 'POST',
data: productData, data: productData,
success: (res) => { success: (res) => {
console.log('商品创建成功:', res); console.log('商品创建成功:', res);
wx.hideLoading(); wx.hideLoading();
// 关闭编辑弹窗 // 关闭编辑弹窗
this.setData({ showEditModal: false }); this.setData({ showEditModal: false });
// 恢复页面滚动 // 恢复页面滚动
this.enablePageScroll(); this.enablePageScroll();
wx.showToast({ title: '更新成功,等待审核', duration: 2000 }); wx.showToast({ title: '更新成功,等待审核', duration: 2000 });
// 重新加载商品列表 // 重新加载商品列表
setTimeout(() => { setTimeout(() => {
this.loadSupplies(); this.loadSupplies();
}, 100); }, 100);
}, },
fail: (err) => { fail: (err) => {
console.error('商品创建失败:', err); console.error('商品创建失败:', err);
wx.hideLoading(); wx.hideLoading();
wx.showToast({ title: '创建失败,请重试', icon: 'none', duration: 2000 }); wx.showToast({ title: '创建失败,请重试', icon: 'none', duration: 2000 });
}
});
} }
}); });
}
});
}, },
// 预览图片 // 预览图片
@ -2025,7 +2033,7 @@ Page({
} else if (e.touches.length === 1) { } else if (e.touches.length === 1) {
// 单指触摸时记录触摸点 - 使用pageX和pageY而非clientX和clientY // 单指触摸时记录触摸点 - 使用pageX和pageY而非clientX和clientY
const touch = e.touches[0] const touch = e.touches[0]
this.setData({ this.setData({
lastTouchPoint: { lastTouchPoint: {
pageX: touch.pageX, pageX: touch.pageX,
pageY: touch.pageY pageY: touch.pageY
@ -2110,7 +2118,7 @@ Page({
// 假设屏幕宽度为375px // 假设屏幕宽度为375px
const screenWidth = 375 const screenWidth = 375
let newScale = 2 let newScale = 2
this.setData({ scale: newScale }) this.setData({ scale: newScale })
}, },
@ -2223,7 +2231,7 @@ Page({
// 计算蛋黄和规格的索引值 // 计算蛋黄和规格的索引值
const yolkIndex = this.data.yolkOptions.indexOf(supply.yolk) >= 0 ? this.data.yolkOptions.indexOf(supply.yolk) : 0; const yolkIndex = this.data.yolkOptions.indexOf(supply.yolk) >= 0 ? this.data.yolkOptions.indexOf(supply.yolk) : 0;
const specIndex = this.data.specOptions.indexOf(supply.spec) >= 0 ? this.data.specOptions.indexOf(supply.spec) : 0; const specIndex = this.data.specOptions.indexOf(supply.spec) >= 0 ? this.data.specOptions.indexOf(supply.spec) : 0;
// 设置编辑货源数据,显示编辑弹窗 // 设置编辑货源数据,显示编辑弹窗
const supplyWithFormattedTime = { const supplyWithFormattedTime = {
...supply, ...supply,
@ -2293,7 +2301,7 @@ Page({
const userId = wx.getStorageSync('userId'); const userId = wx.getStorageSync('userId');
const openid = wx.getStorageSync('openid'); const openid = wx.getStorageSync('openid');
const userInfo = wx.getStorageSync('userInfo'); const userInfo = wx.getStorageSync('userInfo');
if (!userId || !openid || !userInfo) { if (!userId || !openid || !userInfo) {
wx.showModal({ wx.showModal({
title: '提示', title: '提示',
@ -2307,7 +2315,7 @@ Page({
}); });
return; return;
} }
// 检查用户合作状态 // 检查用户合作状态
API.getUserInfo(openid) API.getUserInfo(openid)
.then(response => { .then(response => {
@ -2332,7 +2340,7 @@ Page({
}); });
return; return;
} }
const id = e.currentTarget.dataset.id const id = e.currentTarget.dataset.id
// 优先使用编辑中的商品数据 // 优先使用编辑中的商品数据
let supply = null let supply = null
@ -2355,7 +2363,7 @@ Page({
}); });
return; return;
} }
wx.showLoading({ title: '处理中...', mask: true }); wx.showLoading({ title: '处理中...', mask: true });
// 判断当前货源状态,决定设置什么状态 // 判断当前货源状态,决定设置什么状态
@ -2840,25 +2848,25 @@ Page({
// 注意:这里不立即清空 currentRejectSupply,确保后续操作能使用 // 注意:这里不立即清空 currentRejectSupply,确保后续操作能使用
}); });
}, },
// 打开规格选择弹窗 // 打开规格选择弹窗
openSpecSelectModal: function (e) { openSpecSelectModal: function (e) {
const mode = e.currentTarget.dataset.mode || 'create'; const mode = e.currentTarget.dataset.mode || 'create';
const currentSpec = mode === 'create' ? this.data.newSupply.spec : this.data.editSupply.spec; const currentSpec = mode === 'create' ? this.data.newSupply.spec : this.data.editSupply.spec;
const specOptions = this.data.specOptions; const specOptions = this.data.specOptions;
let selectedIndex = -1; let selectedIndex = -1;
// 查找当前选中规格的索引 // 查找当前选中规格的索引
if (currentSpec) { if (currentSpec) {
selectedIndex = specOptions.indexOf(currentSpec); selectedIndex = specOptions.indexOf(currentSpec);
} }
// 通过全局数据控制自定义tab-bar的显示状态 // 通过全局数据控制自定义tab-bar的显示状态
const app = getApp(); const app = getApp();
if (app && app.globalData) { if (app && app.globalData) {
app.globalData.showTabBar = false; app.globalData.showTabBar = false;
} }
this.setData({ this.setData({
showSpecSelectModal: true, showSpecSelectModal: true,
currentSpecMode: mode, currentSpecMode: mode,
@ -2868,7 +2876,7 @@ Page({
showTabBar: false // 隐藏底部tab-bar showTabBar: false // 隐藏底部tab-bar
}); });
}, },
// 关闭规格选择弹窗 // 关闭规格选择弹窗
closeSpecSelectModal: function () { closeSpecSelectModal: function () {
// 通过全局数据控制自定义tab-bar的显示状态 // 通过全局数据控制自定义tab-bar的显示状态
@ -2876,7 +2884,7 @@ Page({
if (app && app.globalData) { if (app && app.globalData) {
app.globalData.showTabBar = true; app.globalData.showTabBar = true;
} }
this.setData({ this.setData({
showSpecSelectModal: false, showSpecSelectModal: false,
modalSpecSearchKeyword: '', modalSpecSearchKeyword: '',
@ -2884,26 +2892,26 @@ Page({
showTabBar: true // 显示底部tab-bar showTabBar: true // 显示底部tab-bar
}); });
}, },
// 弹窗中规格搜索输入 // 弹窗中规格搜索输入
onModalSpecSearchInput: function (e) { onModalSpecSearchInput: function (e) {
const keyword = e.detail.value; const keyword = e.detail.value;
const specOptions = this.data.specOptions; const specOptions = this.data.specOptions;
let filteredOptions = specOptions; let filteredOptions = specOptions;
if (keyword) { if (keyword) {
filteredOptions = specOptions.filter(option => { filteredOptions = specOptions.filter(option => {
return option.toLowerCase().includes(keyword.toLowerCase()); return option.toLowerCase().includes(keyword.toLowerCase());
}); });
} }
this.setData({ this.setData({
modalSpecSearchKeyword: keyword, modalSpecSearchKeyword: keyword,
filteredModalSpecOptions: filteredOptions, filteredModalSpecOptions: filteredOptions,
selectedModalSpecIndex: -1 // 搜索时重置选择 selectedModalSpecIndex: -1 // 搜索时重置选择
}); });
}, },
// 清除弹窗中的规格搜索关键词 // 清除弹窗中的规格搜索关键词
clearModalSpecSearch: function () { clearModalSpecSearch: function () {
this.setData({ this.setData({
@ -2912,18 +2920,18 @@ Page({
selectedModalSpecIndex: -1 selectedModalSpecIndex: -1
}); });
}, },
// 双击检测变量 // 双击检测变量
lastTapTime: {}, lastTapTime: {},
tapCount: {}, tapCount: {},
// 通用双击检测函数 // 通用双击检测函数
handleDoubleTap: function(e, type, callback) { handleDoubleTap: function (e, type, callback) {
const currentTime = Date.now(); const currentTime = Date.now();
const tapKey = `${type}-${e.currentTarget.dataset.index}`; const tapKey = `${type}-${e.currentTarget.dataset.index}`;
const lastTap = this.lastTapTime[tapKey] || 0; const lastTap = this.lastTapTime[tapKey] || 0;
const tapInterval = currentTime - lastTap; const tapInterval = currentTime - lastTap;
if (tapInterval < 300 && tapInterval > 0) { if (tapInterval < 300 && tapInterval > 0) {
// 双击事件触发,执行确认选择 // 双击事件触发,执行确认选择
callback(); callback();
@ -2935,7 +2943,7 @@ Page({
}, 300); }, 300);
} }
}, },
// 弹窗中选择规格 // 弹窗中选择规格
onModalSpecSelect: function (e) { onModalSpecSelect: function (e) {
const index = e.currentTarget.dataset.index; const index = e.currentTarget.dataset.index;
@ -2944,13 +2952,13 @@ Page({
selectedModalSpecIndex: index, selectedModalSpecIndex: index,
modalSpecSearchKeyword: selectedSpec // 自动填充搜索框为当前选择的规格 modalSpecSearchKeyword: selectedSpec // 自动填充搜索框为当前选择的规格
}); });
// 检测双击 // 检测双击
this.handleDoubleTap(e, 'spec', () => { this.handleDoubleTap(e, 'spec', () => {
this.confirmSpecSelection(); this.confirmSpecSelection();
}); });
}, },
// 确认规格选择 // 确认规格选择
confirmSpecSelection: function () { confirmSpecSelection: function () {
if (this.data.selectedModalSpecIndex === -1) { if (this.data.selectedModalSpecIndex === -1) {
@ -2960,11 +2968,11 @@ Page({
}); });
return; return;
} }
const selectedSpec = this.data.filteredModalSpecOptions[this.data.selectedModalSpecIndex]; const selectedSpec = this.data.filteredModalSpecOptions[this.data.selectedModalSpecIndex];
const specOptions = this.data.specOptions; const specOptions = this.data.specOptions;
const originalIndex = specOptions.indexOf(selectedSpec); const originalIndex = specOptions.indexOf(selectedSpec);
// 根据当前模式更新对应的规格信息 // 根据当前模式更新对应的规格信息
if (this.data.currentSpecMode === 'create') { if (this.data.currentSpecMode === 'create') {
const newSupply = this.data.newSupply; const newSupply = this.data.newSupply;
@ -2973,7 +2981,7 @@ Page({
this.setData({ this.setData({
newSupply: newSupply newSupply: newSupply
}); });
// 实时保存到本地存储 // 实时保存到本地存储
wx.setStorageSync('newSupplyDraft', newSupply); wx.setStorageSync('newSupplyDraft', newSupply);
} else if (this.data.currentSpecMode === 'edit') { } else if (this.data.currentSpecMode === 'edit') {
@ -2982,10 +2990,10 @@ Page({
'editSupply.specIndex': originalIndex 'editSupply.specIndex': originalIndex
}); });
} }
// 关闭弹窗 // 关闭弹窗
this.closeSpecSelectModal(); this.closeSpecSelectModal();
// 恢复页面滚动 // 恢复页面滚动
this.enablePageScroll(); this.enablePageScroll();
@ -3104,7 +3112,7 @@ Page({
this.setData({ this.setData({
newSupply: newSupply newSupply: newSupply
}); });
// 实时保存到本地存储 // 实时保存到本地存储
wx.setStorageSync('newSupplyDraft', newSupply); wx.setStorageSync('newSupplyDraft', newSupply);
} else { } else {
@ -3199,7 +3207,7 @@ Page({
this.setData({ this.setData({
newSupply: newSupply newSupply: newSupply
}); });
// 实时保存到本地存储 // 实时保存到本地存储
wx.setStorageSync('newSupplyDraft', newSupply); wx.setStorageSync('newSupplyDraft', newSupply);
} else { } else {
@ -3273,12 +3281,12 @@ Page({
filterSpecOptions(keyword, type) { filterSpecOptions(keyword, type) {
const specOptions = this.data.specOptions; const specOptions = this.data.specOptions;
let filteredOptions = specOptions; let filteredOptions = specOptions;
if (keyword) { if (keyword) {
filteredOptions = specOptions.filter(option => { filteredOptions = specOptions.filter(option => {
return option.toLowerCase().includes(keyword); return option.toLowerCase().includes(keyword);
}); });
// 如果有匹配的规格选项,自动填充第一个匹配项 // 如果有匹配的规格选项,自动填充第一个匹配项
if (filteredOptions.length > 0) { if (filteredOptions.length > 0) {
if (type === 'create') { if (type === 'create') {
@ -3309,7 +3317,7 @@ Page({
}); });
} }
} }
if (type === 'create') { if (type === 'create') {
this.setData({ this.setData({
filteredSpecOptions: filteredOptions filteredSpecOptions: filteredOptions
@ -3341,6 +3349,118 @@ Page({
}); });
}, },
// 打开创建货源的地区选择弹窗
openCreateRegionModal() {
this.setData({
currentRegionMode: 'create',
regionSearchKeyword: '',
filteredRegionOptions: this.data.regionOptions,
showRegionSelectModal: true
});
},
// 打开编辑货源的地区选择弹窗
openEditRegionModal() {
this.setData({
currentRegionMode: 'edit',
editRegionSearchKeyword: '',
filteredRegionOptions: this.data.regionOptions,
showRegionSelectModal: true
});
},
// 关闭地区选择弹窗
closeRegionModal() {
this.setData({
showRegionSelectModal: false,
selectedRegionIndex: -1
});
},
// 处理创建货源弹窗中的地区搜索输入
onRegionSearchInput(e) {
const keyword = e.detail.value.toLowerCase().trim();
this.setData({
regionSearchKeyword: keyword
});
// 过滤地区选项
this.filterRegionOptions(keyword, 'create');
},
// 处理编辑货源弹窗中的地区搜索输入
onEditRegionSearchInput(e) {
const keyword = e.detail.value.toLowerCase().trim();
this.setData({
editRegionSearchKeyword: keyword
});
// 过滤地区选项
this.filterRegionOptions(keyword, 'edit');
},
// 过滤地区选项的通用函数
filterRegionOptions(keyword, type) {
const regionOptions = this.data.regionOptions;
let filteredOptions = regionOptions;
if (keyword) {
filteredOptions = regionOptions.filter(option => {
return option.toLowerCase().includes(keyword);
});
}
this.setData({
filteredRegionOptions: filteredOptions
});
},
// 清除地区搜索关键词
clearRegionSearch() {
this.setData({
regionSearchKeyword: '',
filteredRegionOptions: this.data.regionOptions
});
},
// 清除编辑弹窗中的地区搜索关键词
clearEditRegionSearch() {
this.setData({
editRegionSearchKeyword: '',
filteredRegionOptions: this.data.regionOptions
});
},
// 选择地区
selectRegion(e) {
const index = e.currentTarget.dataset.index;
this.setData({
selectedRegionIndex: index
});
},
// 确认地区选择
confirmRegionSelection() {
const selectedIndex = this.data.selectedRegionIndex;
if (selectedIndex === -1) {
this.closeRegionModal();
return;
}
const selectedRegion = this.data.filteredRegionOptions[selectedIndex];
const mode = this.data.currentRegionMode;
if (mode === 'create') {
this.setData({
'newSupply.region': selectedRegion
});
} else if (mode === 'edit') {
this.setData({
'editSupply.region': selectedRegion
});
}
this.closeRegionModal();
},
/** /**
* 阻止触摸移动事件用于WXML绑定 * 阻止触摸移动事件用于WXML绑定
*/ */
@ -3396,7 +3516,7 @@ Page({
return false return false
} }
}, },
// 商品名称选择弹窗相关函数 // 商品名称选择弹窗相关函数
openNameSelectModal() { openNameSelectModal() {
// 设置当前选中的索引 // 设置当前选中的索引
@ -3407,55 +3527,55 @@ Page({
currentName = this.data.newSupply.name; currentName = this.data.newSupply.name;
} }
const index = currentName ? this.data.productNameOptions.indexOf(currentName) : -1; const index = currentName ? this.data.productNameOptions.indexOf(currentName) : -1;
// 通过全局数据控制自定义tab-bar的显示状态 // 通过全局数据控制自定义tab-bar的显示状态
const app = getApp(); const app = getApp();
if (app && app.globalData) { if (app && app.globalData) {
app.globalData.showTabBar = false; app.globalData.showTabBar = false;
} }
this.setData({ this.setData({
showNameSelectModal: true, showNameSelectModal: true,
selectedNameIndex: index >= 0 ? index : -1, selectedNameIndex: index >= 0 ? index : -1,
showTabBar: false // 隐藏底部tab-bar showTabBar: false // 隐藏底部tab-bar
}); });
}, },
closeNameSelectModal() { closeNameSelectModal() {
// 通过全局数据控制自定义tab-bar的显示状态 // 通过全局数据控制自定义tab-bar的显示状态
const app = getApp(); const app = getApp();
if (app && app.globalData) { if (app && app.globalData) {
app.globalData.showTabBar = true; app.globalData.showTabBar = true;
} }
this.setData({ this.setData({
showNameSelectModal: false, showNameSelectModal: false,
showTabBar: true // 显示底部tab-bar showTabBar: true // 显示底部tab-bar
}); });
}, },
onNameSelect(e) { onNameSelect(e) {
const index = e.currentTarget.dataset.index; const index = e.currentTarget.dataset.index;
this.setData({ this.setData({
selectedNameIndex: index selectedNameIndex: index
}); });
// 检测双击 // 检测双击
this.handleDoubleTap(e, 'name', () => { this.handleDoubleTap(e, 'name', () => {
this.confirmNameSelection(); this.confirmNameSelection();
}); });
}, },
confirmNameSelection() { confirmNameSelection() {
if (this.data.selectedNameIndex >= 0) { if (this.data.selectedNameIndex >= 0) {
const selectedName = this.data.productNameOptions[this.data.selectedNameIndex]; const selectedName = this.data.productNameOptions[this.data.selectedNameIndex];
// 通过全局数据控制自定义tab-bar的显示状态 // 通过全局数据控制自定义tab-bar的显示状态
const app = getApp(); const app = getApp();
if (app && app.globalData) { if (app && app.globalData) {
app.globalData.showTabBar = true; app.globalData.showTabBar = true;
} }
// 根据当前是编辑还是创建模式,更新对应的对象 // 根据当前是编辑还是创建模式,更新对应的对象
if (this.data.showEditModal) { if (this.data.showEditModal) {
this.setData({ this.setData({
@ -3471,13 +3591,13 @@ Page({
showNameSelectModal: false, showNameSelectModal: false,
showTabBar: true // 显示底部tab-bar showTabBar: true // 显示底部tab-bar
}); });
// 实时保存到本地存储 // 实时保存到本地存储
wx.setStorageSync('newSupplyDraft', newSupply); wx.setStorageSync('newSupplyDraft', newSupply);
} }
} }
}, },
// 蛋黄选择弹窗相关函数 // 蛋黄选择弹窗相关函数
openYolkSelectModal() { openYolkSelectModal() {
// 设置当前选中的索引 // 设置当前选中的索引
@ -3488,55 +3608,55 @@ Page({
currentYolk = this.data.newSupply.yolk; currentYolk = this.data.newSupply.yolk;
} }
const index = currentYolk ? this.data.yolkOptions.indexOf(currentYolk) : -1; const index = currentYolk ? this.data.yolkOptions.indexOf(currentYolk) : -1;
// 通过全局数据控制自定义tab-bar的显示状态 // 通过全局数据控制自定义tab-bar的显示状态
const app = getApp(); const app = getApp();
if (app && app.globalData) { if (app && app.globalData) {
app.globalData.showTabBar = false; app.globalData.showTabBar = false;
} }
this.setData({ this.setData({
showYolkSelectModal: true, showYolkSelectModal: true,
selectedYolkIndex: index >= 0 ? index : -1, selectedYolkIndex: index >= 0 ? index : -1,
showTabBar: false // 隐藏底部tab-bar showTabBar: false // 隐藏底部tab-bar
}); });
}, },
closeYolkSelectModal() { closeYolkSelectModal() {
// 通过全局数据控制自定义tab-bar的显示状态 // 通过全局数据控制自定义tab-bar的显示状态
const app = getApp(); const app = getApp();
if (app && app.globalData) { if (app && app.globalData) {
app.globalData.showTabBar = true; app.globalData.showTabBar = true;
} }
this.setData({ this.setData({
showYolkSelectModal: false, showYolkSelectModal: false,
showTabBar: true // 显示底部tab-bar showTabBar: true // 显示底部tab-bar
}); });
}, },
onYolkSelect(e) { onYolkSelect(e) {
const index = e.currentTarget.dataset.index; const index = e.currentTarget.dataset.index;
this.setData({ this.setData({
selectedYolkIndex: index selectedYolkIndex: index
}); });
// 检测双击 // 检测双击
this.handleDoubleTap(e, 'yolk', () => { this.handleDoubleTap(e, 'yolk', () => {
this.confirmYolkSelection(); this.confirmYolkSelection();
}); });
}, },
confirmYolkSelection() { confirmYolkSelection() {
if (this.data.selectedYolkIndex >= 0) { if (this.data.selectedYolkIndex >= 0) {
const selectedYolk = this.data.yolkOptions[this.data.selectedYolkIndex]; const selectedYolk = this.data.yolkOptions[this.data.selectedYolkIndex];
// 通过全局数据控制自定义tab-bar的显示状态 // 通过全局数据控制自定义tab-bar的显示状态
const app = getApp(); const app = getApp();
if (app && app.globalData) { if (app && app.globalData) {
app.globalData.showTabBar = true; app.globalData.showTabBar = true;
} }
// 根据当前是编辑还是创建模式,更新对应的对象 // 根据当前是编辑还是创建模式,更新对应的对象
if (this.data.showEditModal) { if (this.data.showEditModal) {
this.setData({ this.setData({
@ -3554,7 +3674,7 @@ Page({
showYolkSelectModal: false, showYolkSelectModal: false,
showTabBar: true // 显示底部tab-bar showTabBar: true // 显示底部tab-bar
}); });
// 实时保存到本地存储 // 实时保存到本地存储
wx.setStorageSync('newSupplyDraft', newSupply); wx.setStorageSync('newSupplyDraft', newSupply);
} }

66
pages/seller/index.wxml

@ -534,15 +534,13 @@
<view style="font-size: 28rpx; font-weight: 500; color: #333; margin-bottom: 12rpx; margin-left: 10rpx;">地区</view> <view style="font-size: 28rpx; font-weight: 500; color: #333; margin-bottom: 12rpx; margin-left: 10rpx;">地区</view>
<picker <view
mode="region"
value="{{newSupplyRegionArray}}"
bindchange="onNewSupplyRegionChange"
class="region-picker input" class="region-picker input"
bindtap="openCreateRegionModal"
style="width: 100%; height: 90rpx; line-height: 90rpx; padding: 0 24rpx; font-size: 30rpx; border: 2rpx solid #eee; border-radius: 12rpx; box-sizing: border-box; margin: 0 auto 30rpx; display: block;" style="width: 100%; height: 90rpx; line-height: 90rpx; padding: 0 24rpx; font-size: 30rpx; border: 2rpx solid #eee; border-radius: 12rpx; box-sizing: border-box; margin: 0 auto 30rpx; display: block;"
> >
<text>{{newSupply.region || '请选择省市区'}}</text> <text>{{newSupply.region || '请选择省市区'}}</text>
</picker> </view>
<view style="display: flex; justify-content: space-between; margin-top: 20rpx; margin-bottom: 20rpx; gap: 20rpx;"> <view style="display: flex; justify-content: space-between; margin-top: 20rpx; margin-bottom: 20rpx; gap: 20rpx;">
<button bindtap="hideModal" style="flex: 1; height: 90rpx; line-height: 90rpx; background-color: #f5f5f5; color: #666; font-size: 30rpx; border-radius: 12rpx; margin: 0; display: flex; align-items: center; justify-content: center;">取消</button> <button bindtap="hideModal" style="flex: 1; height: 90rpx; line-height: 90rpx; background-color: #f5f5f5; color: #666; font-size: 30rpx; border-radius: 12rpx; margin: 0; display: flex; align-items: center; justify-content: center;">取消</button>
@ -617,15 +615,13 @@
<view style="font-size: 28rpx; font-weight: 500; color: #333; margin-bottom: 12rpx; margin-left: 10rpx;">地区</view> <view style="font-size: 28rpx; font-weight: 500; color: #333; margin-bottom: 12rpx; margin-left: 10rpx;">地区</view>
<picker <view
mode="region"
value="{{editSupplyRegionArray}}"
bindchange="onEditSupplyRegionChange"
class="region-picker input" class="region-picker input"
bindtap="openEditRegionModal"
style="width: 100%; height: 90rpx; line-height: 90rpx; padding: 0 24rpx; font-size: 30rpx; border: 2rpx solid #eee; border-radius: 12rpx; box-sizing: border-box; margin: 0 auto 30rpx; display: block;" style="width: 100%; height: 90rpx; line-height: 90rpx; padding: 0 24rpx; font-size: 30rpx; border: 2rpx solid #eee; border-radius: 12rpx; box-sizing: border-box; margin: 0 auto 30rpx; display: block;"
> >
<text>{{editSupply.region || '请选择省市区'}}</text> <text>{{editSupply.region || '请选择省市区'}}</text>
</picker> </view>
<view style="display: flex; justify-content: space-between; margin-top: 20rpx; margin-bottom: 20rpx; gap: 20rpx;"> <view style="display: flex; justify-content: space-between; margin-top: 20rpx; margin-bottom: 20rpx; gap: 20rpx;">
<button bindtap="hideEditModal" style="flex: 1; height: 90rpx; line-height: 90rpx; background-color: #f5f5f5; color: #666; font-size: 30rpx; border-radius: 12rpx; margin: 0; display: flex; align-items: center; justify-content: center;">取消</button> <button bindtap="hideEditModal" style="flex: 1; height: 90rpx; line-height: 90rpx; background-color: #f5f5f5; color: #666; font-size: 30rpx; border-radius: 12rpx; margin: 0; display: flex; align-items: center; justify-content: center;">取消</button>
@ -860,4 +856,54 @@
</view> </view>
</view> </view>
<!-- 地区选择弹窗 -->
<view class="region-select-modal" wx:if="{{showRegionSelectModal}}" style="position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; justify-content: center; z-index: 9999;" catchtouchmove="true">
<view style="position: fixed; bottom: 0; left: 0; right: 0; background: white; border-radius: 20rpx 20rpx 0 0; max-height: 80vh;">
<!-- 顶部操作栏:取消和确定按钮 -->
<view style="padding: 20rpx; display: flex; justify-content: space-between; align-items: center; border-bottom: 1rpx solid #eee;">
<view bindtap="closeRegionModal" style="font-size: 32rpx; color: #333; padding: 10rpx 20rpx;">取消</view>
<view bindtap="confirmRegionSelection" style="font-size: 32rpx; color: #07c160; padding: 10rpx 20rpx;">确定</view>
</view>
<!-- 搜索框区域 -->
<view style="padding: 20rpx;">
<view style="position: relative; background: #f5f5f5; border-radius: 40rpx; padding: 0 30rpx;">
<input
type="text"
placeholder="搜索地区"
value="{{currentRegionMode === 'create' ? regionSearchKeyword : editRegionSearchKeyword}}"
bindinput="{{currentRegionMode === 'create' ? 'onRegionSearchInput' : 'onEditRegionSearchInput'}}"
confirm-type="search"
style="width: 100%; height: 70rpx; line-height: 70rpx; font-size: 28rpx; background: transparent;"
/>
<view
wx:if="{{currentRegionMode === 'create' ? regionSearchKeyword : editRegionSearchKeyword}}"
bindtap="{{currentRegionMode === 'create' ? 'clearRegionSearch' : 'clearEditRegionSearch'}}"
style="position: absolute; right: 30rpx; top: 50%; transform: translateY(-50%); color: #999;"
>
</view>
</view>
</view>
<!-- 地区列表 -->
<scroll-view
scroll-y="true"
style="max-height: 60vh; padding: 0; -webkit-overflow-scrolling: touch;"
enable-back-to-top="false"
>
<view
wx:for="{{filteredRegionOptions}}"
wx:key="index"
class="region-item {{selectedRegionIndex === index ? 'selected' : ''}}"
bindtap="selectRegion"
data-index="{{index}}"
style="padding: 32rpx 40rpx; border-bottom: 1rpx solid #f0f0f0; font-size: 32rpx; color: {{selectedRegionIndex === index ? '#07c160' : '#131413'}}; text-align: center;"
>
{{item}}
</view>
</scroll-view>
</view>
</view>
</view> </view>

116
pages/seller/index.wxss

@ -824,4 +824,120 @@ button {
-webkit-transform: translateZ(0); -webkit-transform: translateZ(0);
transform: translateZ(0); transform: translateZ(0);
will-change: transform; will-change: transform;
}
/* 地区选择弹窗样式 */
.region-select-modal {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
z-index: 9999;
overflow: hidden;
}
.region-select-modal .modal-content {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: white;
border-radius: 20rpx 20rpx 0 0;
max-height: 80vh;
will-change: transform;
-webkit-transition: transform 0.3s ease;
transition: transform 0.3s ease;
}
.region-select-modal .modal-header {
padding: 20rpx;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1rpx solid #eee;
background-color: white;
border-radius: 20rpx 20rpx 0 0;
}
.region-select-modal .modal-title {
font-size: 32rpx;
font-weight: 500;
color: #333;
}
.region-select-modal .modal-btn {
font-size: 32rpx;
padding: 10rpx 20rpx;
}
.region-select-modal .modal-btn.cancel {
color: #333;
}
.region-select-modal .modal-btn.confirm {
color: #07c160;
}
.region-select-modal .search-area {
padding: 20rpx;
background-color: white;
border-bottom: 1rpx solid #f0f0f0;
}
.region-select-modal .search-box {
position: relative;
background: #f5f5f5;
border-radius: 40rpx;
padding: 0 30rpx;
}
.region-select-modal .search-input {
width: 100%;
height: 70rpx;
line-height: 70rpx;
font-size: 28rpx;
background: transparent;
-webkit-appearance: none;
appearance: none;
border: none;
outline: none;
}
.region-select-modal .search-clear {
position: absolute;
right: 30rpx;
top: 50%;
transform: translateY(-50%);
color: #999;
font-size: 32rpx;
cursor: pointer;
}
.region-select-modal .region-list {
max-height: 60vh;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
.region-select-modal .region-item {
padding: 32rpx 40rpx;
border-bottom: 1rpx solid #f0f0f0;
font-size: 32rpx;
color: #131413;
text-align: center;
cursor: pointer;
transition: background-color 0.2s ease;
}
.region-select-modal .region-item:hover {
background-color: #f5f5f5;
}
.region-select-modal .region-item.selected {
color: #07c160;
background-color: #f0f8f3;
} }
Loading…
Cancel
Save