rechargeVIP.vue 7.5 KB

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