hand_pin.vue 6.1 KB

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