index.vue 9.7 KB

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