index.vue 7.8 KB

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