recharge.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <view class="re-body pd16_15">
  3. <p v-if="is_player" class="ft14">账户余额<span class="ft14 kb-txt">{{user_info.total_coin}}</span>K币</p>
  4. <view v-if="is_player == false" style="margin: 10px 0;">
  5. <p class="ft18">请选择充值金额 <label class="ft14" style="float: right;">账户余额<span class="ft14 kb-txt">{{user_info.total_coin}}</span>K币</label></p>
  6. <text class="ft14" style="font-weight: bold;padding-top: 10px;display: block;">1元=100K币</text>
  7. </view>
  8. <view class="box options-box">
  9. <block v-for="(item,key) in list" :key="key">
  10. <view @click="selectItem(item)" class="box mt16 options-item"
  11. :class="item.id == select.id ?'select' :'' " v-if="item.type =='COIN'">
  12. <p><text v-if="item.is_first_pay" class="ft14 top-lab">首冲</text></p>
  13. <text class="ft18 pirice-txt txt-other" :style="item.is_first_pay ==1 ? '': 'padding-top: 25px;'">
  14. {{item.price}}元</text>
  15. <p class="ft14 cz-desc-txt txt-other">{{item.price_text}} <text
  16. class="ft14 pirice-txt">+{{item.given}}币</text></p>
  17. <p class="ft14 cz-desc-txt txt-other" :class="item.id == select.id ?'select_text' :'given-txt' ">
  18. {{item.given_amount}} <text v-if="item.id == select.id" class="ft14 xz-hh">&#10003;️</text> </p>
  19. </view>
  20. <view @click="selectItem(item)" class="box mt16 options-item vip"
  21. :class="item.id == select.id ?'select' :'' " v-else>
  22. <text class="ft18 pirice-txt txt-other"> {{item.price}}元</text>
  23. <p class="ft14 cz-desc-txt txt-other">{{item.price_text}}</text></p>
  24. <p class="ft14 cz-desc-txt txt-other " :class="item.id == select.id ?'select_text' :'' ">
  25. {{item.given_amount}} <text v-if="item.id == select.id" class="ft14 xz-hh">&#10003;️</text> </p>
  26. </view>
  27. </block>
  28. </view>
  29. <view v-if="is_player == false" @click="toPay" class="ft16 btn-cz box mt16 " >
  30. 确认充值{{select.price}}
  31. </view>
  32. <p class="ft14" style="margin: 10px 0;">付费须知</p>
  33. <view class="ft14 textdesc">
  34. <text class="ft12">1、虚拟商品,一经购买不得退换</text>
  35. <text class="ft12">2、充值后K币可能有延迟,1小时未到账请在“我的”页面联系客服</text>
  36. <text class="ft12">3、未满18岁的未成年需要在监护人陪同下购买并观看短剧剧</text>
  37. <text class="ft12">4、购买成功后,“K币”仅在本小程序中使用</text>
  38. <text class="ft12">5、购买成功后可在”我的”页面订单中心进行查看</text>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import {
  44. getOptions,
  45. getPayInfo
  46. } from "@/common/apis/recharge.js"
  47. export default {
  48. props: {
  49. user_info:{}, // 用户信息
  50. video_info: {}, // 视屏信息
  51. is_player: {
  52. type:Boolean,
  53. default: false
  54. }
  55. },
  56. data() {
  57. return {
  58. list: [],
  59. select: {},
  60. }
  61. },
  62. watch: {
  63. user_info: {
  64. // 此处监听variable变量,当期有变化时执行
  65. handler(item1, item2) {
  66. this.user_info = item1;
  67. // console.log('111111111111','item1',item1,'item2',item2,'this.user_info',this.user_info)
  68. // item1为新值,item2为旧值
  69. }
  70. }
  71. },
  72. created() {
  73. // props 会暴露到 `this` 上
  74. this.get_options();
  75. // console.log(this.user_info, 'getOptions', this.list)
  76. },
  77. methods: {
  78. loginAct() {
  79. this.$emit('loginAct');
  80. },
  81. showQrcodeAct() {
  82. this.$emit('qrcode');
  83. },
  84. async get_options() {
  85. this.list = await getOptions();
  86. this.list.forEach((item, index) => {
  87. if (item.is_default == 1) {
  88. this.select = item;
  89. }
  90. })
  91. },
  92. selectItem(item) {
  93. this.select = item;
  94. },async toPay(){
  95. if(this.select.lenght < 1){
  96. uni.showToast({ title: '请选择要充值的项',icon:"none" });
  97. return false;
  98. }
  99. let params = {
  100. pay_proudct_id:this.select.id,
  101. video_id:this.video_info && this.video_info.video_id ? this.video_info.video_id :1,
  102. video_series_sequence:this.video_info && this.video_info.video_series_sequence ? this.video_info.video_series_sequence :1,
  103. };
  104. // #ifdef MP-WEIXIN
  105. let res = await getPayInfo(params);
  106. return this.$emit();
  107. // #endif
  108. return this.$emit();
  109. // console.log('getPayInfo',res);
  110. }
  111. }
  112. }
  113. </script>
  114. <style>
  115. @import url("style/recharge.css");
  116. </style>