index.vue 8.8 KB

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