index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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. uni.showToast({
  142. title: '此功能暂未开放',
  143. duration: 2000,
  144. icon:"none"
  145. });
  146. }
  147. },
  148. onok(ev) {
  149. uni.uploadFile({
  150. url: 'http://182.92.193.64:8002/api/api_gateway?method=base.bases.base_photo', //仅为示例,非真实的接口地址
  151. filePath: ev.path,
  152. name: 'img_file',
  153. formData: {
  154. 'user': 'test'
  155. },
  156. success: (uploadFileRes) => {
  157. console.log(this.flag)
  158. if (this.flag == 1) {
  159. this.disease(JSON.parse(uploadFileRes.data).data.src)
  160. } else if (this.flag == 2) {
  161. this.worm(JSON.parse(uploadFileRes.data).data.src)
  162. }
  163. uni.navigateTo({
  164. url: "../disandpests/index?datas=" + JSON.stringify(this.res) + "&path=" + JSON.parse(uploadFileRes.data).data
  165. .src
  166. })
  167. }
  168. });
  169. this.url = "";
  170. },
  171. oncancle() {
  172. // url设置为空,隐藏控件
  173. this.url = ''
  174. },
  175. confirm() {
  176. this.flag = 1
  177. uni.chooseImage({
  178. count: 1, //默认9
  179. // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  180. sourceType: ['camera'], //从相册选择
  181. success: (res) => {
  182. this.url = res.tempFilePaths[0]
  183. }
  184. });
  185. },
  186. cancel() {
  187. this.flag = 2
  188. uni.chooseImage({
  189. count: 1, //默认9
  190. // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  191. sourceType: ['camera'], //从相册选择
  192. success: (res) => {
  193. console.log(1)
  194. this.url = res.tempFilePaths[0]
  195. }
  196. });
  197. }
  198. }
  199. }
  200. </script>
  201. <style lang="scss">
  202. .index_uswiper {
  203. width: 95%;
  204. margin: 0 auto;
  205. border-radius: 20rpx !important;
  206. }
  207. .function {
  208. width: 95%;
  209. margin: 20rpx auto;
  210. display: flex;
  211. justify-content: space-around;
  212. .function_item {
  213. width: 18%;
  214. text-align: center;
  215. image {
  216. width: 90rpx;
  217. height: 90rpx;
  218. }
  219. p {
  220. font-size: 24rpx;
  221. }
  222. }
  223. }
  224. .equipment {
  225. width: 95%;
  226. margin: 30rpx auto 0;
  227. .equipment_p {
  228. width: 90%;
  229. border-left: 8rpx solid #4BB85F;
  230. font-weight: 700;
  231. padding-left: 20rpx;
  232. margin-bottom: 20rpx;
  233. }
  234. .equipment_item {
  235. display: flex;
  236. flex-wrap: wrap;
  237. justify-content: space-between;
  238. .equipment_item_img {
  239. width: 49%;
  240. margin-top: 20rpx;
  241. image {
  242. width: 100%;
  243. height: 170rpx;
  244. }
  245. }
  246. }
  247. }
  248. </style>