rechargeCoin.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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"></image>
  27. <image v-else class="image" src="@/static/imgs/read/img_buy_unselect_bi_status.png"></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" :style="{color:current_index==index?color_des:color_default}">
  41. {{item.name}}
  42. </view>
  43. <view class="list__item__container__rmb" :style="{color:current_index==index?color_rmb:color_default}">
  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 color_default = '#000000'
  66. let color_des = '#EB3737'
  67. let color_rmb = '#FF5E00'
  68. let data_list = ref([])
  69. let current_index = ref(-1)
  70. requestRechargeList()
  71. function requestRechargeList() {
  72. let url = config.url_confg.Static.get_recharge_list(3)
  73. http.StaticRequest(url,(err,data)=>{
  74. if(!err) {
  75. // console.log('书币-',data)
  76. if(data.code==config.url_confg.StatesCode.SUCCESS){
  77. data_list.value = data.content
  78. }
  79. } else {
  80. log.Error(err)
  81. }
  82. })
  83. }
  84. function clickItem(index:number){
  85. if(current_index.value==index) {
  86. return
  87. }
  88. current_index.value = index
  89. }
  90. function clickLjgm() {
  91. if(current_index.value<0) {
  92. util.showInfoToast('请选择购买书币金额')
  93. return
  94. }
  95. let data = data_list.value[current_index.value]
  96. util.showLoading('',true)
  97. tools.requestRechargeOrderBuy(tools.getCurBuyType(),data.goods_id,(order_id:string,data:any)=>{
  98. if(order_id.length>0) {
  99. sdkUtil.showPayment({
  100. timeStamp:data.time_stamp,
  101. nonceStr:data.nonce_str,
  102. package:`prepay_id=${data.prepay_id}`,
  103. paySign:data.pay_sign,
  104. signType:data.sign_type},(err:any,pay_res:any)=>{
  105. if(err==null){
  106. setTimeout(function() {
  107. tools.requestRechargeOrderInfo(order_id,(status:number)=>{
  108. util.hideLoading()
  109. if(status==2) {
  110. UserData().update_user_info(()=>{
  111. util.showSuccessToast('充值成功')
  112. })
  113. }
  114. })
  115. }, 2000);
  116. }else{
  117. util.hideLoading()
  118. util.showErrorToast('充值失败')
  119. }
  120. },
  121. )
  122. } else {
  123. util.hideLoading()
  124. }
  125. })
  126. }
  127. </script>
  128. <style lang="scss">
  129. .coin_content{
  130. display: flex;
  131. flex-direction: column;
  132. .top{
  133. margin-top: 40rpx;
  134. display: flex;
  135. justify-content: center;
  136. position: relative;
  137. &__bg{
  138. flex-shrink: 0;
  139. width: 90%; //704rpx;
  140. height: 245rpx;
  141. .image{
  142. width: 100%;
  143. height: 100%;
  144. }
  145. }
  146. &__container{
  147. position: absolute;
  148. display: flex;
  149. flex-direction: column;
  150. width: 90%;
  151. // background-color: green;
  152. &__title{
  153. margin-top: 40rpx;
  154. margin-left: 60rpx;
  155. display: flex;
  156. flex-direction: row;
  157. &__name{
  158. font-size: 20px;
  159. }
  160. &__icon{
  161. margin-left: 10rpx;
  162. flex-shrink: 0;
  163. width: 52rpx;
  164. height: 52rpx;
  165. .image{
  166. width: 100%;
  167. height: 100%;
  168. }
  169. }
  170. }
  171. &__coins{
  172. margin-top: 20rpx;
  173. display: flex;
  174. justify-content: center;
  175. font-size: 29px;
  176. }
  177. }
  178. }
  179. .title-id{
  180. display: flex;
  181. flex-direction: column;
  182. position: relative;
  183. margin-top: 40rpx;
  184. padding: 0 40rpx;
  185. &__name{
  186. margin-left: 10rpx;
  187. font-size: 30px;
  188. font-weight: 600;
  189. color: #EE5DB0;
  190. }
  191. &__des{
  192. font-size: 12px;
  193. color: #EE5DB0;
  194. }
  195. &__line{
  196. position: absolute;
  197. top: 50rpx;
  198. width: 250rpx;
  199. height: 20rpx;
  200. background-color: #EE5DB0;
  201. opacity: 0.4;
  202. }
  203. }
  204. .list{
  205. display: flex;
  206. flex-flow: row wrap; //横向排列、换行排列
  207. padding: 20px 10px;
  208. &__item{
  209. display: flex;
  210. flex-direction: column;
  211. align-items: center;
  212. width: 50%;
  213. height: 140px; //246rpx;
  214. position: relative;
  215. // background-color: green;
  216. .image{
  217. flex-shrink: 0;
  218. position: absolute;
  219. top: 0;
  220. left: 0;
  221. width: 100%;
  222. height: 100%;
  223. // background-color: blue;
  224. }
  225. &__container{
  226. z-index: 9;
  227. display: flex;
  228. flex-direction: column;
  229. // justify-content: center;
  230. align-items: center;
  231. height: 100%;
  232. // background-color: red;
  233. &__image-info{
  234. margin-top: 20px;
  235. display: flex;
  236. align-items: center;
  237. height: 45px; //90rpx;
  238. position: relative;
  239. &__song{
  240. position: absolute;
  241. left: -95rpx;
  242. top: 3px;//10rpx;
  243. width: 45px; //80rpx;
  244. height: 40px; //70rpx;
  245. flex-shrink: 0;
  246. display: flex;
  247. align-items: center;
  248. justify-content: center;
  249. flex-shrink: 0;
  250. .image {
  251. width: 100%;
  252. height: 100%;
  253. }
  254. &__name{
  255. position: absolute;
  256. display: flex;
  257. justify-content: center;
  258. align-items: center;
  259. left: 15rpx;
  260. // background-color: green;
  261. font-size: 9px;
  262. word-break: break-all;
  263. white-space: pre-wrap;
  264. }
  265. }
  266. &__icon{
  267. flex-shrink: 0;
  268. width: 74rpx;
  269. height: 29px; //57rpx;
  270. .image{
  271. width: 100%;
  272. height: 100%;
  273. }
  274. }
  275. }
  276. &__coin{
  277. margin-top: 3px;
  278. height: 25px;
  279. font-size: 19px;
  280. color: #6D6D82;
  281. }
  282. &__rmb{
  283. margin-top: 10px;
  284. height: 25px;
  285. font-size: 17px;
  286. }
  287. }
  288. }
  289. }
  290. .bottom {
  291. margin-top: 100rpx;
  292. display: flex;
  293. justify-content: center;
  294. align-items: center;
  295. &__button-ljgm{
  296. flex-shrink: 0;
  297. width: 80%;
  298. height: 100rpx;
  299. .image{
  300. width: 100%;
  301. height: 100%;
  302. }
  303. }
  304. }
  305. }
  306. </style>