index.vue 8.1 KB

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