bindRoom.vue 2.7 KB

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