小说小程序前端代码仓库(小程序)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
3.1 KiB

  1. <template>
  2. <uv-popup ref="popup" :round="30">
  3. <view class="vote-sheet">
  4. <view class="sheet-header">
  5. <text class="sheet-title">投推荐票</text>
  6. </view>
  7. <view class="vote-options">
  8. <text class="option-label">推荐投票</text>
  9. <view class="quick-options">
  10. <view class="option-btn"
  11. v-for="item in voteList"
  12. :key="item"
  13. :class="{'active': voteCount == item}"
  14. @click="setVotes(item)">{{ item }}</view>
  15. </view>
  16. <text class="option-label">手动设置</text>
  17. <view class="manual-input">
  18. <uv-number-box
  19. v-model="voteCount"
  20. :min="1"
  21. :max="maxVote"
  22. integer
  23. inputWidth="200rpx"
  24. buttonSize="80rpx"
  25. placeholder="请输入投票数" />
  26. </view>
  27. </view>
  28. <button class="submit-btn" @click="submitVote">投票</button>
  29. </view>
  30. </uv-popup>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. voteCount: 1,
  37. id: 0,
  38. voteList: [1, 5, 10],
  39. maxVote : 0,
  40. }
  41. },
  42. methods: {
  43. setVotes(count) {
  44. this.voteCount = Math.min(count, this.maxVote)
  45. },
  46. open(id) {
  47. this.id = id
  48. this.$refs.popup.open('bottom')
  49. this.$fetch('getMyRecommendTicketNum')
  50. .then(res => {
  51. this.maxVote = res
  52. })
  53. },
  54. close() {
  55. this.$refs.popup.close()
  56. },
  57. submitVote() {
  58. this.$fetch('vote', {
  59. bookId: this.id,
  60. num: this.voteCount
  61. }).then(res => {
  62. this.close()
  63. this.$emit('updateVote')
  64. })
  65. }
  66. }
  67. }
  68. </script>
  69. <style scoped lang="scss">
  70. .vote-sheet {
  71. background-color: #fff;
  72. border-radius: 20rpx 20rpx 0 0;
  73. padding: 30rpx;
  74. }
  75. .sheet-header {
  76. text-align: center;
  77. margin-bottom: 40rpx;
  78. }
  79. .sheet-title {
  80. font-size: 32rpx;
  81. font-weight: 500;
  82. }
  83. .vote-options {
  84. margin-bottom: 40rpx;
  85. }
  86. .option-label {
  87. font-size: 28rpx;
  88. color: #666;
  89. margin-bottom: 20rpx;
  90. }
  91. .quick-options {
  92. display: flex;
  93. gap: 20rpx;
  94. margin-top: 30rpx;
  95. margin-bottom: 40rpx;
  96. .option-btn {
  97. flex: 1;
  98. height: 80rpx;
  99. background-color: #f5f5f5;
  100. display: flex;
  101. align-items: center;
  102. justify-content: center;
  103. border-radius: 8rpx;
  104. font-size: 28rpx;
  105. &.active{
  106. background-color: $uni-color;
  107. color: #fff;
  108. }
  109. }
  110. }
  111. .manual-input {
  112. margin-top: 30rpx;
  113. display: flex;
  114. align-items: center;
  115. justify-content: center;
  116. gap: 20rpx;
  117. ::v-deep .uv-number-box__plus{
  118. height: 200rpx !important;
  119. }
  120. ::v-deep .uv-number-box__minus{
  121. height: 200rpx !important;
  122. }
  123. }
  124. .submit-btn {
  125. width: 100%;
  126. height: 88rpx;
  127. background-color: $uni-color;
  128. color: #fff;
  129. border-radius: 8rpx;
  130. font-size: 32rpx;
  131. display: flex;
  132. align-items: center;
  133. justify-content: center;
  134. }
  135. </style>