publish.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <view class="publish">
  3. <textarea class="content" :value="content" placeholder="请输入内容" />
  4. <view class="img-list">
  5. <view class="img-box" v-for="(item,index) in imgList" @click="handleImage(index)" :key="index">
  6. <image class="img" :src="item" mode=""></image>
  7. <view class="del-btn" @click.stop="del(index)">
  8. <u-icon name="close" color="#fff" size="28"></u-icon>
  9. </view>
  10. </view>
  11. <view class="add-image" @click="chooseImage">
  12. <u-icon name="plus" color="#999" size="58"></u-icon>
  13. </view>
  14. </view>
  15. <button class="publish-btn" type="default" @click="publish">发布</button>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. data() {
  21. return {
  22. content: '',
  23. imgList:[]
  24. }
  25. },
  26. methods: {
  27. handleImage(current){
  28. uni.previewImage({
  29. current,
  30. urls:this.imgList,
  31. indicator:'number'
  32. })
  33. },
  34. del(index){
  35. this.imgList.splice(index,1)
  36. },
  37. publish() {
  38. uni.navigateTo({
  39. url:'./community'
  40. })
  41. },
  42. chooseImage(){
  43. let that = this
  44. uni.chooseImage({
  45. success(res){
  46. that.imgList = that.imgList.concat(res.tempFilePaths).slice(0,9)
  47. console.log(that.imgList);
  48. }
  49. })
  50. }
  51. },
  52. }
  53. </script>
  54. <style lang="scss" scoped>
  55. .publish{
  56. padding: 30rpx;
  57. .content{
  58. width: 100%;
  59. padding: 30rpx;
  60. height: 308rpx;
  61. box-sizing: border-box;
  62. background: #F9F9F9;
  63. border-radius: 16rpx;
  64. }
  65. .img-list{
  66. display: flex;
  67. flex-wrap: wrap;
  68. margin-top: 20rpx;
  69. .img-box{
  70. width: 212rpx;
  71. height: 212rpx;
  72. border-radius: 16rpx;
  73. margin: 0 16rpx 20rpx 0;
  74. position: relative;
  75. .img{
  76. width: 212rpx;
  77. height: 212rpx;
  78. border-radius: 16rpx;
  79. }
  80. .del-btn{
  81. position: absolute;
  82. top: 0%;
  83. right: 0;
  84. transform: translate(50%,-50%);
  85. background: rgba(0,0,0,0.6);
  86. border-radius: 50%;
  87. }
  88. }
  89. .add-image{
  90. width: 212rpx;
  91. height: 212rpx;
  92. background: #F9F9F9;
  93. border-radius: 16rpx;
  94. display: flex;
  95. justify-content: center;
  96. align-items: center;
  97. }
  98. }
  99. .publish-btn{
  100. width: 560rpx;
  101. height: 96rpx;
  102. line-height: 96rpx;
  103. border-radius: 48rpx;
  104. background: linear-gradient(270deg, #3074F8 0%, #568FFF 100%);
  105. box-shadow: inset 0rpx 6rpx 12rpx 2rpx rgba(255,255,255,0.16);
  106. color: #fff;
  107. font-size: 32rpx;
  108. margin-top: 300rpx;
  109. }
  110. }
  111. </style>