rechargeCoin.vue 6.8 KB

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