index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. <template>
  2. <div class="uc_recharge_container margin-bottom-xl">
  3. <!-- 头部卡片-->
  4. <div class="mine padding">
  5. <div class="flex justify-between">
  6. <view>
  7. <text class="gray">当前剩余时长(分钟)</text>
  8. </view>
  9. <view @click="to_orderlist">
  10. <text class="cuIcon-calendar"></text>
  11. <text class="under_line">我的订单</text>
  12. </view>
  13. </div>
  14. <view>
  15. <text class="mine_min">{{ userinfo.play_time }}</text>
  16. </view>
  17. </div>
  18. <div v-if="userinfo.level==11">
  19. <!-- 标题-->
  20. <div class="title flex padding-left align-center margin-top-xl margin-bottom">
  21. <div class="line margin-right-xs "></div>
  22. <text class="titles">家庭VIP</text>
  23. </div>
  24. <!-- 黄金会员-->
  25. <div
  26. v-for="(item,index) in time_cards"
  27. :key="index"
  28. class="margin-bottom"
  29. >
  30. <div
  31. class="vip"
  32. :class="item.bg"
  33. @click="changeCardShow(item.goods_id)"
  34. >
  35. <van-row>
  36. <van-col
  37. span="10"
  38. offset="6"
  39. >
  40. <div
  41. class="card_body"
  42. style="padding-top:14px;"
  43. >
  44. <view>
  45. <!-- <text class="mine_min text-white">{{ item.play_time }}</text> -->
  46. <text class="text-white">&nbsp;分钟</text>
  47. </view>
  48. <view>
  49. <text class="text-white text-sm subGrey">{{ item.title1 }}</text>
  50. </view>
  51. </div>
  52. </van-col>
  53. <van-col
  54. span="6"
  55. offset="1"
  56. >
  57. <div class="card_body">
  58. <view class="price">
  59. <text class="text-white text-sm">价格</text>
  60. </view>
  61. <view class="text-center">
  62. <text class="text-white mine_min_litt"><text class="text-white text-sm">¥</text>{{ item.price }}</text>
  63. </view>
  64. <view class="text-center">
  65. <button
  66. :class="index==0?'monthly_btn_bg': index==1?'seasonly_btn_bg':'yearly_btn_bg'"
  67. class="check_detail text-white cu-btn round"
  68. v-if="card_action_show == item.goods_id">
  69. 收起详情
  70. </button>
  71. <button
  72. :class="index==0?'monthly_btn_bg': index==1?'seasonly_btn_bg':'yearly_btn_bg'"
  73. class="check_detail text-white cu-btn round"
  74. v-else>
  75. 查看详情
  76. </button>
  77. <!-- <img
  78. src="https://img.shuimuai.com/web/btn_seedetil_1%402x.png"
  79. class="check_detail"
  80. alt=""
  81. v-if="card_action_show == item.goods_id"
  82. >
  83. <img
  84. src="https://img.shuimuai.com/web/btn_seedetil_2.png"
  85. class="check_detail"
  86. alt=""
  87. v-else
  88. > -->
  89. </view>
  90. </div>
  91. </van-col>
  92. </van-row>
  93. </div>
  94. <view v-if="card_action_show == item.goods_id">
  95. <!-- 描述-->
  96. <view class="flex justify-center">
  97. <view
  98. class="desc"
  99. v-html="item.content"
  100. >
  101. </view>
  102. </view>
  103. <!-- 购买按钮-->
  104. <div class="buy_button">
  105. <button
  106. class="cu-btn lg bg-orange text-center margin yellowButt"
  107. @click="to_confirm_vip(item)"
  108. >购买{{item.goods_name}}</button>
  109. </div>
  110. </view>
  111. </div>
  112. <div class="title flex padding-left align-center margin-top-lg margin-bottom">
  113. <div class="line margin-right-xs"></div>
  114. <text class="titles">专注时间包</text>
  115. </div>
  116. <!-- 体验次卡-->
  117. <div
  118. v-for="(item,index) in frequency_card"
  119. :key="index"
  120. class="margin-bottom"
  121. >
  122. <div
  123. class="vip"
  124. :class="item.bgBott"
  125. @click="changeCardShow(item.goods_id)"
  126. >
  127. <van-row>
  128. <van-col
  129. span="10"
  130. offset="6"
  131. >
  132. <div
  133. class="card_body"
  134. style="padding-top:14px;"
  135. >
  136. <view>
  137. <text class="mine_min" :class="index==0?'relax_text':'hard_text'">{{ item.play_time }}</text>
  138. <text :class="index==0?'relax_text':'hard_text'">&nbsp;分钟</text>
  139. </view>
  140. <view>
  141. <text class="text-white text-sm subGrey">{{ item.title1 }}</text>
  142. </view>
  143. </div>
  144. </van-col>
  145. <van-col
  146. span="6"
  147. offset="1"
  148. >
  149. <div class="card_body">
  150. <view class="price">
  151. <text class="text-white text-sm">价格</text>
  152. </view>
  153. <view class="text-center">
  154. <text class="text-white mine_min_litt">{{ item.price }}</text>
  155. </view>
  156. <view class="text-center">
  157. <button
  158. :class="index==0?'relax_btn_bg':'hard_btn_bg'"
  159. class="check_detail text-white cu-btn round"
  160. v-if="card_action_show == item.goods_id">
  161. 收起详情
  162. </button>
  163. <button
  164. :class="index==0?'relax_btn_bg':'hard_btn_bg'"
  165. class="check_detail text-white cu-btn round"
  166. v-else>
  167. 查看详情
  168. </button>
  169. <!-- <img
  170. src="https://img.shuimuai.com/web/btn_seedetil_1%402x.png"
  171. class="check_detail"
  172. alt=""
  173. v-if="card_action_show == item.goods_id"
  174. > -->
  175. <!-- <img
  176. src="https://img.shuimuai.com/web/btn_seedetil_2.png"
  177. class="check_detail"
  178. alt=""
  179. v-else
  180. > -->
  181. </view>
  182. </div>
  183. </van-col>
  184. </van-row>
  185. </div>
  186. <view v-if="card_action_show == item.goods_id">
  187. <!-- 描述-->
  188. <view class="flex justify-center">
  189. <view
  190. class="desc"
  191. v-html="item.content"
  192. >
  193. </view>
  194. </view>
  195. <!-- 购买按钮-->
  196. <div class="buy_button">
  197. <button
  198. class="cu-btn lg bg-orange text-center margin yellowButt"
  199. @click="to_confirm_time(item)"
  200. >购买{{
  201. item.goods_name
  202. }}
  203. </button>
  204. </div>
  205. </view>
  206. </div>
  207. </div>
  208. <div class="text-center scan_wrap" v-else>
  209. <span>请扫包装盒中的VIP会员卡二维码</span>
  210. <button class="text-white cu-btn round scan_btn" @click="to_scan">扫描</button>
  211. </div>
  212. <!-- 购买vip提示弹窗 -->
  213. <van-popup
  214. :show="vip_err_show"
  215. @close="close_err_pop"
  216. round
  217. >
  218. <div class="err_container flex flex-direction align-center justify-around padding-top-xl padding-lr-sm">
  219. <div v-text="cant_buy_vip" class="padding-lr-lg text-lg text-black" style="line-height:28px"></div>
  220. <div class="button_group flex justify-around">
  221. <button
  222. class="cu-btn bg-gray text-white lg margin-right-lg btnFail"
  223. @click="close_err_pop"
  224. >取消</button>
  225. <button
  226. class="cu-btn bg-primary text-white lg btnFail"
  227. @click="to_confirm(buy_vip_item)"
  228. >确认</button>
  229. </div>
  230. </div>
  231. </van-popup>
  232. <!-- 不能购买时间弹窗 -->
  233. <van-popup
  234. :custom-style='cant_buy_popup'
  235. :show="is_cant_buy"
  236. :round="true"
  237. @close="onClosePopup">
  238. <div v-text="cant_buy_time"></div>
  239. </van-popup>
  240. <van-toast id="van-toast"/>
  241. </div>
  242. </template>
  243. <script>
  244. import Toast from "../../../../static/vant/toast/toast";
  245. import { goodsCardList } from "../../../requests/goods";
  246. import { createOrder, deleteOrder } from "../../../requests/orders";
  247. import { vipCode, check_vip } from "../../../requests/vip";
  248. var $this;
  249. export default {
  250. name: "uc_recharge_container",
  251. components: {},
  252. data() {
  253. return {
  254. order: {},
  255. card_action_show: 0,
  256. //时间卡列表
  257. time_cards: [],
  258. //次卡列表
  259. frequency_card: [],
  260. //用户信息
  261. userinfo: {},
  262. // 选中的充值卡
  263. selection_card: {},
  264. // vip购买提示弹窗
  265. vip_err_show:false,
  266. cant_buy_vip:"",
  267. buy_vip_item:{},
  268. // 不可购买时间弹窗
  269. is_cant_buy: false,
  270. cant_buy_time:"",
  271. cant_buy_popup: `height:120px;
  272. width:70%;
  273. display:flex;
  274. padding:10px;
  275. flex-direction:column;
  276. justify-content:center;
  277. align-items:center
  278. `,
  279. };
  280. },
  281. watch: {},
  282. methods: {
  283. to_confirm_vip($item) {
  284. check_vip(1).then((res) => {
  285. console.log("vip", res);
  286. let $res = res.data
  287. if ($res.code == 0) {
  288. $this.to_confirm($item)
  289. }else {
  290. $this.cant_buy_vip = $res.errmsg
  291. $this.buy_vip_item = $item
  292. $this.vip_err_show = true;
  293. }
  294. });
  295. },
  296. //确认订单
  297. to_confirm_time($item) {
  298. // 判断家庭VIP是否过期
  299. check_vip(2).then((res) => {
  300. console.log("vip", res);
  301. let $res = res.data
  302. if ($res.code == 0) {
  303. $this.to_confirm($item)
  304. } else {
  305. $this.cant_buy_time = $res.errmsg
  306. $this.is_cant_buy = true;
  307. }
  308. });
  309. },
  310. // 支付通用
  311. to_confirm($item){
  312. console.log("data", $item);
  313. //实付
  314. if ($item.coupon.type == 3) {
  315. $item["total_price"] =
  316. Math.round($item.price * $item.coupon.discount * 100) / 100;
  317. } else if ($item.coupon.type == 2) {
  318. $item["total_price"] =
  319. Math.round(($item.price - $item.coupon.reduce) * 100) / 100;
  320. } else if ($item.coupon.type == 4) {
  321. $item["total_price"] =
  322. Math.round(($item.price - $item.coupon.random) * 100) / 100;
  323. } else {
  324. $item["total_price"] =
  325. Math.round($item.price * $item.discount * 100) / 100;
  326. }
  327. //减多少
  328. if ($item.coupon.type == 3) {
  329. $item["reduce"] =
  330. Math.round(
  331. ($item.price - $item.price * $item.coupon.discount) * 100
  332. ) / 100;
  333. } else if ($item.coupon.type == 2) {
  334. $item["reduce"] = $item.coupon.reduce;
  335. } else if ($item.coupon.type == 4) {
  336. $item["reduce"] = $item.coupon.random;
  337. }
  338. // $item["total_price"] = ($item.price * $item.discount).toFixed(2);
  339. if ($item.goods_id == 1) {
  340. $item["add_price"] = 20;
  341. $item["add_month"] = "一";
  342. } else if ($item.goods_id == 2) {
  343. $item["add_price"] = 30;
  344. $item["add_month"] = "三";
  345. } else if ($item.goods_id == 3) {
  346. $item["add_price"] = 30;
  347. $item["add_month"] = "三";
  348. }
  349. $this.selection_card = $item;
  350. var data = JSON.stringify($item);
  351. mpvue.navigateTo({
  352. url: "/pages/user_center/confirmPay/main?data=" + data,
  353. });
  354. },
  355. onClosePopup() {
  356. $this.is_cant_buy = false;
  357. },
  358. close_err_pop(){
  359. $this.vip_err_show = false;
  360. },
  361. //跳转填写地址
  362. to_write_address() {
  363. mpvue.navigateTo({
  364. url: "/pages/user_center/address/list/main",
  365. });
  366. },
  367. // 获取充值卡列表
  368. get_card_list() {
  369. goodsCardList().then((res) => {
  370. let $data = res.data.data;
  371. $this.time_cards = $data.time_card;
  372. let $bg = ["gold", "platina", "diamond"];
  373. let $bgBott = ["normal", "oneMonth"];
  374. $this.time_cards.forEach(($val, $index) => {
  375. $this.time_cards[$index]["bg"] = $bg[$index];
  376. $this.time_cards[$index]["price"] = Math.ceil($val["price"]);
  377. });
  378. $this.frequency_card = $data.frequency_card;
  379. $this.frequency_card.forEach(($val, $index) => {
  380. $this.frequency_card[$index]["bgBott"] = $bgBott[$index];
  381. $this.frequency_card[$index]["price"] = Math.round($val["price"]);
  382. });
  383. });
  384. },
  385. to_orderlist() {
  386. mpvue.navigateTo({
  387. url: "/pages/user_center/orders/main",
  388. });
  389. },
  390. // 扫描会员卡
  391. to_scan() {
  392. wx.scanCode({
  393. onlyFromCamera: true,
  394. success(res) {
  395. let $data = res;
  396. if ($data.result) {
  397. // console.log($data.result)
  398. let url = decodeURIComponent($data.result);
  399. let $code = url.match(/\?code=(.*)/);
  400. // 会员码
  401. let $vip_code = $code[1];
  402. vipCode($vip_code).then((res) => {
  403. let $res = res.data;
  404. console.log("vipcode", $res);
  405. if ($res.code == 0) {
  406. mpvue.navigateTo({
  407. url: "/pages/index/main",
  408. });
  409. } else {
  410. Toast.fail($res.errmsg);
  411. }
  412. });
  413. }
  414. },
  415. });
  416. },
  417. // 切换显示
  418. changeCardShow($id) {
  419. // console.log($id);
  420. if ($this.card_action_show == $id) {
  421. $this.card_action_show = 0;
  422. } else {
  423. $this.card_action_show = $id;
  424. }
  425. },
  426. },
  427. mounted() {
  428. $this.get_card_list();
  429. $this.userinfo = wx.getStorageSync("userinfo");
  430. },
  431. onShow() {
  432. $this.get_card_list();
  433. $this.is_cant_buy = false
  434. $this.vip_err_show = false;
  435. },
  436. created() {
  437. $this = this;
  438. },
  439. onLoad() {},
  440. onUnload() {
  441. // $this.close_success_pop();
  442. // $this.close_err_pop();
  443. },
  444. };
  445. </script>
  446. <style scoped>
  447. .mine {
  448. width: 330px;
  449. height: 84px;
  450. background: rgba(242, 243, 255, 0.6);
  451. box-shadow: 0px 3px 7px 0px rgba(159, 159, 159, 0.84);
  452. border-radius: 0px 0px 11px 11px;
  453. margin: 0px auto;
  454. }
  455. .mine_min {
  456. font-size: 36px;
  457. font-family: Microsoft YaHei;
  458. font-weight: 400;
  459. }
  460. .mine_min_litt {
  461. font-size: 30px;
  462. font-family: Microsoft YaHei;
  463. font-weight: 400;
  464. }
  465. .line {
  466. width: 4px;
  467. height: 16px;
  468. background: #5d4db8;
  469. }
  470. /* 扫描 */
  471. .scan_wrap {
  472. width: 100%;
  473. height: 100px;
  474. position: fixed;
  475. left: 50%;
  476. top: 50%;
  477. transform: translate(-50%, -50%);
  478. display: flex;
  479. flex-direction: column;
  480. align-items: center;
  481. justify-content: space-between;
  482. }
  483. .scan_btn {
  484. width: 90%;
  485. height: 40px;
  486. background: #4a73ef;
  487. border-radius: 40px;
  488. }
  489. /*会员*/
  490. .vip {
  491. width: 345px;
  492. height: 103px;
  493. background-position: center;
  494. background-size: 100% 100%;
  495. margin: 0px auto;
  496. }
  497. .gold {
  498. background-image: url("https://img.shuimuai.com/bg_monthly_vip.png");
  499. }
  500. .platina {
  501. background-image: url("https://img.shuimuai.com/bg_seasonly_vip.png");
  502. }
  503. .diamond {
  504. background-image: url("https://img.shuimuai.com/bg_yearly_vip.png");
  505. }
  506. .normal {
  507. background-image: url("https://img.shuimuai.com/bg_relaxly_time.png");
  508. }
  509. .oneMonth {
  510. background-image: url("https://img.shuimuai.com/bg_hardly_time.png");
  511. }
  512. .card_body {
  513. padding: 3px 0px;
  514. }
  515. .check_detail {
  516. width: 90px;
  517. height: 28px;
  518. }
  519. /* 家庭VIP */
  520. .monthly_btn_bg {
  521. background: #ec7945;
  522. }
  523. .seasonly_btn_bg {
  524. background: #1c6cda;
  525. }
  526. .yearly_btn_bg {
  527. background: #5959f8;
  528. }
  529. .btnFail{
  530. width: 146px;
  531. height: 44px;
  532. }
  533. .err_container {
  534. width: 344px;
  535. height: 312px;
  536. }
  537. /* 专注时间包颜色 */
  538. .relax_text {
  539. color: #eb7d07;
  540. }
  541. .hard_text {
  542. color: #4ca8eb;
  543. }
  544. .relax_btn_bg {
  545. background: #e87f12;
  546. }
  547. .hard_btn_bg {
  548. background: #2f9ae8;
  549. }
  550. .desc {
  551. width: 324px;
  552. /* height: 128px; */
  553. margin: 10px auto;
  554. font-size: 10px;
  555. color: #6b6b6b;
  556. line-height: 18px;
  557. }
  558. .titles {
  559. font-size: 15px;
  560. font-family: Microsoft YaHei;
  561. font-weight: 400;
  562. color: #010101;
  563. }
  564. .buy_button {
  565. text-align: center;
  566. }
  567. .order_confirm,
  568. .err_container {
  569. width: 344px;
  570. height: 312px;
  571. }
  572. .order_price_container {
  573. margin-top: 110px;
  574. }
  575. /*充值按钮*/
  576. .recharge_button {
  577. position: absolute;
  578. bottom: 20px;
  579. width: 90%;
  580. }
  581. /*标题*/
  582. .err_container .title {
  583. font-size: 20px;
  584. font-weight: bold;
  585. color: #4c4c4c;
  586. line-height: 24px;
  587. }
  588. .err_img {
  589. width: 73px;
  590. height: 83px;
  591. }
  592. .button_group {
  593. width: 100%;
  594. }
  595. /*子标题*/
  596. .err_container .sub-title {
  597. font-size: 12px;
  598. font-family: Microsoft YaHei;
  599. font-weight: 400;
  600. color: #4b4b4b;
  601. width: 200px;
  602. }
  603. .boy_logo {
  604. width: 167px;
  605. height: 184px;
  606. }
  607. .ext_container {
  608. height: 320px;
  609. /*background-image: url("https://img.shuimuai.com/web/boyya_bg.png");*/
  610. /*background-size: 100% 100%;*/
  611. /*background-position: center;*/
  612. background-color: rgba(255, 255, 255, 0);
  613. }
  614. .under_line {
  615. margin-left: 5px;
  616. font-size: 12px;
  617. font-family: PingFang;
  618. font-weight: 400;
  619. text-decoration: underline;
  620. color: #000000;
  621. }
  622. .gray {
  623. font-size: 12px;
  624. font-family: Microsoft YaHei;
  625. font-weight: 400;
  626. color: #6d6d6d;
  627. }
  628. .title {
  629. margin-left: -8px;
  630. }
  631. .subGrey {
  632. font-size: 10px;
  633. font-family: Microsoft YaHei;
  634. font-weight: 400;
  635. color: #ffffff;
  636. opacity: 0.8;
  637. }
  638. .price {
  639. margin: 3px 0 0 3px;
  640. font-size: 10px;
  641. font-family: Microsoft YaHei;
  642. font-weight: 400;
  643. color: #ffffff;
  644. }
  645. .yellowButt {
  646. width: 320px;
  647. height: 40px;
  648. background: linear-gradient(-90deg, #e1a268 0%, #f7cfaa 100%);
  649. border-radius: 40px;
  650. margin-bottom: 27px;
  651. }
  652. </style>
  653. <style>
  654. </style>