Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

111 rindas
2.5 KiB

  1. <template>
  2. <view class="tool">
  3. <view class="tip card">
  4. <text class="tip-title">{{ title || 'AI工具' }}</text>
  5. <text class="tip-desc">工具类型:{{ type || '未指定' }}</text>
  6. <text class="tip-note">这是通用工具详情页骨架。后续按 type 渲染不同的上传/参数表单,并调用 toolApi.submitTask 提交生成任务、轮询结果。</text>
  7. </view>
  8. <!-- 示例:图片上传占位 -->
  9. <view class="upload card" @click="chooseImage">
  10. <view v-if="!image" class="upload-empty">
  11. <text class="upload-plus">+</text>
  12. <text class="upload-text">上传图片</text>
  13. </view>
  14. <image v-else class="upload-img" :src="image" mode="aspectFit" />
  15. </view>
  16. <view class="btn-primary submit" @click="onSubmit">开始生成</view>
  17. </view>
  18. </template>
  19. <script setup>
  20. import { ref } from 'vue'
  21. import { onLoad } from '@dcloudio/uni-app'
  22. import { useUserStore } from '@/store/user.js'
  23. import { useApp } from '@/utils/useApp.js'
  24. const { toast } = useApp()
  25. const userStore = useUserStore()
  26. const type = ref('')
  27. const title = ref('')
  28. const image = ref('')
  29. onLoad((options) => {
  30. type.value = options.type || ''
  31. title.value = options.title ? decodeURIComponent(options.title) : ''
  32. if (title.value) uni.setNavigationBarTitle({ title: title.value })
  33. })
  34. function chooseImage() {
  35. uni.chooseImage({
  36. count: 1,
  37. success: (res) => {
  38. image.value = res.tempFilePaths[0]
  39. }
  40. })
  41. }
  42. function onSubmit() {
  43. if (!userStore.isLogin) return uni.navigateTo({ url: '/pages/login/login' })
  44. if (!image.value) return toast('请先上传图片')
  45. // TODO: 上传图片 -> toolApi.submitTask -> 轮询结果 -> 跳转结果页
  46. toast('生成逻辑待接入')
  47. }
  48. </script>
  49. <style lang="scss" scoped>
  50. .tool {
  51. padding: 24rpx 0;
  52. }
  53. .tip {
  54. margin-top: 24rpx;
  55. padding: 32rpx;
  56. display: flex;
  57. flex-direction: column;
  58. gap: 12rpx;
  59. .tip-title {
  60. font-size: 34rpx;
  61. font-weight: 700;
  62. }
  63. .tip-desc {
  64. font-size: 26rpx;
  65. color: $ai-accent;
  66. }
  67. .tip-note {
  68. font-size: 24rpx;
  69. color: $ai-muted;
  70. line-height: 1.6;
  71. }
  72. }
  73. .upload {
  74. margin-top: 24rpx;
  75. height: 400rpx;
  76. display: flex;
  77. align-items: center;
  78. justify-content: center;
  79. .upload-empty {
  80. display: flex;
  81. flex-direction: column;
  82. align-items: center;
  83. color: $ai-muted;
  84. }
  85. .upload-plus {
  86. font-size: 60rpx;
  87. }
  88. .upload-text {
  89. font-size: 26rpx;
  90. }
  91. .upload-img {
  92. width: 100%;
  93. height: 100%;
  94. }
  95. }
  96. .submit {
  97. margin: 48rpx $ai-gutter 0;
  98. }
  99. </style>