国外MOSE官网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

325 lines
6.6 KiB

2 days ago
  1. <template>
  2. <view class="publish-page">
  3. <!-- 顶部提示容器 -->
  4. <view class="tip-container">
  5. <uv-icon name="info-circle-fill" size="16" color="#007AFF"></uv-icon>
  6. <text class="tip-text">留言板内容要经过审核才能发布成功提交审核中请耐心等待审核通过后会上线</text>
  7. </view>
  8. <!-- 主要内容容器 -->
  9. <view class="main-container">
  10. <!-- 木邻说标题 -->
  11. <view class="title-section">
  12. <!-- 加一个小竖条 -->
  13. <view class="vertical-line" :class="isPhoto ? 'red' : 'blue'"></view>
  14. <text class="title-text"> {{ isPhoto ? '木龄见' : '木龄说' }} </text>
  15. </view>
  16. <!-- 留言板输入区域 -->
  17. <view class="message-section">
  18. <text class="section-label">您对本社区发展有什么建议和期待欢迎留言</text>
  19. <view class="textarea-container">
  20. <textarea
  21. class="message-textarea"
  22. v-model="messageContent"
  23. placeholder="请输入您的留言内容..."
  24. maxlength="500"
  25. :show-confirm-bar="false"
  26. ></textarea>
  27. <view class="char-count">
  28. <text class="count-text">{{ messageContent.length }}/500</text>
  29. </view>
  30. </view>
  31. </view>
  32. <!-- 添加图片区域 -->
  33. <view class="image-section">
  34. <view class="image-grid">
  35. <!-- 已选择的图片 -->
  36. <view
  37. class="image-item"
  38. v-for="(image, index) in selectedImages"
  39. :key="index"
  40. >
  41. <image class="preview-image" :src="image" mode="aspectFill"></image>
  42. <view class="delete-btn" @click="removeImage(index)">
  43. <uv-icon name="close" size="12" color="white"></uv-icon>
  44. </view>
  45. </view>
  46. <!-- 添加图片按钮 -->
  47. <view
  48. class="add-image-btn"
  49. v-if="selectedImages.length < 9"
  50. @click="chooseImage"
  51. >
  52. <uv-icon name="plus" size="24" color="#999"></uv-icon>
  53. <text class="add-text">添加图片</text>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <!-- 提交按钮容器 -->
  59. <view class="submit-container">
  60. <uv-button
  61. class="submit-btn"
  62. type="primary"
  63. shape="circle"
  64. :disabled="!messageContent.trim()"
  65. @click="submitPost"
  66. >
  67. 提交审核
  68. </uv-button>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. export default {
  74. name: 'PublishPost',
  75. data() {
  76. return {
  77. messageContent: '',
  78. selectedImages: [],
  79. isPhoto: false
  80. }
  81. },
  82. methods: {
  83. chooseImage() {
  84. const remainingCount = 9 - this.selectedImages.length
  85. uni.chooseMedia({
  86. count: remainingCount,
  87. mediaType: ['image'],
  88. sourceType: ['album', 'camera'],
  89. success: (res) => {
  90. const tempFiles = res.tempFiles.map(file => file.tempFilePath)
  91. this.selectedImages = [...this.selectedImages, ...tempFiles]
  92. },
  93. fail: (err) => {
  94. console.error('选择图片失败:', err)
  95. }
  96. })
  97. },
  98. removeImage(index) {
  99. this.selectedImages.splice(index, 1)
  100. },
  101. submitPost() {
  102. if (!this.messageContent.trim()) {
  103. uni.showToast({
  104. title: '请输入留言内容',
  105. icon: 'none'
  106. })
  107. return
  108. }
  109. // 模拟提交
  110. uni.showLoading({
  111. title: '提交中...'
  112. })
  113. setTimeout(() => {
  114. uni.hideLoading()
  115. uni.showToast({
  116. title: '提交成功,等待审核',
  117. icon: 'success'
  118. })
  119. setTimeout(() => {
  120. uni.navigateBack()
  121. }, 1500)
  122. }, 2000)
  123. }
  124. },
  125. onLoad(options) {
  126. if (options.page === 'photo') {
  127. this.isPhoto = true
  128. console.log(this.isPhoto);
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="scss" scoped>
  134. .publish-page {
  135. min-height: 100vh;
  136. background-color: #F3F7F8;
  137. // display: flex;
  138. // flex-direction: column;
  139. }
  140. // 顶部提示容器
  141. .tip-container {
  142. background-color: #E3F2FD;
  143. padding: 24rpx 32rpx;
  144. margin: 20rpx;
  145. border-radius: 12rpx;
  146. display: flex;
  147. align-items: flex-start;
  148. gap: 16rpx;
  149. border-left: 6rpx solid #007AFF;
  150. }
  151. .tip-text {
  152. font-size: 26rpx;
  153. color: #1976D2;
  154. line-height: 1.5;
  155. flex: 1;
  156. }
  157. // 主要内容容器
  158. .main-container {
  159. flex: 1;
  160. margin: 0 20rpx;
  161. background-color: white;
  162. border-radius: 16rpx;
  163. padding: 32rpx;
  164. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
  165. }
  166. .title-section {
  167. margin-bottom: 32rpx;
  168. display: flex;
  169. align-items: center;
  170. gap: 16rpx;
  171. }
  172. .vertical-line {
  173. width: 8rpx;
  174. height: 40rpx;
  175. border-radius: 4rpx;
  176. &.red {
  177. background-color: #FF4757;
  178. }
  179. &.blue {
  180. background-color: #007AFF;
  181. }
  182. }
  183. .title-text {
  184. font-size: 36rpx;
  185. font-weight: bold;
  186. color: #333;
  187. }
  188. // 留言板区域
  189. .message-section {
  190. margin-bottom: 40rpx;
  191. }
  192. .section-label {
  193. font-size: 28rpx;
  194. color: #666;
  195. display: block;
  196. margin-bottom: 20rpx;
  197. }
  198. .textarea-container {
  199. position: relative;
  200. background-color: #f5f5f5;
  201. border-radius: 12rpx;
  202. padding: 24rpx;
  203. }
  204. .message-textarea {
  205. width: 100%;
  206. min-height: 300rpx;
  207. font-size: 30rpx;
  208. color: #333;
  209. background-color: transparent;
  210. border: none;
  211. outline: none;
  212. resize: none;
  213. line-height: 1.6;
  214. }
  215. .char-count {
  216. position: absolute;
  217. bottom: 16rpx;
  218. right: 16rpx;
  219. }
  220. .count-text {
  221. font-size: 24rpx;
  222. color: #999;
  223. }
  224. // 图片区域
  225. .image-section {
  226. margin-bottom: 40rpx;
  227. }
  228. .image-grid {
  229. display: flex;
  230. flex-wrap: wrap;
  231. gap: 16rpx;
  232. }
  233. .image-item {
  234. position: relative;
  235. width: 200rpx;
  236. height: 200rpx;
  237. border-radius: 12rpx;
  238. overflow: hidden;
  239. }
  240. .preview-image {
  241. width: 100%;
  242. height: 100%;
  243. }
  244. .delete-btn {
  245. position: absolute;
  246. top: 8rpx;
  247. right: 8rpx;
  248. width: 40rpx;
  249. height: 40rpx;
  250. background-color: rgba(0, 0, 0, 0.6);
  251. border-radius: 50%;
  252. display: flex;
  253. align-items: center;
  254. justify-content: center;
  255. }
  256. .add-image-btn {
  257. width: 200rpx;
  258. height: 200rpx;
  259. border: 2rpx dashed #ddd;
  260. border-radius: 12rpx;
  261. display: flex;
  262. flex-direction: column;
  263. align-items: center;
  264. justify-content: center;
  265. gap: 12rpx;
  266. background-color: #fafafa;
  267. transition: all 0.3s ease;
  268. &:active {
  269. background-color: #f0f0f0;
  270. border-color: #007AFF;
  271. }
  272. }
  273. .add-text {
  274. font-size: 24rpx;
  275. color: #999;
  276. }
  277. // 提交按钮容器
  278. .submit-container {
  279. padding: 32rpx 40rpx;
  280. // background-color: white;
  281. margin-top: 60rpx;
  282. border-top: 1rpx solid #f0f0f0;
  283. }
  284. .submit-btn {
  285. width: 100%;
  286. height: 88rpx;
  287. border-radius: 44rpx;
  288. font-size: 32rpx;
  289. font-weight: bold;
  290. }
  291. </style>