PayPopup.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <view class="container flex-center">
  3. <view class="popup flex-center">
  4. <image :src="`${assetsUrl}popup-close-white.png`" mode="aspectFill" class="close" @click="close"></image>
  5. <view class="top flex-start">
  6. <image :src="`${assetsUrl}popup-vip.png`" mode="aspectFill" class="top-icon"></image>
  7. <view class="top-text font40 fw600">
  8. 4项特权
  9. </view>
  10. </view>
  11. <swiper :indicator-dots="true" indicator-color="rgba(255,255,255,0.3)" indicator-active-color="#ffffff" :autoplay="true" :interval="5000" :duration="1000" class="swiper" :current="privilegeIndex">
  12. <swiper-item v-for="(item,index) in privileges" :key="index">
  13. <view class="swiper-item flex-center">
  14. <view class="si-content">
  15. <image :src="`${assetsUrl}${item.img}.png`" mode="aspectFill" class="si-img"></image>
  16. <view class="si-title font36 fw600">
  17. {{item.title}}
  18. </view>
  19. <view class="si-text font28 fw400">
  20. {{item.text}}
  21. </view>
  22. </view>
  23. </view>
  24. </swiper-item>
  25. </swiper>
  26. <scroll-view scroll-x="true" class="tabs flex-start">
  27. <view class="tab" :class="tabIndex===index?'active-tab':'no-active'" v-for="(item,index) in priceDatas.prices2" :key="index" @click="tabClick(index)">
  28. <view class="tab-time font28 fw600" :style="{'color':`${tabIndex===index?'#FFDDBD':''}`}">
  29. {{item.name}}
  30. </view>
  31. <view class="tab-price" :style="{'color':`${tabIndex===index?'#FFDDBD':''}`}">
  32. <span style="font-size: 72rpx;" >{{item.priceFenPerMonth/100}}</span><span class="font22 fw500">元/月</span>
  33. </view>
  34. <view class="tab-under font24 fw400" :style="{'color':`${tabIndex===index?'#FFDDBD':''}`}">
  35. {{item.originalPriceFenPerMonth/100}}元/月
  36. </view>
  37. <view class="tab-tag font20 fw600" v-if="tabIndex===index">
  38. {{item.tags}}
  39. </view>
  40. </view>
  41. </scroll-view>
  42. <view class="btn font32 fw600" @click="toPay">
  43. {{platForm==='ios'?'联系客服':'立即解锁'}}
  44. </view>
  45. <view class="tip font22 fw400" v-if="platForm==='ios'">
  46. 成为会员即代表同意<text style="color:#ffffff">《增值服务协议》</text></br>
  47. iOS暂不支持微信支付,请点击<text style="color:#ffffff">联系客服</text>并回复“充值”。
  48. </view>
  49. <view class="tip font22 fw400" v-else>
  50. 成为会员即代表同意<text style="color:#ffffff">《增值服务协议》</text>
  51. ,如果支付成功,但是没有开通VIP,请<text style="color:#ffffff">联系客服</text>。
  52. </view>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. name:"VipPopup",
  59. props:{
  60. swiperIndex:{
  61. type:Number,
  62. default:''
  63. }
  64. },
  65. data() {
  66. return {
  67. assetsUrl: this.$util.assetsUrl,
  68. privileges:[
  69. {img:'popup-talk',title:'随心畅聊',text:'10次/天主动私聊女生'},
  70. {img:'popup-recommend',title:'特别推荐',text:'尊贵标识,优先推荐'},
  71. {img:'popup-limit',title:'颜遇无限',text:'无限次数查看女士主页和相册'},
  72. {img:'popup-visitor',title:'查看访客',text:'解锁女生来访痕迹'},
  73. ],
  74. privilegeIndex:0,
  75. tabIndex:0,
  76. priceDatas:{},
  77. totalPrice:0,
  78. priceConfig:{
  79. feeFen: null,
  80. sceneId: null,
  81. scene: null,
  82. body : null,
  83. userId: null,
  84. pkgCate:'JyPark'
  85. },
  86. };
  87. },
  88. watch:{
  89. 'swiperIndex':function(val,oldval){
  90. console.log(val)
  91. this.privilegeIndex=val;
  92. }
  93. },
  94. computed:{
  95. platForm(){
  96. return this.$store.state.platform
  97. }
  98. },
  99. mounted() {
  100. if(!uni.getStorageSync('token')){
  101. return;
  102. }
  103. this.getConfigData();
  104. },
  105. methods:{
  106. close(){
  107. this.$emit('closePopup');
  108. },
  109. getConfigData(){
  110. let user=JSON.parse(uni.getStorageSync('user'));
  111. this.$api.public.priceBySceneConfigs({
  112. completeUser:user,
  113. scene:'Member'
  114. }).then(res=>{
  115. this.priceDatas=res.data;
  116. this.totalPrice=this.priceDatas.prices2[this.tabIndex].priceFen;
  117. this.priceConfig.feeFen=this.priceDatas.prices2[this.tabIndex].priceFen;
  118. this.priceConfig.scene=this.priceDatas.prices2[this.tabIndex].sceneCate;
  119. this.priceConfig.sceneId=this.priceDatas.prices2[this.tabIndex].sceneId;
  120. this.priceConfig.body=this.priceDatas.prices2[this.tabIndex].name;
  121. this.priceConfig.userId=(this.$store.state.userInfo||JSON.parse(uni.getStorageSync('userInfo'))).id;
  122. })
  123. },
  124. tabClick(index){
  125. this.tabIndex=index;
  126. this.totalPrice=this.priceDatas.prices2[index].priceFen;
  127. this.priceConfig.feeFen=this.priceDatas.prices2[index].priceFen;
  128. this.priceConfig.scene=this.priceDatas.prices2[index].sceneCate;
  129. this.priceConfig.sceneId=this.priceDatas.prices2[index].sceneId;
  130. this.priceConfig.body=this.priceDatas.prices2[index].name;
  131. this.priceConfig.userId=(this.$store.state.userInfo||JSON.parse(uni.getStorageSync('userInfo'))).id;
  132. },
  133. toService(){
  134. uni.openCustomerServiceChat({
  135. extInfo:{
  136. url:'https://work.weixin.qq.com/kfid/kfca1b21d2f7e8a18e9',//客服链接
  137. },
  138. corpId:'wwa8f2a0d8a6dc0950',//企业ID
  139. fail(res){
  140. console.log(res)
  141. uni.showToast({
  142. title: '客服联系失败',
  143. icon:'none'
  144. })
  145. }
  146. })
  147. this.$emit('closePopup');
  148. },
  149. toPay(){
  150. if(this.platForm==='ios'){
  151. this.$emit('closePopup');
  152. uni.openCustomerServiceChat({
  153. extInfo:{
  154. url:'https://work.weixin.qq.com/kfid/kfca1b21d2f7e8a18e9',//客服链接
  155. },
  156. corpId:'wwa8f2a0d8a6dc0950',//企业ID
  157. fail(res){
  158. console.log(res)
  159. wx.showToast({
  160. title: '客服联系失败',
  161. icon:'none'
  162. })
  163. }
  164. })
  165. return;
  166. }
  167. uni.getProvider({
  168. service:'payment',
  169. success:(provider)=>{
  170. console.log(provider.provider)
  171. this.$api.pay.creatWxOrder(this.priceConfig).then(res=>{
  172. if(res.data.succ){
  173. uni.requestPayment({
  174. provider:provider.provider[0],
  175. timeStamp: String(res.data.timeStamp),
  176. nonceStr: res.data.nonceStr,
  177. package: `prepay_id=${res.data.wxUniPrePayId}`,
  178. signType: 'MD5',
  179. paySign: res.data.paySign,
  180. success:(result)=>{
  181. console.log(result)
  182. if(result.errMsg==='requestPayment:ok'){
  183. uni.showToast({
  184. icon:'success',
  185. title:'支付成功'
  186. })
  187. this.$emit('closePopup');
  188. }
  189. },
  190. fail:(err)=>{console.log(err)}
  191. })
  192. }
  193. })
  194. }
  195. })
  196. }
  197. }
  198. }
  199. </script>
  200. <style lang="scss" scoped>
  201. .container{
  202. flex-direction: column;
  203. position: relative;
  204. z-index: 999;
  205. .popup{
  206. width: 100vw;
  207. background-color: #6C52F4;
  208. position: relative;
  209. flex-direction: column;
  210. border-radius: 40rpx 40rpx 0rpx 0rpx;
  211. .close{
  212. position: absolute;
  213. right: 20rpx;
  214. top: 20rpx;
  215. width: 32rpx;
  216. height: 32rpx;
  217. }
  218. .top{
  219. height: 132rpx;
  220. width: 630rpx;
  221. padding: 40rpx 40rpx 0rpx 0rpx;
  222. box-sizing: border-box;
  223. .top-icon{
  224. width: 160rpx;
  225. height: 60rpx;
  226. }
  227. .top-text{
  228. color: #ffffff;
  229. margin-left: 8rpx;
  230. }
  231. }
  232. .swiper{
  233. width: 100%;
  234. height: 430rpx;
  235. .swiper-item{
  236. width: 100%;
  237. flex-direction: column;
  238. .si-img{
  239. width: 630rpx;
  240. height: 256rpx;
  241. }
  242. .si-title{
  243. color: #ffffff;
  244. text-align: center;
  245. }
  246. .si-text{
  247. color: #ffffff;
  248. text-align: center;
  249. margin-top: 16rpx;
  250. }
  251. }
  252. }
  253. .tabs{
  254. height: 340rpx;
  255. white-space:nowrap;
  256. .tab{
  257. position: relative;
  258. margin-right: 12rpx;
  259. border-radius: 40rpx;
  260. display: inline-block;
  261. transition: all .1s;
  262. overflow: hidden;
  263. &:nth-of-type(1){
  264. margin-left: 32rpx;
  265. }
  266. &:nth-last-of-type(1){
  267. margin-right: 32rpx;
  268. }
  269. .tab-time{
  270. color: #79726B;
  271. }
  272. .tab-price{
  273. color: #79726B;
  274. margin-top: 24rpx;
  275. }
  276. .tab-under{
  277. color: #79726B;
  278. text-decoration: line-through;
  279. margin-top: 24rpx;
  280. }
  281. .tab-tag{
  282. color: #79726B;
  283. background: #FFDDBD;
  284. border-radius: 0rpx 40rpx 0px 16rpx;
  285. width: 88rpx;
  286. height: 36rpx;
  287. line-height: 36rpx;
  288. text-align: center;
  289. position: absolute;
  290. right: -1rpx;
  291. top: -1rpx;
  292. }
  293. }
  294. .no-active{
  295. border: 1rpx solid #79726B;
  296. padding: 40rpx 24rpx;
  297. width: 188rpx;
  298. background-color: #0D0B0A;
  299. }
  300. .active-tab{
  301. padding: 40rpx 24rpx;
  302. width: 182rpx;
  303. border: 4rpx solid #FFDDBD !important;
  304. background-color: #221F1C !important;
  305. }
  306. }
  307. .btn{
  308. width: 630rpx;
  309. height: 104rpx;
  310. background: #FFFFFF;
  311. border-radius: 56rpx;
  312. color: #6C52F4;
  313. line-height: 104rpx;
  314. text-align: center;
  315. }
  316. .tip{
  317. margin: 0 32rpx;
  318. color: #D4D4F1;
  319. line-height: 32rpx;
  320. padding-bottom: 68rpx;
  321. margin-top: 16rpx;
  322. text-align: center;
  323. }
  324. }
  325. }
  326. </style>