hand_lei.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <view>
  3. <view class="content" :class="typeClass">
  4. <view class="luck">
  5. <view class="row">
  6. <view class="term">
  7. 红包个数
  8. </view>
  9. <view class="input">
  10. <input type="number" v-model="number" placeholder="输入红包个数" /> 个
  11. </view>
  12. </view>
  13. <view class="row">
  14. <view class="term">
  15. 总金额
  16. </view>
  17. <view class="input">
  18. <input type="number" v-model="luckMoney" placeholder="输入金额" /> 元
  19. </view>
  20. </view>
  21. <view class="row">
  22. <view class="term">
  23. 红包雷值
  24. </view>
  25. <view class="input">
  26. <input type="number" disabled="true" placeholder="请点击下方选择雷值" v-if="!lei.length"/>
  27. <view class="lei-content" v-if="lei.length">
  28. <view class="input-num" v-for="(item,index) in lei">{{item}}</view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="tis">
  33. * 提示再次点击选中的雷为取消
  34. </view>
  35. <view class="blessing">
  36. <view :class="['input-num-select',selected_num0 ? ' active': '']" @tap="taptLei(0)">0</view>
  37. <view :class="['input-num-select',selected_num1 ? ' active': '']" @tap="taptLei(1)">1</view>
  38. <view :class="['input-num-select',selected_num2 ? ' active': '']" @tap="taptLei(2)">2</view>
  39. <view :class="['input-num-select',selected_num3 ? ' active': '']" @tap="taptLei(3)">3</view>
  40. <view :class="['input-num-select',selected_num4 ? ' active': '']" @tap="taptLei(4)">4</view>
  41. <view :class="['input-num-select',selected_num5 ? ' active': '']" @tap="taptLei(5)">5</view>
  42. <view :class="['input-num-select',selected_num6 ? ' active': '']" @tap="taptLei(6)">6</view>
  43. <view :class="['input-num-select',selected_num7 ? ' active': '']" @tap="taptLei(7)">7</view>
  44. <view :class="['input-num-select',selected_num8 ? ' active': '']" @tap="taptLei(8)">8</view>
  45. <view :class="['input-num-select',selected_num9 ? ' active': '']" @tap="taptLei(9)">9</view>
  46. </view>
  47. <view class="hand" @tap="hand('luck')">
  48. 发红包
  49. </view>
  50. </view>
  51. <view class="normal">
  52. <view class="row">
  53. <view class="term">
  54. 红包个数
  55. </view>
  56. <view class="input">
  57. <input type="number" v-model="number" placeholder="输入红包个数" /> 个
  58. </view>
  59. </view>
  60. <view class="row">
  61. <view class="term">
  62. 单个金额
  63. </view>
  64. <view class="input">
  65. <input type="number" v-model="money" placeholder="输入金额" /> 元
  66. </view>
  67. </view>
  68. <view class="tis">
  69. 小伙伴领取的金额相同
  70. </view>
  71. <view class="blessing">
  72. <input type="text" maxlength="12" placeholder="恭喜发财" v-model="blessing" />
  73. </view>
  74. <view class="hand" @tap="hand('normal')">
  75. 发红包
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. </template>
  81. <script>
  82. import _get from '../../../common/_get';
  83. import _hook from '../../../common/_hook';
  84. import _page from '../../../common/common';
  85. export default {
  86. data() {
  87. return {
  88. typeClass:'luck',//normal
  89. number:'',
  90. money:'',
  91. luckMoney:'',
  92. blessing:'',
  93. click:true,
  94. lei:[],
  95. page_params:{},
  96. selected_num0:false,
  97. selected_num1:false,
  98. selected_num2:false,
  99. selected_num3:false,
  100. selected_num4:false,
  101. selected_num5:false,
  102. selected_num6:false,
  103. selected_num7:false,
  104. selected_num8:false,
  105. selected_num9:false,
  106. };
  107. },
  108. onLoad(options) {
  109. let _this = this;
  110. _this.page_params = options;
  111. },
  112. onShow(){
  113. _hook.routeTabBarHook();
  114. // uni.$on('get_password_reslut',this.getPassword);
  115. },
  116. computed:{
  117. },
  118. methods:{
  119. deleteNum(i){
  120. var index = this.lei.indexOf(i);
  121. this.lei.splice(index, 1)
  122. },
  123. taptLei(num){
  124. switch (num) {
  125. case 0:
  126. if(this.selected_num0){
  127. this.deleteNum(num)
  128. return this.selected_num0 = false;
  129. }else {
  130. this.lei.push(num)
  131. return this.selected_num0 = true;
  132. }
  133. case 1:
  134. if(this.selected_num1){
  135. this.deleteNum(num)
  136. return this.selected_num1 = false;
  137. }else {
  138. this.lei.push(num)
  139. return this.selected_num1 = true;
  140. }
  141. case 2:
  142. if(this.selected_num2){
  143. this.deleteNum(num)
  144. return this.selected_num2 = false;
  145. }else {
  146. this.lei.push(num)
  147. return this.selected_num2 = true;
  148. }
  149. case 3:
  150. if(this.selected_num3){
  151. this.deleteNum(num)
  152. return this.selected_num3 = false;
  153. }else {
  154. this.lei.push(num)
  155. return this.selected_num3 = true;
  156. }
  157. case 4:
  158. if(this.selected_num4){
  159. this.deleteNum(num)
  160. return this.selected_num4 = false;
  161. }else {
  162. this.lei.push(num)
  163. return this.selected_num4 = true;
  164. }
  165. case 5:
  166. if(this.selected_num5){
  167. this.deleteNum(num)
  168. return this.selected_num5 = false;
  169. }else {
  170. this.lei.push(num)
  171. return this.selected_num5 = true;
  172. }
  173. case 6:
  174. if(this.selected_num6){
  175. this.deleteNum(num)
  176. return this.selected_num6 = false;
  177. }else {
  178. this.lei.push(num)
  179. return this.selected_num6 = true;
  180. }
  181. case 7:
  182. if(this.selected_num7){
  183. this.deleteNum(num)
  184. return this.selected_num7 = false;
  185. }else {
  186. this.lei.push(num)
  187. return this.selected_num7 = true;
  188. }
  189. case 8:
  190. if(this.selected_num8){
  191. this.deleteNum(num)
  192. return this.selected_num8 = false;
  193. }else {
  194. this.lei.push(num)
  195. return this.selected_num8 = true;
  196. }
  197. case 9:
  198. if(this.selected_num9){
  199. this.deleteNum(num)
  200. return this.selected_num9 = false;
  201. }else {
  202. this.lei.push(num)
  203. return this.selected_num9 = true;
  204. }
  205. }
  206. },
  207. switchType(type){
  208. this.typeClass = type;
  209. },
  210. hand(type){
  211. //校验余额判断有无设置交易密码
  212. let _this = this;
  213. let redEnvelopeData = {
  214. type:2, //拼手气红包
  215. num:this.number,
  216. hongbao_msg:this.lei,
  217. amount:this.money
  218. }
  219. if(type == 'luck'){
  220. redEnvelopeData.amount = this.luckMoney;
  221. }
  222. if(_this.lei.length <= 0){
  223. return uni.showToast({title:"请选择红包雷",icon:'none'});
  224. }
  225. //判断数据有效性
  226. if((!redEnvelopeData.amount)||redEnvelopeData.amount<=0)
  227. {
  228. return uni.showToast({title:"金额不能为空",icon:'none'});
  229. }
  230. if(redEnvelopeData.num!=Math.abs(parseInt(redEnvelopeData.num))){
  231. return uni.showToast({title:"数量填写大于0的整数",icon:'none'});
  232. }
  233. redEnvelopeData.hongbao_msg = JSON.stringify(redEnvelopeData.hongbao_msg)||'恭喜发财';//没填写则默认恭喜发财
  234. redEnvelopeData = Object.assign(this.page_params,redEnvelopeData);
  235. _get.checkBeforePay(redEnvelopeData,function (res) {
  236. _get.createLeiHongBao(redEnvelopeData,function (res) {
  237. uni.navigateTo({url:'../message?list_id='+_this.page_params.list_id})
  238. },function (res) {
  239. _this.click = true;
  240. uni.showToast({title:res.msg,icon:'none'});
  241. })
  242. },function (res) {
  243. console.log("fail callback")
  244. uni.showToast({title:res.msg,icon:'none'});
  245. },function (res) {
  246. uni.showToast({title:res.msg,icon:'none'});
  247. });
  248. },
  249. getPassword(n) {
  250. console.log("参数传递", n);
  251. let _this = this;
  252. if(!_this.click) return false;
  253. _this.click = false;
  254. //此处实际应用时应该post到服务器,然后服务器广播长连接
  255. uni.showLoading({title:'提交中'});
  256. _get.createLeiHongBao(n,function (res) {
  257. uni.navigateTo({url:'../message?list_id='+_this.page_params.list_id})
  258. },function (res) {
  259. _this.click = true;
  260. })
  261. // this.$refs.payKeyboard.cleanNum();
  262. }
  263. }
  264. }
  265. </script>
  266. <style lang="scss">
  267. page{
  268. background-color: #f3f3f3;
  269. }
  270. view{
  271. display: flex;
  272. flex-wrap: wrap;
  273. }
  274. .tabr{
  275. width: 94%;
  276. height: 105upx;
  277. padding: 0 3%;
  278. border-bottom: solid 1upx #dedede;
  279. view{
  280. width: 50%;
  281. height: 100upx;
  282. justify-content: center;
  283. align-items: center;
  284. font-size: 28upx;
  285. color: #999;
  286. }
  287. .on{
  288. color: #cf3c35;
  289. }
  290. .border{
  291. height: 4upx;
  292. background-color: #cf3c35;
  293. transition: all .3s ease-out;
  294. &.normal{
  295. transform: translate3d(100%,0,0);
  296. }
  297. }
  298. }
  299. .content{
  300. width: 100%;
  301. height: 80vh;
  302. overflow: hidden;
  303. &.normal{
  304. .luck{
  305. transform: translate3d(-100%,0,0);
  306. }
  307. .normal{
  308. transform: translate3d(0,-100%,0);
  309. }
  310. }
  311. .luck,.normal{
  312. transition: all .3s ease-out;
  313. }
  314. .luck{
  315. }
  316. .normal{
  317. transform: translate3d(100%,-100%,0);
  318. }
  319. .row,.tis,.blessing,.hand{
  320. width: 94%;
  321. }
  322. .row,.tis,.blessing{
  323. border-bottom: #dedede solid 1upx;
  324. }
  325. .row,.blessing{
  326. padding: 30upx;
  327. background-color: #fff;
  328. display: flex;
  329. justify-items: center;
  330. justify-content: center;
  331. }
  332. .row,.hand{
  333. align-items: center;
  334. }
  335. .row{
  336. justify-content: space-between;
  337. flex-wrap: nowrap;
  338. .term,.input{
  339. width: 50%;
  340. }
  341. .input{
  342. flex-shrink: 0;
  343. flex-wrap: nowrap;
  344. justify-content: flex-end;
  345. align-items: center;
  346. input{
  347. height: 50upx;
  348. display: flex;
  349. justify-content: flex-end;
  350. align-items: center;
  351. text-align: right;
  352. margin-right: 20upx;
  353. font-size: 30upx;
  354. }
  355. }
  356. }
  357. .input-lei {
  358. flex-shrink: 0;
  359. flex-wrap: nowrap;
  360. justify-content: flex-end;
  361. align-items: center;
  362. text{
  363. height: 50upx;
  364. display: flex;
  365. justify-content: flex-start;
  366. align-items: center;
  367. text-align: left;
  368. margin-right: 20upx;
  369. font-size: 30upx;
  370. }
  371. }
  372. .tis{
  373. height: 60upx;
  374. padding: 20upx 3%;
  375. font-size: 16px;
  376. color: red;
  377. }
  378. .hand{
  379. margin: 30upx 3%;
  380. background-color: #cf3c35;
  381. color: #fff;
  382. font-size: 34upx;
  383. justify-content: center;
  384. border-radius: 10upx;
  385. height: 100upx;
  386. }
  387. .input-num{
  388. width: 20px;
  389. height: 20px;
  390. font-size: 12px;
  391. font-weight: 700;
  392. line-height: 20px;
  393. text-align: center;
  394. background: url('/static/theme/default/chat/lei1.png') no-repeat;
  395. background-size: 100% 100%;
  396. display: inline-block;
  397. margin-left: 5px;
  398. }
  399. }
  400. .input-num-select{
  401. display: inline-block;
  402. width: 50px;
  403. height: 50px;
  404. line-height: 50px;
  405. text-align: center;
  406. border-radius: 100%;
  407. background: #fff;
  408. font-size: 18px;
  409. font-weight: 700;
  410. margin: 0 9px 10px 0;
  411. background: url('/static/theme/default/chat/lei1.png') no-repeat;
  412. background-size: 100% 100%;
  413. }
  414. .input-num-select:nth-child(2n){ //双号的球换图片
  415. background: url('/static/theme/default/chat/lei2.png') no-repeat !important;
  416. background-size: 100% 100% !important;
  417. }
  418. .lei-content{
  419. display: flex;
  420. word-break: break-all;
  421. width: 300rpx;
  422. justify-content: flex-end;
  423. }
  424. .blessing .active{
  425. background: url('/static/theme/default/chat/lei3.png') no-repeat !important;
  426. background-size: 100% 100% !important;
  427. }
  428. </style>