addcont.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view>
  3. <view class="context_box">
  4. <view class="weatherbox">
  5. <u--form labelPosition="left" :model="weatherdatas" :rules="rules" ref="form1">
  6. <u-form-item label="监测事项" prop="temp" ref="item1" labelWidth="80">
  7. <u--input v-model="weatherdatas.temp" border="none"></u--input>
  8. </u-form-item>
  9. </u--form>
  10. </view>
  11. <view class="imgbox">
  12. <view class="title">
  13. 图像信息
  14. </view>
  15. <view class="imgbox_box">
  16. <view class="addimg" @click="gainimg">
  17. <u-icon size="20" name="plus" color="#409eff"></u-icon>
  18. </view>
  19. <view class="imgitem" v-for="item,index in urllist" :key="index">
  20. <image :src="item" mode="" class="img"></image>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="describe_box">
  25. <view class="title">
  26. 图像信息
  27. </view>
  28. <view class="textarea">
  29. <u--textarea v-model="value1" placeholder="请输入内容" :autoHeight="true"></u--textarea>
  30. </view>
  31. </view>
  32. </view>
  33. <kps-image-cutter @ok="onok" @cancel="oncancle" :url="kpsurlL" :fixed="false" :blob="false" :maxWidth="500"
  34. :maxHeight="500"></kps-image-cutter>
  35. </view>
  36. </template>
  37. <script>
  38. import kpsImageCutter from "@/components/ksp-image-cutter/ksp-image-cutter.vue";
  39. export default {
  40. data() {
  41. return {
  42. weatherdatas: {
  43. temp: ""
  44. },
  45. rules: {
  46. 'temp': {
  47. type: 'string',
  48. required: true,
  49. message: '请填写温度',
  50. trigger: ['blur', 'change']
  51. },
  52. },
  53. urllist: [],
  54. value1: "",
  55. kpsurlL:""
  56. }
  57. },
  58. components:{
  59. kpsImageCutter
  60. },
  61. methods: {
  62. gainimg() { //添加图片
  63. uni.chooseImage({
  64. count: 1, //默认9
  65. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  66. sourceType: ['album', 'camera'], //从相册选择
  67. success: (res) => {
  68. console.log(res)
  69. // this.urllist.push(res.tempFilePaths[0])
  70. this.kpsurlL = res.tempFilePaths[0]
  71. }
  72. });
  73. },
  74. oncancle(){
  75. },
  76. onok(ev){
  77. uni.uploadFile({
  78. url: 'http://192.168.1.17:12345/api/api_gateway?method=monitor_manage.cbd_manage.add_img', //仅为示例,非真实的接口地址
  79. filePath: ev.path,
  80. name: 'img_file',
  81. success: (uploadFileRes) => {
  82. // console.log(ev.path)
  83. console.log(JSON.parse(uploadFileRes.data).data.src)
  84. // this.path = JSON.parse(uploadFileRes.data).data.src
  85. // this.uploadingTF=true
  86. // this.toloadTF = false
  87. }
  88. });
  89. }
  90. },
  91. onLoad(){
  92. console.log(this.baseUrl)
  93. }
  94. }
  95. </script>
  96. <style lang="less" scoped>
  97. .context_box {
  98. width: 90%;
  99. margin: 0 auto;
  100. /deep/.u-form-item__body {
  101. border-bottom: 1px solid #F6F6F6;
  102. margin-bottom: 20rpx;
  103. }
  104. .imgbox {
  105. width: 100%;
  106. display: flex;
  107. margin-top: 30rpx;
  108. .title {
  109. font-size: 30rpx;
  110. width: 160rpx;
  111. }
  112. .imgbox_box {
  113. display: flex;
  114. flex-wrap: wrap;
  115. width: 80%;
  116. // justify-content: space-around;
  117. .addimg {
  118. width: 140rpx;
  119. height: 140rpx;
  120. border: 1px dashed #409eff;
  121. // text-align: center;
  122. display: flex;
  123. justify-content: space-around;
  124. margin-right: 30rpx;
  125. margin-bottom: 30rpx;
  126. }
  127. .imgitem {
  128. width: 140rpx;
  129. height: 140rpx;
  130. margin-right: 30rpx;
  131. margin-bottom: 30rpx;
  132. .img {
  133. width: 100%;
  134. height: 100%;
  135. }
  136. }
  137. }
  138. }
  139. .describe_box {
  140. width: 100%;
  141. display: flex;
  142. margin-top: 30rpx;
  143. .title {
  144. font-size: 30rpx;
  145. width: 160rpx;
  146. }
  147. .textarea {
  148. width: 80%;
  149. }
  150. }
  151. }
  152. </style>