open_door.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <view class="page" style="position: relative;">
  3. <radio-group class="block" @change="RadioChange">
  4. <view class="cu-list menu text-left">
  5. <view class="cu-item" @click="activedIndex=index" v-for="(item,index) in device_list" :key="index">
  6. <label class="flex justify-between align-center flex-sub">
  7. <view class="flex-sub margin-left-sm">{{item.deviceName}}</view>
  8. <u-icon size="36" name="checkmark-circle-fill" color="#2f7ff5" v-if="activedIndex==index"></u-icon>
  9. </label>
  10. </view>
  11. </view>
  12. </radio-group>
  13. <view class="bottom">
  14. <button @click="openDoor" class="cu-btn cuIcon round bg-white shadow1"
  15. style="height: 150rpx;width: 150rpx;margin-bottom: 160rpx;border: 1rpx solid #c6c6c6;">
  16. <text v-if="!isOpen" class="cuIcon-lock" style="font-size: 50rpx;color: #989898;"></text>
  17. <u-loading mode="flower" size="40" v-else></u-loading>
  18. </button>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. var app = getApp()
  24. var that;
  25. export default {
  26. data() {
  27. return {
  28. guestRecordId:'',
  29. guestTel: '',
  30. memberId: '',
  31. residentialId: '',
  32. activedIndex: 0,
  33. device_list: [],
  34. isOpen:false,
  35. };
  36. },
  37. onLoad(options) {
  38. that = this
  39. this.guestTel = options.guestTel
  40. this.memberId = options.memberId
  41. this.residentialId = options.residentialId
  42. this.guestRecordId=options.guestRecordId
  43. this.getAuthDevice()
  44. },
  45. methods: {
  46. /**
  47. * 立即开门
  48. */
  49. openDoor() {
  50. let item=this.device_list[this.activedIndex]
  51. if (this.$isEmpty(item)) {
  52. this.$dialog.showModal('设备不存在')
  53. return
  54. }
  55. let params = {
  56. guestId: this.guestRecordId,
  57. serialNum: item.deviceSerialNum,
  58. deviceFactory: item.deviceFactory,
  59. residentialId: item.residentialId,
  60. userType: 'FK_'
  61. }
  62. this.isOpen=true
  63. this.$http.openDoor(params).then(res => {
  64. this.isOpen=false
  65. if (res.data.success) {
  66. this.$u.toast('开门成功')
  67. } else {
  68. this.$u.toast('开门失败')
  69. }
  70. }).catch(err=>{
  71. this.isOpen=false
  72. })
  73. },
  74. /**
  75. * 获取设备列表
  76. */
  77. getAuthDevice: function() {
  78. let params = {
  79. id: this.memberId,
  80. residentialId: this.residentialId
  81. }
  82. this.$http.getAuthDeviceByMemberId(params).then(res => {
  83. if (res.data.success) {
  84. this.device_list = res.data.data
  85. }
  86. });
  87. },
  88. }
  89. };
  90. </script>
  91. <style lang="scss" scoped>
  92. .bottom {
  93. position: fixed;
  94. bottom: 0;
  95. left: 40%;
  96. }
  97. .shadow1 {
  98. box-shadow: 0 0 20rpx #cbcbcb
  99. }
  100. button:active {
  101. box-shadow: 0 0 10rpx rgba(203, 203, 203, 0.2);
  102. position: relative;
  103. top: 2px;
  104. }
  105. </style>