index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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. uni.navigateTo({
  155. url:"/pages/monitor/index"
  156. })
  157. }else if(index==3){
  158. uni.navigateTo({
  159. url: "../environment/index"
  160. })
  161. } else if (index == 4) {
  162. uni.navigateTo({
  163. url: "../equipMange/index/index"
  164. })
  165. } else if (index == 5) {
  166. console.log(5)
  167. }
  168. },
  169. onok(ev) {
  170. uni.uploadFile({
  171. url: 'http://182.92.193.64:8002/api/api_gateway?method=base.bases.base_photo', //仅为示例,非真实的接口地址
  172. filePath: ev.path,
  173. name: 'img_file',
  174. formData: {
  175. 'user': 'test'
  176. },
  177. success: (uploadFileRes) => {
  178. console.log(this.flag)
  179. if(this.flag == 1){
  180. }else if(this.flag == 2){
  181. this.worm(JSON.parse(uploadFileRes.data).data.src)
  182. }
  183. uni.navigateTo({
  184. url:"../disandpests/index?datas="+JSON.stringify(this.res)+"&path="+JSON.parse(uploadFileRes.data).data.src
  185. })
  186. }
  187. });
  188. this.url = "";
  189. },
  190. oncancle() {
  191. // url设置为空,隐藏控件
  192. this.url = ''
  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>