recharge.vue 5.1 KB

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