index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <view class="member-container">
  3. <view class="header dir-top-wrap cross-center">
  4. <view class="title">会员充值</view>
  5. <text class="tips">会员指定短剧无限观看、xxx 等特权</text>
  6. </view>
  7. <view class="content main-left">
  8. <view
  9. v-for="(item,index) in settings"
  10. :key="index"
  11. class="item dir-top-wrap cross-center main-center"
  12. :class="{active: activeIndex === index}"
  13. @click="handleSelect(index)"
  14. >
  15. <view class="border" />
  16. <view v-if="activeIndex === index" class="selected">已选择</view>
  17. <text class="day">{{ item.valid_day }}天</text>
  18. <text class="price">¥{{ item.price }}</text>
  19. </view>
  20. </view>
  21. <view class="free main-center cross-center" @click="$u.route('/pages/member/free')">
  22. 查看 <text>免费片单</text>
  23. </view>
  24. <!--购买弹窗-->
  25. <u-modal
  26. :show="modal.show"
  27. content="确定购买?"
  28. show-cancel-button
  29. @confirm="handleBuy"
  30. @cancel="modal.show = false"
  31. />
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. settings: [],
  39. activeIndex: 0,
  40. payId: null,
  41. interval: null,
  42. modal: {
  43. show: false
  44. }
  45. }
  46. },
  47. methods: {
  48. getSetting() {
  49. this.$loading()
  50. this.$api.user.vip.setting().then(res => {
  51. this.$hideLoading()
  52. this.settings = res.data
  53. })
  54. },
  55. handleSelect(index) {
  56. this.activeIndex = index
  57. this.modal.show = true
  58. },
  59. handleBuy() {
  60. const item = this.settings[this.activeIndex]
  61. this.$loading('购买中...')
  62. this.$api.user.vip.create({ id: item.id }).then(res => {
  63. this.$hideLoading()
  64. this.payId = res.pay_id
  65. this.modal.show = false
  66. /* ifdef MP-TOUTIAO */
  67. tt.pay({
  68. service: 5,
  69. orderInfo: {
  70. order_id: res.data.order_id,
  71. order_token: res.data.order_token
  72. },
  73. success: payRes => {
  74. if (payRes.code === 0) {
  75. this.query()
  76. } else {
  77. this.$u.toast('支付失败')
  78. }
  79. },
  80. fail(res) {
  81. // 调起收银台失败处理逻辑
  82. }
  83. })
  84. /* endif */
  85. }).catch(() => {
  86. this.$hideLoading()
  87. })
  88. },
  89. query() {
  90. if (this.interval) return
  91. setInterval(() => {
  92. this.$loading('支付结果查询中...')
  93. this.$api.pay.query(this.payId).then(res => {
  94. this.$hideLoading()
  95. this.$u.toast('支付成功')
  96. // 获取用户信息
  97. this.$api.user.info().then(res => {
  98. this.$store.dispatch('user/info', res.data)
  99. })
  100. }).catch(err => {
  101. })
  102. }, 1000)
  103. }
  104. },
  105. onLoad() {
  106. this.getSetting()
  107. }
  108. }
  109. </script>
  110. <style lang="scss" scoped>
  111. .member-container{
  112. padding: 20rpx 0;
  113. font-size: 30rpx;
  114. .header{
  115. color: $primary-color;
  116. margin-top: 50rpx;
  117. .title{
  118. position: relative;
  119. font-size: 42rpx;
  120. font-weight: 600;
  121. width: 100%;
  122. text-align: center;
  123. &:before,&:after{
  124. content: "";
  125. background: url("/static/image/member-line-bg.png") no-repeat;
  126. background-size: 100%;
  127. position: absolute;
  128. top: 50%;
  129. left: 60rpx;
  130. width: 200rpx;
  131. height: 20rpx;
  132. }
  133. &:after{
  134. transform: rotate(180deg);
  135. right: 60rpx;
  136. left: unset;
  137. top: 20%;
  138. }
  139. }
  140. .tips{
  141. color: $dark-color;
  142. font-size: 26rpx;
  143. margin-top: 20rpx;
  144. }
  145. }
  146. .content{
  147. padding: 0 20rpx;
  148. margin-top: 80rpx;
  149. .item{
  150. color: $default-color;
  151. margin-left: 20rpx;
  152. flex: 1;
  153. height: 300rpx;
  154. position: relative;
  155. .border{
  156. position: absolute;
  157. top: 0;
  158. left: 0;
  159. right: 0;
  160. bottom: 0;
  161. z-index: 0;
  162. border: 4rpx solid $info-color;
  163. border-radius: 10rpx;
  164. overflow: hidden;
  165. }
  166. &.active .border{
  167. border: unset;
  168. &:after{
  169. content: "";
  170. position: absolute;
  171. top: 0;
  172. left: 0;
  173. right: 0;
  174. bottom: 0;
  175. border: 4rpx solid;
  176. border-image: linear-gradient(222deg, #6EEBE8, #FF74B9) 1;
  177. z-index: 0;
  178. }
  179. }
  180. .selected{
  181. position: absolute;
  182. top: -20rpx;
  183. background: url("/static/image/member-selected-bg.png") no-repeat;
  184. background-size: 100%;
  185. text-align: center;
  186. width: 120rpx;
  187. height: 40rpx;
  188. font-size: 24rpx;
  189. line-height: 40rpx;
  190. left: 20rpx;
  191. z-index: 1;
  192. }
  193. &:first-child{
  194. margin-left: 0;
  195. }
  196. .day{
  197. font-size: 32rpx;
  198. margin-bottom: 80rpx;
  199. }
  200. .price{
  201. font-size: 38rpx;
  202. color: $primary-color;
  203. }
  204. }
  205. }
  206. .free{
  207. background: #1B1E32;
  208. width: 100%;
  209. padding: 20rpx 0;
  210. color: $info-color;
  211. text-align: center;
  212. font-size: 26rpx;
  213. margin-top: 60px;
  214. text{
  215. color: $dark-color;
  216. }
  217. }
  218. }
  219. </style>