index.vue 8.7 KB

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