completeTask.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988
  1. <template>
  2. <view class="container">
  3. <scroll-view class="content" scroll-y>
  4. <!-- 标题 -->
  5. <view class="form-section">
  6. <view class="form-label">
  7. <text class="required">*</text>
  8. <text>标题</text>
  9. </view>
  10. <view class="form-input-wrapper">
  11. <textarea
  12. class="form-input"
  13. style="height: 100rpx;"
  14. v-model="formData.title"
  15. placeholder="请输入标题"
  16. maxlength="50"
  17. @input="onTitleInput"
  18. ></textarea>
  19. <view class="char-count">{{ titleLength }}/50</view>
  20. </view>
  21. </view>
  22. <!-- 摘要 -->
  23. <view class="form-section">
  24. <view class="form-label">
  25. <text>摘要 (选填)</text>
  26. </view>
  27. <view class="form-input-wrapper">
  28. <textarea
  29. class="form-input"
  30. v-model="formData.summary"
  31. placeholder="请输入摘要"
  32. maxlength="100"
  33. @input="onSummaryInput"
  34. ></textarea>
  35. <view class="char-count">{{ summaryLength }}/100</view>
  36. </view>
  37. </view>
  38. <!-- 项目分组 -->
  39. <view class="form-section">
  40. <view class="form-label">
  41. <text class="required">*</text>
  42. <text>项目分组</text>
  43. </view>
  44. <view class="form-select" @click="showGroupPicker = true">
  45. <text :class="formData.groupId ? '' : 'placeholder'">
  46. {{ formData.groupName || '请选择分组' }}
  47. </text>
  48. <text class="arrow-right">></text>
  49. </view>
  50. </view>
  51. <!-- 项目标签 -->
  52. <view class="form-section">
  53. <view class="form-label">
  54. <text class="required">*</text>
  55. <text>项目标签</text>
  56. </view>
  57. <view class="form-select" @click="showTagPicker = true">
  58. <text :class="formData.tagId ? '' : 'placeholder'">
  59. {{ formData.tagName || '请选择标签' }}
  60. </text>
  61. <text class="arrow-right">></text>
  62. </view>
  63. </view>
  64. <!-- 上传封面 -->
  65. <view class="form-section">
  66. <view class="form-label">
  67. <text class="required">*</text>
  68. <text>上传封面</text>
  69. </view>
  70. <view class="form-tips">仅支持jpg/png文件,单个图片不超过2M</view>
  71. <view class="upload-cover" @click="chooseCoverImage">
  72. <image class="img" v-if="formData.coverImage" :src="formData.coverImage" mode=""></image>
  73. <view v-else class="upload-placeholder">
  74. <image class="w48 h48" src="@/static/image/icon_camera1.png" mode=""></image>
  75. </view>
  76. </view>
  77. </view>
  78. <!-- 上传进度弹窗 -->
  79. <view class="upload-modal" v-if="showUploadModal">
  80. <view class="upload-modal-content">
  81. <view class="upload-modal-title">文件上传中</view>
  82. <view class="upload-progress-wrapper">
  83. <progress :percent="percent" stroke-width="8" show-info activeColor="#4CAF50" border-radius="10"></progress>
  84. </view>
  85. <view class="upload-modal-tips">请勿关闭页面</view>
  86. </view>
  87. </view>
  88. <!-- 上传附件 -->
  89. <view class="form-section">
  90. <view class="form-label">
  91. <text class="required">*</text>
  92. <text>上传附件</text>
  93. </view>
  94. <view v-if="taskType==4" class="form-tips">支持PDF等文件,单个文件不超过2M</view>
  95. <view v-else class="form-tips">支持MP4等文件,单个文件不超过500M</view>
  96. <view class="attachment-list">
  97. <view class="attachment-item" v-for="(item, index) in formData.attachments" :key="index">
  98. <text class="attachment-icon"></text>
  99. <view class="attachment-info" style="width: 90%;">
  100. <text class="attachment-name one-t" style="width: 90%;">{{ item.name }}</text>
  101. <text class="attachment-size">{{ item.size }}</text>
  102. </view>
  103. <text class="attachment-delete" @click="removeAttachment(index)">×</text>
  104. </view>
  105. <view class="add-attachment" @click="chooseAttachment">
  106. <text class="add-icon">+</text>
  107. <text>添加附件</text>
  108. </view>
  109. </view>
  110. </view>
  111. </scroll-view>
  112. <!-- 提交按钮 -->
  113. <view class="submit-box">
  114. <view class="submit-btn" @click="handleSubmit">提交</view>
  115. </view>
  116. <!-- 分组选择弹窗 -->
  117. <view class="picker-popup" v-if="showGroupPicker" @click="showGroupPicker = false">
  118. <view class="picker-content" @click.stop>
  119. <view class="picker-header">
  120. <view class="picker-cancel" @click="showGroupPicker = false">取消</view>
  121. <view class="picker-title">选择分组</view>
  122. <view class="picker-confirm" @click="confirmGroup">确定</view>
  123. </view>
  124. <view class="picker-body">
  125. <view class="picker-item"
  126. :class="{ active: tempGroupId === item.id }"
  127. v-for="(item, index) in groupOptions"
  128. :key="index"
  129. @click="tempGroupId = item.id; tempGroupName = item.projectName">
  130. {{ item.projectName }}
  131. </view>
  132. </view>
  133. </view>
  134. </view>
  135. <!-- 标签选择弹窗 -->
  136. <view class="picker-popup" v-if="showTagPicker" @click="showTagPicker = false">
  137. <view class="picker-content" @click.stop>
  138. <view class="picker-header">
  139. <view class="picker-cancel" @click="showTagPicker = false">取消</view>
  140. <view class="picker-title">选择标签</view>
  141. <view class="picker-confirm" @click="confirmTag">确定</view>
  142. </view>
  143. <view class="picker-body">
  144. <view class="picker-item"
  145. :class="{ active: tempTagId === item.dictValue }"
  146. v-for="(item, index) in tagOptions"
  147. :key="index"
  148. @click="tempTagId = item.dictValue; tempTagName = item.dictLabel">
  149. {{ item.dictLabel }}
  150. </view>
  151. </view>
  152. </view>
  153. </view>
  154. </view>
  155. </template>
  156. <script>
  157. import { submitTask, getGroupOptions, getTagOptions } from '@/api/airClassroom'
  158. import { deleteFile, deleteBatch, checkFast, complete,postPolicy} from '@/api/common.js'
  159. export default {
  160. data() {
  161. return {
  162. percent: 0,
  163. showUploadModal: false, // 控制上传进度弹窗显示
  164. statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px',
  165. taskId: '',
  166. taskType:null,
  167. isEdit: false,
  168. showGroupPicker: false,
  169. showTagPicker: false,
  170. tempGroupId: '',
  171. tempGroupName: '',
  172. tempTagId: '',
  173. tempTagName: '',
  174. formData: {
  175. title: '',
  176. summary: '',
  177. groupId: '',
  178. groupName: '',
  179. tagId: '',
  180. tagName: '',
  181. coverImage: '',
  182. attachments: []
  183. },
  184. groupOptions: [
  185. // { id: '1', name: '学术' },
  186. // { id: '2', name: '临床' },
  187. // { id: '3', name: '科研' }
  188. ],
  189. tagOptions: [
  190. // { id: '1', name: '长视频' },
  191. // { id: '2', name: '短视频' },
  192. // { id: '3', name: '文章' }
  193. ]
  194. }
  195. },
  196. computed: {
  197. titleLength() {
  198. return this.formData.title.length
  199. },
  200. summaryLength() {
  201. return this.formData.summary.length
  202. }
  203. },
  204. onLoad(options) {
  205. if (options.id) {
  206. this.taskId = options.id
  207. this.taskType = options.taskType
  208. }
  209. if (options.edit === 'true') {
  210. this.isEdit = true
  211. this.loadTaskData()
  212. }
  213. this.loadOptions()
  214. },
  215. methods: {
  216. goBack() {
  217. uni.navigateBack()
  218. },
  219. onTitleInput(e) {
  220. this.formData.title = e.detail.value
  221. },
  222. onSummaryInput(e) {
  223. this.formData.summary = e.detail.value
  224. },
  225. confirmGroup() {
  226. this.formData.groupId = this.tempGroupId
  227. this.formData.groupName = this.tempGroupName
  228. this.showGroupPicker = false
  229. },
  230. confirmTag() {
  231. this.formData.tagId = this.tempTagId
  232. this.formData.tagName = this.tempTagName
  233. this.showTagPicker = false
  234. },
  235. chooseCoverImage() {
  236. uni.chooseImage({
  237. count: 1,
  238. sizeType: ['compressed'],
  239. sourceType: ['album', 'camera'],
  240. success: (res) => {
  241. uni.showLoading({ title: '上传中...' })
  242. console.log('图片路径',res)
  243. const filePath = res.tempFilePaths[0]
  244. const requestPath = uni.getStorageSync('requestPath')
  245. const uploadTask = uni.uploadFile({
  246. url: `${requestPath}/app/common/uploadOSS`,
  247. filePath: filePath,
  248. name: 'file',
  249. formData: {},
  250. success: (uploadRes) => {
  251. uni.hideLoading()
  252. try {
  253. const result = typeof uploadRes.data === 'string' ? JSON.parse(uploadRes.data) : uploadRes.data
  254. if (result.code == 200) {
  255. this.formData.coverImage = result.url
  256. uni.showToast({ icon: 'success', title: '上传成功' })
  257. } else {
  258. uni.showToast({ icon: 'none', title: result.msg || '上传失败' })
  259. }
  260. } catch (e) {
  261. uni.hideLoading()
  262. console.error('解析上传结果失败', e)
  263. uni.showToast({ icon: 'none', title: '上传失败' })
  264. }
  265. },
  266. fail: (err) => {
  267. // this.percent = 0;
  268. console.error('上传失败', err)
  269. uni.showToast({ icon: 'none', title: '上传失败' })
  270. }
  271. })
  272. }
  273. })
  274. },
  275. chooseAttachment(){
  276. var vm = this;
  277. 
  278. // 对更多字符编码的 url encode 格式
  279. var camSafeUrlEncode = function (str) {
  280. return encodeURIComponent(str)
  281. .replace(/!/g, '%21')
  282. .replace(/'/g, '%27')
  283. .replace(/\(/g, '%28')
  284. .replace(/\)/g, '%29')
  285. .replace(/\*/g, '%2A');
  286. };
  287.  const requestPath = uni.getStorageSync('requestPath')
  288. // 获取上传路径、上传凭证
  289. var getUploadInfo = function (extName, callback) {
  290. // 传入文件后缀,让后端生成随机的 COS 对象路径,并返回上传域名、PostObject 接口要用的 policy 签名
  291. // 参考服务端示例:https://github.com/tencentyun/cos-demo/tree/main/server/post-policy
  292. uni.request({
  293. url: `${requestPath}/app/upload/post-policy?ext=` + extName,
  294. success: (res) => {
  295. // 确认返回格式是否正确
  296. //console.log(res);
  297. callback && callback(null, res.data);
  298. },
  299. error(err) {
  300. callback && callback(err);
  301. },
  302. });
  303. };
  304. 
  305. // 发起上传请求,上传使用 PostObject 接口,使用 policy 签名保护
  306. // 接口文档:https://cloud.tencent.com/document/product/436/14690#.E7.AD.BE.E5.90.8D.E4.BF.9D.E6.8A.A4
  307. var uploadFile = function (opt, callback) {
  308. console.log("上传参数", opt);
  309. // 构建表单数据(字段名必须使用带连字符的格式,符合腾讯云 PostObject 接口要求)
  310. var formData = {
  311. key: opt.data.key, // 文件路径(必须是 key,不是 cosKey)
  312. policy: opt.data.policy, // policy 的 base64 字符串
  313. success_action_status: '200', // 成功状态码
  314. 'q-sign-algorithm': opt.data.qsignAlgorithm,// 签名算法(必须是 q-sign-algorithm)
  315. 'q-ak': opt.data.qak,
  316. 'q-key-time': opt.data.qkeyTime, // 密钥有效时间(必须是 q-key-time)
  317. 'q-signature': opt.data.qsignature // 签名(必须是 q-signature)
  318. };
  319. // 如果服务端用了临时密钥计算,需要传 x-cos-security-token
  320. if (opt.data.securityToken) {
  321. formData['x-cos-security-token'] = opt.data.securityToken;
  322. }
  323. console.log("上传URL", opt.data.url);
  324. console.log("文件路径", opt.filePath);
  325. // 显示上传进度弹窗
  326. vm.showUploadModal = true;
  327. vm.percent = 0;
  328. const uploadTask=uni.uploadFile({
  329. url: opt.data.url, // COS 上传域名
  330. filePath: opt.filePath, // 文件路径(不在 formData 中)
  331. name: 'file', // 文件字段名
  332. formData: formData, // 表单数据
  333. success: (res) => {
  334. console.log("上传响应", res);
  335. // 关闭上传进度弹窗
  336. vm.showUploadModal = false;
  337. vm.percent = 0;
  338. if (![200, 204].includes(res.statusCode)) {
  339. console.error("上传失败,状态码:", res.statusCode, res);
  340. return callback && callback(res);
  341. }
  342. // 构建文件访问 URL
  343. var fileUrl = opt.data.url + '/' + camSafeUrlEncode(opt.data.key).replace(/%2F/g, '/');
  344. console.log("上传成功,文件URL:", fileUrl);
  345. callback && callback(null, fileUrl);
  346. },
  347. fail: (err) => {
  348. console.error("上传失败", err);
  349. // 关闭上传进度弹窗
  350. vm.showUploadModal = false;
  351. vm.percent = 0;
  352. callback && callback(err);
  353. }
  354. });
  355. uploadTask.onProgressUpdate(function(res) {
  356. vm.percent = res.progress;
  357. });
  358. };
  359. 
  360. // 根据 taskType 选择不同的文件类型
  361. // taskType = 4(科普文章):上传普通文档文件
  362. // taskType = 5 或 6:上传视频文件
  363. var taskType = vm.taskType;
  364. console.log('当前 taskType:', taskType);
  365. // taskType = 5 或 6,选择视频文件
  366. if (taskType == 5 || taskType == 6) {
  367. // 选择视频文件
  368. wx.chooseMessageFile({
  369. count: 3,
  370. type: 'video',
  371. success: (chooseRes) => {
  372. console.log('选择视频', chooseRes);
  373. var filePath = chooseRes.tempFiles[0].path;
  374. var size = chooseRes.tempFiles[0].size;
  375. var name = chooseRes.tempFiles[0].name;
  376. var lastIndex = filePath.lastIndexOf('.');
  377. var extName = lastIndex > -1 ? filePath.slice(lastIndex + 1) : '';
  378. // 获取预上传用的域名、路径、凭证
  379. getUploadInfo(extName, function (err, info) {
  380. if (err) {
  381. console.error('获取上传信息失败', err);
  382. uni.showToast({ icon: 'none', title: '获取上传信息失败' });
  383. return;
  384. }
  385. console.log("上传信息", info);
  386. info.filePath = filePath;
  387. // 上传文件
  388. uploadFile(info, function (err, fileUrl) {
  389. if (err) {
  390. console.error('上传失败', err);
  391. uni.showToast({ icon: 'none', title: '上传失败' });
  392. return;
  393. }
  394. console.log('上传成功,文件URL:', fileUrl);
  395. // 添加到附件列表
  396. vm.formData.attachments.push({
  397. name:name,
  398. size: vm.formatFileSize(size || 0),
  399. url: fileUrl
  400. });
  401. uni.showToast({ icon: 'success', title: '上传成功' });
  402. });
  403. });
  404. },
  405. fail: (err) => {
  406. if (err.errMsg && !err.errMsg.includes('cancel')) {
  407. console.error('选择视频失败', err);
  408. uni.showToast({ icon: 'none', title: '选择视频失败' });
  409. }
  410. }
  411. });
  412. return;
  413. }else{
  414. wx.chooseMessageFile({
  415. count: 1,
  416. type: 'file', // 选择文档文件(不包括视频和图片)
  417. success: (res) => {
  418. console.log('文档路径',res)
  419. const filePath = res.tempFiles[0].path
  420. const fileName = res.tempFiles[0].name
  421. const size = res.tempFiles[0].size;
  422. const requestPath = uni.getStorageSync('requestPath')
  423. // 显示上传进度弹窗
  424. vm.showUploadModal = true;
  425. vm.percent = 0;
  426. const uploadTask = uni.uploadFile({
  427. url: `${requestPath}/app/common/uploadOSS`,
  428. filePath: filePath,
  429. name: 'file',
  430. formData: {},
  431. success: (uploadRes) => {
  432. // 关闭上传进度弹窗
  433. vm.showUploadModal = false;
  434. vm.percent = 0;
  435. try {
  436. const result = typeof uploadRes.data === 'string' ? JSON.parse(uploadRes.data) : uploadRes.data
  437. if (result.code == 200) {
  438. //this.formData.attachmentUrl = result.url
  439. vm.formData.attachments.push({
  440. name:fileName,
  441. size: vm.formatFileSize(size || 0),
  442. url: result.url
  443. });
  444. uni.showToast({ icon: 'success', title: '上传成功' })
  445. } else {
  446. uni.showToast({ icon: 'none', title: result.msg || '上传失败' })
  447. }
  448. } catch (e) {
  449. console.error('解析上传结果失败', e)
  450. uni.showToast({ icon: 'none', title: '上传失败' })
  451. }
  452. },
  453. fail: (err) => {
  454. // 关闭上传进度弹窗
  455. vm.showUploadModal = false;
  456. vm.percent = 0;
  457. console.error('上传失败', err)
  458. uni.showToast({ icon: 'none', title: '上传失败' })
  459. }
  460. })
  461. // 监听上传进度
  462. uploadTask.onProgressUpdate(function(res) {
  463. vm.percent = res.progress;
  464. })
  465. },
  466. fail: (err) => {
  467. if (err.errMsg && !err.errMsg.includes('cancel')) {
  468. console.error('选择文档失败', err);
  469. uni.showToast({ icon: 'none', title: '选择文档失败' });
  470. }
  471. }
  472. });
  473. }
  474. },
  475. removeAttachment(index) {
  476. this.formData.attachments.splice(index, 1)
  477. },
  478. formatFileSize(bytes) {
  479. if (bytes < 1024) return bytes + 'B'
  480. if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(2) + 'KB'
  481. return (bytes / (1024 * 1024)).toFixed(2) + 'MB'
  482. },
  483. // 根据文件扩展名获取文件类型
  484. getFileType(fileExt) {
  485. const typeMap = {
  486. // 视频
  487. 'mp4': 'video',
  488. 'avi': 'video',
  489. 'mov': 'video',
  490. 'wmv': 'video',
  491. 'flv': 'video',
  492. 'mkv': 'video',
  493. // 音频
  494. 'mp3': 'audio',
  495. 'wav': 'audio',
  496. 'wma': 'audio',
  497. // 图片
  498. 'jpg': 'image',
  499. 'jpeg': 'image',
  500. 'png': 'image',
  501. 'gif': 'image',
  502. 'bmp': 'image',
  503. // 文档
  504. 'pdf': 'document',
  505. 'doc': 'document',
  506. 'docx': 'document',
  507. 'xls': 'document',
  508. 'xlsx': 'document',
  509. 'ppt': 'document',
  510. 'pptx': 'document',
  511. 'txt': 'document'
  512. }
  513. return typeMap[fileExt] || 'other'
  514. },
  515. async loadOptions() {
  516. try {
  517. const [groupRes, tagRes] = await Promise.all([
  518. getGroupOptions(),
  519. getTagOptions({dictType:'project_label'})
  520. ])
  521. if (groupRes.code === 200 && groupRes.data) {
  522. this.groupOptions = groupRes.data
  523. }
  524. if (tagRes.code === 200 && tagRes.data) {
  525. this.tagOptions = tagRes.data
  526. }
  527. } catch (e) {
  528. console.error('加载选项失败', e)
  529. }
  530. },
  531. async loadTaskData() {
  532. // 加载已有任务数据
  533. },
  534. async handleSubmit() {
  535. if (!this.formData.title) {
  536. uni.showToast({ icon: 'none', title: '请输入标题' })
  537. return
  538. }
  539. if (!this.formData.groupId) {
  540. uni.showToast({ icon: 'none', title: '请选择项目分组' })
  541. return
  542. }
  543. if (!this.formData.tagId) {
  544. uni.showToast({ icon: 'none', title: '请选择项目标签' })
  545. return
  546. }
  547. if (!this.formData.coverImage) {
  548. uni.showToast({ icon: 'none', title: '请上传封面' })
  549. return
  550. }
  551. // 附件可选,不再强制要求
  552. // if (this.formData.attachments.length === 0) {
  553. // uni.showToast({ icon: 'none', title: '请上传附件' })
  554. // return
  555. // }
  556. try {
  557. uni.showLoading({ title: '提交中...' })
  558. // 获取用户信息
  559. const userInfo = JSON.parse(uni.getStorageSync('userInfo') || '{}')
  560. const userId = userInfo.id || ''
  561. // 构建附件 URL(多个附件用逗号分隔,确保是字符串类型)
  562. const attachmentUrl = this.formData.attachments && this.formData.attachments.length > 0
  563. ? this.formData.attachments.map(item => item.url).filter(url => url).join(',')
  564. : '' // 如果没有附件,返回空字符串
  565. // 按照 API 要求的 JSON 结构构建提交数据
  566. const submitData = {
  567. attachmentUrl: attachmentUrl, // 附件 URL(多个用逗号分隔)
  568. content: this.formData.summary || '', // 摘要/内容
  569. coverImage: this.formData.coverImage, // 封面图片
  570. projectId: parseInt(this.formData.groupId) || 0, // 项目分组 ID
  571. tagIds: this.formData.tagId || '', // 标签 ID(字符串)
  572. taskId: parseInt(this.taskId) || 0, // 任务 ID
  573. title: this.formData.title, // 标题
  574. userId: userId, // 用户 ID
  575. taskType:this.taskType,
  576. // 以下字段为可选,设置默认值
  577. // deliveryName: '',
  578. // deliveryNo: '',
  579. // projectLink: '',
  580. // remark: '',
  581. // taskName: '',
  582. // taskType:this.taskType,
  583. // validViews: 0,
  584. // viewCount: 0
  585. }
  586. const res = await submitTask(submitData)
  587. uni.hideLoading()
  588. if (res.code === 200) {
  589. uni.navigateTo({
  590. url: '/pages_task/taskCompleteSuccess'
  591. })
  592. } else {
  593. uni.showToast({ icon: 'none', title: res.msg || '提交失败' })
  594. }
  595. } catch (e) {
  596. uni.hideLoading()
  597. console.error('提交失败', e)
  598. uni.showToast({ icon: 'none', title: '提交失败' })
  599. }
  600. }
  601. }
  602. }
  603. </script>
  604. <style lang="scss" scoped>
  605. .container {
  606. min-height: 100vh;
  607. background: #f5f5f5;
  608. display: flex;
  609. flex-direction: column;
  610. }
  611. .status-bar {
  612. width: 100%;
  613. background: #fff;
  614. }
  615. .header {
  616. position: relative;
  617. height: 88rpx;
  618. display: flex;
  619. align-items: center;
  620. justify-content: center;
  621. background: #fff;
  622. border-bottom: 1rpx solid #f0f0f0;
  623. .back-btn {
  624. position: absolute;
  625. left: 24rpx;
  626. width: 40rpx;
  627. height: 40rpx;
  628. image {
  629. width: 100%;
  630. height: 100%;
  631. }
  632. }
  633. .title {
  634. font-size: 36rpx;
  635. font-weight: bold;
  636. color: #333;
  637. }
  638. .header-right {
  639. position: absolute;
  640. right: 24rpx;
  641. display: flex;
  642. align-items: center;
  643. gap: 16rpx;
  644. .more-icon {
  645. font-size: 32rpx;
  646. color: #333;
  647. }
  648. }
  649. }
  650. .content {
  651. flex: 1;
  652. padding: 24rpx;
  653. padding-bottom: 120rpx;
  654. box-sizing: border-box;
  655. }
  656. .form-section {
  657. background: #fff;
  658. border-radius: 16rpx;
  659. padding: 24rpx;
  660. &:last-child{
  661. border-bottom: 0;
  662. }
  663. // margin-bottom: 24rpx;
  664. .form-label {
  665. display: flex;
  666. align-items: center;
  667. margin-bottom: 16rpx;
  668. font-size: 28rpx;
  669. color: #333;
  670. .required {
  671. color: #FF5030;
  672. margin-right: 4rpx;
  673. }
  674. }
  675. .form-tips {
  676. font-size: 24rpx;
  677. color: #999;
  678. margin-bottom: 16rpx;
  679. }
  680. .form-input-wrapper {
  681. position: relative;
  682. border-bottom: 1rpx solid #EBEDF0;
  683. .form-input {
  684. width: 100%;
  685. min-height: 120rpx;
  686. padding: 16rpx;
  687. font-size: 28rpx;
  688. color: #333;
  689. box-sizing: border-box;
  690. }
  691. .char-count {
  692. position: absolute;
  693. right: 16rpx;
  694. bottom: 16rpx;
  695. font-size: 24rpx;
  696. color: #999;
  697. }
  698. }
  699. .form-select {
  700. display: flex;
  701. align-items: center;
  702. justify-content: space-between;
  703. height: 80rpx;
  704. padding: 0 24rpx;
  705. border-bottom: 1rpx solid #EBEDF0;
  706. font-size: 28rpx;
  707. color: #333;
  708. .placeholder {
  709. color: #999;
  710. }
  711. .arrow-right {
  712. font-size: 24rpx;
  713. color: #999;
  714. }
  715. }
  716. .upload-cover {
  717. width: 200rpx;
  718. height: 200rpx;
  719. background: #f5f5f5;
  720. border-radius: 8rpx;
  721. display: flex;
  722. align-items: center;
  723. justify-content: center;
  724. .img {
  725. width: 100%;
  726. height: 100%;
  727. border-radius: 8rpx;
  728. }
  729. .upload-placeholder {
  730. .camera-icon {
  731. font-size: 60rpx;
  732. }
  733. }
  734. }
  735. .attachment-list {
  736. .attachment-item {
  737. display: flex;
  738. align-items: center;
  739. padding: 16rpx;
  740. background: #f5f5f5;
  741. border-radius: 8rpx;
  742. margin-bottom: 16rpx;
  743. .attachment-icon {
  744. font-size: 32rpx;
  745. margin-right: 16rpx;
  746. }
  747. .attachment-info {
  748. flex: 1;
  749. display: flex;
  750. flex-direction: column;
  751. .attachment-name {
  752. font-size: 28rpx;
  753. color: #333;
  754. margin-bottom: 4rpx;
  755. }
  756. .attachment-size {
  757. font-size: 24rpx;
  758. color: #999;
  759. }
  760. }
  761. .attachment-delete {
  762. font-size: 40rpx;
  763. color: #999;
  764. width: 40rpx;
  765. height: 40rpx;
  766. display: flex;
  767. align-items: center;
  768. justify-content: center;
  769. }
  770. }
  771. .add-attachment {
  772. display: flex;
  773. align-items: center;
  774. justify-content: center;
  775. padding: 24rpx;
  776. background: rgba(56,139,255,0.08);
  777. border-radius: 12rpx 12rpx 12rpx 12rpx;
  778. border: 2rpx solid #388BFF;
  779. font-family: PingFang SC, PingFang SC;
  780. font-weight: 400;
  781. font-size: 28rpx;
  782. color: #388BFF;
  783. .add-icon {
  784. font-size: 32rpx;
  785. margin-right: 8rpx;
  786. }
  787. }
  788. }
  789. }
  790. .submit-box{
  791. position: fixed;
  792. bottom: 0;
  793. left: 0;
  794. right: 0;
  795. background: #fff;
  796. z-index: 100;
  797. padding: 24rpx 32rpx;
  798. .submit-btn {
  799. height: 88rpx;
  800. background: #388BFF;
  801. border-radius: 200rpx 200rpx 200rpx 200rpx;
  802. display: flex;
  803. align-items: center;
  804. justify-content: center;
  805. font-size: 32rpx;
  806. color: #fff;
  807. font-weight: 500;
  808. }
  809. }
  810. .picker-popup {
  811. position: fixed;
  812. top: 0;
  813. left: 0;
  814. right: 0;
  815. bottom: 0;
  816. background: rgba(0, 0, 0, 0.5);
  817. z-index: 999;
  818. display: flex;
  819. align-items: flex-end;
  820. }
  821. .picker-content {
  822. width: 100%;
  823. background: #fff;
  824. border-radius: 24rpx 24rpx 0 0;
  825. .picker-header {
  826. display: flex;
  827. align-items: center;
  828. justify-content: space-between;
  829. padding: 24rpx;
  830. border-bottom: 1rpx solid #f0f0f0;
  831. .picker-cancel {
  832. font-size: 30rpx;
  833. color: #666;
  834. }
  835. .picker-title {
  836. font-size: 32rpx;
  837. font-weight: bold;
  838. color: #333;
  839. }
  840. .picker-confirm {
  841. font-size: 30rpx;
  842. color: #388BFF;
  843. }
  844. }
  845. .picker-body {
  846. padding: 24rpx;
  847. max-height: 600rpx;
  848. overflow-y: auto;
  849. .picker-item {
  850. padding: 24rpx 0;
  851. font-size: 30rpx;
  852. color: #333;
  853. border-bottom: 1rpx solid #f0f0f0;
  854. &:last-child {
  855. border-bottom: none;
  856. }
  857. &.active {
  858. color: #388BFF;
  859. font-weight: bold;
  860. }
  861. }
  862. }
  863. }
  864. // 上传进度弹窗样式
  865. .upload-modal {
  866. position: fixed;
  867. top: 0;
  868. left: 0;
  869. right: 0;
  870. bottom: 0;
  871. background: rgba(0, 0, 0, 0.6);
  872. z-index: 9999;
  873. display: flex;
  874. align-items: center;
  875. justify-content: center;
  876. .upload-modal-content {
  877. width: 560rpx;
  878. background: #fff;
  879. border-radius: 24rpx;
  880. padding: 48rpx 40rpx;
  881. display: flex;
  882. flex-direction: column;
  883. align-items: center;
  884. .upload-modal-title {
  885. font-size: 32rpx;
  886. font-weight: bold;
  887. color: #333;
  888. margin-bottom: 40rpx;
  889. }
  890. .upload-progress-wrapper {
  891. width: 100%;
  892. margin-bottom: 32rpx;
  893. }
  894. .upload-modal-tips {
  895. font-size: 24rpx;
  896. color: #999;
  897. }
  898. }
  899. }
  900. </style>