index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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>
  42. </template>
  43. <script>
  44. import {
  45. Debounce,
  46. Throttle
  47. } from "../../util/anitthro.js"
  48. export default {
  49. data() {
  50. return {
  51. data: {
  52. ret: 'list',
  53. search: '',
  54. page_size: 10,
  55. page: 1
  56. },
  57. baselist: [],
  58. actionSheetList: [{
  59. text: "编辑基地"
  60. }, {
  61. text: "删除基地"
  62. }],
  63. post_show: false,
  64. delid: "",
  65. facilitynum: ""
  66. }
  67. },
  68. methods: {
  69. async getFourbase() { //基地列表
  70. const res = await this.$myRequest({
  71. url: '/api/api_gateway?method=base.bases.base_list',
  72. data: this.data
  73. })
  74. this.baselist = this.baselist.concat(res.data)
  75. console.log(this.baselist)
  76. for(var i=0;i<this.baselist.length;i++){
  77. var arr = this.baselist[i].base_equip.split("#")
  78. if(arr[0]==''){
  79. arr.shift(1)
  80. }
  81. console.log(arr)
  82. this.baselist[i].num = arr.length
  83. }
  84. },
  85. async delbase() { //基地列表
  86. const res = await this.$myRequest({
  87. url: '/api/api_gateway?method=base.bases.base_list',
  88. data: {
  89. ret: "del",
  90. base_id: this.delid.id
  91. }
  92. })
  93. },
  94. clickLeft() { //返回主页
  95. uni.switchTab({
  96. url: "../index/index"
  97. })
  98. },
  99. clickRight() { //添加基地
  100. uni.navigateTo({
  101. url: "./addbase"
  102. })
  103. },
  104. searchinput() { //搜索
  105. this.data.page = 1
  106. this.baselist = []
  107. Debounce(() => {
  108. this.getFourbase()
  109. }, 1000)()
  110. },
  111. search() { //搜索按钮
  112. this.data.page = 1
  113. this.baselist = []
  114. this.getFourbase()
  115. this.$forceUpdate()
  116. },
  117. details(id) { //详情页
  118. uni.navigateTo({
  119. url: "./basefacility?id=" + id
  120. })
  121. },
  122. XQclick(item) { //编辑
  123. this.post_show = !this.post_show
  124. this.delid = item
  125. },
  126. message(index) { //编辑或者删除
  127. console.log(index)
  128. if (index == 1) {
  129. console.log(this.delid.id)
  130. uni.showModal({
  131. title: '提示',
  132. content: '确定要删除该基地吗?',
  133. success: (res) => {
  134. if (res.confirm) {
  135. this.delbase()
  136. } else if (res.cancel) {
  137. console.log('用户点击取消');
  138. }
  139. }
  140. });
  141. } else {
  142. uni.navigateTo({
  143. url: "./modification?id=" + JSON.stringify(this.delid)
  144. })
  145. }
  146. this.$forceUpdate()
  147. }
  148. },
  149. onLoad() {
  150. this.getFourbase()
  151. },
  152. onReachBottom() { //滑动到底部加载
  153. this.data.page++
  154. this.getFourbase()
  155. },
  156. onShow() {
  157. this.$forceUpdate()
  158. }
  159. }
  160. </script>
  161. <style lang="scss">
  162. .tianjia {
  163. position: absolute;
  164. top: 24rpx;
  165. right: 24rpx;
  166. font-size: 38rpx;
  167. }
  168. .bases_search {
  169. width: 100%;
  170. position: fixed;
  171. top: 88px;
  172. z-index: 100;
  173. background-color: #FFFFFF;
  174. .bases_search_text {
  175. width: 90%;
  176. margin: 0 auto;
  177. background-color: #F8F8F8;
  178. height: 60rpx;
  179. border-radius: 30rpx;
  180. display: flex;
  181. line-height: 60rpx;
  182. .search {
  183. padding: 0 20rpx;
  184. font-size: 34rpx;
  185. }
  186. input {
  187. width: 80%;
  188. margin-top: 10rpx;
  189. font-size: 28rpx;
  190. }
  191. }
  192. }
  193. .bases {
  194. width: 100%;
  195. position: relative;
  196. top: 170rpx;
  197. .bases_list {
  198. width: 90%;
  199. margin: 0 auto 20rpx;
  200. height: 276rpx;
  201. position: relative;
  202. .bases_list_bgi {
  203. .bgcolor {
  204. width: 100%;
  205. height: 276rpx;
  206. background-color: rgba(0, 0, 0, 0.3);
  207. border-radius: 25rpx;
  208. }
  209. image {
  210. position: absolute;
  211. top: 0;
  212. left: 0;
  213. width: 100%;
  214. height: 276rpx;
  215. border-radius: 25rpx;
  216. z-index: -1;
  217. }
  218. }
  219. .bases_list_text {
  220. position: absolute;
  221. top: 0;
  222. left: 0;
  223. z-index: 10;
  224. padding: 40rpx;
  225. color: #FFFFFF;
  226. p {
  227. margin-bottom: 10rpx;
  228. }
  229. }
  230. .bases_list_xiangqing {
  231. position: absolute;
  232. top: 20rpx;
  233. right: 20rpx;
  234. transform: rotate(90deg);
  235. font-size: 26rpx;
  236. color: #FFFFFF;
  237. }
  238. .photoshow {
  239. width: 160rpx;
  240. height: 34rpx;
  241. display: flex;
  242. position: absolute;
  243. bottom: 26rpx;
  244. right: 36rpx;
  245. background-color: #a7a8a0;
  246. border-radius: 18rpx;
  247. padding: 4rpx;
  248. image {
  249. width: 32rpx;
  250. height: 32rpx;
  251. margin-right: 4rpx;
  252. }
  253. .photoshow_num {
  254. width: 50rpx;
  255. height: 30rpx;
  256. border: 1px solid #FFFFFF;
  257. border-radius: 17rpx;
  258. text-align: center;
  259. line-height: 28rpx;
  260. font-size: 24rpx;
  261. color: #FFFFFF;
  262. }
  263. }
  264. }
  265. }
  266. </style>