open_door.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <view class="page" style="position: relative;">
  3. <loading isFullScreen color="#59a5f0" :active="isloading" text="开门中..."></loading>
  4. <radio-group class="block" @change="RadioChange">
  5. <view class="cu-list menu text-left">
  6. <view class="cu-item" v-for="(item,index) in device_list" :key="index">
  7. <label class="flex justify-between align-center flex-sub">
  8. <view class="flex-sub margin-left-sm">{{item.name}}</view>
  9. <radio class="roundn blue" :class="doorValue==item.id?'checked':''" :checked="doorValue==item.id?true:false"
  10. :value="item.id"></radio>
  11. </label>
  12. </view>
  13. </view>
  14. </radio-group>
  15. <view class="bottom">
  16. <button @click="open" class="cu-btn cuIcon round bg-white shadow1" style="height: 150rpx;width: 150rpx;margin-bottom: 160rpx;border: 1rpx solid #c6c6c6;">
  17. <text :class="isopen?'cuIcon-unlock':'cuIcon-lock'" :style="{'color':(isopen?'#55aa7f':'#989898')}" style="font-size: 60rpx;color: #989898;"></text>
  18. </button>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. var app=getApp()
  24. var that;
  25. import loading from "@/comps/loading/loading.vue"
  26. export default {
  27. components:{
  28. loading
  29. },
  30. data() {
  31. return {
  32. guestTel:'',
  33. memberId:'',
  34. residentialId:'',
  35. isopen:false,
  36. isloading:false,
  37. doorValue:'',
  38. device_list:[]
  39. };
  40. },
  41. onLoad(options) {
  42. that=this
  43. this.guestTel=options.guestTel
  44. this.memberId=options.memberId
  45. this.residentialId=options.residentialId
  46. console.log(this.memberId);
  47. this.getAuthDevice()
  48. },
  49. methods:{
  50. RadioChange(e) {
  51. this.doorValue = e.detail.value
  52. },
  53. open(){
  54. //进度条加载
  55. this.isloading=true
  56. setTimeout(()=>{
  57. that.openDoor()
  58. },2300)
  59. },
  60. /**
  61. * 立即开门
  62. */
  63. openDoor() {
  64. let device_id=this.doorValue
  65. let params = {};
  66. params['member_id'] = this.memberId;
  67. params['device_id'] = device_id;
  68. params['phone']=this.guestTel
  69. params['is_guest']='1'
  70. let operation = 'member/openDoor';
  71. app.globalData.postRequest(params, operation, function (res) {
  72. that.isloading=false
  73. that.isopen=true
  74. app.globalData.oneFailHint(res.data.result_msg,function(){
  75. that.isopen=false
  76. });
  77. });
  78. },
  79. /**
  80. * 获取设备列表
  81. */
  82. getAuthDevice: function () {
  83. let that = this;
  84. let params = {};
  85. params['member_id'] = this.memberId;
  86. let operation = 'member/getAuthDeviceByMemberId';
  87. app.globalData.postRequest(params, operation, function (res) {
  88. if (res.data.result_code == 1) {
  89. let list=[]
  90. res.data.list.map(item => {
  91. if (item.residentialId.indexOf(that.residentialId)>=0) {
  92. list.push(item);
  93. }
  94. });
  95. that.device_list=list
  96. that.doorValue=list[0].id
  97. }
  98. });
  99. },
  100. }
  101. };
  102. </script>
  103. <style lang="scss" scoped>
  104. .bottom{
  105. position: fixed;
  106. bottom: 0;
  107. left: 40%;
  108. }
  109. .shadow1{
  110. box-shadow: 0 0 20rpx #cbcbcb
  111. }
  112. button:active{
  113. box-shadow: 0 0 10rpx rgba(203, 203, 203, 0.2);
  114. position: relative;
  115. top: 2px;
  116. }
  117. </style>