index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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="false" :maxWidth="500" :maxHeight="500"></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. res: {},
  73. path: '',
  74. flag: 1,
  75. show: false
  76. }
  77. },
  78. onLoad() {
  79. },
  80. methods: {
  81. // pest.pests.insect_discern 虫害
  82. async worm(data) {
  83. const res = await this.$myRequest({
  84. url: '/api/api_gateway?method=pest.pests.insect_discern',
  85. data: {
  86. img_file: data
  87. }
  88. })
  89. this.res = res.data
  90. },
  91. //pest.pests.insect_discern病害识别
  92. async disease(data) {
  93. const res = await this.$myRequest({
  94. url: '/api/api_gateway?method=pest.pests.plant_discern',
  95. data: {
  96. img_file: data
  97. }
  98. })
  99. this.res = res.data
  100. },
  101. tabfunction(index) {
  102. if (index == 0) {
  103. uni.navigateTo({
  104. url: "../fourBase/index"
  105. })
  106. } else if (index == 1) {
  107. var that = this
  108. this.show = true
  109. } else if (index == 2) {
  110. uni.navigateTo({
  111. url: "../expertDiagnosis/index"
  112. })
  113. } else if (index == 3) {
  114. uni.navigateTo({
  115. url: "../afterSale/index"
  116. })
  117. }
  118. },
  119. tabequipment(index) {
  120. if (index == 0) {
  121. uni.navigateTo({
  122. url: "../cb/index/index"
  123. })
  124. } else if (index == 1) {
  125. uni.navigateTo({
  126. url: "../prevention/index"
  127. })
  128. } else if (index == 2) {
  129. uni.navigateTo({
  130. url: "/pages/monitor/index"
  131. })
  132. } else if (index == 3) {
  133. uni.navigateTo({
  134. url: "../environment/index"
  135. })
  136. } else if (index == 4) {
  137. uni.navigateTo({
  138. url: "../equipMange/index/index"
  139. })
  140. } else if (index == 5) {
  141. console.log(5)
  142. }
  143. },
  144. onok(ev) {
  145. uni.uploadFile({
  146. url: 'http://182.92.193.64:8002/api/api_gateway?method=base.bases.base_photo', //仅为示例,非真实的接口地址
  147. filePath: ev.path,
  148. name: 'img_file',
  149. formData: {
  150. 'user': 'test'
  151. },
  152. success: (uploadFileRes) => {
  153. console.log(this.flag)
  154. if (this.flag == 1) {
  155. this.disease(JSON.parse(uploadFileRes.data).data.src)
  156. } else if (this.flag == 2) {
  157. this.worm(JSON.parse(uploadFileRes.data).data.src)
  158. }
  159. uni.navigateTo({
  160. url: "../disandpests/index?datas=" + JSON.stringify(this.res) + "&path=" + JSON.parse(uploadFileRes.data).data
  161. .src
  162. })
  163. }
  164. });
  165. this.url = "";
  166. },
  167. oncancle() {
  168. // url设置为空,隐藏控件
  169. this.url = ''
  170. },
  171. confirm() {
  172. this.flag = 1
  173. uni.chooseImage({
  174. count: 1, //默认9
  175. // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  176. sourceType: ['camera'], //从相册选择
  177. success: (res) => {
  178. this.url = res.tempFilePaths[0]
  179. }
  180. });
  181. },
  182. cancel() {
  183. this.flag = 2
  184. uni.chooseImage({
  185. count: 1, //默认9
  186. // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  187. sourceType: ['camera'], //从相册选择
  188. success: (res) => {
  189. console.log(1)
  190. this.url = res.tempFilePaths[0]
  191. }
  192. });
  193. }
  194. }
  195. }
  196. </script>
  197. <style lang="scss">
  198. .index_uswiper {
  199. width: 95%;
  200. margin: 0 auto;
  201. border-radius: 20rpx !important;
  202. }
  203. .function {
  204. width: 95%;
  205. margin: 20rpx auto;
  206. display: flex;
  207. justify-content: space-around;
  208. .function_item {
  209. width: 18%;
  210. text-align: center;
  211. image {
  212. width: 90rpx;
  213. height: 90rpx;
  214. }
  215. p {
  216. font-size: 24rpx;
  217. }
  218. }
  219. }
  220. .equipment {
  221. width: 95%;
  222. margin: 30rpx auto 0;
  223. .equipment_p {
  224. width: 90%;
  225. border-left: 8rpx solid #4BB85F;
  226. font-weight: 700;
  227. padding-left: 20rpx;
  228. margin-bottom: 20rpx;
  229. }
  230. .equipment_item {
  231. display: flex;
  232. flex-wrap: wrap;
  233. justify-content: space-between;
  234. .equipment_item_img {
  235. width: 49%;
  236. margin-top: 20rpx;
  237. image {
  238. width: 100%;
  239. height: 170rpx;
  240. }
  241. }
  242. }
  243. }
  244. </style>