open_door.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 red" :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. isopen:false,
  33. isloading:false,
  34. doorValue:'5678',
  35. device_list:[
  36. {
  37. id:'1234',
  38. name:'宁夏冬美小区'
  39. },
  40. {
  41. id:'5678',
  42. name:'宁夏冬美小区2'
  43. },
  44. ]
  45. };
  46. },
  47. onLoad() {
  48. that=this
  49. },
  50. methods:{
  51. RadioChange(e) {
  52. this.doorValue = e.detail.value
  53. },
  54. open(){
  55. //进度条加载
  56. this.isloading=true
  57. setTimeout(()=>{
  58. that.openDoor()
  59. },2300)
  60. },
  61. /**
  62. * 立即开门
  63. */
  64. openDoor() {
  65. let device_id=this.doorValue
  66. let params = {};
  67. params['member_id'] = app.globalData.member.id;
  68. params['device_id'] = device_id;
  69. let operation = 'member/openDoor';
  70. app.globalData.postRequest(params, operation, function (res) {
  71. that.isloading=false
  72. that.isopen=true
  73. app.globalData.oneFailHint(res.data.result_msg,function(){
  74. that.isopen=false
  75. });
  76. });
  77. },
  78. }
  79. };
  80. </script>
  81. <style lang="scss" scoped>
  82. .bottom{
  83. position: fixed;
  84. bottom: 0;
  85. left: 40%;
  86. }
  87. .shadow1{
  88. box-shadow: 0 0 20rpx #cbcbcb
  89. }
  90. button:active{
  91. box-shadow: 0 0 10rpx rgba(203, 203, 203, 0.2);
  92. position: relative;
  93. top: 2px;
  94. }
  95. </style>