index.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346
  1. <template>
  2. <view class="vip-container" >
  3. <view class="heard-box" :class="`active${selectedPrice}`">
  4. <!-- 自定义头部 -->
  5. <PageHeader title="" class="PageHeader" :class="{ 'whitePhageHeader': headerOpacity > 0.2 }"
  6. :style="{ opacity: headerOpacity < 0.2 ? 1 : headerOpacity }">
  7. <template v-slot:center>
  8. <view class="center-title" style="font-size: 32rpx;color: #fff;">会员中心</view>
  9. </template>
  10. <template v-slot:right>
  11. <view class="more-options" @tap="toggleDropdown">
  12. <image src="@/static/icon/more3.png" v-if="headerOpacity < 0.2" style="width: 64rpx;height: 64rpx; margin-top: 15rpx;" mode="widthFix"></image>
  13. <image src="@/static/icon/more2.png" v-else style="width: 64rpx;height: 64rpx; margin-top: 15rpx;" mode="widthFix"></image>
  14. <view class="dropdown-menu" v-if="showDropdown">
  15. <view class="dropdown-item" @tap="handleOption('vipRecord')">VIP记录</view>
  16. <view class="dropdown-item" @tap="handleOption('contact')">联系客服</view>
  17. </view>
  18. </view>
  19. </template>
  20. </PageHeader>
  21. <view class="reserveASeat"></view>
  22. <view class="vip-card-box">
  23. <!-- 顶部会员信息 -->
  24. <view class="vip-header">
  25. <view class="vip-info">
  26. <CircleAvatar class="vip-info-left" v-if="userInfo.avator" :src="userInfo.avator">
  27. </CircleAvatar>
  28. <view class="vip-info-right">
  29. <view class="vip-nickname">{{ userInfo.nickname }}</view>
  30. <view class="vip-expire" v-if="userInfo.is_vip">VIP到期时间: {{ userInfo.vip_date }}</view>
  31. <view class="vip-expire" v-else>暂未开通</view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="vip-content">
  38. <!-- 会员价格选择 -->
  39. <view class="vip-price-options">
  40. <view class="price-option" v-for="(item, index) in priceOptions" :key="index"
  41. :class="{ active: selectedPrice === index }" @tap="selectPrice(index)">
  42. <view class="price-left-img" v-if="item.limitedTimeGift">
  43. <!-- 限时优惠M币{{ item.limitedTimeGift }} -->
  44. 限时优惠
  45. </view>
  46. <view class="price-tag" v-if="item.tag">{{ item.tag }}</view>
  47. <view class="duration">{{ item.name }}</view>
  48. <view class="price"><text style="font-size: 40rpx;">¥</text>{{ item.price }}</view>
  49. <view class="originalPrice">¥{{ item.originalPrice }}</view>
  50. </view>
  51. </view>
  52. <uv-notice-bar direction="column" speed="250" color="#333" :text="memberInformation"></uv-notice-bar>
  53. <!-- 会员特权列表 -->
  54. <view class="vip-privileges">
  55. <view class="privileges-title">尊享特权</view>
  56. <view class="privileges-list">
  57. <view class="privilege-item" v-for="(item, index) in privileges" :key="index">
  58. <image class="privilege-icon" v-if="item.icon" :src="item.icon" mode="aspectFit"></image>
  59. <view class="privilege-info">
  60. <view class="privilege-name">{{ item.name }}</view>
  61. <view class="privilege-desc">{{ item.desc }}</view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="agree">
  68. <view class="agree2" @click="agreeChk()">
  69. <image style="width: 32rpx;height: 32rpx;" src="../../static/icon/wd_icon_gouxuan04.png"
  70. v-if="is_agree == 0">
  71. </image>
  72. <image style="width: 32rpx;height: 32rpx;" src="../../static/icon/wd_icon_gouxuan05.png"
  73. v-if="is_agree == 1">
  74. </image>
  75. </view>
  76. <view>
  77. 同意
  78. <text class="xy" @click="goPage('/pages/AboutUs/pay_xy')">
  79. 《充值服务协议》
  80. </text>,充值M币仅【萌创星球】使用,点击查看
  81. <text class="xy" @click="goPage('/pages/vip/record?type=vip')">
  82. 充值记录
  83. </text>
  84. </view>
  85. </view>
  86. <view class="bottom-pay-btn-bottom"
  87. v-if="priceOptions && priceOptions[selectedPrice] && priceOptions[selectedPrice].price"
  88. :class="{ 'btn-loading': isSubmitting }" @tap="showPaymentOptions">
  89. <text class="price-value" v-if="!isSubmitting">¥{{ priceOptions[selectedPrice].price }}</text>
  90. <text v-if="!isSubmitting">立即购买</text>
  91. <view v-if="isSubmitting" class="loading-spinner"></view>
  92. </view>
  93. <!-- 支付方式选择弹窗 -->
  94. <uni-popup ref="paymentPopup" type="bottom">
  95. <view class="payment-popup">
  96. <view class="popup-header">
  97. <view class="popup-title">选择支付方式</view>
  98. <!-- <view class="popup-close" @tap="closePaymentPopup">×</view> -->
  99. </view>
  100. <view class="payment-options">
  101. <view class="payment-option" @tap="selectPayment('alipay')">
  102. <image class="payment-icon" src="../../static/icon/pay_ali.png" mode="aspectFit"></image>
  103. <view class="payment-name">支付宝支付</view>
  104. <image class="payment-select"
  105. :src="paymentMethod === 'alipay' ? '../../static/icon/wd_icon_gouxuan05.png' : '../../static/icon/wd_icon_gouxuan04.png'"
  106. mode="aspectFit"></image>
  107. </view>
  108. <view v-if="isWeChatPay" class="payment-option" @tap="selectPayment('wechat')">
  109. <image class="payment-icon" src="../../static/icon/pay_wx.png" mode="aspectFit"></image>
  110. <view class="payment-name">微信支付</view>
  111. <image class="payment-select"
  112. :src="paymentMethod === 'wechat' ? '../../static/icon/wd_icon_gouxuan05.png' : '../../static/icon/wd_icon_gouxuan04.png'"
  113. mode="aspectFit"></image>
  114. </view>
  115. </view>
  116. <view class="confirm-payment" @tap="confirmPayment">立即支付</view>
  117. </view>
  118. </uni-popup>
  119. <CustomerServicePopup ref="customerServicePopup"></CustomerServicePopup>
  120. </view>
  121. </template>
  122. <script>
  123. import { mapState } from 'vuex'
  124. export default {
  125. data() {
  126. return {
  127. userInfo: {
  128. is_vip: false,
  129. vip_date: '2023-10-23'
  130. },
  131. headerOpacity: 0,
  132. memberInformation: [
  133. '墨色** 于10分钟前开通了月会员',
  134. '雾散时** 于24分钟前开通了季会员',
  135. 'Jox** 于17分钟前开通了月会员',
  136. '漂亮的** 于19分钟前开通了年会员',
  137. 'Ri** 于30分钟前开通了季会员',
  138. '山桃** 于15分钟前开通了月会员',
  139. 'zx** 于19分钟前开通了年会员',
  140. '** 于13分钟前开通了年会员',
  141. 'CarrollSo** 于21分钟前开通了季会员',
  142. 'Nanng** 于17分钟前开通了月会员',
  143. '芭比B** 于9分钟前开通了年会员',
  144. '小周不是** 于29分钟前开通了季会员',
  145. '落雪_** 于26分钟前开通了月会员',
  146. '雾岛听蝉9** 于19分钟前开通了年会员',
  147. '如** 于19分钟前开通了季会员',
  148. '言川Art** 于25分钟前开通了月会员',
  149. '兔子君mrbun** 于30分钟前开通了月会员',
  150. '呼哧Hac** 于6分钟前开通了年会员',
  151. 'alxe_不爱吹** 于17分钟前开通了季会员',
  152. '飞清** 于25分钟前开通了月会员',
  153. ],
  154. // memberInformation:[
  155. // '墨色轨迹于10分钟前开通了月会员',
  156. // '雾散时见山于24分钟前开通了季会员',
  157. // 'Joxin于17分钟前开通了月会员',
  158. // '漂亮的倾城于19分钟前开通了年会员',
  159. // 'Rick于30分钟前开通了季会员',
  160. // '山桃始华于15分钟前开通了月会员',
  161. // 'zx浊酒于19分钟前开通了年会员',
  162. // '桥九于13分钟前开通了年会员',
  163. // 'CarrollSong于21分钟前开通了季会员',
  164. // 'Nanngua于17分钟前开通了月会员',
  165. // '芭比Box于9分钟前开通了年会员',
  166. // '小周不是小粥于29分钟前开通了季会员',
  167. // '落雪_桃桃于26分钟前开通了月会员',
  168. // '雾岛听蝉999于19分钟前开通了年会员',
  169. // '如青稞于19分钟前开通了季会员',
  170. // '言川Artie于25分钟前开通了月会员',
  171. // '兔子君mrbunny于30分钟前开通了月会员',
  172. // '呼哧Hachi于6分钟前开通了年会员',
  173. // 'alxe_不爱吹泡泡于17分钟前开通了季会员',
  174. // '飞清云淡于25分钟前开通了月会员',
  175. // ],
  176. priceOptions: [
  177. ],
  178. selectedPrice: 1, // 默认选中的价格选项索引
  179. privileges: [{
  180. name: 'VIP专属通道',
  181. icon: '../../static/vip/hy_icon_quanyi01.png',
  182. desc: '创作加速,更快生成'
  183. },
  184. // {
  185. // name: '专属星源礼包',
  186. // icon: '../../static/vip/hy_icon_quanyi02.png',
  187. // desc: '每日登录领更多星源'
  188. // },
  189. {
  190. name: '数据安全增强',
  191. icon: '../../static/vip/hy_icon_quanyi03.png',
  192. desc: '多重数据安全更放心'
  193. },
  194. {
  195. name: '深度思考升级',
  196. icon: '../../static/vip/hy_icon_quanyi04.png',
  197. desc: '深度思考,提升50%'
  198. },
  199. {
  200. name: '成长加成',
  201. icon: '../../static/vip/hy_icon_quanyi05.png',
  202. desc: '设计达人等级加速'
  203. },
  204. // {
  205. // name: 'VIP专属通道',
  206. // icon: '../../static/vip/hy_icon_quanyi05.png',
  207. // desc: '创作加速,更快生成'
  208. // },
  209. // {
  210. // name: '免广告',
  211. // icon: '../../static/vip/hy_icon_quanyi06.png',
  212. // desc: '无广告免费体验'
  213. // }
  214. ],
  215. paymentMethod: 'alipay', // 默认支付方式
  216. privilegesHeight: 0, // 添加存储特权区域高度的变量
  217. showDropdown: false, // 控制下拉菜单显示状态
  218. is_agree: 0,
  219. linkid: '',
  220. lastClickTime: 0,
  221. isSubmitting: false,
  222. isIOS: false, // 是否为iOS系统
  223. currentOrderId: "", // 当前苹果内购订单ID
  224. }
  225. },
  226. computed: {
  227. ...mapState('hideModule', ['isWeChatPay'])
  228. },
  229. onShow() {
  230. this.isSubmitting = false;
  231. this.checkPlatform(); // 检查平台类型
  232. },
  233. onLoad() {
  234. // 获取用户信息,检查是否为VIP
  235. this.getUserInfo();
  236. this.checkPlatform(); // 检查平台类型
  237. },
  238. onReady() {
  239. // 页面渲染完成后获取vip-privileges的高度
  240. this.getPrivilegesHeight();
  241. },
  242. onPageScroll(e) {
  243. console.log(e.scrollTop, "滚动高度");
  244. var scrollTop = e.scrollTop - 10;
  245. if (scrollTop > 0) {
  246. this.headerOpacity = Math.min(scrollTop / 100, 1);
  247. }
  248. if (e.scrollTop == 0) {
  249. this.headerOpacity = 0;
  250. }
  251. },
  252. methods: {
  253. // 获取用户信息
  254. getUserInfo() {
  255. // 这里添加获取用户信息的API调用
  256. uni.request({
  257. url: this.$apiHost + "/User/getinfo",
  258. data: {
  259. uuid: getApp().globalData.uuid,
  260. skey: getApp().globalData.skey,
  261. },
  262. header: {
  263. "content-type": "application/json",
  264. sign: getApp().globalData.headerSign,
  265. },
  266. success: (res) => {
  267. if (res) {
  268. console.log("获取到用户信息", res.data);
  269. this.userInfo = res.data
  270. }
  271. },
  272. complete: (com) => {
  273. },
  274. fail: (e) => {
  275. console.log("----e:", e);
  276. },
  277. });
  278. uni.request({
  279. url: this.$apiHost + "/Member/vipList",
  280. data: {
  281. uuid: getApp().globalData.uuid,
  282. skey: getApp().globalData.skey,
  283. },
  284. header: {
  285. "content-type": "application/json",
  286. sign: getApp().globalData.headerSign,
  287. },
  288. success: (res) => {
  289. console.log("作品列表数据:", res.data);
  290. // 确保在任何情况下都完成加载
  291. if (
  292. res.data.success == "yes" &&
  293. res.data.list &&
  294. res.data.list.length > 0
  295. ) {
  296. console.log(res.data.list, "会员列表数据");
  297. this.priceOptions = []
  298. res.data.list.reverse()
  299. res.data.list.forEach(v => {
  300. this.priceOptions.push({
  301. id: v.id,
  302. limitedTimeGift: v.price_market - v.price,
  303. name: v.name,
  304. price: v.price,
  305. originalPrice: v.price_market,
  306. tag: v.tag,
  307. numDay: v.num_day,
  308. numSong: v.num_song,
  309. })
  310. });
  311. this.priceOptions[1].tag = "推荐"
  312. console.log(this.priceOptions, "会员列表数据");
  313. } else {
  314. // priceOptions: [{
  315. // name: '月度VIP',
  316. // price: '98',
  317. // originalPrice: '168',
  318. // tag: '',
  319. // limitedTimeGift: ""
  320. // },
  321. // {
  322. // name: '季度VIP',
  323. // price: '198',
  324. // originalPrice: '268',
  325. // tag: '推荐',
  326. // limitedTimeGift: "100"
  327. // },
  328. // {
  329. // name: '年度VIP',
  330. // price: '398',
  331. // originalPrice: '498',
  332. // tag: '',
  333. // limitedTimeGift: "1500"
  334. // }
  335. // ],
  336. }
  337. },
  338. complete: () => {
  339. },
  340. fail: (e) => {
  341. console.log("请求关注列表失败:", e);
  342. },
  343. });
  344. },
  345. // 选择价格选项
  346. selectPrice(index) {
  347. this.selectedPrice = index;
  348. },
  349. // 显示支付方式选择弹窗
  350. showPaymentOptions() {
  351. const now = Date.now();
  352. if (now - this.lastClickTime < 3000) {
  353. uni.showToast({
  354. title: "请勿频繁点击",
  355. icon: "none"
  356. });
  357. return;
  358. }
  359. this.lastClickTime = now;
  360. if (this.isSubmitting) return;
  361. if (this.is_agree == 0) {
  362. uni.showToast({
  363. title: "请确认并选择协议",
  364. icon: "none",
  365. });
  366. return;
  367. }
  368. this.isSubmitting = true;
  369. // iOS系统直接使用苹果内购
  370. if (this.isIOS) {
  371. this.submitAppleIap();
  372. return;
  373. }
  374. this.$refs.paymentPopup.open();
  375. this.isSubmitting = false;
  376. },
  377. // 关闭支付方式选择弹窗
  378. closePaymentPopup() {
  379. this.$refs.paymentPopup.close();
  380. },
  381. // 选择支付方式
  382. selectPayment(method) {
  383. this.paymentMethod = method;
  384. },
  385. // 确认支付
  386. confirmPayment() {
  387. if (!this.priceOptions || !this.priceOptions[this.selectedPrice]) {
  388. uni.showToast({
  389. title: '请选择会员套餐',
  390. icon: 'none'
  391. });
  392. return;
  393. }
  394. if (this.is_agree == 0) {
  395. uni.showToast({
  396. title: "请确认并选择协议",
  397. icon: "none",
  398. });
  399. return;
  400. }
  401. this.isSubmitting = true;
  402. this.submitPayment();
  403. },
  404. // 提交支付
  405. submitPayment() {
  406. let that = this;
  407. uni.showLoading({
  408. title: '创建订单中...'
  409. });
  410. uni.request({
  411. url: this.$apiHost + '/Order/submit',
  412. data: {
  413. uuid: getApp().globalData.uuid,
  414. skey: getApp().globalData.skey,
  415. product_id: this.priceOptions[this.selectedPrice].id,
  416. type: 'buyVip',
  417. payType: this.paymentMethod
  418. },
  419. header: {
  420. 'content-type': 'application/json',
  421. sign: getApp().globalData.headerSign
  422. },
  423. success: (res) => {
  424. console.log("支付订单创建结果:", res.data);
  425. if (res.data.success == 'yes') {
  426. this.linkid = res.data.linkid;
  427. this.$refs.paymentPopup.close();
  428. // 根据支付方式调用不同的支付接口
  429. if (this.paymentMethod === 'wechat') {
  430. uni.requestPayment({
  431. provider: "wxpay",
  432. orderInfo: {
  433. appid: res.data.wepay.appid,
  434. partnerid: res.data.wepay.partnerid,
  435. prepayid: res.data.wepay.prepayid,
  436. package: "Sign=WXPay",
  437. noncestr: res.data.wepay.noncestr,
  438. timestamp: res.data.wepay.timestamp,
  439. sign: res.data.wepay.sign
  440. },
  441. success: (payRes) => {
  442. console.log("微信支付成功:", payRes);
  443. that.checkPayStatus();
  444. },
  445. fail: (err) => {
  446. console.log("微信支付失败:", err);
  447. uni.hideLoading();
  448. that.isSubmitting = false;
  449. uni.hideLoading()
  450. uni.showToast({
  451. title: '支付取消',
  452. icon: 'none'
  453. });
  454. }
  455. });
  456. } else if (this.paymentMethod === 'alipay') {
  457. uni.requestPayment({
  458. provider: "alipay",
  459. orderInfo: res.data.ali_pay,
  460. success: (payRes) => {
  461. console.log("支付宝支付成功:", payRes);
  462. that.checkPayStatus();
  463. },
  464. fail: (err) => {
  465. console.log("支付宝支付失败:", err);
  466. uni.hideLoading();
  467. that.isSubmitting = false;
  468. uni.hideLoading()
  469. uni.showToast({
  470. title: '支付取消',
  471. icon: 'none'
  472. });
  473. }
  474. });
  475. }
  476. } else {
  477. uni.hideLoading();
  478. that.isSubmitting = false;
  479. uni.hideLoading()
  480. uni.showToast({
  481. title: res.data.msg || '创建订单失败',
  482. icon: "error"
  483. });
  484. }
  485. },
  486. fail: (err) => {
  487. console.log("创建订单失败:", err);
  488. uni.hideLoading();
  489. that.isSubmitting = false;
  490. uni.hideLoading()
  491. uni.showToast({
  492. title: '网络错误,请稍后重试',
  493. icon: "error"
  494. });
  495. }
  496. });
  497. },
  498. // 检查支付状态
  499. checkPayStatus() {
  500. let that = this;
  501. uni.request({
  502. url: this.$apiHost + "/Order/getstatus",
  503. data: {
  504. uuid: getApp().globalData.uuid,
  505. linkid: this.linkid,
  506. },
  507. header: {
  508. "content-type": "application/json",
  509. 'sign': getApp().globalData.headerSign
  510. },
  511. success: (res) => {
  512. if (res.data.success == "yes") {
  513. uni.hideLoading();
  514. uni.showToast({
  515. title: "充值成功",
  516. icon: "none",
  517. });
  518. // 支付成功后刷新用户信息
  519. this.getUserInfo();
  520. } else {
  521. setTimeout(function () {
  522. that.checkPayStatus();
  523. }, 1000);
  524. }
  525. },
  526. fail: (err) => {
  527. console.log("检查支付状态失败:", err);
  528. uni.hideLoading();
  529. uni.showToast({
  530. title: "网络错误,请重试",
  531. icon: "none"
  532. });
  533. }
  534. });
  535. },
  536. // 获取特权列表区域的高度
  537. getPrivilegesHeight() {
  538. const query = uni.createSelectorQuery().in(this);
  539. query.select('.vip-privileges').boundingClientRect(data => {
  540. if (data) {
  541. this.privilegesHeight = data.height;
  542. console.log('特权区域高度:', this.privilegesHeight);
  543. } else {
  544. console.log('未能获取到特权区域元素');
  545. // 如果首次获取失败,可以添加延迟重试
  546. setTimeout(() => {
  547. this.getPrivilegesHeight();
  548. }, 100);
  549. }
  550. }).exec();
  551. },
  552. // 如果需要在某些数据变化后重新获取高度
  553. updatePrivilegesHeight() {
  554. this.$nextTick(() => {
  555. this.getPrivilegesHeight();
  556. });
  557. },
  558. // 切换下拉菜单显示状态
  559. toggleDropdown() {
  560. this.showDropdown = !this.showDropdown;
  561. },
  562. // 处理下拉菜单选项点击
  563. handleOption(type) {
  564. this.showDropdown = false;
  565. switch (type) {
  566. case 'vipRecord':
  567. uni.navigateTo({
  568. url: '/pages/vip/record?type=vip'
  569. });
  570. break;
  571. case 'help':
  572. uni.navigateTo({
  573. url: '/pages/help/index'
  574. });
  575. break;
  576. case 'contact':
  577. this.openCustomPopup();
  578. break;
  579. }
  580. },
  581. openCustomPopup() {
  582. this.$refs.customerServicePopup.open();
  583. },
  584. goPage(page) {
  585. uni.navigateTo({
  586. url: page,
  587. })
  588. }, agreeChk() {
  589. if (this.is_agree == 0) {
  590. this.is_agree = 1;
  591. } else {
  592. this.is_agree = 0;
  593. }
  594. },
  595. // 检查平台类型
  596. checkPlatform() {
  597. const systemInfo = uni.getSystemInfoSync();
  598. this.isIOS = systemInfo.platform === 'ios';
  599. console.log('当前平台:', systemInfo.platform, '是否为iOS:', this.isIOS);
  600. },
  601. // 苹果内购提交
  602. submitAppleIap() {
  603. let that = this;
  604. // 先创建订单
  605. uni.request({
  606. url: this.$apiHost + "/AppleIap/submit",
  607. data: {
  608. uuid: getApp().globalData.uuid,
  609. product_id: this.priceOptions[this.selectedPrice].id,
  610. type: "buyVip",
  611. },
  612. header: {
  613. "content-type": "application/json",
  614. },
  615. success: (res) => {
  616. console.log("苹果内购VIP订单创建:", res.data);
  617. if (res.data.success == "yes") {
  618. that.currentOrderId = res.data.order_id;
  619. // 调用苹果内购
  620. that.requestApplePayment(res.data.apple_product_id);
  621. } else {
  622. uni.showToast({
  623. title: res.data.msg || "创建订单失败",
  624. icon: "none",
  625. });
  626. that.isSubmitting = false;
  627. }
  628. },
  629. fail: (err) => {
  630. console.log("创建苹果内购VIP订单失败:", err);
  631. uni.showToast({
  632. title: "网络错误,请重试",
  633. icon: "none"
  634. });
  635. that.isSubmitting = false;
  636. }
  637. });
  638. },
  639. // 调用苹果内购
  640. requestApplePayment(productId) {
  641. let that = this;
  642. // 请求苹果内购
  643. uni.requestPayment({
  644. provider: 'appleiap',
  645. orderInfo: {
  646. productid: productId
  647. },
  648. success: function (res) {
  649. console.log('苹果内购VIP支付成功:', res);
  650. // 验证收据
  651. that.verifyAppleReceipt(res.transactionReceipt, res.transactionIdentifier);
  652. },
  653. fail: function (err) {
  654. console.log('苹果内购VIP支付失败:', err);
  655. uni.showToast({
  656. title: '支付失败:' + err,
  657. icon: 'none'
  658. });
  659. that.isSubmitting = false;
  660. }
  661. });
  662. },
  663. // 验证苹果收据
  664. verifyAppleReceipt(receiptData, transactionId) {
  665. let that = this;
  666. uni.request({
  667. url: that.$apiHost + "/AppleIap/verify",
  668. method: 'POST',
  669. data: {
  670. uuid: getApp().globalData.uuid,
  671. order_id: that.currentOrderId,
  672. receipt_data: receiptData,
  673. transaction_id: transactionId
  674. },
  675. header: {
  676. "content-type": "application/json",
  677. },
  678. success: (res) => {
  679. console.log("苹果VIP收据验证结果:", res.data);
  680. if (res.data.success == "yes") {
  681. uni.showToast({
  682. title: "开通成功",
  683. icon: "success",
  684. });
  685. // 刷新用户信息
  686. that.getUserInfo();
  687. } else {
  688. uni.showToast({
  689. title: res.data.msg || "验证失败",
  690. icon: "none",
  691. });
  692. }
  693. that.isSubmitting = false;
  694. },
  695. fail: (err) => {
  696. console.log("验证苹果VIP收据失败:", err);
  697. uni.showToast({
  698. title: "验证失败,请联系客服",
  699. icon: "none"
  700. });
  701. that.isSubmitting = false;
  702. }
  703. });
  704. },
  705. }
  706. }
  707. </script>
  708. <style lang="scss">
  709. .vip-container {
  710. min-height: 100vh;
  711. padding-bottom: 360rpx;
  712. position: relative;
  713. left: 0;
  714. top: 0;
  715. .heard-box {
  716. .PageHeader {
  717. background-image: url("@/static/vip/hy_bg_01.png");
  718. background-size: 100% auto;
  719. background-repeat: no-repeat;
  720. background-position-y: -var(--status-bar-height);
  721. ::v-deep .uni-icons {
  722. color: #fff !important;
  723. }
  724. .fa {
  725. color: #fff;
  726. }
  727. &.whitePhageHeader {
  728. background-image: none !important;
  729. background: #fff;
  730. .center-title {
  731. color: #1f1f1f !important;
  732. }
  733. ::v-deep .uni-icons {
  734. color: #000 !important;
  735. }
  736. }
  737. }
  738. .vip-card-box {
  739. width: 100%;
  740. padding: 0 36rpx;
  741. height: 300rpx;
  742. padding-top: 40rpx;
  743. .vip-header {
  744. width: 100%;
  745. height: 210rpx;
  746. padding-left: 28rpx;
  747. padding-top: 110rpx;
  748. .vip-info {
  749. padding-top: 10rpx;
  750. padding-left: 4rpx;
  751. display: flex;
  752. .vip-info-left {
  753. width: 60rpx;
  754. height: 60rpx;
  755. border: #fff solid 2rpx;
  756. margin-right: 10rpx;
  757. }
  758. .vip-info-right {
  759. .vip-nickname {
  760. font-size: 26rpx;
  761. font-weight: 400;
  762. font-family: 'PingFang SC-Bold';
  763. }
  764. .vip-expire {
  765. font-size: 22rpx;
  766. font-family: 'PingFang SC-Medium';
  767. }
  768. }
  769. }
  770. }
  771. }
  772. &.active0 {
  773. background: url("@/static/vip/hy_bg_01.png") center/100% 100% no-repeat;
  774. .PageHeader {
  775. background-image: url("@/static/vip/hy_bg_01.png");
  776. }
  777. .vip-card-box {
  778. .vip-header {
  779. background: url("@/static/vip/hy_card_01.png") top center/100% auto no-repeat;
  780. .vip-info {
  781. .vip-nickname {
  782. color: #1f1f1f;
  783. }
  784. .vip-expire {
  785. color: rgba(31, 31, 31, 0.7);
  786. }
  787. }
  788. }
  789. }
  790. }
  791. &.active1 {
  792. background: url("@/static/vip/hy_bg_02.png") center/100% 100% no-repeat;
  793. .PageHeader {
  794. background-image: url("@/static/vip/hy_bg_02.png");
  795. }
  796. .vip-card-box {
  797. .vip-header {
  798. background: url("@/static/vip/hy_card_02.png") top center/100% auto no-repeat;
  799. .vip-info {
  800. .vip-nickname {
  801. color: #FFE590;
  802. }
  803. .vip-expire {
  804. color: rgba(255, 229, 144, 0.35);
  805. }
  806. }
  807. }
  808. }
  809. }
  810. &.active2 {
  811. background: url("@/static/vip/hy_bg_03.png") center/100% 100% no-repeat;
  812. .PageHeader {
  813. background-image: url("@/static/vip/hy_bg_03.png");
  814. }
  815. .vip-card-box {
  816. .vip-header {
  817. background: url("@/static/vip/hy_card_03.png") top center/100% auto no-repeat;
  818. .vip-info {
  819. .vip-nickname {
  820. color: #FFFFFF;
  821. }
  822. .vip-expire {
  823. color: rgba(255, 255, 255, 0.35);
  824. }
  825. }
  826. }
  827. }
  828. }
  829. .reserveASeat {
  830. width: 100%;
  831. background: transparent;
  832. height: calc(var(--status-bar-height) + 90rpx);
  833. }
  834. }
  835. .vip-content {
  836. background: #fff;
  837. border-top-left-radius: 32rpx;
  838. border-top-right-radius: 32rpx;
  839. .vip-price-options {
  840. display: flex;
  841. justify-content: space-between;
  842. padding: 32rpx;
  843. padding-bottom: 24rpx;
  844. margin-top: -60rpx;
  845. .price-option {
  846. width: 218rpx;
  847. height: 250rpx;
  848. background-color: #fff;
  849. border-radius: 20rpx;
  850. display: flex;
  851. flex-direction: column;
  852. justify-content: center;
  853. align-items: center;
  854. position: relative;
  855. transition: all 0.3s;
  856. border-radius: 20rpx;
  857. border: 6rpx solid #E9E9E9;
  858. padding-top: 48rpx;
  859. padding-bottom: 34rpx;
  860. .price-left-img {
  861. min-width: 160rpx;
  862. height: 48rpx;
  863. padding: 6rpx 12rpx 14rpx 12rpx;
  864. position: absolute;
  865. left: -11rpx;
  866. top: -6rpx;
  867. background: url("../../static/vip/hy_biaoqian_02.png") center/100% 100% no-repeat;
  868. font-weight: 400;
  869. font-size: 10px;
  870. color: #898888;
  871. display: flex;
  872. align-items: center;
  873. justify-content: center;
  874. }
  875. .price-tag {
  876. position: absolute;
  877. bottom: -4rpx;
  878. right: -4rpx;
  879. font-family: 'PingFang SC-Bold';
  880. font-weight: 400;
  881. background-color: #4A4A4A;
  882. color: #ffffff;
  883. font-size: 24rpx;
  884. width: 86rpx;
  885. height: 36rpx;
  886. border-top-left-radius: 20rpx;
  887. border-bottom-right-radius: 20rpx;
  888. display: flex;
  889. align-items: center;
  890. justify-content: center;
  891. }
  892. .duration {
  893. font-family: 'PingFang SC-Bold';
  894. font-weight: 400;
  895. font-size: 32rpx;
  896. color: #1F1F1F;
  897. }
  898. .price {
  899. font-size: 68rpx;
  900. font-weight: bold;
  901. color: #4A4A4A;
  902. // padding-top: -10rpx;
  903. line-height: 1;
  904. padding-top: 8rpx;
  905. padding-bottom: 2rpx;
  906. }
  907. .originalPrice {
  908. font-size: 28rpx;
  909. color: #999999;
  910. text-decoration: line-through;
  911. }
  912. &.active {
  913. background: linear-gradient(to bottom, #F0FFD9, rgba(0, 0, 0, 0));
  914. border-color: #1f1f1f;
  915. transform: scale(1.05);
  916. .price-tag {
  917. background: #1f1f1f;
  918. }
  919. .price-left-img {
  920. background: url("../../static/vip/hy_biaoqian_01.png") center/100% no-repeat;
  921. color: #ACF934;
  922. }
  923. .price {
  924. color: #7CCB00;
  925. }
  926. }
  927. }
  928. }
  929. .vip-privileges {
  930. padding: 0 30rpx;
  931. .privileges-title {
  932. font-family: 'PingFang SC-Bold';
  933. font-weight: 400;
  934. font-size: 16px;
  935. color: #1F1F1F;
  936. padding-top: 36rpx;
  937. padding-bottom: 22rpx;
  938. }
  939. .privileges-list {
  940. display: flex;
  941. flex-wrap: wrap;
  942. justify-content: space-between;
  943. }
  944. .privilege-item {
  945. width: 330rpx;
  946. height: 136rpx;
  947. flex-grow: 0;
  948. background-color: #F7F7F7;
  949. border-radius: 16rpx;
  950. padding: 26rpx;
  951. padding-right: 0;
  952. // padding-left: 20rpx;
  953. margin-bottom: 20rpx;
  954. display: flex;
  955. align-items: center;
  956. }
  957. .privilege-icon {
  958. width: 84rpx;
  959. height: 84rpx;
  960. margin-right: 20rpx;
  961. }
  962. .privilege-name {
  963. font-size: 28rpx;
  964. font-weight:400;
  965. color: #1f1f1f;
  966. margin-bottom: 10rpx;
  967. font-family: 'PingFang SC-Bold';
  968. }
  969. .privilege-desc {
  970. font-size: 20rpx;
  971. color: #999999;
  972. }
  973. }
  974. }
  975. .uv-notice-bar {
  976. background-color: #F2F6F2 !important;
  977. border-radius: 108rpx;
  978. width: calc(100% - 64rpx);
  979. margin: 0 auto;
  980. ::v-deep.uvicon-volume {
  981. color: #333 !important;
  982. }
  983. }
  984. .bottom-pay-btn {
  985. position: fixed;
  986. bottom: 0;
  987. left: 0;
  988. right: 0;
  989. display: flex;
  990. align-items: center;
  991. justify-content: space-between;
  992. background-color: #242424;
  993. padding: 30rpx 40rpx;
  994. box-sizing: border-box;
  995. .total-price {
  996. color: #cccccc;
  997. font-size: 28rpx;
  998. }
  999. .price-value {
  1000. color: #ffffff;
  1001. font-size: 40rpx;
  1002. font-weight: bold;
  1003. }
  1004. .pay-button {
  1005. background: linear-gradient(to right, #9758DE, #5F17DD);
  1006. color: #ffffff;
  1007. padding: 20rpx 60rpx;
  1008. border-radius: 50rpx;
  1009. font-size: 32rpx;
  1010. }
  1011. }
  1012. /* 支付方式选择弹窗样式 */
  1013. .payment-popup {
  1014. background-color: #ffffff;
  1015. border-radius: 24rpx 24rpx 0 0;
  1016. padding: 40rpx;
  1017. .popup-header {
  1018. display: flex;
  1019. justify-content: center;
  1020. align-items: center;
  1021. margin-bottom: 40rpx;
  1022. position: relative;
  1023. }
  1024. .popup-title {
  1025. font-size: 32rpx;
  1026. color: #333;
  1027. font-weight: 500;
  1028. text-align: center;
  1029. }
  1030. .popup-close {
  1031. position: absolute;
  1032. right: 0;
  1033. top: 50%;
  1034. transform: translateY(-50%);
  1035. font-size: 48rpx;
  1036. color: #999999;
  1037. line-height: 1;
  1038. }
  1039. .payment-options {
  1040. margin-bottom: 40rpx;
  1041. }
  1042. .payment-option {
  1043. display: flex;
  1044. align-items: center;
  1045. padding: 32rpx 0;
  1046. border-bottom: 1rpx solid #EEEEEE;
  1047. &:last-child {
  1048. border-bottom: none;
  1049. }
  1050. }
  1051. .payment-icon {
  1052. width: 72rpx;
  1053. height: 72rpx;
  1054. margin-right: 24rpx;
  1055. }
  1056. .payment-name {
  1057. flex: 1;
  1058. color: #333;
  1059. font-size: 32rpx;
  1060. }
  1061. .payment-select {
  1062. width: 40rpx;
  1063. height: 40rpx;
  1064. }
  1065. .confirm-payment {
  1066. background: #333333;
  1067. color: #ACF934;
  1068. text-align: center;
  1069. padding: 28rpx 0;
  1070. border-radius: 76rpx;
  1071. font-size: 32rpx;
  1072. margin-top: 60rpx;
  1073. font-weight: 500;
  1074. }
  1075. }
  1076. ::v-deep .uni-popup .uni-popup__wrapper {
  1077. border-radius: 24rpx 24rpx 0 0;
  1078. }
  1079. ::v-deep .uni-popup .uni-popup__wrapper-box {
  1080. border-radius: 24rpx 24rpx 0 0;
  1081. }
  1082. .more-options {
  1083. position: relative;
  1084. display: inline-block;
  1085. .fa {
  1086. font-size: 40rpx;
  1087. padding: 0 20rpx;
  1088. }
  1089. .dropdown-menu {
  1090. position: absolute;
  1091. top: calc(100% + 10rpx);
  1092. right: 20rpx;
  1093. background-color: #ffffff;
  1094. border-radius: 20rpx;
  1095. padding: 0;
  1096. width: 200rpx;
  1097. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
  1098. z-index: 100;
  1099. transform-origin: top right;
  1100. animation: dropdownAnimation 0.2s ease-out;
  1101. overflow: hidden;
  1102. .dropdown-item {
  1103. padding: 24rpx 0;
  1104. color: #333333;
  1105. font-size: 28rpx;
  1106. position: relative;
  1107. text-align: center;
  1108. &:not(:last-child)::after {
  1109. content: '';
  1110. position: absolute;
  1111. left: 0;
  1112. right: 0;
  1113. bottom: 0;
  1114. height: 1rpx;
  1115. background-color: #EEEEEE;
  1116. }
  1117. &:active {
  1118. background-color: #f8f8f8;
  1119. }
  1120. }
  1121. }
  1122. }
  1123. @keyframes dropdownAnimation {
  1124. 0% {
  1125. opacity: 0;
  1126. transform: scale(0.95) translateY(-5rpx);
  1127. }
  1128. 100% {
  1129. opacity: 1;
  1130. transform: scale(1) translateY(0);
  1131. }
  1132. }
  1133. @keyframes spin {
  1134. to {
  1135. transform: rotate(360deg);
  1136. }
  1137. }
  1138. }
  1139. .agree {
  1140. width: 90%;
  1141. margin: 0 auto;
  1142. color: #666666;
  1143. font-size: 24rpx;
  1144. margin-top: 40rpx;
  1145. display: flex;
  1146. align-items: center;
  1147. text-align: left;
  1148. line-height: 32rpx;
  1149. position: absolute;
  1150. bottom: 210rpx;
  1151. left: 50%;
  1152. transform: translateX(-50%);
  1153. .agree2 {
  1154. display: flex;
  1155. flex-direction: row;
  1156. justify-content: flex-start;
  1157. align-items: center;
  1158. padding-right: 8rpx;
  1159. flex-shrink: 0;
  1160. margin-bottom: 34rpx;
  1161. }
  1162. .xy {
  1163. color: #0084FF;
  1164. display: inline;
  1165. }
  1166. image {
  1167. width: 32rpx;
  1168. height: 32rpx;
  1169. }
  1170. }
  1171. .bottom-pay-btn-bottom {
  1172. width: 626rpx;
  1173. height: 88rpx;
  1174. background: linear-gradient(to left, #1F1F1F, #444444);
  1175. border-radius: 76rpx;
  1176. margin: 0 auto;
  1177. margin-top: 70rpx;
  1178. color: #ACF934;
  1179. display: flex;
  1180. align-items: center;
  1181. justify-content: center;
  1182. font-size: 32rpx;
  1183. line-height: 0;
  1184. position: relative;
  1185. overflow: hidden;
  1186. transition: all 0.3s ease;
  1187. position: absolute;
  1188. bottom: 100rpx;
  1189. left: 50%;
  1190. transform: translateX(-50%);
  1191. .price-value {
  1192. font-size: 44rpx;
  1193. font-family: 'CustomFont';
  1194. }
  1195. &.btn-loading {
  1196. opacity: 0.7;
  1197. pointer-events: none;
  1198. }
  1199. .loading-spinner {
  1200. width: 40rpx;
  1201. height: 40rpx;
  1202. border: 4rpx solid rgba(255, 255, 255, 0.3);
  1203. border-radius: 50%;
  1204. border-top-color: #fff;
  1205. animation: spin 1s linear infinite;
  1206. }
  1207. text {
  1208. display: inline-block;
  1209. margin-right: 10rpx;
  1210. }
  1211. }
  1212. </style>