index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 44px;">
  5. <view style="position: fixed;z-index: 100;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="四情基地"></uni-nav-bar>
  7. <u-icon name="plus-circle" class="tianjia" @click="clickRight"></u-icon>
  8. </view>
  9. <view class="bases_search">
  10. <view class="bases_search_text">
  11. <u-icon name="search" class="search" @click="search"></u-icon>
  12. <input type="text" v-model="data.search" placeholder="请输入基地名称" @input="searchinput" />
  13. </view>
  14. </view>
  15. <view class="bases_none" v-if="base_none">
  16. 暂无数据
  17. </view>
  18. <view class="bases" v-else>
  19. <view class="bases_list" v-for="(items,index) in baselist" :key="index" @click="details(items.id)">
  20. <view class="bases_list_bgi">
  21. <image :src="items.base_img" mode=""></image>
  22. <view class="bgcolor"></view><!-- 黑色蒙版 -->
  23. </view>
  24. <view class="bases_list_text">
  25. <p >{{items.base_name}}</p>
  26. <p style="font-size: 24rpx;">面积:{{items.base_area}}</p>
  27. <p style="font-size: 24rpx;">联系人:{{items.base_charge}}</p>
  28. <p style="font-size: 24rpx;">联系电话:{{items.base_phone}}</p>
  29. <p style="font-size: 24rpx;">描述:{{items.base_describe}}</p>
  30. </view>
  31. <view class="bases_list_xiangqing">
  32. <u-icon name="more-dot-fill" class="" @click.native.stop="XQclick(items)"></u-icon>
  33. </view>
  34. <view class="photoshow">
  35. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/fourMoodBase/2.png'" mode=""></image>
  36. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/fourMoodBase/3.png'" mode=""></image>
  37. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/fourMoodBase/5.png'" mode=""></image>
  38. <view class="photoshow_num">
  39. {{items.num}}
  40. </view>
  41. </view>
  42. </view>
  43. <u-action-sheet :list="actionSheetList" v-model="post_show" @click="message"></u-action-sheet>
  44. </view>
  45. </view>
  46. <view class="top" v-if="isTop" @click="top">
  47. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/6209a98f0cb3b5086f2ca36152c9269.png'" mode=""></image>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import {
  53. Debounce,
  54. Throttle
  55. } from "../../util/anitthro.js"
  56. export default {
  57. data() {
  58. return {
  59. data: {
  60. ret: 'list',
  61. search: '',
  62. page_size: 10,
  63. page: 1
  64. },
  65. baselist: [],
  66. actionSheetList: [{
  67. text: "编辑基地"
  68. }, {
  69. text: "删除基地"
  70. }],
  71. post_show: false,
  72. delid: "",
  73. facilitynum: "",
  74. isTop:false,
  75. jurisdiction:{
  76. addbase:false,
  77. alter:false
  78. },
  79. base_none:true//基地列表为空判断
  80. }
  81. },
  82. methods: {
  83. async getFourbase() { //基地列表
  84. const res = await this.$myRequest({
  85. url: '/api/api_gateway?method=base.bases.base_list',
  86. data: this.data
  87. })
  88. console.log(res,'get four base')
  89. this.baselist = this.baselist.concat(res.data)
  90. if(this.baselist.length==0){
  91. this.base_none = true
  92. }else{
  93. this.base_none = false
  94. }
  95. for (var i = 0; i < this.baselist.length; i++) {
  96. var arr = this.baselist[i].base_equip.split("#")
  97. if (arr[0] == '') {
  98. arr.shift(1)
  99. }
  100. console.log(arr)
  101. this.baselist[i].num = arr.length
  102. }
  103. console.log(this.baselist,'------------------------- base list')
  104. },
  105. async delbase() { //基地列表
  106. const res = await this.$myRequest({
  107. url: '/api/api_gateway?method=base.bases.base_list',
  108. data: {
  109. ret: "del",
  110. base_id: this.delid.id
  111. }
  112. })
  113. if(res){
  114. uni.showToast({
  115. title: '操作成功!',
  116. duration: 2000,
  117. icon:"none"
  118. });
  119. this.baselist = []
  120. this.data.page = 1
  121. this.getFourbase()
  122. }
  123. },
  124. clickLeft() { //返回主页
  125. uni.switchTab({
  126. url: "../index/index"
  127. })
  128. },
  129. clickRight() { //添加基地
  130. if(this.jurisdiction.addbase){
  131. uni.navigateTo({
  132. url: "./addbase"
  133. })
  134. }else{
  135. uni.showToast({
  136. title: "您暂无权限进行此操作,如有需要,请联系管理员",
  137. icon: "none"
  138. })
  139. }
  140. },
  141. searchinput() { //搜索
  142. this.data.page = 1
  143. this.baselist = []
  144. Debounce(() => {
  145. this.getFourbase()
  146. }, 1000)()
  147. },
  148. search() { //搜索按钮
  149. this.data.page = 1
  150. this.baselist = []
  151. this.getFourbase()
  152. this.$forceUpdate()
  153. },
  154. details(id) { //详情页
  155. uni.navigateTo({
  156. url: "./basefacility?id=" + id
  157. })
  158. },
  159. XQclick(item) { //编辑
  160. this.post_show = !this.post_show
  161. this.delid = item
  162. },
  163. message(index) { //编辑或者删除
  164. console.log(index)
  165. if (index == 1) {
  166. console.log(this.delid.id)
  167. uni.showModal({
  168. title: '提示',
  169. content: '确定要删除该基地吗?',
  170. success: (res) => {
  171. if (res.confirm) {
  172. this.delbase()
  173. // this.baselist = []
  174. // this.data.page = 1
  175. // this.getFourbase()
  176. } else if (res.cancel) {
  177. console.log('用户点击取消');
  178. }
  179. }
  180. });
  181. } else {
  182. if(this.jurisdiction.addbase){
  183. uni.navigateTo({
  184. url: "./modification?id=" + JSON.stringify(this.delid)
  185. })
  186. }else{
  187. uni.showToast({
  188. title: "您暂无权限进行此操作,如有需要,请联系管理员",
  189. icon: "none"
  190. })
  191. }
  192. }
  193. this.$forceUpdate()
  194. },
  195. top() {
  196. uni.pageScrollTo({
  197. scrollTop: 0,
  198. duration: 500
  199. })
  200. }
  201. },
  202. onLoad() {
  203. console.warn('onload four base')
  204. // this.getFourbase()
  205. uni.getStorage({
  206. key:"jurisdiction",
  207. success:(res)=>{
  208. console.log(JSON.parse(res.data))
  209. let items = JSON.parse(res.data).filter((item)=>{
  210. return item.pur_id == 25//"四情基地"
  211. })
  212. let items2 = items[0].children.filter((item)=>{
  213. return item.pur_id == 26//"基地管理"
  214. })
  215. console.log(items2)
  216. this.jurisdiction.addbase =items2[0].children.some((item)=>{
  217. return item.pur_id == 111//"新增"
  218. })
  219. this.jurisdiction.alter =items2[0].children.some((item)=>{
  220. return item.pur_id == 110//"修改"
  221. })
  222. },
  223. })
  224. },
  225. onReachBottom() { //滑动到底部加载
  226. console.log('on each bottom 2')
  227. this.data.page++
  228. this.getFourbase()
  229. },
  230. onShow() {
  231. console.warn('onshow four base')
  232. this.data.page = 1
  233. this.baselist = []
  234. this.getFourbase()
  235. this.$forceUpdate()
  236. },
  237. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  238. if (e.scrollTop > 200) { //距离大于200时显示
  239. this.isTop = true
  240. } else { //距离小于200时隐藏
  241. this.isTop = false
  242. }
  243. },
  244. }
  245. </script>
  246. <style lang="scss">
  247. .tianjia {
  248. position: absolute;
  249. top: 24rpx;
  250. right: 24rpx;
  251. font-size: 38rpx;
  252. }
  253. .bases_search {
  254. width: 100%;
  255. position: fixed;
  256. top: 88px;
  257. z-index: 100;
  258. background-color: #FFFFFF;
  259. .bases_search_text {
  260. width: 90%;
  261. margin: 0 auto;
  262. background-color: #F8F8F8;
  263. height: 60rpx;
  264. border-radius: 30rpx;
  265. display: flex;
  266. line-height: 60rpx;
  267. .search {
  268. padding: 0 20rpx;
  269. font-size: 34rpx;
  270. }
  271. input {
  272. width: 80%;
  273. margin-top: 10rpx;
  274. font-size: 28rpx;
  275. }
  276. }
  277. }
  278. .bases_none{
  279. width: 100%;
  280. position: relative;
  281. top: 200rpx;
  282. font-size: 36rpx;
  283. text-align: center;
  284. }
  285. .bases {
  286. width: 100%;
  287. position: relative;
  288. top: 170rpx;
  289. .bases_list {
  290. width: 90%;
  291. margin: 0 auto 20rpx;
  292. height: 276rpx;
  293. position: relative;
  294. .bases_list_bgi {
  295. .bgcolor {
  296. width: 100%;
  297. height: 276rpx;
  298. background-color: rgba(0, 0, 0, 0.3);
  299. border-radius: 25rpx;
  300. }
  301. image {
  302. position: absolute;
  303. top: 0;
  304. left: 0;
  305. width: 100%;
  306. height: 276rpx;
  307. border-radius: 25rpx;
  308. z-index: -1;
  309. }
  310. }
  311. .bases_list_text {
  312. position: absolute;
  313. top: 0;
  314. left: 0;
  315. z-index: 10;
  316. padding: 40rpx;
  317. color: #FFFFFF;
  318. width: 100%;
  319. box-sizing: border-box;
  320. p:first-child{
  321. font-size: 36rpx;
  322. width: 90%;
  323. }
  324. p:nth-child(3){
  325. width: 70%;
  326. }
  327. p:last-child{
  328. width: 70%;
  329. }
  330. p {
  331. margin-bottom: 10rpx;
  332. overflow: hidden;//溢出隐藏
  333. white-space: nowrap;//禁止换行
  334. text-overflow: ellipsis;//...
  335. }
  336. }
  337. .bases_list_xiangqing {
  338. position: absolute;
  339. top: 20rpx;
  340. right: 20rpx;
  341. transform: rotate(90deg);
  342. font-size: 26rpx;
  343. color: #FFFFFF;
  344. width: 40rpx;
  345. height: 40rpx;
  346. z-index: 99999;
  347. }
  348. .photoshow {
  349. width: 160rpx;
  350. height: 34rpx;
  351. display: flex;
  352. position: absolute;
  353. bottom: 26rpx;
  354. right: 36rpx;
  355. background-color: #a7a8a0;
  356. border-radius: 18rpx;
  357. padding: 4rpx;
  358. image {
  359. width: 32rpx;
  360. height: 32rpx;
  361. margin-right: 4rpx;
  362. }
  363. .photoshow_num {
  364. width: 50rpx;
  365. height: 30rpx;
  366. border: 1px solid #FFFFFF;
  367. border-radius: 17rpx;
  368. text-align: center;
  369. line-height: 28rpx;
  370. font-size: 24rpx;
  371. color: #FFFFFF;
  372. }
  373. }
  374. }
  375. }
  376. .top {
  377. position: fixed;
  378. right: 30px;
  379. bottom: 100px;
  380. z-index: 100;
  381. image {
  382. width: 100rpx;
  383. height: 100rpx;
  384. }
  385. }
  386. </style>