rechargeCoin.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <view class="coin_content">
  3. <view class="top">
  4. <view class="top__bg">
  5. <image class="image" src="../../static/imgs/public/img_top_bg_2.png" mode="aspectFit"></image>
  6. </view>
  7. <view class="top__container">
  8. <view class="top__container__title">
  9. <view class="top__container__title__name">我的书币</view>
  10. <view class="top__container__title__icon">
  11. <image class="image" src="../../static/imgs/public/img_coin.png" mode="aspectFill"></image>
  12. </view>
  13. </view>
  14. <view class="top__container__coins">
  15. {{UserData().getData().coin}}
  16. </view>
  17. </view>
  18. </view>
  19. <view class="title-id">
  20. <view class="title-id__name">书币充值</view>
  21. <view class="title-id__des">畅 \ 读 \ 精 \ 品 \ 小 \ 说</view>
  22. <view class="title-id__line"></view>
  23. </view>
  24. <view class="list">
  25. <view class="list__item" v-for="(item,index) in data_list" :key="index" @click="clickItem(index)">
  26. <image v-if="current_index==index" class="image" src="@/static/imgs/read/img_buy_onselect_bi_status.png" mode="aspectFit"></image>
  27. <image v-else class="image" src="@/static/imgs/read/img_buy_unselect_bi_status.png" mode="aspectFit"></image>
  28. <view class="list__item__container">
  29. <view class="list__item__container__image-info">
  30. <view class="list__item__container__image-info__song">
  31. <image class="image" src="../../static/imgs/read/img_song_db.png" mode="aspectFit"></image>
  32. <text v-if="item.give_coin>0" class="list__item__container__image-info__song__name">
  33. 送\n{{item.give_coin}}
  34. </text>
  35. </view>
  36. <view class="list__item__container__image-info__icon">
  37. <image class="image" src="@/static/imgs/read/img_coin.png" mode="aspectFit"></image>
  38. </view>
  39. </view>
  40. <view class="list__item__container__coin">
  41. {{item.name}}
  42. </view>
  43. <view class="list__item__container__rmb">
  44. <text style="font-size: 13px;">¥</text> {{item.amount/100}}
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="bottom" @click="clickLjgm">
  50. <view class="bottom__button-ljgm">
  51. <image class="image" src="../../static/imgs/public/img_ljgm.png" mode=""></image>
  52. </view>
  53. </view>
  54. </view>
  55. </template>
  56. <script setup lang="ts">
  57. import { ref } from 'vue';
  58. import { config } from '../../config/config';
  59. import { http } from '../../framework/http';
  60. import { log } from '../../framework/log';
  61. import { UserData } from '../../stores/userDataManager';
  62. import { util } from '../../framework/util';
  63. import { tools } from '../../framework/tools';
  64. import { sdkUtil } from '../../framework/sdkUtil';
  65. let data_list = ref([])
  66. let current_index = ref(-1)
  67. requestRechargeList()
  68. function requestRechargeList() {
  69. let url = config.url_confg.Static.get_recharge_list(3)
  70. http.StaticRequest(url,(err,data)=>{
  71. if(!err) {
  72. // console.log('书币-',data)
  73. if(data.code==config.url_confg.StatesCode.SUCCESS){
  74. data_list.value = data.content
  75. }
  76. } else {
  77. log.Error(err)
  78. }
  79. })
  80. }
  81. function clickItem(index:number){
  82. if(current_index.value==index) {
  83. return
  84. }
  85. current_index.value = index
  86. }
  87. function clickLjgm() {
  88. if(current_index.value<0) {
  89. util.showInfoToast('请选择购买书币金额')
  90. return
  91. }
  92. let data = data_list.value[current_index.value]
  93. util.showLoading('',true)
  94. tools.requestRechargeOrderBuy(tools.getCurBuyType(),data.goods_id,(order_id:string,data:any)=>{
  95. if(order_id.length>0) {
  96. sdkUtil.showPayment({
  97. timeStamp:data.time_stamp,
  98. nonceStr:data.nonce_str,
  99. package:`prepay_id=${data.prepay_id}`,
  100. paySign:data.pay_sign,
  101. signType:data.sign_type},(err:any,pay_res:any)=>{
  102. if(err==null){
  103. setTimeout(function() {
  104. tools.requestRechargeOrderInfo(order_id,(status:number)=>{
  105. util.hideLoading()
  106. if(status==2) {
  107. UserData().update_user_info(()=>{
  108. util.showSuccessToast('充值成功')
  109. })
  110. }
  111. })
  112. }, 2000);
  113. }else{
  114. util.hideLoading()
  115. util.showErrorToast('充值失败')
  116. }
  117. },
  118. )
  119. } else {
  120. util.hideLoading()
  121. }
  122. })
  123. }
  124. </script>
  125. <style lang="scss">
  126. .coin_content{
  127. display: flex;
  128. flex-direction: column;
  129. .top{
  130. margin-top: 40rpx;
  131. display: flex;
  132. justify-content: center;
  133. position: relative;
  134. &__bg{
  135. flex-shrink: 0;
  136. width: 90%; //704rpx;
  137. height: 245rpx;
  138. .image{
  139. width: 100%;
  140. height: 100%;
  141. }
  142. }
  143. &__container{
  144. position: absolute;
  145. display: flex;
  146. flex-direction: column;
  147. width: 90%;
  148. // background-color: green;
  149. &__title{
  150. margin-top: 40rpx;
  151. margin-left: 60rpx;
  152. display: flex;
  153. flex-direction: row;
  154. &__name{
  155. font-size: 20px;
  156. }
  157. &__icon{
  158. margin-left: 10rpx;
  159. flex-shrink: 0;
  160. width: 52rpx;
  161. height: 52rpx;
  162. .image{
  163. width: 100%;
  164. height: 100%;
  165. }
  166. }
  167. }
  168. &__coins{
  169. margin-top: 20rpx;
  170. display: flex;
  171. justify-content: center;
  172. font-size: 29px;
  173. }
  174. }
  175. }
  176. .title-id{
  177. display: flex;
  178. flex-direction: column;
  179. position: relative;
  180. margin-top: 40rpx;
  181. padding: 0 40rpx;
  182. &__name{
  183. margin-left: 10rpx;
  184. font-size: 30px;
  185. font-weight: 600;
  186. color: #EE5DB0;
  187. }
  188. &__des{
  189. font-size: 12px;
  190. color: #EE5DB0;
  191. }
  192. &__line{
  193. position: absolute;
  194. top: 50rpx;
  195. width: 250rpx;
  196. height: 20rpx;
  197. background-color: #EE5DB0;
  198. opacity: 0.4;
  199. }
  200. }
  201. .list{
  202. display: flex;
  203. flex-flow: row wrap; //横向排列、换行排列
  204. padding: 40rpx 20rpx;
  205. &__item{
  206. display: flex;
  207. flex-direction: column;
  208. align-items: center;
  209. width: 50%;
  210. height: 140px; //246rpx;
  211. position: relative;
  212. // background-color: green;
  213. .image{
  214. position: absolute;
  215. top: 0;
  216. left: 0;
  217. width: 100%;
  218. height: 100%;
  219. // background-color: blue;
  220. }
  221. &__container{
  222. z-index: 9;
  223. display: flex;
  224. flex-direction: column;
  225. // justify-content: center;
  226. align-items: center;
  227. height: 100%;
  228. // background-color: red;
  229. &__image-info{
  230. margin-top: 20px;
  231. display: flex;
  232. align-items: center;
  233. height: 45px; //90rpx;
  234. position: relative;
  235. &__song{
  236. position: absolute;
  237. left: -95rpx;
  238. top: 3px;//10rpx;
  239. width: 45px; //80rpx;
  240. height: 40px; //70rpx;
  241. flex-shrink: 0;
  242. display: flex;
  243. align-items: center;
  244. justify-content: center;
  245. flex-shrink: 0;
  246. .image {
  247. width: 100%;
  248. height: 100%;
  249. }
  250. &__name{
  251. position: absolute;
  252. display: flex;
  253. justify-content: center;
  254. align-items: center;
  255. left: 15rpx;
  256. // background-color: green;
  257. font-size: 9px;
  258. word-break: break-all;
  259. white-space: pre-wrap;
  260. }
  261. }
  262. &__icon{
  263. flex-shrink: 0;
  264. width: 74rpx;
  265. height: 29px; //57rpx;
  266. .image{
  267. width: 100%;
  268. height: 100%;
  269. }
  270. }
  271. }
  272. &__coin{
  273. margin-top: 0px;
  274. font-size: 19px;
  275. color: #6D6D82;
  276. }
  277. &__rmb{
  278. margin-top: 11px;
  279. font-size: 17px;
  280. }
  281. }
  282. }
  283. }
  284. .bottom {
  285. margin-top: 100rpx;
  286. display: flex;
  287. justify-content: center;
  288. align-items: center;
  289. &__button-ljgm{
  290. flex-shrink: 0;
  291. width: 80%;
  292. height: 100rpx;
  293. .image{
  294. width: 100%;
  295. height: 100%;
  296. }
  297. }
  298. }
  299. }
  300. </style>