join.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="cu-modal" :class="{ show: visible }">
  3. <view class="cu-dialog wrapper">
  4. <view class="content">
  5. <image :src="ossurl.welfare.passwordDiaolgTitle" mode="widthFix" class="image" />
  6. <view class="contentWrapper">
  7. <view class="input-wrapper marginB20 flex-align paddingX10">
  8. <input v-model="password" class="flex1 input" />
  9. <text
  10. class="cuIcon-close"
  11. v-if="password"
  12. @click="password = ''"
  13. style="font-size: 32rpx"
  14. ></text>
  15. </view>
  16. <view class="flex-align-between">
  17. <view class="btn btnCancel" @click="close">取消</view>
  18. <view class="btn btnApply" @click="apply">加入房间</view>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import { throttle } from '@/utils'
  27. import ossurl from '@/utils/ossurl'
  28. import { WX_PUSH_MESSAGE_ID } from '@/utils/config'
  29. export default {
  30. props: {
  31. roomId: Number
  32. },
  33. data() {
  34. return {
  35. ossurl,
  36. visible: false,
  37. password: ''
  38. }
  39. },
  40. computed: {},
  41. methods: {
  42. show() {
  43. this.password = ''
  44. this.visible = true
  45. },
  46. async apply() {
  47. if (!this.password) return
  48. if (WX_PUSH_MESSAGE_ID && WX_PUSH_MESSAGE_ID.length > 0) {
  49. wx.requestSubscribeMessage({
  50. tmplIds: WX_PUSH_MESSAGE_ID,
  51. success(res) {},
  52. complete: async () => {
  53. throttle.call(this.realApply)
  54. }
  55. })
  56. } else {
  57. throttle.call(this.realApply)
  58. }
  59. },
  60. async realApply() {
  61. const res = await this.$service.weal.join(this.roomId, this.password)
  62. if (res) {
  63. this.$emit('success')
  64. this.close()
  65. } else {
  66. this.password = ''
  67. }
  68. },
  69. close() {
  70. this.visible = false
  71. }
  72. }
  73. }
  74. </script>
  75. <style lang="scss" scoped>
  76. .mask {
  77. position: absolute;
  78. left: 0;
  79. right: 0;
  80. top: 0;
  81. bottom: 0;
  82. }
  83. .wrapper {
  84. width: 100%;
  85. margin-top: -100px;
  86. background: transparent;
  87. font-size: 0;
  88. .content {
  89. margin: 0 20px;
  90. background-size: 100% auto;
  91. background-position: top;
  92. background-repeat: no-repeat;
  93. font-size: 0;
  94. line-height: 0;
  95. .image{
  96. width: 100%;
  97. margin-bottom:-2rpx;
  98. }
  99. .input-wrapper {
  100. margin-top:-2rpx;
  101. height: 100rpx;
  102. font-size: 32rpx;
  103. background-color: #f8f8f8;
  104. border-radius: 8rpx;
  105. line-height: 100rpx;
  106. }
  107. .contentWrapper {
  108. background-color: #fff;
  109. border-radius: 0 0 16px 16px;
  110. padding: 20rpx 60rpx 40rpx 60rpx;
  111. }
  112. }
  113. }
  114. .btn {
  115. width: 240rpx;
  116. font-size: 24rpx;
  117. height: 64rpx;
  118. text-align: center;
  119. color: #000;
  120. line-height: 64rpx;
  121. border-radius: 64rpx;
  122. }
  123. .btnCancel {
  124. background-color: #fff7e3;
  125. }
  126. .btnApply {
  127. background-color: #fec433;
  128. }
  129. </style>