index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <view>
  3. <view class="tabr">
  4. <view :class="{on:typeClass=='luck'}" @tap="switchType('luck')">拼手气红包</view><view :class="{on:typeClass=='normal'}" @tap="switchType('normal')">普通红包</view>
  5. <view class="border" :class="typeClass"></view>
  6. </view>
  7. <view class="content" :class="typeClass">
  8. <view class="luck">
  9. <view class="row">
  10. <view class="term">
  11. 红包个数
  12. </view>
  13. <view class="input">
  14. <input type="number" v-model="redPacket.number" placeholder="输入红包个数" /> 个
  15. </view>
  16. </view>
  17. <view class="row">
  18. <view class="term">
  19. 总金额
  20. </view>
  21. <view class="input">
  22. <input type="number" v-model="redPacket.money" placeholder="输入金额" /> 元
  23. </view>
  24. </view>
  25. <view class="tis">
  26. 小伙伴领取的金额随机
  27. </view>
  28. <view class="blessing">
  29. <input type="text" maxlength="12" placeholder="恭喜发财" v-model="redPacket.title" />
  30. </view>
  31. <view class="hand" @tap="hand('luck')">
  32. 发红包
  33. </view>
  34. </view>
  35. <view class="normal">
  36. <view class="row">
  37. <view class="term">
  38. 红包个数
  39. </view>
  40. <view class="input">
  41. <input type="number" v-model="redPacket.number" placeholder="输入红包个数" /> 个
  42. </view>
  43. </view>
  44. <view class="row">
  45. <view class="term">
  46. 单个金额
  47. </view>
  48. <view class="input">
  49. <input type="number" v-model="redPacket.money" placeholder="输入金额" /> 元
  50. </view>
  51. </view>
  52. <view class="tis">
  53. 小伙伴领取的金额相同
  54. </view>
  55. <view class="blessing">
  56. <input type="text" maxlength="12" placeholder="恭喜发财" v-model="redPacket.title" />
  57. </view>
  58. <view class="hand" @tap="hand('normal')">
  59. 发红包
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. export default {
  67. name:'red-envelope',
  68. props: {
  69. },
  70. data() {
  71. return {
  72. typeClass:'luck',//normal
  73. redPacket: {
  74. title: '恭喜发财,大吉大利',
  75. money: 0.00,
  76. number: 0,
  77. status: 0
  78. }
  79. };
  80. },
  81. methods:{
  82. switchType(type){
  83. this.typeClass = type;
  84. },
  85. hand(type){
  86. //判断数据有效性
  87. if((!this.redPacket.money)||this.redPacket.money<=0)
  88. {
  89. return uni.showToast({title:"金额不能为空",icon:'none'});
  90. }
  91. if(this.redPacket.number!=Math.abs(parseInt(this.redPacket.number))){
  92. return uni.showToast({title:"数量填写大于0的整数",icon:'none'});
  93. }
  94. this.redPacket.title = this.redPacket.title ||'恭喜发财';
  95. this.$emit('sendRedPacket',this.redPacket)
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. page{
  102. background-color: #F6F7F8;
  103. }
  104. view{
  105. display: flex;
  106. flex-wrap: wrap;
  107. }
  108. .tabr{
  109. width: 94%;
  110. height: 105upx;
  111. padding: 0 5%;
  112. border-bottom: solid 1upx #dedede;
  113. view{
  114. width: 50%;
  115. height: 100upx;
  116. justify-content: center;
  117. align-items: center;
  118. font-size: 16px;
  119. font-weight: 600;
  120. color: #171717;
  121. }
  122. .on{
  123. color: #E3653E;
  124. font-size: 16px;
  125. font-weight: 600;
  126. }
  127. .border{
  128. height: 4px;
  129. background-color: #E3653E;
  130. -webkit-transition: all .3s ease-out;
  131. transition: all .3s ease-out;
  132. margin-top: -3px;
  133. border-radius: 10px;
  134. &.normal{
  135. transform: translate3d(100%,0,0);
  136. }
  137. }
  138. }
  139. .content{
  140. width: 100%;
  141. height: 80vh;
  142. overflow: hidden;
  143. &.normal{
  144. .luck{
  145. transform: translate3d(-100%,0,0);
  146. }
  147. .normal{
  148. transform: translate3d(0,-100%,0);
  149. }
  150. }
  151. .luck,.normal{
  152. transition: all .3s ease-out;
  153. }
  154. .luck{
  155. }
  156. .normal{
  157. transform: translate3d(100%,-100%,0);
  158. }
  159. .row,.tis,.blessing,.hand{
  160. width: 94%;
  161. }
  162. .row,.tis,.blessing{
  163. border-bottom: #eeeeee solid 3upx;
  164. }
  165. .row,.blessing{
  166. padding: 0 3%;
  167. background-color: #fff;
  168. }
  169. .row,.blessing,.hand{
  170. height: 100upx;
  171. align-items: center;
  172. }
  173. .row{
  174. font-size: 25rpx;
  175. font-weight: 600;
  176. color: #171717;
  177. justify-content: space-between;
  178. flex-wrap: nowrap;
  179. .term,.input{
  180. width: 50%;
  181. }
  182. .input{
  183. flex-shrink: 0;
  184. flex-wrap: nowrap;
  185. justify-content: flex-end;
  186. align-items: center;
  187. input{
  188. height: 50upx;
  189. display: flex;
  190. justify-content: flex-end;
  191. align-items: center;
  192. text-align: right;
  193. margin-right: 20upx;
  194. font-size: 30upx;
  195. }
  196. }
  197. }
  198. .tis{
  199. height: 100upx;
  200. padding: 30upx 3%;
  201. font-size: 30upx;
  202. color: #919191;
  203. }
  204. .blessing{
  205. input{
  206. width: 100%;
  207. height: 50upx;
  208. font-size: 30upx;
  209. font-weight: 600;
  210. }
  211. }
  212. .hand{
  213. margin: 30upx 30%;
  214. color: #fff;
  215. font-size: 34upx;
  216. justify-content: center;
  217. background-color: #F5A48A;
  218. border-radius: 100upx;
  219. height: 90upx;
  220. }
  221. }
  222. </style>