index.vue 5.6 KB

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