hand.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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="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="luckMoney" 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="blessing" />
  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" :disabled
  42. ="disable" v-model="number" placeholder="输入红包个数" /> 个
  43. </view>
  44. </view>
  45. <view class="row">
  46. <view class="term">
  47. 单个金额
  48. </view>
  49. <view class="input">
  50. <input type="number" v-model="money" placeholder="输入金额" /> 元
  51. </view>
  52. </view>
  53. <view class="tis">
  54. 小伙伴领取的金额相同
  55. </view>
  56. <view class="blessing">
  57. <input type="text" maxlength="12" placeholder="恭喜发财" v-model="blessing" />
  58. </view>
  59. <view class="hand" @tap="hand('normal')">
  60. 发红包
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. import _get from '../../../common/_get';
  68. import _hook from '../../../common/_hook';
  69. import _page from '../../../common/common';
  70. export default {
  71. data() {
  72. return {
  73. typeClass:'luck',//normal
  74. number:'',
  75. money:'',
  76. luckMoney:'',
  77. blessing:'',
  78. click:true,
  79. disable:false,
  80. page_params:{}
  81. };
  82. },
  83. onLoad(options) {
  84. let _this = this;
  85. _this.page_params = options;
  86. if(_this.page_params.msg_type == 1){
  87. this.typeClass = 'luck';
  88. }else {
  89. _this.number = 1;
  90. _this.disable = true;
  91. this.typeClass = 'normal';
  92. }
  93. },
  94. onShow(){
  95. _hook.routeTabBarHook();
  96. // uni.$on('get_password_reslut',this.getPassword);
  97. },
  98. methods:{
  99. switchType(type){
  100. if(this.page_params.msg_type == 0){
  101. return false;
  102. }
  103. this.typeClass = type;
  104. },
  105. hand(type){
  106. //校验余额判断有无设置交易密码
  107. let redEnvelopeData = {
  108. type:(type == 'luck' ? 2 : 1),
  109. num:this.number,
  110. hongbao_msg:this.blessing,
  111. amount:this.money
  112. }
  113. if(type == 'luck'){
  114. redEnvelopeData.amount = this.luckMoney;
  115. }
  116. //判断数据有效性
  117. if((!redEnvelopeData.amount)||redEnvelopeData.amount<=0)
  118. {
  119. return uni.showToast({title:"金额不能为空",icon:'none'});
  120. }
  121. if(redEnvelopeData.num!=Math.abs(parseInt(redEnvelopeData.num))){
  122. return uni.showToast({title:"数量填写大于0的整数",icon:'none'});
  123. }
  124. redEnvelopeData.hongbao_msg = redEnvelopeData.hongbao_msg||'恭喜发财';//没填写则默认恭喜发财
  125. redEnvelopeData = Object.assign(this.page_params,redEnvelopeData);
  126. _get.checkBeforePay(redEnvelopeData,function (res) {
  127. uni.redirectTo({
  128. url: 'input_password?'+_page.pageParam(redEnvelopeData),
  129. });
  130. },function (res) {
  131. console.log("fail callback")
  132. uni.showToast({title:res.msg,icon:'none'});
  133. });
  134. },
  135. getPassword(n) {
  136. console.log("参数传递", n);
  137. let _this = this;
  138. if(!_this.click) return false;
  139. _this.click = false;
  140. //此处实际应用时应该post到服务器,然后服务器广播长连接
  141. uni.showLoading({title:'提交中'});
  142. _get.createHongBao(n,function (res) {
  143. uni.navigateTo({url:'../message?list_id='+_this.page_params.list_id})
  144. },function (res) {
  145. _this.click = true;
  146. })
  147. // this.$refs.payKeyboard.cleanNum();
  148. }
  149. }
  150. }
  151. </script>
  152. <style lang="scss">
  153. page{
  154. background-color: #f3f3f3;
  155. }
  156. view{
  157. display: flex;
  158. flex-wrap: wrap;
  159. }
  160. .tabr{
  161. width: 94%;
  162. height: 105upx;
  163. padding: 0 3%;
  164. border-bottom: solid 1upx #dedede;
  165. view{
  166. width: 50%;
  167. height: 100upx;
  168. justify-content: center;
  169. align-items: center;
  170. font-size: 28upx;
  171. color: #999;
  172. }
  173. .on{
  174. color: #cf3c35;
  175. }
  176. .border{
  177. height: 4upx;
  178. background-color: #cf3c35;
  179. transition: all .3s ease-out;
  180. &.normal{
  181. transform: translate3d(100%,0,0);
  182. }
  183. }
  184. }
  185. .content{
  186. width: 100%;
  187. height: 80vh;
  188. overflow: hidden;
  189. &.normal{
  190. .luck{
  191. transform: translate3d(-100%,0,0);
  192. }
  193. .normal{
  194. transform: translate3d(0,-100%,0);
  195. }
  196. }
  197. .luck,.normal{
  198. transition: all .3s ease-out;
  199. }
  200. .luck{
  201. }
  202. .normal{
  203. transform: translate3d(100%,-100%,0);
  204. }
  205. .row,.tis,.blessing,.hand{
  206. width: 94%;
  207. }
  208. .row,.tis,.blessing{
  209. border-bottom: #dedede solid 1upx;
  210. }
  211. .row,.blessing{
  212. padding: 0 3%;
  213. background-color: #fff;
  214. }
  215. .row,.blessing,.hand{
  216. height: 100upx;
  217. align-items: center;
  218. }
  219. .row{
  220. justify-content: space-between;
  221. flex-wrap: nowrap;
  222. .term,.input{
  223. width: 50%;
  224. }
  225. .input{
  226. flex-shrink: 0;
  227. flex-wrap: nowrap;
  228. justify-content: flex-end;
  229. align-items: center;
  230. input{
  231. height: 50upx;
  232. display: flex;
  233. justify-content: flex-end;
  234. align-items: center;
  235. text-align: right;
  236. margin-right: 20upx;
  237. font-size: 30upx;
  238. }
  239. }
  240. }
  241. .tis{
  242. height: 60upx;
  243. padding: 20upx 3%;
  244. font-size: 30upx;
  245. color: #999;
  246. }
  247. .blessing{
  248. input{
  249. width: 100%;
  250. height: 50upx;
  251. font-size: 32upx;
  252. }
  253. }
  254. .hand{
  255. margin: 30upx 3%;
  256. background-color: #cf3c35;
  257. color: #fff;
  258. font-size: 34upx;
  259. justify-content: center;
  260. border-radius: 10upx;
  261. height: 90upx;
  262. }
  263. }
  264. </style>