sales-publish.vue 24 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  1. <template>
  2. <view class="sales-publish-container">
  3. <!-- 表单内容 -->
  4. <view class="form-container">
  5. <!-- 产品名称 -->
  6. <view class="form-item">
  7. <view class="item-label">
  8. <text class="label-text">产品名称</text>
  9. <text class="required">*</text>
  10. </view>
  11. <view class="item-content">
  12. <input class="form-input" v-model="formData.title" placeholder="请输入产品名称"
  13. placeholder-style="color: #999;" maxlength="20" @input="onNameInput" />
  14. <view class="char-count">{{ nameLength }}/20</view>
  15. </view>
  16. </view>
  17. <!-- 产品分类 -->
  18. <view class="form-item">
  19. <view class="item-label">
  20. <text class="label-text">产品分类</text>
  21. <text class="required">*</text>
  22. </view>
  23. <view class="item-content">
  24. <view class="category-selector" @click="showCategoryPicker = true">
  25. <text class="selector-text" :class="{ placeholder: !formData.categoryId }">
  26. <!-- {{ formData.categoryLabel || '请选择产品分类' }} -->
  27. {{getDictLabel('agricultural_category',formData.categoryId) || '请选择产品分类' }}
  28. </text>
  29. <text class="arrow-icon">></text>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="form-item">
  34. <!-- 所在地 -->
  35. <view class="item-label">
  36. <text class="label-text">所在地</text>
  37. <text class="required">*</text>
  38. </view>
  39. <LocationPicker
  40. v-model="formData.location"
  41. mode="edit"
  42. />
  43. </view>
  44. <!-- 销售价格 -->
  45. <view class="form-item">
  46. <view class="item-label">
  47. <text class="label-text">销售价格</text>
  48. <text class="required">*</text>
  49. </view>
  50. <view class="item-content">
  51. <view class="input-with-unit">
  52. <text class="currency-symbol">¥</text>
  53. <input class="form-input" v-model="formData.price" placeholder="请输入销售价格"
  54. placeholder-style="color: #999;" type="digit" />
  55. <!-- <text class="unit-text">元/斤</text> -->
  56. </view>
  57. </view>
  58. </view>
  59. <!-- 单位-->
  60. <view class="form-item">
  61. <view class="item-label">
  62. <text class="label-text">单位</text>
  63. <text class="required">*</text>
  64. </view>
  65. <view class="item-content">
  66. <view class="category-selector" @click="showUnitPicker = true">
  67. <text class="selector-text" :class="{ placeholder: !formData.unit }">
  68. <!-- {{ formData.dictLabel || '请选择价格单位' }} -->
  69. {{ getDictLabel('agricultural_unit',formData.unit) || '请选择价格单位'}}
  70. </text>
  71. <text class="arrow-icon">></text>
  72. </view>
  73. </view>
  74. </view>
  75. <!-- 收购数量 -->
  76. <view class="form-item">
  77. <view class="item-label">
  78. <text class="label-text">产品数量</text>
  79. <text class="required">*</text>
  80. </view>
  81. <view class="item-content">
  82. <view class="input-with-unit">
  83. <input
  84. class="form-input"
  85. v-model="formData.quantity"
  86. placeholder="请输入产品数量"
  87. placeholder-style="color: #999;"
  88. type="number"
  89. />
  90. <!-- <text class="unit-text">斤</text> -->
  91. </view>
  92. </view>
  93. </view>
  94. <!-- 产品简介 -->
  95. <view class="form-item">
  96. <view class="item-label">
  97. <text class="label-text">产品简介</text>
  98. </view>
  99. <view class="item-content">
  100. <textarea class="form-textarea" v-model="formData.description" placeholder="请简单介绍您的农产品特色、种植方式等"
  101. placeholder-style="color: #999;" maxlength="80" auto-height @input="onDescInput" />
  102. <view class="char-count">{{ descLength }}/80</view>
  103. </view>
  104. </view>
  105. <!-- 产品图片 -->
  106. <view class="form-item">
  107. <view class="item-label">
  108. <text class="label-text">产品图片</text>
  109. <text class="required">*</text>
  110. <text class="optional">(最多6张)</text>
  111. </view>
  112. <view class="item-content">
  113. <view class="image-upload-area">
  114. <view class="image-item" v-for="(image, index) in formData.images" :key="index">
  115. <image class="uploaded-image" :src="image.url" mode="aspectFill"></image>
  116. <view class="image-delete" @click="removeImage(index)">×</view>
  117. </view>
  118. <view class="image-upload-btn" v-if="formData.images.length < 6" @click="chooseImage">
  119. <text class="upload-icon">+</text>
  120. <text class="upload-text">上传图片</text>
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. <!-- 产地信息 -->
  126. <!-- <view class="form-item">
  127. <view class="item-label">
  128. <text class="label-text">产地信息</text>
  129. </view>
  130. <view class="contact-info">
  131. <view class="contact-row">
  132. <text class="contact-label">产地:</text>
  133. <text class="contact-value">{{ locationInfo.address }}</text>
  134. </view>
  135. <view class="contact-row">
  136. <text class="contact-label">地块:</text>
  137. <text class="contact-value">{{ locationInfo.field }}</text>
  138. </view>
  139. </view>
  140. </view> -->
  141. <!-- 联系人信息 -->
  142. <view class="form-item">
  143. <view class="item-label">
  144. <text class="label-text">联系人信息</text>
  145. </view>
  146. <view class="item-content">
  147. <view class="contact-input-row">
  148. <text class="contact-label">联系人:</text>
  149. <input class="contact-input" v-model="formData.contactName" placeholder="请输入联系人姓名"
  150. placeholder-style="color: #999;" maxlength="10" />
  151. </view>
  152. <view class="contact-input-row">
  153. <text class="contact-label">电话:</text>
  154. <input class="contact-input" v-model="formData.contactPhone" placeholder="请输入联系电话"
  155. placeholder-style="color: #999;" type="number" maxlength="11" />
  156. </view>
  157. </view>
  158. </view>
  159. </view>
  160. <!-- 底部提交按钮 -->
  161. <view class="bottom-action-bar">
  162. <view class="submit-btn" @click="submitForm">
  163. <text class="btn-text">{{ isEditMode ? '保存修改' : '提交审核' }}</text>
  164. </view>
  165. </view>
  166. <!-- 分类选择弹窗 -->
  167. <view class="picker-modal" v-if="showCategoryPicker" @click="showCategoryPicker = false">
  168. <view class="picker-content" @click.stop>
  169. <view class="picker-header">
  170. <text class="picker-title">选择产品分类</text>
  171. <text class="picker-close" @click="showCategoryPicker = false">×</text>
  172. </view>
  173. <view class="picker-options">
  174. <view class="picker-option"
  175. v-for="category in dictDataOptions.agricultural_category"
  176. :key="category.dictCode"
  177. @click="selectCategory(category)"
  178. :class="{ 'active': category.dictValue == formData.categoryId }">
  179. <text class="option-text">{{ category.dictLabel }}</text>
  180. </view>
  181. </view>
  182. </view>
  183. </view>
  184. <!-- 单位选择弹窗 -->
  185. <view class="picker-modal" v-if="showUnitPicker" @click="showUnitPicker = false">
  186. <view class="picker-content" @click.stop>
  187. <view class="picker-header">
  188. <text class="picker-title">选择价格单位</text>
  189. <text class="picker-close" @click="showUnitPicker = false">×</text>
  190. </view>
  191. <view class="picker-options">
  192. <view class="picker-option"
  193. v-for="unit in dictDataOptions.agricultural_unit"
  194. :key="unit.dictCode"
  195. @click="selectUnit(unit)"
  196. :class="{ 'active': unit.dictValue == formData.unit }">
  197. <text class="option-text">{{ unit.dictLabel }}</text>
  198. </view>
  199. </view>
  200. </view>
  201. </view>
  202. </view>
  203. </template>
  204. <script setup>
  205. import { ref, reactive, computed, onMounted } from 'vue'
  206. import LocationPicker from "@/components/common/LocationPicker.vue"
  207. import api from "@/config/api.js"
  208. import storage from "@/utils/storage.js"
  209. import { addProductInfo, getProductInfoById, editProductInfo } from '@/api/services/productInfo.js'
  210. import { useDict } from '@/utils/composables/useDict'
  211. import { getFormattedTime } from '@/utils/dateUtils'
  212. // 使用 useDict 替换 dictMixin
  213. const { dictData } = useDict(['agricultural_unit', 'agricultural_category'])
  214. // 响应式状态
  215. const isEditMode = ref(false)
  216. const editProductId = ref('')
  217. const productType = ref('0')
  218. const showCategoryPicker = ref(false)
  219. const showUnitPicker = ref(false)
  220. const nameLength = ref(0)
  221. const descLength = ref(0)
  222. // 使用 reactive 管理复杂的表单对象
  223. const formData = reactive({
  224. title: '',
  225. categoryId: '',
  226. price: '',
  227. description: '',
  228. imageUrl: '',
  229. images: [],
  230. unit: '',
  231. quantity: '',
  232. contactName: '',
  233. contactPhone: '',
  234. location: '',
  235. publishTime: getFormattedTime(),
  236. userId: storage.getUserInfo().userid,
  237. type: 0, // 出售
  238. status: 1 // 审核中
  239. })
  240. const locationInfo = reactive({
  241. address: '张家村',
  242. field: '水稻田A区'
  243. })
  244. const currentUserInfo = storage.getUserInfo()
  245. // 计算属性:dictDataOptions
  246. const dictDataOptions = computed(() => dictData.value)
  247. // onLoad 替换为 onMounted + getCurrentPages
  248. onMounted(() => {
  249. const pages = getCurrentPages()
  250. const currentPage = pages[pages.length - 1]
  251. const options = currentPage.options
  252. // 检查是否为编辑模式
  253. if (options.action === 'edit' && options.id) {
  254. isEditMode.value = true
  255. editProductId.value = options.id
  256. productType.value = options.type || '0'
  257. // 设置页面标题
  258. uni.setNavigationBarTitle({
  259. title: productType.value === '0' ? '编辑销售信息' : '编辑收购信息'
  260. })
  261. // 加载产品数据
  262. loadProductData()
  263. } else {
  264. // 新建模式
  265. isEditMode.value = false
  266. uni.setNavigationBarTitle({
  267. title: '发布农产品'
  268. })
  269. }
  270. })
  271. // 方法定义
  272. // 加载产品数据(编辑模式)
  273. const loadProductData = () => {
  274. uni.showLoading({
  275. title: '加载中...'
  276. })
  277. getProductInfoById(editProductId.value).then(res => {
  278. if (res.data.code === 200) {
  279. Object.assign(formData, res.data.data)
  280. // 更新字符计数
  281. nameLength.value = formData.title.length
  282. descLength.value = formData.description.length
  283. console.log("this.goodsDetail", formData)
  284. // 处理图片数据
  285. if (formData.imageUrl) {
  286. try {
  287. formData.images = formData.imageUrl.split(',').map(url => ({ url, status: 'success' }))
  288. console.log('解析后的图片数据:', formData.images)
  289. } catch (e) {
  290. console.error('解析图片数据失败:', e)
  291. formData.images = []
  292. }
  293. } else {
  294. formData.images = []
  295. }
  296. uni.hideLoading()
  297. } else {
  298. uni.showToast({
  299. title: res.data.msg || '获取农品信息失败',
  300. icon: 'none'
  301. })
  302. }
  303. })
  304. }
  305. // 产品名称输入处理
  306. const onNameInput = (e) => {
  307. nameLength.value = e.detail.value.length
  308. }
  309. // 描述输入处理
  310. const onDescInput = (e) => {
  311. descLength.value = e.detail.value.length
  312. }
  313. // 选择分类
  314. const selectCategory = (category) => {
  315. formData.categoryId = category.dictValue
  316. formData.categoryLabel = category.dictLabel
  317. showCategoryPicker.value = false
  318. }
  319. // 选择单位
  320. const selectUnit = (unit) => {
  321. formData.unit = unit.dictValue
  322. formData.dictLabel = unit.dictLabel
  323. showUnitPicker.value = false
  324. }
  325. // 获取字典标签
  326. const getDictLabel = (dictKey, value) => {
  327. if (!dictData.value || !dictData.value[dictKey]) {
  328. return ''
  329. }
  330. const list = dictData.value[dictKey] || []
  331. const item = list.find(u => u.dictValue == value)
  332. return item ? item.dictLabel : ''
  333. }
  334. // 选择图片
  335. const chooseImage = () => {
  336. uni.chooseImage({
  337. count: 6 - formData.images.length,
  338. sizeType: ['original', 'compressed'],
  339. sourceType: ['album', 'camera'],
  340. success: (res) => {
  341. console.log('选择图片成功:', res);
  342. // 验证文件类型和大小
  343. const validFiles = [];
  344. const invalidFiles = [];
  345. const maxSize = 5 * 1024 * 1024; // 5MB 最大限制
  346. // 检查每个文件
  347. res.tempFiles.forEach((file, index) => {
  348. // 检查文件类型
  349. const isImage = /\.(jpg|jpeg|png|gif)$/i.test(file.name);
  350. // 检查文件大小
  351. const isValidSize = file.size <= maxSize;
  352. if (isImage && isValidSize) {
  353. validFiles.push(res.tempFilePaths[index]);
  354. } else {
  355. invalidFiles.push({
  356. path: file.path,
  357. size: file.size,
  358. reason: !isImage ? '文件格式不支持' : '文件大于5MB'
  359. });
  360. }
  361. });
  362. // 显示无效文件提示
  363. if (invalidFiles.length > 0) {
  364. uni.showToast({
  365. title: `${invalidFiles.length}个文件无效,请检查格式和大小`,
  366. icon: 'none',
  367. duration: 2000
  368. });
  369. }
  370. // 如果有有效文件,则上传
  371. if (validFiles.length > 0) {
  372. uploadImages(validFiles)
  373. }
  374. },
  375. fail: (err) => {
  376. console.error('选择图片失败:', err)
  377. uni.showToast({
  378. title: '选择图片失败',
  379. icon: 'none'
  380. })
  381. }
  382. })
  383. }
  384. // 上传图片到服务器
  385. const uploadImages = (tempFilePaths) => {
  386. uni.showLoading({
  387. title: '上传中...',
  388. mask: true
  389. });
  390. // 上传成功的图片计数
  391. let successCount = 0;
  392. let failCount = 0;
  393. const totalFiles = tempFilePaths.length;
  394. const newImages = [];
  395. // 遍历处理每张图片
  396. tempFilePaths.forEach((path, index) => {
  397. // 调用上传API
  398. uni.uploadFile({
  399. // url: api.serve + '/base/tasks/uploadTaskImage',
  400. url: api.serve + '/file/upload',
  401. filePath: path,
  402. name: 'file', // 文件参数名称,需要与后端接口匹配
  403. formData: {
  404. type: 'task', // 标识文件类型,用于后端区分不同业务的文件
  405. // directory: '/opt/app/nongxiaoyu/uploadImage' // 指定保存目录
  406. },
  407. header: {
  408. 'Authorization': `Bearer ${storage.getAccessToken()}`
  409. },
  410. success: (res) => {
  411. try {
  412. const response = JSON.parse(res.data);
  413. uni.showToast({
  414. title: `返回: ${response.data}`,
  415. icon: 'none',
  416. });
  417. if (response.code === 200) {
  418. // 获取返回的URL
  419. const imageUrl = response.data.url;
  420. console.log('上传成功,返回的图片URL:', imageUrl);
  421. // 上传成功,将图片信息添加到数组
  422. newImages.push({
  423. url: imageUrl, // 保存原始URL,在显示时会通过getImageUrl方法处理
  424. path: path, // 保存本地路径用于预览
  425. status: 'success',
  426. fileName: response.data.fileName || '' // 保存文件名,如果后端返回的话
  427. });
  428. successCount++;
  429. } else {
  430. failCount++;
  431. console.error('上传失败:', response.msg);
  432. }
  433. } catch (e) {
  434. failCount++;
  435. uni.showToast({
  436. title: `解析响应失败: ${e}`,
  437. icon: 'none',
  438. });
  439. console.error('解析响应失败:', e);
  440. }
  441. },
  442. fail: (err) => {
  443. failCount++;
  444. console.error('上传请求失败:', err);
  445. uni.showToast({
  446. title: `上传请求失败: ${err}`,
  447. icon: 'none',
  448. });
  449. },
  450. complete: () => {
  451. // 当所有文件都已处理完成
  452. if (successCount + failCount === totalFiles) {
  453. if (newImages.length > 0) {
  454. // 将新上传的图片添加到已有图片列表
  455. formData.images = [...formData.images, ...newImages]
  456. // 更新taskImages字段,将图片URL用逗号连接
  457. formData.imageUrl = formData.images.map(item => item.url).join(',')
  458. // 显示成功提示
  459. uni.hideLoading()
  460. uni.showToast({
  461. title: `成功上传${successCount}张图片`,
  462. icon: 'success'
  463. })
  464. } else {
  465. // 全部失败
  466. uni.showToast({
  467. title: `图片上传: ${newImages}`,
  468. icon: 'none'
  469. })
  470. uni.hideLoading()
  471. }
  472. }
  473. }
  474. })
  475. })
  476. }
  477. const removeImage = (index) => {
  478. uni.showModal({
  479. title: '确认删除',
  480. content: '确定要删除这张图片吗?',
  481. success: (res) => {
  482. if (res.confirm) {
  483. console.log("删除前:", formData.images, index)
  484. formData.images.splice(index, 1)
  485. // 更新taskImages字段
  486. formData.imageUrl = formData.images.map(item => item.url).join(',')
  487. console.log("删除后:", formData.imageUrl)
  488. uni.showToast({
  489. title: '已删除',
  490. icon: 'none'
  491. })
  492. }
  493. }
  494. })
  495. }
  496. // 表单验证
  497. const validateForm = () => {
  498. if (!formData.title.trim()) {
  499. uni.showToast({
  500. title: '请输入产品名称',
  501. icon: 'none'
  502. })
  503. return false
  504. }
  505. if (!formData.categoryId) {
  506. uni.showToast({
  507. title: '请选择产品分类',
  508. icon: 'none'
  509. })
  510. return false
  511. }
  512. if (!formData.price || formData.price <= 0) {
  513. uni.showToast({
  514. title: '请输入有效的销售价格',
  515. icon: 'none'
  516. })
  517. return false
  518. }
  519. if (!formData.quantity || formData.quantity <= 0) {
  520. uni.showToast({
  521. title: '请输入有效的收购数量',
  522. icon: 'none'
  523. })
  524. return false
  525. }
  526. if (formData.imageUrl.length === 0) {
  527. uni.showToast({
  528. title: '请至少上传一张产品图片',
  529. icon: 'none'
  530. })
  531. return false
  532. }
  533. if (!formData.contactName.trim()) {
  534. uni.showToast({
  535. title: '请输入联系人姓名',
  536. icon: 'none'
  537. })
  538. return false
  539. }
  540. if (!formData.contactPhone.trim()) {
  541. uni.showToast({
  542. title: '请输入联系电话',
  543. icon: 'none'
  544. })
  545. return false
  546. }
  547. // 简单的手机号格式验证
  548. const phoneRegex = /^1[3-9]\d{9}$/
  549. if (!phoneRegex.test(formData.contactPhone)) {
  550. uni.showToast({
  551. title: '请输入正确的手机号码',
  552. icon: 'none'
  553. })
  554. return false
  555. }
  556. return true
  557. }
  558. // 提交表单
  559. const submitForm = () => {
  560. if (!validateForm()) {
  561. return
  562. }
  563. // 显示加载提示
  564. const loadingTitle = isEditMode.value ? '保存中...' : '提交中...'
  565. uni.showLoading({
  566. title: loadingTitle
  567. })
  568. uni.hideLoading()
  569. if (isEditMode.value) {
  570. editProductInfo(formData).then(res => {
  571. if (res.data.code === 200) {
  572. uni.showModal({
  573. title: '保存成功',
  574. content: '您的修改已保存成功!',
  575. showCancel: false,
  576. success: () => {
  577. uni.navigateBack()
  578. }
  579. })
  580. } else {
  581. uni.showToast({
  582. title: res.data.msg || '提交失败,请稍后重试',
  583. icon: 'none'
  584. })
  585. }
  586. }).catch(err => {
  587. console.error("提交异常:", err)
  588. uni.showToast({
  589. title: '网络错误,请检查后重试',
  590. icon: 'none'
  591. })
  592. })
  593. } else {
  594. // 新建模式 - 提交审核
  595. console.log("this.formData", formData)
  596. addProductInfo(formData).then(res => {
  597. console.log("新增出售农产品", res)
  598. if (res.data.code === 200) {
  599. uni.showModal({
  600. title: '提交成功',
  601. content: '您的农产品信息已提交审核,审核通过后将在销售页面展示。',
  602. showCancel: false,
  603. success: () => {
  604. uni.navigateBack()
  605. }
  606. })
  607. } else {
  608. uni.showToast({
  609. title: res.data.msg || '提交失败,请稍后重试',
  610. icon: 'none'
  611. })
  612. }
  613. }).catch(err => {
  614. console.error("提交异常:", err)
  615. uni.showToast({
  616. title: '网络错误,请检查后重试',
  617. icon: 'none'
  618. })
  619. })
  620. }
  621. }
  622. </script>
  623. <style lang="scss">
  624. .sales-publish-container {
  625. min-height: 100vh;
  626. background-color: #f5f5f5;
  627. padding-bottom: calc(128rpx + env(safe-area-inset-bottom));
  628. }
  629. .form-container {
  630. padding: 20rpx;
  631. }
  632. .form-item {
  633. background-color: #fff;
  634. border-radius: 12rpx;
  635. padding: 24rpx;
  636. margin-bottom: 16rpx;
  637. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  638. }
  639. .item-label {
  640. display: flex;
  641. align-items: center;
  642. margin-bottom: 16rpx;
  643. }
  644. .label-text {
  645. font-size: 28rpx;
  646. color: #333;
  647. font-weight: bold;
  648. }
  649. .required {
  650. color: #ff4d4f;
  651. font-size: 28rpx;
  652. margin-left: 4rpx;
  653. }
  654. .optional {
  655. color: #999;
  656. font-size: 24rpx;
  657. margin-left: 8rpx;
  658. }
  659. .item-content {
  660. position: relative;
  661. }
  662. .form-input {
  663. width: 100%;
  664. height: 44rpx;
  665. font-size: 28rpx;
  666. color: #333;
  667. line-height: 44rpx;
  668. }
  669. .form-textarea {
  670. width: 100%;
  671. min-height: 120rpx;
  672. font-size: 28rpx;
  673. color: #333;
  674. line-height: 1.5;
  675. }
  676. .char-count {
  677. position: absolute;
  678. right: 0;
  679. bottom: -4rpx;
  680. font-size: 24rpx;
  681. color: #999;
  682. }
  683. // 分类选择器
  684. .category-selector {
  685. display: flex;
  686. align-items: center;
  687. justify-content: space-between;
  688. padding: 12rpx 0;
  689. border-bottom: 1rpx solid #f0f0f0;
  690. }
  691. .selector-text {
  692. font-size: 28rpx;
  693. color: #333;
  694. &.placeholder {
  695. color: #999;
  696. }
  697. }
  698. .arrow-icon {
  699. font-size: 24rpx;
  700. color: #999;
  701. }
  702. // 带单位的输入框
  703. .input-with-unit {
  704. display: flex;
  705. align-items: center;
  706. border-bottom: 1rpx solid #f0f0f0;
  707. padding: 12rpx 0;
  708. }
  709. .currency-symbol {
  710. font-size: 28rpx;
  711. color: #333;
  712. margin-right: 8rpx;
  713. }
  714. .unit-text {
  715. font-size: 28rpx;
  716. color: #666;
  717. margin-left: 8rpx;
  718. white-space: nowrap;
  719. }
  720. // 图片上传
  721. .image-upload-area {
  722. display: flex;
  723. flex-wrap: wrap;
  724. gap: 16rpx;
  725. }
  726. .image-item {
  727. position: relative;
  728. width: 160rpx;
  729. height: 160rpx;
  730. border-radius: 8rpx;
  731. overflow: hidden;
  732. }
  733. .uploaded-image {
  734. width: 100%;
  735. height: 100%;
  736. }
  737. .image-delete {
  738. position: absolute;
  739. top: -8rpx;
  740. right: -8rpx;
  741. width: 32rpx;
  742. height: 32rpx;
  743. background-color: #ff4d4f;
  744. color: #fff;
  745. border-radius: 50%;
  746. display: flex;
  747. align-items: center;
  748. justify-content: center;
  749. font-size: 20rpx;
  750. font-weight: bold;
  751. }
  752. .image-upload-btn {
  753. width: 160rpx;
  754. height: 160rpx;
  755. border: 2rpx dashed #ddd;
  756. border-radius: 8rpx;
  757. display: flex;
  758. flex-direction: column;
  759. align-items: center;
  760. justify-content: center;
  761. background-color: #fafafa;
  762. }
  763. .upload-icon {
  764. font-size: 48rpx;
  765. color: #999;
  766. margin-bottom: 8rpx;
  767. }
  768. .upload-text {
  769. font-size: 24rpx;
  770. color: #999;
  771. }
  772. // 产地信息
  773. .contact-info {
  774. background-color: #f8f9fa;
  775. border-radius: 8rpx;
  776. padding: 20rpx;
  777. }
  778. .contact-row {
  779. display: flex;
  780. align-items: center;
  781. margin-bottom: 12rpx;
  782. &:last-child {
  783. margin-bottom: 0;
  784. }
  785. }
  786. .contact-value {
  787. font-size: 26rpx;
  788. color: #333;
  789. }
  790. // 联系人信息输入
  791. .contact-input-row {
  792. display: flex;
  793. align-items: center;
  794. margin-bottom: 20rpx;
  795. &:last-child {
  796. margin-bottom: 0;
  797. }
  798. }
  799. .contact-label {
  800. font-size: 28rpx;
  801. color: #333;
  802. width: 120rpx;
  803. font-weight: bold;
  804. }
  805. .contact-input {
  806. flex: 1;
  807. height: 44rpx;
  808. font-size: 28rpx;
  809. color: #333;
  810. line-height: 44rpx;
  811. border-bottom: 1rpx solid #f0f0f0;
  812. padding: 12rpx 0;
  813. }
  814. // 底部提交按钮
  815. .bottom-action-bar {
  816. position: fixed;
  817. bottom: 0;
  818. left: 0;
  819. right: 0;
  820. width: 100%;
  821. background-color: #fff;
  822. border-top: 1rpx solid #f0f0f0;
  823. padding: 20rpx 30rpx;
  824. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  825. z-index: 1000;
  826. box-shadow: 0 -2rpx 8rpx rgba(0, 0, 0, 0.05);
  827. box-sizing: border-box;
  828. }
  829. .submit-btn {
  830. width: 100%;
  831. height: 88rpx;
  832. background-color: #4CAF50;
  833. border-radius: 12rpx;
  834. display: flex;
  835. align-items: center;
  836. justify-content: center;
  837. transition: background-color 0.2s ease;
  838. box-sizing: border-box;
  839. &:active {
  840. background-color: #45a049;
  841. }
  842. .btn-text {
  843. font-size: 32rpx;
  844. color: #fff;
  845. font-weight: bold;
  846. }
  847. }
  848. // 分类选择弹窗
  849. .picker-modal {
  850. position: fixed;
  851. top: 0;
  852. left: 0;
  853. width: 100%;
  854. height: 100%;
  855. background-color: rgba(0, 0, 0, 0.5);
  856. z-index: 2000;
  857. display: flex;
  858. align-items: flex-end;
  859. }
  860. .picker-content {
  861. width: 100%;
  862. background-color: #fff;
  863. border-radius: 24rpx 24rpx 0 0;
  864. padding: 0;
  865. }
  866. .picker-header {
  867. display: flex;
  868. justify-content: space-between;
  869. align-items: center;
  870. padding: 30rpx;
  871. border-bottom: 1rpx solid #f0f0f0;
  872. }
  873. .picker-title {
  874. font-size: 32rpx;
  875. font-weight: bold;
  876. color: #333;
  877. }
  878. .picker-close {
  879. font-size: 36rpx;
  880. color: #999;
  881. }
  882. .picker-options {
  883. padding: 20rpx 0;
  884. }
  885. .picker-option {
  886. padding: 24rpx 30rpx;
  887. border-bottom: 1rpx solid #f8f8f8;
  888. transition: background-color 0.2s ease;
  889. &:last-child {
  890. border-bottom: none;
  891. }
  892. &:active {
  893. // background-color: #f5f5f5;
  894. background-color: #f0f0f0;
  895. color: #007aff;
  896. font-weight: bold;
  897. }
  898. }
  899. .picker-option.active {
  900. background-color: #f0f0f0;
  901. color: #007aff;
  902. font-weight: bold;
  903. }
  904. .option-text {
  905. font-size: 30rpx;
  906. color: #333;
  907. }
  908. </style>