index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. mask:true,
  140. success:function(){
  141. console.log(999)
  142. }
  143. });
  144. if(this.flag == 2){
  145. console.log('111')
  146. // pest.pests.insect_discern 虫害
  147. // uni.uploadFile({
  148. // // url: 'http://182.92.193.64:8002/api/api_gateway?method=base.bases.base_photo', //仅为示例,非真实的接口地址
  149. // url: 'http://182.92.193.64:8002/api/api_gateway?method=pest.pests.insect_discern', //仅为示例,非真实的接口地址
  150. // filePath: ev.path,
  151. // name: 'img_file',
  152. // formData: {
  153. // 'user': 'test'
  154. // },
  155. // success: (uploadFileRes) => {
  156. // console.log(JSON.parse(uploadFileRes.data))
  157. // uni.navigateTo({
  158. // url: "../disandpests/index?datas=" + uploadFileRes.data + "&path=" + ev.path
  159. // })
  160. // }
  161. // });
  162. }else if(this.flag == 1){
  163. //pest.pests.insect_discern病害识别
  164. uni.showLoading({
  165. title: '加载中'
  166. });
  167. uni.uploadFile({
  168. // url: 'http://182.92.193.64:8002/api/api_gateway?method=base.bases.base_photo', //仅为示例,非真实的接口地址
  169. url: 'http://182.92.193.64:8002/api/api_gateway?method=pest.pests.plant_discern', //仅为示例,非真实的接口地址
  170. filePath: ev.path,
  171. name: 'img_file',
  172. formData: {
  173. 'user': 'test'
  174. },
  175. success: (uploadFileRes) => {
  176. console.log(JSON.parse(uploadFileRes.data))
  177. uni.navigateTo({
  178. url: "../disandpests/index?datas="+uploadFileRes.data + "&path=" + ev.path
  179. })
  180. }
  181. });
  182. }
  183. this.url = "";
  184. },
  185. oncancle() {
  186. // url设置为空,隐藏控件
  187. this.url = ''
  188. },
  189. confirm() {
  190. this.flag = 1
  191. uni.chooseImage({
  192. count: 1, //默认9
  193. // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  194. sourceType: ['camera','album'], //从相册选择
  195. success: (res) => {
  196. this.url = res.tempFilePaths[0]
  197. }
  198. });
  199. console.log(1)
  200. },
  201. cancel() {
  202. this.flag = 2
  203. uni.chooseImage({
  204. count: 1, //默认9
  205. // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  206. sourceType: ['camera','album'], //从相册选择
  207. success: (res) => {
  208. console.log(1)
  209. this.url = res.tempFilePaths[0]
  210. }
  211. });
  212. }
  213. }
  214. }
  215. </script>
  216. <style lang="scss">
  217. .index_uswiper {
  218. width: 95%;
  219. margin: 0 auto;
  220. border-radius: 20rpx !important;
  221. }
  222. .loading{
  223. position: absolute;
  224. top: 0;
  225. left: 0;
  226. z-index: 100;
  227. width:100%;
  228. height: 100vh;
  229. background-color: rgba(0,0,0,0.5);
  230. display: flex;
  231. justify-content: center;
  232. align-items: center;
  233. }
  234. .function {
  235. width: 95%;
  236. margin: 20rpx auto;
  237. display: flex;
  238. justify-content: space-around;
  239. .function_item {
  240. width: 18%;
  241. text-align: center;
  242. image {
  243. width: 90rpx;
  244. height: 90rpx;
  245. }
  246. p {
  247. font-size: 24rpx;
  248. }
  249. }
  250. }
  251. .equipment {
  252. width: 95%;
  253. margin: 30rpx auto 0;
  254. .equipment_p {
  255. width: 90%;
  256. border-left: 8rpx solid #4BB85F;
  257. font-weight: 700;
  258. padding-left: 20rpx;
  259. margin-bottom: 20rpx;
  260. }
  261. .equipment_item {
  262. display: flex;
  263. flex-wrap: wrap;
  264. justify-content: space-between;
  265. .equipment_item_img {
  266. width: 49%;
  267. margin-top: 20rpx;
  268. image {
  269. width: 100%;
  270. height: 170rpx;
  271. }
  272. }
  273. }
  274. }
  275. </style>