sales-publish.vue 26 KB

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