suggest.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <view>
  3. <view class="box" :isFull="true" title="反馈意见" :thumbnail="contentIcon">
  4. <textarea v-model="data.content" placeholder="您的反馈对我们非常重要,请在此输入."></textarea>
  5. </view>
  6. <view class="box" :isFull="true" title="上传图片" :thumbnail="imgListIcon">
  7. <view class="imgs" v-for="(item, index) in data.imgList" :key="index">
  8. <image class="img" @click="previewImage(index)" :src="item.path" mode="aspectFit" />
  9. <uni-icons @click="removeImage(index)" style="color: white; font-size: 30rpx;" type="closeempty" class="remove"></uni-icons>
  10. </view>
  11. <view class="imgs" @click="chooseImage">
  12. <view class="img add-img">
  13. <image style="position:absolute; line-height: 150rpx; font-size: 149rpx;" type="camera"></image>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="box" :isFull="true" title="联系方式" :thumbnail="contactIcon">
  18. <input v-model="data.contact" placeholder="手机 QQ或e-mail,方便我们联系您" />
  19. </view>
  20. <button class="submit-btn" @click="submit">提交</button>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. data() {
  26. return {
  27. data: {
  28. imgList: [],
  29. content: "",
  30. contact: ""
  31. },
  32. contentIcon: require("./icons/suggestion.png"),
  33. contactIcon: require("./icons/contact.png"),
  34. imgListIcon: require("./icons/image.png")
  35. }
  36. },
  37. methods: {
  38. chooseImage() {
  39. let _self = this;
  40. uni.chooseImage({
  41. sizeType: ['compressed', 'original'],
  42. sourceType: ['album', 'camera'],
  43. success: function(res) {
  44. _self.data.imgList = _self.data.imgList.concat(res.tempFiles)
  45. },
  46. fail: function(err) {
  47. console.log(err);
  48. }
  49. });
  50. },
  51. removeImage(index) {
  52. this.data.imgList.splice(index, 1)
  53. },
  54. previewImage(index) {
  55. uni.previewImage({
  56. current: index,
  57. urls: this.data.imgList.map(r => r.path)
  58. });
  59. },
  60. submit() {
  61. this.$emit("submit", this.data)
  62. }
  63. }
  64. }
  65. </script>
  66. <style lang="scss">
  67. .box {
  68. margin-bottom: 20rpx;
  69. }
  70. .imgs {
  71. position: relative;
  72. display: inline-flex;
  73. flex-wrap: wrap;
  74. margin: 10rpx;
  75. width: 150rpx;
  76. height: 150rpx;
  77. .img {
  78. width: 100%;
  79. height: 100%;
  80. border-radius: 10rpx;
  81. border: 1rpx solid #ebebeb;
  82. }
  83. .remove {
  84. line-height: 30rpx;
  85. text-align: center;
  86. border-radius: 10rpx;
  87. position: absolute;
  88. right: 0rpx;
  89. top: 0rpx;
  90. width: 30rpx;
  91. height: 30rpx;
  92. font-weight: bold;
  93. background-color: #e53c25;
  94. }
  95. .add-img {
  96. background-color: #f0f0f0;
  97. }
  98. }
  99. .submit-btn {
  100. background-color: #49abe8;
  101. margin: 20rpx 0;
  102. }
  103. </style>