index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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. }
  248. },
  249. onok(ev) {
  250. this.path = this.url
  251. console.log(ev)
  252. this.loadTF = true
  253. uni.showLoading({
  254. mask:true,
  255. success:function(){
  256. console.log(999)
  257. }
  258. });
  259. if(this.flag == 2){
  260. console.log('111')
  261. // pest.pests.insect_discern 虫害
  262. uni.uploadFile({
  263. // url: 'http://182.92.193.64:8002/api/api_gateway?method=base.bases.base_photo', //仅为示例,非真实的接口地址
  264. url: 'https://wx.hnyfwlw.com/api/api_gateway?method=pest.pests.insect_discern', //仅为示例,非真实的接口地址
  265. filePath: ev.path,
  266. name: 'img_file',
  267. formData: {
  268. 'user': 'test'
  269. },
  270. success: (uploadFileRes) => {
  271. console.log(JSON.parse(uploadFileRes.data))
  272. uni.navigateTo({
  273. url: "../disandpests/index?datas=" + uploadFileRes.data + "&path=" + ev.path
  274. })
  275. }
  276. });
  277. }else if(this.flag == 1){
  278. //pest.pests.insect_discern病害识别
  279. uni.showLoading({
  280. title: '加载中'
  281. });
  282. uni.uploadFile({
  283. // url: 'http://182.92.193.64:8002/api/api_gateway?method=base.bases.base_photo', //仅为示例,非真实的接口地址
  284. url: 'https://wx.hnyfwlw.com/api/api_gateway?method=pest.pests.plant_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. }
  298. this.url = "";
  299. },
  300. oncancle() {
  301. // url设置为空,隐藏控件
  302. this.url = ''
  303. },
  304. confirm() {
  305. this.flag = 1
  306. uni.chooseImage({
  307. count: 1, //默认9
  308. // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  309. sourceType: ['camera','album'], //从相册选择
  310. success: (res) => {
  311. this.url = res.tempFilePaths[0]
  312. }
  313. });
  314. console.log(1)
  315. },
  316. cancel() {
  317. this.flag = 2
  318. uni.chooseImage({
  319. count: 1, //默认9
  320. // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  321. sourceType: ['camera','album'], //从相册选择
  322. success: (res) => {
  323. console.log(1)
  324. this.url = res.tempFilePaths[0]
  325. }
  326. });
  327. }
  328. }
  329. }
  330. </script>
  331. <style lang="scss">
  332. .index_uswiper {
  333. width: 95%;
  334. margin: 0 auto;
  335. border-radius: 20rpx !important;
  336. }
  337. .loading{
  338. position: absolute;
  339. top: 0;
  340. left: 0;
  341. z-index: 100;
  342. width:100%;
  343. height: 100vh;
  344. background-color: rgba(0,0,0,0.5);
  345. display: flex;
  346. justify-content: center;
  347. align-items: center;
  348. }
  349. .function {
  350. width: 95%;
  351. margin: 20rpx auto;
  352. display: flex;
  353. justify-content: space-around;
  354. .function_item {
  355. width: 18%;
  356. text-align: center;
  357. image {
  358. width: 90rpx;
  359. height: 90rpx;
  360. }
  361. p {
  362. font-size: 24rpx;
  363. }
  364. }
  365. }
  366. .equipment {
  367. width: 95%;
  368. margin: 30rpx auto 0;
  369. .equipment_p {
  370. width: 90%;
  371. border-left: 8rpx solid #4BB85F;
  372. font-weight: 700;
  373. padding-left: 20rpx;
  374. margin-bottom: 20rpx;
  375. }
  376. .equipment_item {
  377. display: flex;
  378. flex-wrap: wrap;
  379. justify-content: space-between;
  380. .equipment_item_img {
  381. width: 49%;
  382. margin-top: 20rpx;
  383. image {
  384. width: 100%;
  385. height: 190rpx;
  386. }
  387. }
  388. }
  389. }
  390. </style>