completeTask.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987
  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. // 对更多字符编码的 url encode 格式
  278. var camSafeUrlEncode = function (str) {
  279. return encodeURIComponent(str)
  280. .replace(/!/g, '%21')
  281. .replace(/'/g, '%27')
  282. .replace(/\(/g, '%28')
  283. .replace(/\)/g, '%29')
  284. .replace(/\*/g, '%2A');
  285. };
  286.  const requestPath = uni.getStorageSync('requestPath')
  287. // 获取上传路径、上传凭证
  288. var getUploadInfo = function (extName, callback) {
  289. // 传入文件后缀,让后端生成随机的 COS 对象路径,并返回上传域名、PostObject 接口要用的 policy 签名
  290. // 参考服务端示例:https://github.com/tencentyun/cos-demo/tree/main/server/post-policy
  291. uni.request({
  292. url: `${requestPath}/app/upload/post-policy?ext=` + extName,
  293. success: (res) => {
  294. // 确认返回格式是否正确
  295. //console.log(res);
  296. callback && callback(null, res.data);
  297. },
  298. error(err) {
  299. callback && callback(err);
  300. },
  301. });
  302. };
  303. 
  304. // 发起上传请求,上传使用 PostObject 接口,使用 policy 签名保护
  305. // 接口文档:https://cloud.tencent.com/document/product/436/14690#.E7.AD.BE.E5.90.8D.E4.BF.9D.E6.8A.A4
  306. var uploadFile = function (opt, callback) {
  307. console.log("上传参数", opt);
  308. // 构建表单数据(字段名必须使用带连字符的格式,符合腾讯云 PostObject 接口要求)
  309. var formData = {
  310. key: opt.data.key, // 文件路径(必须是 key,不是 cosKey)
  311. policy: opt.data.policy, // policy 的 base64 字符串
  312. success_action_status: '200', // 成功状态码
  313. 'q-sign-algorithm': opt.data.qsignAlgorithm,// 签名算法(必须是 q-sign-algorithm)
  314. 'q-ak': opt.data.qak,
  315. 'q-key-time': opt.data.qkeyTime, // 密钥有效时间(必须是 q-key-time)
  316. 'q-signature': opt.data.qsignature // 签名(必须是 q-signature)
  317. };
  318. // 如果服务端用了临时密钥计算,需要传 x-cos-security-token
  319. if (opt.data.securityToken) {
  320. formData['x-cos-security-token'] = opt.data.securityToken;
  321. }
  322. console.log("上传URL", opt.data.url);
  323. console.log("文件路径", opt.filePath);
  324. // 显示上传进度弹窗
  325. vm.showUploadModal = true;
  326. vm.percent = 0;
  327. const uploadTask=uni.uploadFile({
  328. url: opt.data.url, // COS 上传域名
  329. filePath: opt.filePath, // 文件路径(不在 formData 中)
  330. name: 'file', // 文件字段名
  331. formData: formData, // 表单数据
  332. success: (res) => {
  333. console.log("上传响应", res);
  334. // 关闭上传进度弹窗
  335. vm.showUploadModal = false;
  336. vm.percent = 0;
  337. if (![200, 204].includes(res.statusCode)) {
  338. console.error("上传失败,状态码:", res.statusCode, res);
  339. return callback && callback(res);
  340. }
  341. // 构建文件访问 URL
  342. var fileUrl = opt.data.url + '/' + camSafeUrlEncode(opt.data.key).replace(/%2F/g, '/');
  343. console.log("上传成功,文件URL:", fileUrl);
  344. callback && callback(null, fileUrl);
  345. },
  346. fail: (err) => {
  347. console.error("上传失败", err);
  348. // 关闭上传进度弹窗
  349. vm.showUploadModal = false;
  350. vm.percent = 0;
  351. callback && callback(err);
  352. }
  353. });
  354. uploadTask.onProgressUpdate(function(res) {
  355. vm.percent = res.progress;
  356. });
  357. };
  358. 
  359. // 根据 taskType 选择不同的文件类型
  360. // taskType = 4(科普文章):上传普通文档文件
  361. // taskType = 5 或 6:上传视频文件
  362. var taskType = vm.taskType;
  363. console.log('当前 taskType:', taskType);
  364. // taskType = 5 或 6,选择视频文件
  365. if (taskType == 3 ||taskType == 5 || taskType == 6) {
  366. // 选择视频文件
  367. wx.chooseMessageFile({
  368. count: 1,
  369. type: 'video',
  370. success: (chooseRes) => {
  371. console.log('选择视频', chooseRes);
  372. var filePath = chooseRes.tempFiles[0].path;
  373. var size = chooseRes.tempFiles[0].size;
  374. var name = chooseRes.tempFiles[0].name;
  375. var lastIndex = filePath.lastIndexOf('.');
  376. var extName = lastIndex > -1 ? filePath.slice(lastIndex + 1) : '';
  377. // 获取预上传用的域名、路径、凭证
  378. getUploadInfo(extName, function (err, info) {
  379. if (err) {
  380. console.error('获取上传信息失败', err);
  381. uni.showToast({ icon: 'none', title: '获取上传信息失败' });
  382. return;
  383. }
  384. console.log("上传信息", info);
  385. info.filePath = filePath;
  386. // 上传文件
  387. uploadFile(info, function (err, fileUrl) {
  388. if (err) {
  389. console.error('上传失败', err);
  390. uni.showToast({ icon: 'none', title: '上传失败' });
  391. return;
  392. }
  393. console.log('上传成功,文件URL:', fileUrl);
  394. // 添加到附件列表
  395. vm.formData.attachments.push({
  396. name:name,
  397. size: vm.formatFileSize(size || 0),
  398. url: fileUrl
  399. });
  400. uni.showToast({ icon: 'success', title: '上传成功' });
  401. });
  402. });
  403. },
  404. fail: (err) => {
  405. if (err.errMsg && !err.errMsg.includes('cancel')) {
  406. console.error('选择视频失败', err);
  407. uni.showToast({ icon: 'none', title: '选择视频失败' });
  408. }
  409. }
  410. });
  411. return;
  412. }else{
  413. wx.chooseMessageFile({
  414. count: 1,
  415. type:'file',
  416. success: (res) => {
  417. console.log('文档路径',res)
  418. const filePath = res.tempFiles[0].path
  419. const fileName = res.tempFiles[0].name
  420. const size = res.tempFiles[0].size;
  421. const requestPath = uni.getStorageSync('requestPath')
  422. // 显示上传进度弹窗
  423. vm.showUploadModal = true;
  424. vm.percent = 0;
  425. const uploadTask = uni.uploadFile({
  426. url: `${requestPath}/app/common/uploadOSS`,
  427. filePath: filePath,
  428. name: 'file',
  429. formData: {},
  430. success: (uploadRes) => {
  431. // 关闭上传进度弹窗
  432. vm.showUploadModal = false;
  433. vm.percent = 0;
  434. try {
  435. const result = typeof uploadRes.data === 'string' ? JSON.parse(uploadRes.data) : uploadRes.data
  436. if (result.code == 200) {
  437. //this.formData.attachmentUrl = result.url
  438. vm.formData.attachments.push({
  439. name:fileName,
  440. size: vm.formatFileSize(size || 0),
  441. url: result.url
  442. });
  443. uni.showToast({ icon: 'success', title: '上传成功' })
  444. } else {
  445. uni.showToast({ icon: 'none', title: result.msg || '上传失败' })
  446. }
  447. } catch (e) {
  448. console.error('解析上传结果失败', e)
  449. uni.showToast({ icon: 'none', title: '上传失败' })
  450. }
  451. },
  452. fail: (err) => {
  453. // 关闭上传进度弹窗
  454. vm.showUploadModal = false;
  455. vm.percent = 0;
  456. console.error('上传失败', err)
  457. uni.showToast({ icon: 'none', title: '上传失败' })
  458. }
  459. })
  460. // 监听上传进度
  461. uploadTask.onProgressUpdate(function(res) {
  462. vm.percent = res.progress;
  463. })
  464. },
  465. fail: (err) => {
  466. if (err.errMsg && !err.errMsg.includes('cancel')) {
  467. console.error('选择文档失败', err);
  468. uni.showToast({ icon: 'none', title: '选择文档失败' });
  469. }
  470. }
  471. });
  472. }
  473. },
  474. removeAttachment(index) {
  475. this.formData.attachments.splice(index, 1)
  476. },
  477. formatFileSize(bytes) {
  478. if (bytes < 1024) return bytes + 'B'
  479. if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(2) + 'KB'
  480. return (bytes / (1024 * 1024)).toFixed(2) + 'MB'
  481. },
  482. // 根据文件扩展名获取文件类型
  483. getFileType(fileExt) {
  484. const typeMap = {
  485. // 视频
  486. 'mp4': 'video',
  487. 'avi': 'video',
  488. 'mov': 'video',
  489. 'wmv': 'video',
  490. 'flv': 'video',
  491. 'mkv': 'video',
  492. // 音频
  493. 'mp3': 'audio',
  494. 'wav': 'audio',
  495. 'wma': 'audio',
  496. // 图片
  497. 'jpg': 'image',
  498. 'jpeg': 'image',
  499. 'png': 'image',
  500. 'gif': 'image',
  501. 'bmp': 'image',
  502. // 文档
  503. 'pdf': 'document',
  504. 'doc': 'document',
  505. 'docx': 'document',
  506. 'xls': 'document',
  507. 'xlsx': 'document',
  508. 'ppt': 'document',
  509. 'pptx': 'document',
  510. 'txt': 'document'
  511. }
  512. return typeMap[fileExt] || 'other'
  513. },
  514. async loadOptions() {
  515. try {
  516. const [groupRes, tagRes] = await Promise.all([
  517. getGroupOptions(),
  518. getTagOptions({dictType:'project_label'})
  519. ])
  520. if (groupRes.code === 200 && groupRes.data) {
  521. this.groupOptions = groupRes.data
  522. }
  523. if (tagRes.code === 200 && tagRes.data) {
  524. this.tagOptions = tagRes.data
  525. }
  526. } catch (e) {
  527. console.error('加载选项失败', e)
  528. }
  529. },
  530. async loadTaskData() {
  531. // 加载已有任务数据
  532. },
  533. async handleSubmit() {
  534. if (!this.formData.title) {
  535. uni.showToast({ icon: 'none', title: '请输入标题' })
  536. return
  537. }
  538. // if (!this.formData.groupId) {
  539. // uni.showToast({ icon: 'none', title: '请选择项目分组' })
  540. // return
  541. // }
  542. // if (!this.formData.tagId) {
  543. // uni.showToast({ icon: 'none', title: '请选择项目标签' })
  544. // return
  545. // }
  546. if (!this.formData.coverImage) {
  547. uni.showToast({ icon: 'none', title: '请上传封面' })
  548. return
  549. }
  550. // 附件可选,不再强制要求
  551. // if (this.formData.attachments.length === 0) {
  552. // uni.showToast({ icon: 'none', title: '请上传附件' })
  553. // return
  554. // }
  555. try {
  556. uni.showLoading({ title: '提交中...' })
  557. // 获取用户信息
  558. const userInfo = JSON.parse(uni.getStorageSync('userInfo') || '{}')
  559. const userId = userInfo.id || ''
  560. // 构建附件 URL(多个附件用逗号分隔,确保是字符串类型)
  561. const attachmentUrl = this.formData.attachments && this.formData.attachments.length > 0
  562. ? this.formData.attachments.map(item => item.url).filter(url => url).join(',')
  563. : '' // 如果没有附件,返回空字符串
  564. // 按照 API 要求的 JSON 结构构建提交数据
  565. const submitData = {
  566. attachmentUrl: attachmentUrl, // 附件 URL(多个用逗号分隔)
  567. content: this.formData.summary || '', // 摘要/内容
  568. coverImage: this.formData.coverImage, // 封面图片
  569. //projectId: parseInt(this.formData.groupId) || 0, // 项目分组 ID
  570. //tagIds: this.formData.tagId || '', // 标签 ID(字符串)
  571. taskId: parseInt(this.taskId) || 0, // 任务 ID
  572. title: this.formData.title, // 标题
  573. userId: userId, // 用户 ID
  574. taskType:this.taskType,
  575. // 以下字段为可选,设置默认值
  576. // deliveryName: '',
  577. // deliveryNo: '',
  578. // projectLink: '',
  579. // remark: '',
  580. // taskName: '',
  581. // taskType:this.taskType,
  582. // validViews: 0,
  583. // viewCount: 0
  584. }
  585. const res = await submitTask(submitData)
  586. uni.hideLoading()
  587. if (res.code === 200) {
  588. uni.navigateTo({
  589. url: '/pages_task/taskCompleteSuccess'
  590. })
  591. } else {
  592. uni.showToast({ icon: 'none', title: res.msg || '提交失败' })
  593. }
  594. } catch (e) {
  595. uni.hideLoading()
  596. console.error('提交失败', e)
  597. uni.showToast({ icon: 'none', title: '提交失败' })
  598. }
  599. }
  600. }
  601. }
  602. </script>
  603. <style lang="scss" scoped>
  604. .container {
  605. min-height: 100vh;
  606. background: #f5f5f5;
  607. display: flex;
  608. flex-direction: column;
  609. }
  610. .status-bar {
  611. width: 100%;
  612. background: #fff;
  613. }
  614. .header {
  615. position: relative;
  616. height: 88rpx;
  617. display: flex;
  618. align-items: center;
  619. justify-content: center;
  620. background: #fff;
  621. border-bottom: 1rpx solid #f0f0f0;
  622. .back-btn {
  623. position: absolute;
  624. left: 24rpx;
  625. width: 40rpx;
  626. height: 40rpx;
  627. image {
  628. width: 100%;
  629. height: 100%;
  630. }
  631. }
  632. .title {
  633. font-size: 36rpx;
  634. font-weight: bold;
  635. color: #333;
  636. }
  637. .header-right {
  638. position: absolute;
  639. right: 24rpx;
  640. display: flex;
  641. align-items: center;
  642. gap: 16rpx;
  643. .more-icon {
  644. font-size: 32rpx;
  645. color: #333;
  646. }
  647. }
  648. }
  649. .content {
  650. flex: 1;
  651. padding: 24rpx;
  652. padding-bottom: 120rpx;
  653. box-sizing: border-box;
  654. }
  655. .form-section {
  656. background: #fff;
  657. border-radius: 16rpx;
  658. padding: 24rpx;
  659. &:last-child{
  660. border-bottom: 0;
  661. }
  662. // margin-bottom: 24rpx;
  663. .form-label {
  664. display: flex;
  665. align-items: center;
  666. margin-bottom: 16rpx;
  667. font-size: 28rpx;
  668. color: #333;
  669. .required {
  670. color: #FF5030;
  671. margin-right: 4rpx;
  672. }
  673. }
  674. .form-tips {
  675. font-size: 24rpx;
  676. color: #999;
  677. margin-bottom: 16rpx;
  678. }
  679. .form-input-wrapper {
  680. position: relative;
  681. border-bottom: 1rpx solid #EBEDF0;
  682. .form-input {
  683. width: 100%;
  684. min-height: 120rpx;
  685. padding: 16rpx;
  686. font-size: 28rpx;
  687. color: #333;
  688. box-sizing: border-box;
  689. }
  690. .char-count {
  691. position: absolute;
  692. right: 16rpx;
  693. bottom: 16rpx;
  694. font-size: 24rpx;
  695. color: #999;
  696. }
  697. }
  698. .form-select {
  699. display: flex;
  700. align-items: center;
  701. justify-content: space-between;
  702. height: 80rpx;
  703. padding: 0 24rpx;
  704. border-bottom: 1rpx solid #EBEDF0;
  705. font-size: 28rpx;
  706. color: #333;
  707. .placeholder {
  708. color: #999;
  709. }
  710. .arrow-right {
  711. font-size: 24rpx;
  712. color: #999;
  713. }
  714. }
  715. .upload-cover {
  716. width: 200rpx;
  717. height: 200rpx;
  718. background: #f5f5f5;
  719. border-radius: 8rpx;
  720. display: flex;
  721. align-items: center;
  722. justify-content: center;
  723. .img {
  724. width: 100%;
  725. height: 100%;
  726. border-radius: 8rpx;
  727. }
  728. .upload-placeholder {
  729. .camera-icon {
  730. font-size: 60rpx;
  731. }
  732. }
  733. }
  734. .attachment-list {
  735. .attachment-item {
  736. display: flex;
  737. align-items: center;
  738. padding: 16rpx;
  739. background: #f5f5f5;
  740. border-radius: 8rpx;
  741. margin-bottom: 16rpx;
  742. .attachment-icon {
  743. font-size: 32rpx;
  744. margin-right: 16rpx;
  745. }
  746. .attachment-info {
  747. flex: 1;
  748. display: flex;
  749. flex-direction: column;
  750. .attachment-name {
  751. font-size: 28rpx;
  752. color: #333;
  753. margin-bottom: 4rpx;
  754. }
  755. .attachment-size {
  756. font-size: 24rpx;
  757. color: #999;
  758. }
  759. }
  760. .attachment-delete {
  761. font-size: 40rpx;
  762. color: #999;
  763. width: 40rpx;
  764. height: 40rpx;
  765. display: flex;
  766. align-items: center;
  767. justify-content: center;
  768. }
  769. }
  770. .add-attachment {
  771. display: flex;
  772. align-items: center;
  773. justify-content: center;
  774. padding: 24rpx;
  775. background: rgba(56,139,255,0.08);
  776. border-radius: 12rpx 12rpx 12rpx 12rpx;
  777. border: 2rpx solid #388BFF;
  778. font-family: PingFang SC, PingFang SC;
  779. font-weight: 400;
  780. font-size: 28rpx;
  781. color: #388BFF;
  782. .add-icon {
  783. font-size: 32rpx;
  784. margin-right: 8rpx;
  785. }
  786. }
  787. }
  788. }
  789. .submit-box{
  790. position: fixed;
  791. bottom: 0;
  792. left: 0;
  793. right: 0;
  794. background: #fff;
  795. z-index: 100;
  796. padding: 24rpx 32rpx;
  797. .submit-btn {
  798. height: 88rpx;
  799. background: #388BFF;
  800. border-radius: 200rpx 200rpx 200rpx 200rpx;
  801. display: flex;
  802. align-items: center;
  803. justify-content: center;
  804. font-size: 32rpx;
  805. color: #fff;
  806. font-weight: 500;
  807. }
  808. }
  809. .picker-popup {
  810. position: fixed;
  811. top: 0;
  812. left: 0;
  813. right: 0;
  814. bottom: 0;
  815. background: rgba(0, 0, 0, 0.5);
  816. z-index: 999;
  817. display: flex;
  818. align-items: flex-end;
  819. }
  820. .picker-content {
  821. width: 100%;
  822. background: #fff;
  823. border-radius: 24rpx 24rpx 0 0;
  824. .picker-header {
  825. display: flex;
  826. align-items: center;
  827. justify-content: space-between;
  828. padding: 24rpx;
  829. border-bottom: 1rpx solid #f0f0f0;
  830. .picker-cancel {
  831. font-size: 30rpx;
  832. color: #666;
  833. }
  834. .picker-title {
  835. font-size: 32rpx;
  836. font-weight: bold;
  837. color: #333;
  838. }
  839. .picker-confirm {
  840. font-size: 30rpx;
  841. color: #388BFF;
  842. }
  843. }
  844. .picker-body {
  845. padding: 24rpx;
  846. max-height: 600rpx;
  847. overflow-y: auto;
  848. .picker-item {
  849. padding: 24rpx 0;
  850. font-size: 30rpx;
  851. color: #333;
  852. border-bottom: 1rpx solid #f0f0f0;
  853. &:last-child {
  854. border-bottom: none;
  855. }
  856. &.active {
  857. color: #388BFF;
  858. font-weight: bold;
  859. }
  860. }
  861. }
  862. }
  863. // 上传进度弹窗样式
  864. .upload-modal {
  865. position: fixed;
  866. top: 0;
  867. left: 0;
  868. right: 0;
  869. bottom: 0;
  870. background: rgba(0, 0, 0, 0.6);
  871. z-index: 9999;
  872. display: flex;
  873. align-items: center;
  874. justify-content: center;
  875. .upload-modal-content {
  876. width: 560rpx;
  877. background: #fff;
  878. border-radius: 24rpx;
  879. padding: 48rpx 40rpx;
  880. display: flex;
  881. flex-direction: column;
  882. align-items: center;
  883. .upload-modal-title {
  884. font-size: 32rpx;
  885. font-weight: bold;
  886. color: #333;
  887. margin-bottom: 40rpx;
  888. }
  889. .upload-progress-wrapper {
  890. width: 100%;
  891. margin-bottom: 32rpx;
  892. }
  893. .upload-modal-tips {
  894. font-size: 24rpx;
  895. color: #999;
  896. }
  897. }
  898. }
  899. </style>