indexcopy.vue 9.6 KB

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