index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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="../../static/image/fourMoodBase/1.png" mode=""></image>
  31. <image src="../../static/image/fourMoodBase/3.png" mode=""></image>
  32. <image src="../../static/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="../../static/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. }
  71. },
  72. methods: {
  73. async getFourbase() { //基地列表
  74. const res = await this.$myRequest({
  75. url: '/api/api_gateway?method=base.bases.base_list',
  76. data: this.data
  77. })
  78. this.baselist = this.baselist.concat(res.data)
  79. console.log(this.baselist)
  80. for (var i = 0; i < this.baselist.length; i++) {
  81. var arr = this.baselist[i].base_equip.split("#")
  82. if (arr[0] == '') {
  83. arr.shift(1)
  84. }
  85. console.log(arr)
  86. this.baselist[i].num = arr.length
  87. }
  88. },
  89. async delbase() { //基地列表
  90. const res = await this.$myRequest({
  91. url: '/api/api_gateway?method=base.bases.base_list',
  92. data: {
  93. ret: "del",
  94. base_id: this.delid.id
  95. }
  96. })
  97. },
  98. clickLeft() { //返回主页
  99. uni.switchTab({
  100. url: "../index/index"
  101. })
  102. },
  103. clickRight() { //添加基地
  104. uni.navigateTo({
  105. url: "./addbase"
  106. })
  107. },
  108. searchinput() { //搜索
  109. this.data.page = 1
  110. this.baselist = []
  111. Debounce(() => {
  112. this.getFourbase()
  113. }, 1000)()
  114. },
  115. search() { //搜索按钮
  116. this.data.page = 1
  117. this.baselist = []
  118. this.getFourbase()
  119. this.$forceUpdate()
  120. },
  121. details(id) { //详情页
  122. uni.navigateTo({
  123. url: "./basefacility?id=" + id
  124. })
  125. },
  126. XQclick(item) { //编辑
  127. this.post_show = !this.post_show
  128. this.delid = item
  129. },
  130. message(index) { //编辑或者删除
  131. console.log(index)
  132. if (index == 1) {
  133. console.log(this.delid.id)
  134. uni.showModal({
  135. title: '提示',
  136. content: '确定要删除该基地吗?',
  137. success: (res) => {
  138. if (res.confirm) {
  139. this.delbase()
  140. } else if (res.cancel) {
  141. console.log('用户点击取消');
  142. }
  143. }
  144. });
  145. } else {
  146. uni.navigateTo({
  147. url: "./modification?id=" + JSON.stringify(this.delid)
  148. })
  149. }
  150. this.$forceUpdate()
  151. },
  152. top() {
  153. uni.pageScrollTo({
  154. scrollTop: 0,
  155. duration: 500
  156. })
  157. }
  158. },
  159. onLoad() {
  160. this.getFourbase()
  161. },
  162. onReachBottom() { //滑动到底部加载
  163. this.data.page++
  164. this.getFourbase()
  165. },
  166. onShow() {
  167. this.$forceUpdate()
  168. },
  169. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  170. if (e.scrollTop > 200) { //距离大于200时显示
  171. this.isTop = true
  172. } else { //距离小于200时隐藏
  173. this.isTop = false
  174. }
  175. },
  176. }
  177. </script>
  178. <style lang="scss">
  179. .tianjia {
  180. position: absolute;
  181. top: 24rpx;
  182. right: 24rpx;
  183. font-size: 38rpx;
  184. }
  185. .bases_search {
  186. width: 100%;
  187. position: fixed;
  188. top: 88px;
  189. z-index: 100;
  190. background-color: #FFFFFF;
  191. .bases_search_text {
  192. width: 90%;
  193. margin: 0 auto;
  194. background-color: #F8F8F8;
  195. height: 60rpx;
  196. border-radius: 30rpx;
  197. display: flex;
  198. line-height: 60rpx;
  199. .search {
  200. padding: 0 20rpx;
  201. font-size: 34rpx;
  202. }
  203. input {
  204. width: 80%;
  205. margin-top: 10rpx;
  206. font-size: 28rpx;
  207. }
  208. }
  209. }
  210. .bases {
  211. width: 100%;
  212. position: relative;
  213. top: 170rpx;
  214. .bases_list {
  215. width: 90%;
  216. margin: 0 auto 20rpx;
  217. height: 276rpx;
  218. position: relative;
  219. .bases_list_bgi {
  220. .bgcolor {
  221. width: 100%;
  222. height: 276rpx;
  223. background-color: rgba(0, 0, 0, 0.3);
  224. border-radius: 25rpx;
  225. }
  226. image {
  227. position: absolute;
  228. top: 0;
  229. left: 0;
  230. width: 100%;
  231. height: 276rpx;
  232. border-radius: 25rpx;
  233. z-index: -1;
  234. }
  235. }
  236. .bases_list_text {
  237. position: absolute;
  238. top: 0;
  239. left: 0;
  240. z-index: 10;
  241. padding: 40rpx;
  242. color: #FFFFFF;
  243. p {
  244. margin-bottom: 10rpx;
  245. }
  246. }
  247. .bases_list_xiangqing {
  248. position: absolute;
  249. top: 20rpx;
  250. right: 20rpx;
  251. transform: rotate(90deg);
  252. font-size: 26rpx;
  253. color: #FFFFFF;
  254. }
  255. .photoshow {
  256. width: 160rpx;
  257. height: 34rpx;
  258. display: flex;
  259. position: absolute;
  260. bottom: 26rpx;
  261. right: 36rpx;
  262. background-color: #a7a8a0;
  263. border-radius: 18rpx;
  264. padding: 4rpx;
  265. image {
  266. width: 32rpx;
  267. height: 32rpx;
  268. margin-right: 4rpx;
  269. }
  270. .photoshow_num {
  271. width: 50rpx;
  272. height: 30rpx;
  273. border: 1px solid #FFFFFF;
  274. border-radius: 17rpx;
  275. text-align: center;
  276. line-height: 28rpx;
  277. font-size: 24rpx;
  278. color: #FFFFFF;
  279. }
  280. }
  281. }
  282. }
  283. .top {
  284. position: fixed;
  285. right: 30px;
  286. bottom: 100px;
  287. z-index: 100;
  288. image {
  289. width: 100rpx;
  290. height: 100rpx;
  291. }
  292. }
  293. </style>