index.vue 6.5 KB

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