index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  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="'http://static.yfpyx.com/bigdata_app'+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="'http://static.yfpyx.com/bigdata_app'+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: 'http://static.yfpyx.com/bigdata_app/image/index/11.png'
  38. }, ],
  39. functionimg: [{
  40. src: "/image/index/1.png",
  41. text: "四情基地"
  42. },
  43. {
  44. src: "/image/index/2.png",
  45. text: "病虫识别"
  46. },
  47. {
  48. src: "/image/index/3.png",
  49. text: "专家诊断"
  50. },
  51. {
  52. src: "/image/index/4.png",
  53. text: "售后服务"
  54. }
  55. ],
  56. equipmentimg: [{
  57. src: "/image/index/5.png"
  58. },
  59. {
  60. src: "/image/index/6.png"
  61. },
  62. {
  63. src: "/image/index/7.png"
  64. },
  65. {
  66. src: "/image/index/8.png"
  67. },
  68. {
  69. src: "/image/index/9.png"
  70. },
  71. {
  72. src: "/image/index/10.png"
  73. }
  74. ],
  75. url: '',
  76. path: '',
  77. flag: 1,
  78. show: false,
  79. jurisdiction:{
  80. cbtf:false,
  81. jktf:false,
  82. hjtf:false,
  83. fztf:false,
  84. sytf:false,
  85. sbtf:false,
  86. sqtf:false,
  87. zjtf:false
  88. }
  89. }
  90. },
  91. onLoad() {
  92. this.jurisdiction={
  93. cbtf:false,
  94. jktf:false,
  95. hjtf:false,
  96. fztf:false,
  97. sytf:false,
  98. sbtf:false,
  99. sqtf:false,
  100. zjtf:false
  101. }
  102. this.getUserlogin()
  103. },
  104. onShow(){
  105. this.jurisdiction={
  106. cbtf:false,
  107. jktf:false,
  108. hjtf:false,
  109. fztf:false,
  110. sytf:false,
  111. sbtf:false,
  112. sqtf:false,
  113. zjtf:false
  114. }
  115. this.loadTF = false
  116. this.getUserlogin()
  117. },
  118. methods: {
  119. async getUserlogin() {
  120. const res = await this.$myRequest({
  121. url: '/api/api_gateway?method=user.login.user_login_info',
  122. })
  123. uni.setStorage({
  124. key: 'jurisdiction',
  125. data: JSON.stringify(res.children),
  126. })
  127. uni.setStorage({
  128. key: 'myuser_type',
  129. data: JSON.stringify(res.myuser_type),
  130. })
  131. console.log(res.children)
  132. for(var i=0;i<res.children.length;i++){
  133. switch (res.children[i].purview_name){
  134. case "测报系统":
  135. this.jurisdiction.cbtf = true
  136. break;
  137. case "可视农业":
  138. this.jurisdiction.jktf = true
  139. break;
  140. case "环境监测系统":
  141. this.jurisdiction.hjtf = true
  142. break;
  143. case "防治系统":
  144. this.jurisdiction.fztf = true
  145. break;
  146. case "溯源系统":
  147. this.jurisdiction.sytf = true
  148. break;
  149. case "系统管理":
  150. this.jurisdiction.sbtf = true
  151. break;
  152. case "四情基地":
  153. this.jurisdiction.sqtf = true
  154. break;
  155. case "专家诊断":
  156. this.jurisdiction.zjtf = true
  157. break;
  158. }
  159. }
  160. },
  161. tabfunction(index) {
  162. if (index == 0) {
  163. if(this.jurisdiction.sqtf){
  164. uni.navigateTo({
  165. url: "../fourBase/index"
  166. })
  167. }else{
  168. uni.showToast({
  169. title: "此账号未开启此模块,如有需要,请联系管理员",
  170. icon: "none"
  171. })
  172. }
  173. } else if (index == 1) {
  174. var that = this
  175. this.show = true
  176. } else if (index == 2) {
  177. if(this.jurisdiction.zjtf){
  178. uni.navigateTo({
  179. url: "../expertDiagnosis/index",
  180. })
  181. }else{
  182. uni.showToast({
  183. title: "此账号未开启此模块,如有需要,请联系管理员",
  184. icon: "none"
  185. })
  186. }
  187. } else if (index == 3) {
  188. uni.navigateTo({
  189. url: "../afterSale/index"
  190. })
  191. }
  192. },
  193. tabequipment(index) {
  194. if (index == 0) {
  195. if(this.jurisdiction.cbtf){
  196. uni.navigateTo({
  197. url: "../cb/index/index"
  198. })
  199. }else{
  200. uni.showToast({
  201. title: "此账号未开启此模块,如有需要,请联系管理员",
  202. icon: "none"
  203. })
  204. }
  205. } else if (index == 1) {
  206. if(this.jurisdiction.fztf){
  207. uni.navigateTo({
  208. url: "../prevention/index"
  209. })
  210. }else{
  211. uni.showToast({
  212. title: "此账号未开启此模块,如有需要,请联系管理员",
  213. icon: "none"
  214. })
  215. }
  216. } else if (index == 2) {
  217. console.log(this.jurisdiction.jktf)
  218. if(this.jurisdiction.jktf){
  219. uni.navigateTo({
  220. url: "/pages/monitor/index"
  221. })
  222. }else{
  223. uni.showToast({
  224. title: "此账号未开启此模块,如有需要,请联系管理员",
  225. icon: "none"
  226. })
  227. }
  228. } else if (index == 3) {
  229. if(this.jurisdiction.hjtf){
  230. uni.navigateTo({
  231. url: "../environment/index"
  232. })
  233. }else{
  234. uni.showToast({
  235. title: "此账号未开启此模块,如有需要,请联系管理员",
  236. icon: "none"
  237. })
  238. }
  239. } else if (index == 4) {
  240. console.log(this.jurisdiction.sbtf)
  241. if(this.jurisdiction.sbtf){
  242. uni.navigateTo({
  243. url: "../equipMange/index/index"
  244. })
  245. }else{
  246. uni.showToast({
  247. title: "此账号未开启此模块,如有需要,请联系管理员",
  248. icon: "none"
  249. })
  250. }
  251. } else if (index == 5) {
  252. uni.showToast({
  253. title: '此功能暂未开放',
  254. duration: 2000,
  255. icon:"none"
  256. });
  257. // if(this.jurisdiction.cbtf){
  258. // uni.navigateTo({
  259. // url: "../cb/index/index"
  260. // })
  261. // }else{
  262. // uni.showToast({
  263. // title: "此账号未开启此模块,如有需要,请联系管理员",
  264. // icon: "none"
  265. // })
  266. // }
  267. }
  268. },
  269. onok(ev) {
  270. this.path = this.url
  271. console.log(ev)
  272. this.loadTF = true
  273. uni.showLoading({
  274. mask:true,
  275. success:function(){
  276. console.log(999)
  277. }
  278. });
  279. if(this.flag == 2){
  280. console.log('111')
  281. // pest.pests.insect_discern 虫害
  282. uni.uploadFile({
  283. // url: 'http://182.92.193.64:8002/api/api_gateway?method=base.bases.base_photo', //仅为示例,非真实的接口地址
  284. url: 'http://182.92.193.64:8002/api/api_gateway?method=pest.pests.insect_discern', //仅为示例,非真实的接口地址
  285. filePath: ev.path,
  286. name: 'img_file',
  287. formData: {
  288. 'user': 'test'
  289. },
  290. success: (uploadFileRes) => {
  291. console.log(JSON.parse(uploadFileRes.data))
  292. uni.navigateTo({
  293. url: "../disandpests/index?datas=" + uploadFileRes.data + "&path=" + ev.path
  294. })
  295. }
  296. });
  297. }else if(this.flag == 1){
  298. //pest.pests.insect_discern病害识别
  299. uni.showLoading({
  300. title: '加载中'
  301. });
  302. uni.uploadFile({
  303. // url: 'http://182.92.193.64:8002/api/api_gateway?method=base.bases.base_photo', //仅为示例,非真实的接口地址
  304. url: 'http://182.92.193.64:8002/api/api_gateway?method=pest.pests.plant_discern', //仅为示例,非真实的接口地址
  305. filePath: ev.path,
  306. name: 'img_file',
  307. formData: {
  308. 'user': 'test'
  309. },
  310. success: (uploadFileRes) => {
  311. console.log(JSON.parse(uploadFileRes.data))
  312. uni.navigateTo({
  313. url: "../disandpests/index?datas="+uploadFileRes.data + "&path=" + ev.path
  314. })
  315. }
  316. });
  317. }
  318. this.url = "";
  319. },
  320. oncancle() {
  321. // url设置为空,隐藏控件
  322. this.url = ''
  323. },
  324. confirm() {
  325. this.flag = 1
  326. uni.chooseImage({
  327. count: 1, //默认9
  328. // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  329. sourceType: ['camera','album'], //从相册选择
  330. success: (res) => {
  331. this.url = res.tempFilePaths[0]
  332. }
  333. });
  334. console.log(1)
  335. },
  336. cancel() {
  337. this.flag = 2
  338. uni.chooseImage({
  339. count: 1, //默认9
  340. // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  341. sourceType: ['camera','album'], //从相册选择
  342. success: (res) => {
  343. console.log(1)
  344. this.url = res.tempFilePaths[0]
  345. }
  346. });
  347. }
  348. }
  349. }
  350. </script>
  351. <style lang="scss">
  352. .index_uswiper {
  353. width: 95%;
  354. margin: 0 auto;
  355. border-radius: 20rpx !important;
  356. }
  357. .loading{
  358. position: absolute;
  359. top: 0;
  360. left: 0;
  361. z-index: 100;
  362. width:100%;
  363. height: 100vh;
  364. background-color: rgba(0,0,0,0.5);
  365. display: flex;
  366. justify-content: center;
  367. align-items: center;
  368. }
  369. .function {
  370. width: 95%;
  371. margin: 20rpx auto;
  372. display: flex;
  373. justify-content: space-around;
  374. .function_item {
  375. width: 18%;
  376. text-align: center;
  377. image {
  378. width: 90rpx;
  379. height: 90rpx;
  380. }
  381. p {
  382. font-size: 24rpx;
  383. }
  384. }
  385. }
  386. .equipment {
  387. width: 95%;
  388. margin: 30rpx auto 0;
  389. .equipment_p {
  390. width: 90%;
  391. border-left: 8rpx solid #4BB85F;
  392. font-weight: 700;
  393. padding-left: 20rpx;
  394. margin-bottom: 20rpx;
  395. }
  396. .equipment_item {
  397. display: flex;
  398. flex-wrap: wrap;
  399. justify-content: space-between;
  400. .equipment_item_img {
  401. width: 49%;
  402. margin-top: 20rpx;
  403. image {
  404. width: 100%;
  405. height: 190rpx;
  406. }
  407. }
  408. }
  409. }
  410. </style>