index.vue 8.3 KB

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