index.vue 35 KB

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