index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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="$imageURL+ '/bigdata_app'+'/image/fourMoodBase/2.png'" mode=""></image>
  36. <image :src="$imageURL+ '/bigdata_app'+'/image/fourMoodBase/3.png'" mode=""></image>
  37. <image :src="$imageURL+ '/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="$imageURL+ '/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. uni.navigateBack({
  129. delta: 1
  130. })
  131. },
  132. clickRight() { //添加基地
  133. if(this.jurisdiction.addbase){
  134. uni.navigateTo({
  135. url: "./addbase"
  136. })
  137. }else{
  138. uni.showToast({
  139. title: "您暂无权限进行此操作,如有需要,请联系管理员",
  140. icon: "none"
  141. })
  142. }
  143. },
  144. searchinput() { //搜索
  145. this.data.page = 1
  146. this.baselist = []
  147. Debounce(() => {
  148. this.getFourbase()
  149. }, 1000)()
  150. },
  151. search() { //搜索按钮
  152. this.data.page = 1
  153. this.baselist = []
  154. this.getFourbase()
  155. this.$forceUpdate()
  156. },
  157. details(id) { //详情页
  158. uni.navigateTo({
  159. url: "./basefacility?id=" + id
  160. })
  161. },
  162. XQclick(item) { //编辑
  163. this.post_show = !this.post_show
  164. this.delid = item
  165. },
  166. message(index) { //编辑或者删除
  167. console.log(index)
  168. if (index == 1) {
  169. console.log(this.delid.id)
  170. uni.showModal({
  171. title: '提示',
  172. content: '确定要删除该基地吗?',
  173. success: (res) => {
  174. if (res.confirm) {
  175. this.delbase()
  176. // this.baselist = []
  177. // this.data.page = 1
  178. // this.getFourbase()
  179. } else if (res.cancel) {
  180. console.log('用户点击取消');
  181. }
  182. }
  183. });
  184. } else {
  185. if(this.jurisdiction.addbase){
  186. uni.navigateTo({
  187. url: "./modification?id=" + JSON.stringify(this.delid)
  188. })
  189. }else{
  190. uni.showToast({
  191. title: "您暂无权限进行此操作,如有需要,请联系管理员",
  192. icon: "none"
  193. })
  194. }
  195. }
  196. this.$forceUpdate()
  197. },
  198. top() {
  199. uni.pageScrollTo({
  200. scrollTop: 0,
  201. duration: 500
  202. })
  203. }
  204. },
  205. onLoad() {
  206. console.warn('onload four base')
  207. // this.getFourbase()
  208. uni.getStorage({
  209. key:"jurisdiction",
  210. success:(res)=>{
  211. console.log(JSON.parse(res.data))
  212. let items = JSON.parse(res.data).filter((item)=>{
  213. return item.pur_id == 25//"四情基地"
  214. })
  215. let items2 = items[0].children.filter((item)=>{
  216. return item.pur_id == 26//"基地管理"
  217. })
  218. console.log(items2)
  219. this.jurisdiction.addbase =items2[0].children.some((item)=>{
  220. return item.pur_id == 111//"新增"
  221. })
  222. this.jurisdiction.alter =items2[0].children.some((item)=>{
  223. return item.pur_id == 110//"修改"
  224. })
  225. },
  226. })
  227. },
  228. onReachBottom() { //滑动到底部加载
  229. console.log('on each bottom 2')
  230. this.data.page++
  231. this.getFourbase()
  232. },
  233. onShow() {
  234. console.warn('onshow four base')
  235. this.data.page = 1
  236. this.baselist = []
  237. this.getFourbase()
  238. this.$forceUpdate()
  239. },
  240. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  241. if (e.scrollTop > 200) { //距离大于200时显示
  242. this.isTop = true
  243. } else { //距离小于200时隐藏
  244. this.isTop = false
  245. }
  246. },
  247. }
  248. </script>
  249. <style lang="scss">
  250. .tianjia {
  251. position: absolute;
  252. top: 24rpx;
  253. right: 24rpx;
  254. font-size: 38rpx;
  255. }
  256. .bases_search {
  257. width: 100%;
  258. position: fixed;
  259. top: 88px;
  260. z-index: 100;
  261. background-color: #FFFFFF;
  262. .bases_search_text {
  263. width: 90%;
  264. margin: 0 auto;
  265. background-color: #F8F8F8;
  266. height: 60rpx;
  267. border-radius: 30rpx;
  268. display: flex;
  269. line-height: 60rpx;
  270. .search {
  271. padding: 0 20rpx;
  272. font-size: 34rpx;
  273. }
  274. input {
  275. width: 80%;
  276. margin-top: 10rpx;
  277. font-size: 28rpx;
  278. }
  279. }
  280. }
  281. .bases_none{
  282. width: 100%;
  283. position: relative;
  284. top: 200rpx;
  285. font-size: 36rpx;
  286. text-align: center;
  287. }
  288. .bases {
  289. width: 100%;
  290. position: relative;
  291. top: 170rpx;
  292. .bases_list {
  293. width: 90%;
  294. margin: 0 auto 20rpx;
  295. height: 276rpx;
  296. position: relative;
  297. .bases_list_bgi {
  298. .bgcolor {
  299. width: 100%;
  300. height: 276rpx;
  301. background-color: rgba(0, 0, 0, 0.3);
  302. border-radius: 25rpx;
  303. }
  304. image {
  305. position: absolute;
  306. top: 0;
  307. left: 0;
  308. width: 100%;
  309. height: 276rpx;
  310. border-radius: 25rpx;
  311. z-index: -1;
  312. }
  313. }
  314. .bases_list_text {
  315. position: absolute;
  316. top: 0;
  317. left: 0;
  318. z-index: 10;
  319. padding: 40rpx;
  320. color: #FFFFFF;
  321. width: 100%;
  322. box-sizing: border-box;
  323. p:first-child{
  324. font-size: 36rpx;
  325. width: 90%;
  326. }
  327. p:nth-child(3){
  328. width: 70%;
  329. }
  330. p:last-child{
  331. width: 70%;
  332. }
  333. p {
  334. margin-bottom: 10rpx;
  335. overflow: hidden;//溢出隐藏
  336. white-space: nowrap;//禁止换行
  337. text-overflow: ellipsis;//...
  338. }
  339. }
  340. .bases_list_xiangqing {
  341. position: absolute;
  342. top: 20rpx;
  343. right: 20rpx;
  344. transform: rotate(90deg);
  345. font-size: 26rpx;
  346. color: #FFFFFF;
  347. width: 40rpx;
  348. height: 40rpx;
  349. z-index: 99999;
  350. }
  351. .photoshow {
  352. width: 160rpx;
  353. height: 34rpx;
  354. display: flex;
  355. position: absolute;
  356. bottom: 26rpx;
  357. right: 36rpx;
  358. background-color: #a7a8a0;
  359. border-radius: 18rpx;
  360. padding: 4rpx;
  361. image {
  362. width: 32rpx;
  363. height: 32rpx;
  364. margin-right: 4rpx;
  365. }
  366. .photoshow_num {
  367. width: 50rpx;
  368. height: 30rpx;
  369. border: 1px solid #FFFFFF;
  370. border-radius: 17rpx;
  371. text-align: center;
  372. line-height: 28rpx;
  373. font-size: 24rpx;
  374. color: #FFFFFF;
  375. }
  376. }
  377. }
  378. }
  379. .top {
  380. position: fixed;
  381. right: 30px;
  382. bottom: 100px;
  383. z-index: 100;
  384. image {
  385. width: 100rpx;
  386. height: 100rpx;
  387. }
  388. }
  389. </style>