suggest.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view>
  3. <uni-card class="box" :isFull="true" title="反馈问题" :thumbnail="contentIcon">
  4. <textarea v-model="data.content" placeholder="您的反馈对我们非常重要,请在此输入."></textarea>
  5. </uni-card>
  6. <uni-card 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 d-flex a-center j-center">
  13. <uni-icons style="position:absolute; line-height: 150rpx; font-size: 100rpx;" type="camera"></uni-icons>
  14. </view>
  15. </view>
  16. </uni-card>
  17. <uni-card class="box" :isFull="true" title="联系方式" :thumbnail="contactIcon">
  18. <input v-model="data.contact" placeholder="手机 QQ或e-mail,方便我们联系您" />
  19. </uni-card>
  20. <button class="mt-2 d-flex a-center j-center main-bg-color" type="primary" @tap="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. if(!this.data.content){
  62. return uni.showToast({title:"请填写您的反馈问题",icon:"none"})
  63. }
  64. if(!this.data.contact){
  65. return uni.showToast({title:"请填写您的联系方式",icon:"none"})
  66. }
  67. this.$emit("submit", this.data)
  68. }
  69. }
  70. }
  71. </script>
  72. <style lang="scss" scoped>
  73. .box {
  74. margin-bottom: 20rpx;
  75. }
  76. .imgs {
  77. position: relative;
  78. display: inline-flex;
  79. flex-wrap: wrap;
  80. margin: 10rpx;
  81. width: 195rpx;
  82. height: 195rpx;
  83. .img {
  84. width: 100%;
  85. height: 100%;
  86. border-radius: 10rpx;
  87. border: 1rpx solid #ebebeb;
  88. }
  89. .remove {
  90. line-height: 30rpx;
  91. text-align: center;
  92. border-radius: 10rpx;
  93. position: absolute;
  94. right: 0rpx;
  95. top: 0rpx;
  96. width: 30rpx;
  97. height: 30rpx;
  98. font-weight: bold;
  99. background-color: rgba(#e53c25, 0.5);;
  100. }
  101. .add-img {
  102. background-color: #f5f5f5;
  103. }
  104. }
  105. </style>