Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

selectBuilding.vue 2.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <view class="selectBuilding">
  3. <view class="searchStyle">
  4. <u-search placeholder="输入项目名称" v-model="search" @search="s" @custom="s"></u-search>
  5. </view>
  6. <view class="searchResultStyle">
  7. <view class="searchList" v-for="(item,index) in list" :key="index" @click="okSelect(item)">
  8. <text style="flex-grow: 1;">
  9. {{item.propertyName}}
  10. </text>
  11. <text v-if="item.daysRemaining < 0 || item.lockFlag == 1" style="color: #ff0000;flex-shrink: 0;font-size: 26rpx;">({{ item.daysRemaining < 0 ? '已过期' : '' }} {{ item.lockFlag == 1 ? '已禁用' : ''}})</text>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. var config = require("@/config");
  18. export default {
  19. name: "selectBuilding",
  20. data() {
  21. return {
  22. search: "",
  23. list: [],
  24. };
  25. },
  26. methods: {
  27. s(e) {
  28. this.init(e)
  29. },
  30. okSelect(data) {
  31. if (data.lockFlag == 1) {
  32. uni.showToast({
  33. title: `${data.propertyName}项目已禁用,不能操作`,
  34. icon: 'none',
  35. duration: 2000
  36. })
  37. return
  38. }
  39. let lopan = {
  40. id: data.id,
  41. name: data.propertyName
  42. }
  43. uni.setStorageSync("buildingID", lopan);
  44. this.$u.post('/user/addLoginCount', { houseId: data.id}).then(res=> {
  45. uni.navigateBack({
  46. delta: -1
  47. })
  48. }).catch(() => {
  49. uni.navigateBack({
  50. delta: -1
  51. })
  52. })
  53. },
  54. init(e) {
  55. let data = {
  56. houseName: decodeURI(e) || ''
  57. }
  58. uni.request({
  59. url: config.service.getUser,
  60. method: "GET",
  61. data,
  62. header: {
  63. 'content-type': 'application/json',
  64. 'Access-Token': uni.getStorageSync('weapp_session_login_data').token
  65. },
  66. success: (res) => {
  67. console.log(res)
  68. this.list = res.data.data.zkProperties
  69. }
  70. })
  71. }
  72. },
  73. onLoad() {
  74. this.init("")
  75. }
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. .selectBuilding {
  80. .searchStyle {
  81. padding: 20rpx;
  82. }
  83. .searchResultStyle {
  84. padding: 0 30rpx;
  85. .searchList {
  86. border-bottom: 1rpx solid #E0E0E0;
  87. padding: 30rpx 0;
  88. font-size: 30rpx;
  89. display: flex;
  90. justify-content: space-between;
  91. }
  92. }
  93. }
  94. </style>