|
- <template>
- <view class="selectBuilding">
- <view class="searchStyle">
- <u-search placeholder="输入项目名称" v-model="search" @search="s" @custom="s"></u-search>
- </view>
- <view class="searchResultStyle">
- <view class="searchList" v-for="(item,index) in list" :key="index" @click="okSelect(item)">
- <text style="flex-grow: 1;">
- {{item.propertyName}}
- </text>
- <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>
- </view>
- </view>
- </view>
-
- </template>
-
- <script>
- var config = require("@/config");
- export default {
- name: "selectBuilding",
- data() {
- return {
- search: "",
- list: [],
- };
- },
- methods: {
- s(e) {
- this.init(e)
- },
- okSelect(data) {
- if (data.lockFlag == 1) {
- uni.showToast({
- title: `${data.propertyName}项目已禁用,不能操作`,
- icon: 'none',
- duration: 2000
- })
- return
- }
- let lopan = {
- id: data.id,
- name: data.propertyName,
- ...data
- }
- uni.setStorageSync("buildingID", lopan);
- uni.setStorageSync("remind", 0);
- this.$u.post('/user/addLoginCount', { houseId: data.id}).then(res=> {
- uni.navigateBack({
- delta: -1
- })
- }).catch(() => {
- uni.navigateBack({
- delta: -1
- })
- })
- },
- init(e) {
- let data = {
- houseName: decodeURI(e) || ''
- }
- uni.request({
- url: config.service.getUser,
- method: "GET",
- data,
- header: {
- 'content-type': 'application/json',
- 'Access-Token': uni.getStorageSync('weapp_session_login_data').token
- },
- success: (res) => {
- console.log(res)
- this.list = res.data.data.zkProperties
- }
- })
- }
- },
- onLoad() {
- this.init("")
- }
- }
- </script>
-
- <style lang="scss" scoped>
- .selectBuilding {
- .searchStyle {
- padding: 20rpx;
- }
-
- .searchResultStyle {
- padding: 0 30rpx;
-
- .searchList {
- border-bottom: 1rpx solid #E0E0E0;
- padding: 30rpx 0;
- font-size: 30rpx;
- display: flex;
- justify-content: space-between;
- }
- }
- }
- </style>
|