index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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">
  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. if(res){
  102. uni.showToast({
  103. title: '操作成功!',
  104. duration: 2000,
  105. icon:"none"
  106. });
  107. this.getFourbase()
  108. }
  109. },
  110. clickLeft() { //返回主页
  111. uni.switchTab({
  112. url: "../index/index"
  113. })
  114. },
  115. clickRight() { //添加基地
  116. if(this.jurisdiction.addbase){
  117. uni.navigateTo({
  118. url: "./addbase"
  119. })
  120. }else{
  121. uni.showToast({
  122. title: "您暂无权限进行此操作,如有需要,请联系管理员",
  123. icon: "none"
  124. })
  125. }
  126. },
  127. searchinput() { //搜索
  128. this.data.page = 1
  129. this.baselist = []
  130. Debounce(() => {
  131. this.getFourbase()
  132. }, 1000)()
  133. },
  134. search() { //搜索按钮
  135. this.data.page = 1
  136. this.baselist = []
  137. this.getFourbase()
  138. this.$forceUpdate()
  139. },
  140. details(id) { //详情页
  141. uni.navigateTo({
  142. url: "./basefacility?id=" + id
  143. })
  144. },
  145. XQclick(item) { //编辑
  146. this.post_show = !this.post_show
  147. this.delid = item
  148. },
  149. message(index) { //编辑或者删除
  150. console.log(index)
  151. if (index == 1) {
  152. console.log(this.delid.id)
  153. uni.showModal({
  154. title: '提示',
  155. content: '确定要删除该基地吗?',
  156. success: (res) => {
  157. if (res.confirm) {
  158. this.delbase()
  159. } else if (res.cancel) {
  160. console.log('用户点击取消');
  161. }
  162. }
  163. });
  164. } else {
  165. if(this.jurisdiction.addbase){
  166. uni.navigateTo({
  167. url: "./modification?id=" + JSON.stringify(this.delid)
  168. })
  169. }else{
  170. uni.showToast({
  171. title: "您暂无权限进行此操作,如有需要,请联系管理员",
  172. icon: "none"
  173. })
  174. }
  175. }
  176. this.$forceUpdate()
  177. },
  178. top() {
  179. uni.pageScrollTo({
  180. scrollTop: 0,
  181. duration: 500
  182. })
  183. }
  184. },
  185. onLoad() {
  186. // this.getFourbase()
  187. uni.getStorage({
  188. key:"jurisdiction",
  189. success:(res)=>{
  190. console.log(JSON.parse(res.data))
  191. let items = JSON.parse(res.data).filter((item)=>{
  192. return item.purview_name == "四情基地"
  193. })
  194. let items2 = items[0].children.filter((item)=>{
  195. return item.purview_name == "基地管理"
  196. })
  197. console.log(items2)
  198. this.jurisdiction.addbase =items2[0].children.some((item)=>{
  199. return item.purview_name == "新增"
  200. })
  201. this.jurisdiction.alter =items2[0].children.some((item)=>{
  202. return item.purview_name == "修改"
  203. })
  204. },
  205. })
  206. },
  207. onReachBottom() { //滑动到底部加载
  208. this.data.page++
  209. this.getFourbase()
  210. },
  211. onShow() {
  212. this.getFourbase()
  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: 88px;
  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 {
  257. width: 100%;
  258. position: relative;
  259. top: 170rpx;
  260. .bases_list {
  261. width: 90%;
  262. margin: 0 auto 20rpx;
  263. height: 276rpx;
  264. position: relative;
  265. .bases_list_bgi {
  266. .bgcolor {
  267. width: 100%;
  268. height: 276rpx;
  269. background-color: rgba(0, 0, 0, 0.3);
  270. border-radius: 25rpx;
  271. }
  272. image {
  273. position: absolute;
  274. top: 0;
  275. left: 0;
  276. width: 100%;
  277. height: 276rpx;
  278. border-radius: 25rpx;
  279. z-index: -1;
  280. }
  281. }
  282. .bases_list_text {
  283. position: absolute;
  284. top: 0;
  285. left: 0;
  286. z-index: 10;
  287. padding: 40rpx;
  288. color: #FFFFFF;
  289. p {
  290. margin-bottom: 10rpx;
  291. }
  292. }
  293. .bases_list_xiangqing {
  294. position: absolute;
  295. top: 20rpx;
  296. right: 20rpx;
  297. transform: rotate(90deg);
  298. font-size: 26rpx;
  299. color: #FFFFFF;
  300. }
  301. .photoshow {
  302. width: 160rpx;
  303. height: 34rpx;
  304. display: flex;
  305. position: absolute;
  306. bottom: 26rpx;
  307. right: 36rpx;
  308. background-color: #a7a8a0;
  309. border-radius: 18rpx;
  310. padding: 4rpx;
  311. image {
  312. width: 32rpx;
  313. height: 32rpx;
  314. margin-right: 4rpx;
  315. }
  316. .photoshow_num {
  317. width: 50rpx;
  318. height: 30rpx;
  319. border: 1px solid #FFFFFF;
  320. border-radius: 17rpx;
  321. text-align: center;
  322. line-height: 28rpx;
  323. font-size: 24rpx;
  324. color: #FFFFFF;
  325. }
  326. }
  327. }
  328. }
  329. .top {
  330. position: fixed;
  331. right: 30px;
  332. bottom: 100px;
  333. z-index: 100;
  334. image {
  335. width: 100rpx;
  336. height: 100rpx;
  337. }
  338. }
  339. </style>