vip.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. <template>
  2. <view class="container">
  3. <view id="topnav" class="topnav flex-between" :style="{'height':`${topbarOffsetHeight-statusBarHeight}px`,'padding-top':`${statusBarHeight}px`}">
  4. <view class="nav-item flex-center" @click="back">
  5. <image :src="`${assetsUrl}back.png`" mode="widthFix" class="nav-img"></image>
  6. </view>
  7. <view class="nav-text font32 fw600">
  8. {{topbarTitle}}
  9. </view>
  10. <view class="nav-item"></view>
  11. </view>
  12. <scroll-view
  13. scroll-y="true"
  14. :style="{'height': `${scrollHeight}px`,'padding-top':`${topNavHeight}px`}"
  15. v-if="scrollHeight>0"
  16. lower-threshold="200"
  17. refresher-enabled="true"
  18. :refresher-triggered="scrollTriggered"
  19. :refresher-threshold="45"
  20. refresher-default-style="white"
  21. refresher-background="#151126"
  22. @refresherrefresh="scrollRefresh"
  23. @refresherpulling="scrollPulling"
  24. @refresherrestore="scrollRestore"
  25. @refresherabort="scrollAbort"
  26. @scrolltolower="scrollToBottom"
  27. class="scroll-view"
  28. >
  29. <view class="top flex-between">
  30. <view class="top-left">
  31. <view class="user-box flex-start">
  32. <image :src="userInfo.iconThumbnail" mode="aspectFit" class="head-img"></image>
  33. <view class="user-info flex-center">
  34. <view class="name font32 fw600">
  35. {{userInfo.nick}}
  36. </view>
  37. <view class="phone font22 fw400">
  38. {{userInfo.phone}}
  39. </view>
  40. </view>
  41. </view>
  42. <view class="tip font28 fw400">
  43. 开通会员享更多惊喜特权
  44. </view>
  45. </view>
  46. <image :src="`${assetsUrl}vip-bg.png`" mode="aspectFit" class="top-right"></image>
  47. </view>
  48. <scroll-view scroll-x="true" class="tabs flex-start">
  49. <view class="tab" :class="tabIndex===index?'active-tab':'no-active'" v-for="(item,index) in priceDatas.prices2" :key="index" @click="tabClick(index)">
  50. <view class="tab-time font28 fw600">
  51. {{item.name}}
  52. </view>
  53. <view class="tab-price">
  54. <span style="font-size: 72rpx;">{{item.priceFenPerMonth/100}}</span><span class="font22 fw500">元/月</span>
  55. </view>
  56. <view class="tab-under font24 fw400">
  57. {{item.originalPriceFenPerMonth/100}}元/月
  58. </view>
  59. <view class="tab-tag font20 fw600" v-if="tabIndex===index">
  60. {{item.tags}}
  61. </view>
  62. </view>
  63. </scroll-view>
  64. <swiper :indicator-dots="false" :disable-touch="true" :vertical="true" :circular="true" :autoplay="true" :interval="2000" :duration="500" class="swiper">
  65. <view class="swiper-model" @touchmove.stop="catchTouchMove">
  66. <swiper-item class="swiper-item flex-start" v-for="(item,index) in promotions" :key="index" >
  67. <view class="item-box flex-start">
  68. <image :src="item.headImg" mode="aspectFit" class="item-img"></image>
  69. <view class="item-text font24 fw400">
  70. {{item.nick}}刚刚开通了会员
  71. </view>
  72. </view>
  73. </swiper-item>
  74. </view>
  75. </swiper>
  76. <view class="prot font22 fw400">
  77. 成为会员及代表同意<span style="color: #FFDDBD;" @click="toAddedService">《增值服务协议》</span>
  78. </view>
  79. <image :src="`${assetsUrl}vip-action.png`" mode="widthFix" class="action"></image>
  80. <view class="qustion-title font30 fw500">
  81. 支付遇到问题
  82. </view>
  83. <view class="qustions font24 fw400">
  84. 1.如果支付成功,但是没有开通VIP,请<span style="color: #FFDDBD; margin-left: 4rpx;" @click="toService">联系客服</span>
  85. </view>
  86. </scroll-view>
  87. <view class="btn flex-between">
  88. <view class="btn-left">
  89. <view class="bl-total font24 fw500">
  90. 合计:<span style="font-size:24rpx;font-weight: bold;color: #FFDDBD;margin-left: 4rpx;">¥</span><span style="font-size:40rpx;font-weight: bold;color: #FFDDBD;">{{totalPrice/100}}</span>
  91. </view>
  92. <!-- <view class="bl-tip font20 fw400">
  93. 每月自动续费
  94. </view> -->
  95. </view>
  96. <view class="btn-right" @click="pay">
  97. <image :src="`${assetsUrl}vip-btn.png`" mode="aspectFit" class="br-img"></image>
  98. <view class="br-text font32 fw600">
  99. 立即支付
  100. </view>
  101. </view>
  102. </view>
  103. </view>
  104. </template>
  105. <script>
  106. import TopBar from '@/components/TopBar/TopBar.vue';
  107. export default {
  108. components:{TopBar},
  109. data() {
  110. return {
  111. topbarIcon:'back',
  112. topbarTitle:'会员中心',
  113. assetsUrl:this.$util.assetsUrl,
  114. scrollRefreshing:false,
  115. scrollTriggered:true,
  116. scrollHeight:0,
  117. topNavHeight:0,
  118. tabIndex:0,
  119. priceDatas:{},
  120. promotions:[],
  121. totalPrice:0,
  122. priceConfig:{
  123. feeFen: null,
  124. sceneId: null,
  125. scene: null,
  126. body : null,
  127. userId: null,
  128. pkgCate:'JyPark'
  129. }
  130. };
  131. },
  132. mounted() {
  133. this.computedScollviewHeight();
  134. this.getConfigData();
  135. this.getPromotionsData();
  136. },
  137. computed: {
  138. statusBarHeight() {
  139. return this.$store.state.statusBarHeight;
  140. },
  141. topbarOffsetHeight() {
  142. return this.$store.state.topbarOffsetHeight;
  143. },
  144. userInfo(){
  145. return this.$store.state.userInfo||JSON.parse(uni.getStorageSync('userInfo'))
  146. }
  147. },
  148. methods:{
  149. catchTouchMove(){
  150. return false;
  151. },
  152. back(){
  153. uni.navigateBack({
  154. delta:1
  155. })
  156. },
  157. toAddedService(){
  158. uni.navigateTo({
  159. url:`/pages/webview/webview?url=${this.$util.protocal.addedService}`
  160. })
  161. },
  162. /**
  163. * 计算scroll高度
  164. */
  165. computedScollviewHeight() {
  166. let query = uni.createSelectorQuery().in(this);
  167. let heightLeaf =0;
  168. query.select('#topnav').boundingClientRect(data => {
  169. this.topNavHeight=data.height;
  170. heightLeaf += data.height;
  171. }).exec(() => {
  172. let sysInfo = uni.getSystemInfoSync();
  173. this.scrollHeight = sysInfo.windowHeight - heightLeaf;
  174. });
  175. },
  176. /**
  177. * 推荐下拉刷新、加载更多
  178. */
  179. scrollRefresh(){
  180. if (this.scrollRefreshing)
  181. {
  182. return;
  183. }
  184. this.scrollRefreshing = true;
  185. setTimeout(() => {
  186. this.scrollTriggered = false;
  187. this.scrollRefreshing = false;
  188. }, 1000)
  189. this.getConfigData();
  190. },
  191. scrollPulling(e) {},
  192. scrollRestore() {this.scrollTriggered = true;},
  193. scrollAbort() {},
  194. scrollToBottom(){},
  195. getConfigData(){
  196. let user=JSON.parse(uni.getStorageSync('user'));
  197. this.$api.public.priceBySceneConfigs({
  198. completeUser:user,
  199. scene:'Member'
  200. }).then(res=>{
  201. this.priceDatas=res.data;
  202. this.totalPrice=this.priceDatas.prices2[this.tabIndex].priceFen;
  203. this.priceConfig.feeFen=this.priceDatas.prices2[this.tabIndex].priceFen;
  204. this.priceConfig.scene=this.priceDatas.prices2[this.tabIndex].sceneCate;
  205. this.priceConfig.sceneId=this.priceDatas.prices2[this.tabIndex].sceneId;
  206. this.priceConfig.body=this.priceDatas.prices2[this.tabIndex].name;
  207. this.priceConfig.userId=(this.$store.state.userInfo||JSON.parse(uni.getStorageSync('userInfo'))).id;
  208. })
  209. },
  210. getPromotionsData(){
  211. this.$api.public.vipPromotions({}).then(res=>{
  212. this.promotions=res.data;
  213. })
  214. },
  215. tabClick(index){
  216. this.tabIndex=index;
  217. this.totalPrice=this.priceDatas.prices2[index].priceFen;
  218. this.priceConfig.feeFen=this.priceDatas.prices2[index].priceFen;
  219. this.priceConfig.scene=this.priceDatas.prices2[index].sceneCate;
  220. this.priceConfig.sceneId=this.priceDatas.prices2[index].sceneId;
  221. this.priceConfig.body=this.priceDatas.prices2[index].name;
  222. this.priceConfig.userId=(this.$store.state.userInfo||JSON.parse(uni.getStorageSync('userInfo'))).id;
  223. },
  224. pay(){
  225. uni.getProvider({
  226. service:'payment',
  227. success:(provider)=>{
  228. console.log(provider.provider)
  229. this.$api.pay.creatWxOrder(this.priceConfig).then(res=>{
  230. if(res.data.succ){
  231. uni.requestPayment({
  232. provider:provider.provider[0],
  233. timeStamp: String(res.data.timeStamp),
  234. nonceStr: res.data.nonceStr,
  235. package: `prepay_id=${res.data.wxUniPrePayId}`,
  236. signType: 'MD5',
  237. paySign: res.data.paySign,
  238. success:(result)=>{
  239. console.log(result)
  240. if(result.errMsg==='requestPayment:ok'){
  241. uni.showToast({
  242. icon:'success',
  243. title:'支付成功'
  244. })
  245. }
  246. },
  247. fail:(err)=>{console.log(err)}
  248. })
  249. }
  250. })
  251. }
  252. })
  253. },
  254. toService(){
  255. uni.openCustomerServiceChat({
  256. extInfo:{
  257. url:'https://work.weixin.qq.com/kfid/kfca1b21d2f7e8a18e9',//客服链接
  258. },
  259. corpId:'wwa8f2a0d8a6dc0950',//企业ID
  260. fail(res){
  261. console.log(res)
  262. wx.showToast({
  263. title: '客服联系失败',
  264. icon:'none'
  265. })
  266. }
  267. })
  268. }
  269. }
  270. }
  271. </script>
  272. <style lang="scss" scoped>
  273. .container{
  274. width: 100vw;
  275. height: 100vh;
  276. background-color: $bgcolor1;
  277. overflow: hidden;
  278. .topnav {
  279. padding: 0 10rpx;
  280. position: fixed;
  281. top: 0;
  282. left: 0;
  283. width: 100vw;
  284. z-index: 100;
  285. background-color: $bgcolor1;
  286. .nav-item{
  287. width: 40rpx;
  288. height: 40rpx;
  289. margin-left: 16rpx;
  290. .nav-img{
  291. width: 40rpx;
  292. height: 40rpx;
  293. }
  294. }
  295. .nav-text{
  296. flex: 1;
  297. color: $fontcolor5;
  298. height: 40rpx;
  299. text-align: center;
  300. }
  301. }
  302. .scroll-view{
  303. .top{
  304. .top-left{
  305. padding-left: 44rpx;
  306. .user-box{
  307. .head-img{
  308. width: 88rpx;
  309. height: 88rpx;
  310. border-radius: 88rpx;
  311. background-color: #ffffff;
  312. }
  313. .user-info{
  314. flex-direction: column;
  315. margin-left: 16rpx;
  316. align-items: flex-start;
  317. .name{
  318. color: #ffffff;
  319. }
  320. .phone{
  321. color: #FFDDBD;
  322. margin-top: 10rpx;
  323. }
  324. }
  325. }
  326. .tip{
  327. color: #79726B;
  328. margin-top: 40rpx;
  329. }
  330. }
  331. .top-right{
  332. width: 300rpx;
  333. height: 260rpx;
  334. }
  335. }
  336. .tabs{
  337. white-space:nowrap;
  338. .tab{
  339. position: relative;
  340. margin-right: 12rpx;
  341. border-radius: 40rpx;
  342. display: inline-block;
  343. transition: all .1s;
  344. overflow: hidden;
  345. &:nth-of-type(1){
  346. margin-left: 32rpx;
  347. }
  348. &:nth-last-of-type(1){
  349. margin-right: 32rpx;
  350. }
  351. .tab-time{
  352. color: #FFDDBD;
  353. }
  354. .tab-price{
  355. color: #FFDDBD;
  356. margin-top: 24rpx;
  357. }
  358. .tab-under{
  359. color: #FFDDBD;
  360. text-decoration: line-through;
  361. margin-top: 24rpx;
  362. }
  363. .tab-tag{
  364. color: #201F1E;
  365. background: #FFDDBD;
  366. border-radius: 0rpx 40rpx 0px 16rpx;
  367. width: 88rpx;
  368. height: 36rpx;
  369. line-height: 36rpx;
  370. text-align: center;
  371. position: absolute;
  372. right: -1rpx;
  373. top: -1rpx;
  374. }
  375. }
  376. .no-active{
  377. border: 1rpx solid #79726B;
  378. padding: 40rpx 24rpx;
  379. width: 188rpx;
  380. }
  381. .active-tab{
  382. padding: 40rpx 24rpx;
  383. width: 182rpx;
  384. border: 4rpx solid #FFDDBD !important;
  385. background-color: #221F1C !important;
  386. }
  387. }
  388. .swiper{
  389. margin: 48rpx 32rpx 16rpx 32rpx;
  390. height: 80rpx;
  391. position: relative;
  392. .swiper-model{
  393. position: absolute;
  394. z-index: 100;
  395. width: 100%;
  396. height: 80rpx;
  397. }
  398. .swiper-item{
  399. height: 80rpx;
  400. .item-box{
  401. padding: 20rpx 24rpx;
  402. height: 80rpx;
  403. .item-img{
  404. width: 40rpx;
  405. height: 40rpx;
  406. border-radius: 40rpx;
  407. background-color: #ffffff;
  408. }
  409. .item-text{
  410. color: #ffffff;
  411. margin-left: 16rpx;
  412. }
  413. }
  414. }
  415. }
  416. .prot{
  417. margin: 0 32rpx;
  418. color: #ffffff;
  419. }
  420. .action{
  421. margin: 64rpx 32rpx;
  422. width: 686rpx;
  423. }
  424. .qustion-title{
  425. color: #ffffff;
  426. margin: 0 32rpx;
  427. }
  428. .qustions{
  429. color: #79726B;
  430. margin: 20rpx 32rpx 80rpx 32rpx;
  431. padding-bottom: 284rpx;
  432. }
  433. }
  434. .btn{
  435. position: fixed;
  436. bottom: 0;
  437. left: 0;
  438. z-index: 100;
  439. width: 686rpx;
  440. height: 128rpx;
  441. margin: 0rpx 32rpx;
  442. margin-bottom: 76rpx;
  443. background: linear-gradient(133deg, #1B1A1D 0%, #000000 100%);
  444. border-radius: 64rpx;
  445. border: 2rpx solid #979797;
  446. .btn-left{
  447. padding-left:48rpx;
  448. .bl-total{
  449. color: #ffffff;
  450. }
  451. .bl-tip{
  452. color: #79726B;
  453. }
  454. }
  455. .btn-right{
  456. position: relative;
  457. width: 208rpx;
  458. height: 96rpx;
  459. padding-right: 20rpx;
  460. .br-img{
  461. position: absolute;
  462. left: 0;
  463. right: 0;
  464. top: 0;
  465. bottom: 0;
  466. margin: 0 auto;
  467. width: 208rpx;
  468. height: 96rpx;
  469. z-index: 0;
  470. }
  471. .br-text{
  472. color: #000000;
  473. position: relative;
  474. z-index: 1;
  475. width: 208rpx;
  476. height: 96rpx;
  477. text-align: center;
  478. line-height: 96rpx;
  479. }
  480. }
  481. }
  482. }
  483. </style>