index.vue 8.3 KB

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