bindRoom.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <!-- 地址列表 -->
  2. <template>
  3. <view class="address-wrap">
  4. <view class="" v-if="$isNotEmpty(houseList)">
  5. <u-checkbox-group :wrap="true" v-for="(item,index) in houseList" :key="index">
  6. <view class="card_list" @click="checked(item)">
  7. <view class="card_list_left">
  8. <u-icon name="home"></u-icon>
  9. <text class="padding-left-10">{{item.residentialName}} | {{item.buildingName}} |
  10. {{item.unitName}} | {{item.roomName}}</text>
  11. </view>
  12. <view class="card_list_right">
  13. <u-checkbox style="float: right;" v-model="item.checked" :name="item.id"></u-checkbox>
  14. </view>
  15. </view>
  16. </u-checkbox-group>
  17. </view>
  18. <u-empty v-else src="/static/common/empty.png" icon-size="180" marginTop="300"></u-empty>
  19. <view class="" style="position: fixed;bottom: 80rpx;left: 0;right: 0;margin: auto;width: 270rpx;">
  20. <u-button size="medium" :customStyle="confirmStyle" type="primary" @click="confirm">确定绑定</u-button>
  21. <u-button size="medium" :customStyle="cancelStyle" @click="auth">创建新房间</u-button>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. components: {},
  28. data() {
  29. return {
  30. houseList: [],
  31. cancelStyle: {
  32. marginTop: '20rpx', // 注意驼峰命名,并且值必须用引号包括,因为这是对象
  33. border: '1rpx solid #d0d0d0',
  34. color:'#171717',
  35. width:'270rpx'
  36. },
  37. confirmStyle: {
  38. width:'270rpx'
  39. }
  40. };
  41. },
  42. computed: {},
  43. onLoad() {
  44. this.initData()
  45. },
  46. methods: {
  47. initData() {
  48. this.houseList = uni.getStorageSync("houseList") || []
  49. this.houseList.forEach(item => {
  50. item.checked = false
  51. })
  52. },
  53. checked(item) {
  54. item.checked = !item.checked
  55. this.$forceUpdate()
  56. },
  57. confirm() {
  58. let memberId = getApp().globalData.member.id
  59. let checkedList = this.houseList.filter(item => item.checked)
  60. if (this.$isEmpty(checkedList)) {
  61. this.$u.toast('至少选择一个房间')
  62. return
  63. }
  64. let ids = checkedList.map(item => item.id)
  65. this.$http.bindRoom(memberId, ids).then(res => {
  66. if (res.data.success) {
  67. uni.removeStorageSync("houseList")
  68. this.$dialog.showModal('绑定成功', false).then(() => {
  69. uni.reLaunch({
  70. url: "../index/index"
  71. })
  72. })
  73. }
  74. })
  75. },
  76. auth() {
  77. uni.redirectTo({
  78. url: "../auth/auth"
  79. })
  80. }
  81. }
  82. };
  83. </script>
  84. <style lang="scss" scoped>
  85. .card_list {
  86. background-color: #FFFFFF;
  87. padding: 30rpx 0rpx 30rpx 30rpx;
  88. display: flex;
  89. justify-content: space-between;
  90. margin: 10rpx 0;
  91. &_left {}
  92. }
  93. // 底部按钮
  94. .foot_box-wrap {
  95. height: 140rpx;
  96. width: 100%;
  97. }
  98. .foot_box {
  99. padding: 10rpx 20rpx;
  100. position: fixed;
  101. bottom: 0;
  102. left: 0;
  103. width: 100%;
  104. // border-top: 1rpx solid rgba(#ccc, 0.2);
  105. // background-color: #fff;
  106. .sync-wxaddress {
  107. flex: 1;
  108. line-height: 80rpx;
  109. background: #ff9900;
  110. }
  111. .add-btn {
  112. line-height: 80rpx;
  113. flex: 1;
  114. background: $base;
  115. color: rgba(255, 255, 255, 1);
  116. }
  117. }
  118. </style>