index.vue 8.3 KB

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