index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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.$loading('支付结果查询中...')
  76. this.query()
  77. } else {
  78. this.$u.toast('支付失败')
  79. }
  80. },
  81. fail(res) {
  82. // 调起收银台失败处理逻辑
  83. }
  84. })
  85. /* endif */
  86. }).catch(() => {
  87. this.$hideLoading()
  88. })
  89. },
  90. query() {
  91. if (this.interval) return
  92. setInterval(() => {
  93. this.$api.pay.query(this.payId).then(res => {
  94. this.$hideLoading()
  95. this.$u.toast('支付成功')
  96. clearInterval(this.interval)
  97. // 获取用户信息
  98. this.$api.user.info().then(res => {
  99. this.$store.dispatch('user/info', res.data)
  100. })
  101. }).catch(err => {
  102. })
  103. }, 1000)
  104. }
  105. },
  106. onLoad() {
  107. this.getSetting()
  108. }
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. .member-container{
  113. padding: 20rpx 0;
  114. font-size: 30rpx;
  115. .header{
  116. color: $primary-color;
  117. margin-top: 50rpx;
  118. .title{
  119. position: relative;
  120. font-size: 42rpx;
  121. font-weight: 600;
  122. width: 100%;
  123. text-align: center;
  124. &:before,&:after{
  125. content: "";
  126. background: url("/static/image/member-line-bg.png") no-repeat;
  127. background-size: 100%;
  128. position: absolute;
  129. top: 50%;
  130. left: 60rpx;
  131. width: 200rpx;
  132. height: 20rpx;
  133. }
  134. &:after{
  135. transform: rotate(180deg);
  136. right: 60rpx;
  137. left: unset;
  138. top: 20%;
  139. }
  140. }
  141. .tips{
  142. color: $dark-color;
  143. font-size: 26rpx;
  144. margin-top: 20rpx;
  145. }
  146. }
  147. .content{
  148. padding: 0 20rpx;
  149. margin-top: 80rpx;
  150. .item{
  151. color: $default-color;
  152. margin-left: 20rpx;
  153. flex: 1;
  154. height: 300rpx;
  155. position: relative;
  156. .border{
  157. position: absolute;
  158. top: 0;
  159. left: 0;
  160. right: 0;
  161. bottom: 0;
  162. z-index: 0;
  163. border: 4rpx solid $info-color;
  164. border-radius: 10rpx;
  165. overflow: hidden;
  166. }
  167. &.active .border{
  168. border: unset;
  169. &:after{
  170. content: "";
  171. position: absolute;
  172. top: 0;
  173. left: 0;
  174. right: 0;
  175. bottom: 0;
  176. border: 4rpx solid;
  177. border-image: linear-gradient(222deg, #6EEBE8, #FF74B9) 1;
  178. z-index: 0;
  179. }
  180. }
  181. .selected{
  182. position: absolute;
  183. top: -20rpx;
  184. background: url("/static/image/member-selected-bg.png") no-repeat;
  185. background-size: 100%;
  186. text-align: center;
  187. width: 120rpx;
  188. height: 40rpx;
  189. font-size: 24rpx;
  190. line-height: 40rpx;
  191. left: 20rpx;
  192. z-index: 1;
  193. }
  194. &:first-child{
  195. margin-left: 0;
  196. }
  197. .day{
  198. font-size: 32rpx;
  199. margin-bottom: 80rpx;
  200. }
  201. .price{
  202. font-size: 38rpx;
  203. color: $primary-color;
  204. }
  205. }
  206. }
  207. .free{
  208. background: #1B1E32;
  209. width: 100%;
  210. padding: 20rpx 0;
  211. color: $info-color;
  212. text-align: center;
  213. font-size: 26rpx;
  214. margin-top: 60px;
  215. text{
  216. color: $dark-color;
  217. }
  218. }
  219. }
  220. </style>