index.vue 9.2 KB

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