index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <view class="content">
  3. <u-swiper :list="list" mode="dot" class="index_uswiper" height='300'></u-swiper>
  4. <view class="function">
  5. <view class="function_item" v-for="(item,index) in functionimg" :key="index" @click="tabfunction(index)">
  6. <image :src="item.src" mode=""></image>
  7. <p>{{item.text}}</p>
  8. </view>
  9. </view>
  10. <view class="equipment">
  11. <p class="equipment_p">系统设备</p>
  12. <view class="equipment_item">
  13. <view class="equipment_item_img" v-for="(item,index) in equipmentimg" :key="index" @click="tabequipment(index)">
  14. <image :src="item.src" mode=""></image>
  15. </view>
  16. </view>
  17. </view>
  18. <u-modal v-model="show" :mask-close-able="true" title="" :show-cancel-button="true" confirm-text="拍病害" cancel-text="拍虫害"
  19. content="拍照识别病虫害" @confirm="confirm" @cancel="cancel"></u-modal>
  20. <kps-image-cutter @ok="onok" @cancel="oncancle" :url="url" :fixed="false" :blob="true" :maxWidth="500" :maxHeight="380" :height="380"></kps-image-cutter>
  21. </view>
  22. </template>
  23. <script>
  24. import kpsImageCutter from "@/components/ksp-image-cutter/ksp-image-cutter.vue";
  25. export default {
  26. components: {
  27. kpsImageCutter
  28. },
  29. data() {
  30. return {
  31. currentPage: 'tabBar1',
  32. list: [{
  33. image: '../../static/image/index/11.png'
  34. }, ],
  35. functionimg: [{
  36. src: "../../static/image/index/1.png",
  37. text: "四情基地"
  38. },
  39. {
  40. src: "../../static/image/index/2.png",
  41. text: "病虫识别"
  42. },
  43. {
  44. src: "../../static/image/index/3.png",
  45. text: "专家诊断"
  46. },
  47. {
  48. src: "../../static/image/index/4.png",
  49. text: "售后服务"
  50. }
  51. ],
  52. equipmentimg: [{
  53. src: "../../static/image/index/5.png"
  54. },
  55. {
  56. src: "../../static/image/index/6.png"
  57. },
  58. {
  59. src: "../../static/image/index/7.png"
  60. },
  61. {
  62. src: "../../static/image/index/8.png"
  63. },
  64. {
  65. src: "../../static/image/index/9.png"
  66. },
  67. {
  68. src: "../../static/image/index/10.png"
  69. }
  70. ],
  71. url: '',
  72. path: '',
  73. flag: 1,
  74. show: false
  75. }
  76. },
  77. onLoad() {
  78. },
  79. methods: {
  80. tabfunction(index) {
  81. if (index == 0) {
  82. uni.navigateTo({
  83. url: "../fourBase/index"
  84. })
  85. } else if (index == 1) {
  86. var that = this
  87. this.show = true
  88. } else if (index == 2) {
  89. uni.navigateTo({
  90. url: "../expertDiagnosis/index"
  91. })
  92. } else if (index == 3) {
  93. uni.navigateTo({
  94. url: "../afterSale/index"
  95. })
  96. }
  97. },
  98. tabequipment(index) {
  99. if (index == 0) {
  100. uni.navigateTo({
  101. url: "../cb/index/index"
  102. })
  103. } else if (index == 1) {
  104. uni.navigateTo({
  105. url: "../prevention/index"
  106. })
  107. } else if (index == 2) {
  108. uni.navigateTo({
  109. url: "/pages/monitor/index"
  110. })
  111. } else if (index == 3) {
  112. uni.navigateTo({
  113. url: "../environment/index"
  114. })
  115. } else if (index == 4) {
  116. uni.navigateTo({
  117. url: "../equipMange/index/index"
  118. })
  119. } else if (index == 5) {
  120. uni.showToast({
  121. title: '此功能暂未开放',
  122. duration: 2000,
  123. icon:"none"
  124. });
  125. }
  126. },
  127. onok(ev) {
  128. this.path = this.url
  129. console.log(ev)
  130. uni.showLoading({
  131. mask:true,
  132. success:function(){
  133. console.log(999)
  134. }
  135. });
  136. if(this.flag == 2){
  137. console.log('111')
  138. // pest.pests.insect_discern 虫害
  139. // uni.uploadFile({
  140. // // url: 'http://182.92.193.64:8002/api/api_gateway?method=base.bases.base_photo', //仅为示例,非真实的接口地址
  141. // url: 'http://182.92.193.64:8002/api/api_gateway?method=pest.pests.insect_discern', //仅为示例,非真实的接口地址
  142. // filePath: ev.path,
  143. // name: 'img_file',
  144. // formData: {
  145. // 'user': 'test'
  146. // },
  147. // success: (uploadFileRes) => {
  148. // console.log(JSON.parse(uploadFileRes.data))
  149. // uni.navigateTo({
  150. // url: "../disandpests/index?datas=" + uploadFileRes.data + "&path=" + ev.path
  151. // })
  152. // }
  153. // });
  154. }else if(this.flag == 1){
  155. //pest.pests.insect_discern病害识别
  156. uni.showLoading({
  157. title: '加载中'
  158. });
  159. uni.uploadFile({
  160. // url: 'http://182.92.193.64:8002/api/api_gateway?method=base.bases.base_photo', //仅为示例,非真实的接口地址
  161. url: 'http://182.92.193.64:8002/api/api_gateway?method=pest.pests.plant_discern', //仅为示例,非真实的接口地址
  162. filePath: ev.path,
  163. name: 'img_file',
  164. formData: {
  165. 'user': 'test'
  166. },
  167. success: (uploadFileRes) => {
  168. console.log(JSON.parse(uploadFileRes.data))
  169. uni.navigateTo({
  170. url: "../disandpests/index?datas="+uploadFileRes.data + "&path=" + ev.path
  171. })
  172. }
  173. });
  174. }
  175. this.url = "";
  176. },
  177. oncancle() {
  178. // url设置为空,隐藏控件
  179. this.url = ''
  180. },
  181. confirm() {
  182. this.flag = 1
  183. uni.chooseImage({
  184. count: 1, //默认9
  185. // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  186. sourceType: ['camera','album'], //从相册选择
  187. success: (res) => {
  188. this.url = res.tempFilePaths[0]
  189. }
  190. });
  191. console.log(1)
  192. },
  193. cancel() {
  194. this.flag = 2
  195. uni.chooseImage({
  196. count: 1, //默认9
  197. // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  198. sourceType: ['camera','album'], //从相册选择
  199. success: (res) => {
  200. console.log(1)
  201. this.url = res.tempFilePaths[0]
  202. }
  203. });
  204. }
  205. }
  206. }
  207. </script>
  208. <style lang="scss">
  209. .index_uswiper {
  210. width: 95%;
  211. margin: 0 auto;
  212. border-radius: 20rpx !important;
  213. }
  214. .function {
  215. width: 95%;
  216. margin: 20rpx auto;
  217. display: flex;
  218. justify-content: space-around;
  219. .function_item {
  220. width: 18%;
  221. text-align: center;
  222. image {
  223. width: 90rpx;
  224. height: 90rpx;
  225. }
  226. p {
  227. font-size: 24rpx;
  228. }
  229. }
  230. }
  231. .equipment {
  232. width: 95%;
  233. margin: 30rpx auto 0;
  234. .equipment_p {
  235. width: 90%;
  236. border-left: 8rpx solid #4BB85F;
  237. font-weight: 700;
  238. padding-left: 20rpx;
  239. margin-bottom: 20rpx;
  240. }
  241. .equipment_item {
  242. display: flex;
  243. flex-wrap: wrap;
  244. justify-content: space-between;
  245. .equipment_item_img {
  246. width: 49%;
  247. margin-top: 20rpx;
  248. image {
  249. width: 100%;
  250. height: 170rpx;
  251. }
  252. }
  253. }
  254. }
  255. </style>