index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <template>
  2. <div class="uc_recharge_container">
  3. <!-- 头部卡片-->
  4. <div class="mine padding">
  5. <div class="flex justify-between">
  6. <view>
  7. <text class="text-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="text-bold mine_min">{{ userinfo.play_time }}</text>
  16. </view>
  17. </div>
  18. <!-- 标题-->
  19. <div class="title flex padding align-center">
  20. <div class="line margin-right"></div>
  21. <text>会员升级</text>
  22. </div>
  23. <!-- 黄金会员-->
  24. <div
  25. v-for="(item,index) in time_cards"
  26. :key="index"
  27. >
  28. <div
  29. class="vip"
  30. :class="item.bg"
  31. @click="changeCardShow(item.goods_id)"
  32. >
  33. <van-row>
  34. <van-col
  35. span="10"
  36. offset="6"
  37. >
  38. <div
  39. class="card_body"
  40. style="padding-top:14px;"
  41. >
  42. <view>
  43. <text class="mine_min text-white">{{ item.play_time }}</text>
  44. <text class="text-white">分钟</text>
  45. </view>
  46. <view>
  47. <text class="text-white text-sm">{{ item.title1 }}</text>
  48. </view>
  49. </div>
  50. </van-col>
  51. <van-col
  52. span="6"
  53. offset="1"
  54. >
  55. <div class="card_body">
  56. <view>
  57. <text class="text-white text-sm">价格</text>
  58. </view>
  59. <view class="text-center">
  60. <text class="text-white mine_min">{{ item.price }} <text class="text-white text-sm">&yen;</text> </text>
  61. </view>
  62. <view class="text-center">
  63. <img
  64. src="https://img.shuimuai.com/web/btn_seedetil_1%402x.png"
  65. class="check_detail"
  66. alt=""
  67. v-if="card_action_show == item.goods_id"
  68. >
  69. <img
  70. src="https://img.shuimuai.com/web/btn_seedetil_2.png"
  71. class="check_detail"
  72. alt=""
  73. v-else
  74. >
  75. </view>
  76. </div>
  77. </van-col>
  78. </van-row>
  79. </div>
  80. <view v-if="card_action_show == item.goods_id">
  81. <!-- 描述-->
  82. <view
  83. class="desc"
  84. v-html="item.content"
  85. >
  86. </view>
  87. <!-- 购买按钮-->
  88. <div class="buy_button">
  89. <button
  90. class="cu-btn lg bg-orange text-center margin "
  91. @click="open_order_confirm(item)"
  92. >购买{{item.goods_name}}</button>
  93. </div>
  94. </view>
  95. </div>
  96. <div class="title flex padding align-center">
  97. <div class="line margin-right"></div>
  98. <text>体验次卡</text>
  99. </div>
  100. <!-- 体验次卡-->
  101. <div
  102. v-for="(item,index) in frequency_card"
  103. :key="index"
  104. >
  105. <div
  106. class="normal vip"
  107. @click="changeCardShow(item.goods_id)"
  108. >
  109. <van-row>
  110. <van-col
  111. span="10"
  112. offset="6"
  113. >
  114. <div
  115. class="card_body"
  116. style="padding-top:14px;"
  117. >
  118. <view>
  119. <text class="mine_min text-white">{{ item.play_time }}</text>
  120. <text class="text-white">次</text>
  121. </view>
  122. <view>
  123. <text class="text-white text-sm">{{ item.title1 }}</text>
  124. </view>
  125. </div>
  126. </van-col>
  127. <van-col
  128. span="6"
  129. offset="1"
  130. >
  131. <div class="card_body">
  132. <view>
  133. <text class="text-white text-sm">价格</text>
  134. </view>
  135. <view class="text-center">
  136. <text class="text-white mine_min">{{ item.price }} <text class="text-white text-sm">&yen;</text> </text>
  137. </view>
  138. <img
  139. src="https://img.shuimuai.com/web/btn_seedetil_1%402x.png"
  140. class="check_detail"
  141. alt=""
  142. v-if="card_action_show == item.goods_id"
  143. >
  144. <img
  145. src="https://img.shuimuai.com/web/btn_seedetil_2.png"
  146. class="check_detail"
  147. alt=""
  148. v-else
  149. >
  150. </div>
  151. </van-col>
  152. </van-row>
  153. </div>
  154. <view v-if="card_action_show == item.goods_id">
  155. <!-- 描述-->
  156. <view
  157. class="desc"
  158. v-html="item.content"
  159. >
  160. </view>
  161. <!-- 购买按钮-->
  162. <div class="buy_button">
  163. <button
  164. class="cu-btn lg bg-orange text-center margin "
  165. @click="open_order_confirm(item)"
  166. >购买{{
  167. item.goods_name
  168. }}
  169. </button>
  170. </div>
  171. </view>
  172. </div>
  173. <!-- 确认订单 弹窗-->
  174. <van-popup
  175. :show="order_confirm"
  176. @close="close_order_confirm"
  177. round
  178. closeable
  179. >
  180. <div class="order_confirm padding">
  181. <view>
  182. <text class="text-sm text-gray">已选商品&emsp;水母星球-{{ selection_card.goods_name }}</text>
  183. <br>
  184. </view>
  185. <view>
  186. <text class="text-sm text-gray">商品价格&emsp;{{ selection_card.price }}元</text>
  187. <br>
  188. </view>
  189. <view>
  190. <text class="text-sm text-gray">支付方式&emsp;微信支付</text>
  191. <br>
  192. </view>
  193. <view v-if="selection_card.goods_id < 4">
  194. <text class="text-sm text-gray">折扣&emsp;{{ selection_card.discount }}</text>
  195. <br>
  196. </view>
  197. <view class="order_price_container">
  198. <text class="text-sm text-gray">实付(元)&emsp;</text>
  199. <text class="mine_min">{{ selection_card.price * selection_card.discount }}</text>
  200. </view>
  201. <button
  202. class="cu-btn bg-primary lg text-white recharge_button"
  203. @click="success_pay"
  204. :disabled="btn_disabled"
  205. >立即充值</button>
  206. </div>
  207. </van-popup>
  208. <!-- 充值失败-->
  209. <van-popup
  210. :show="err_show"
  211. @close="close_err_pop"
  212. round
  213. :close-on-click-overlay="false"
  214. >
  215. <div class="err_container flex flex-direction align-center justify-around">
  216. <view>
  217. <text class="title">
  218. 充值失败,请再次尝试
  219. </text>
  220. </view>
  221. <img
  222. src="https://img.shuimuai.com/web/sign_notimeJfish.png"
  223. class="err_img"
  224. alt=""
  225. >
  226. <div class="button_group flex justify-around">
  227. <button
  228. class="cu-btn bg-gray text-white lg"
  229. @click="close_err_pop"
  230. >取消支付</button>
  231. <button
  232. class="cu-btn bg-primary text-white lg"
  233. @click="repay"
  234. :disabled="btn_disabled"
  235. >再次支付</button>
  236. </div>
  237. </div>
  238. </van-popup>
  239. <!-- 充值成功-->
  240. <van-popup
  241. :show="success_show"
  242. @close="close_success_pop"
  243. round
  244. :close-on-click-overlay="false"
  245. >
  246. <div class="err_container flex flex-direction align-center justify-around ext_container">
  247. <img
  248. src="https://img.shuimuai.com/web/boyya.png"
  249. class="boy_logo"
  250. alt=""
  251. >
  252. <view>
  253. <text class="title">
  254. 充值成功
  255. </text>
  256. </view>
  257. <view
  258. class="sub-title"
  259. v-if="selection_card.goods_id < 4"
  260. >
  261. <text class="text-gray">
  262. {{ selection_card.goods_name }},请到实体店店员处领取邀请卡
  263. </text>
  264. </view>
  265. <div class="button_group flex justify-around">
  266. <!-- <button class="cu-btn bg-gray text-white lg" @click="close_success_pop">以后再填</button>-->
  267. <!-- <button class="cu-btn bg-primary text-white lg" @click="to_write_address">填写地址</button>-->
  268. <button
  269. class="cu-btn bg-primary text-white lg"
  270. @click="to_index"
  271. >充值成功</button>
  272. </div>
  273. </div>
  274. </van-popup>
  275. </div>
  276. </template>
  277. <script>
  278. import { goodsCardList } from "../../../requests/goods";
  279. import { createOrder, deleteOrder } from "../../../requests/orders";
  280. var $this;
  281. export default {
  282. name: "uc_recharge_container",
  283. components: {},
  284. data() {
  285. return {
  286. order: {},
  287. order_confirm: false,
  288. card_action_show: 0,
  289. err_show: false,
  290. success_show: false,
  291. //时间卡列表
  292. time_cards: [],
  293. //次卡列表
  294. frequency_card: [],
  295. //用户信息
  296. userinfo: {},
  297. // 选中的充值卡
  298. selection_card: {},
  299. //支付信息
  300. payment_info: {},
  301. //订单编号
  302. order_sn: "",
  303. btn_disabled: false,
  304. };
  305. },
  306. watch: {},
  307. methods: {
  308. //弹出确认订单
  309. open_order_confirm($item) {
  310. $this.order_confirm = true;
  311. $this.selection_card = $item;
  312. },
  313. //关闭确认订单
  314. close_order_confirm() {
  315. $this.order_confirm = false;
  316. },
  317. //关闭充值失败窗口
  318. close_err_pop() {
  319. $this.err_show = false;
  320. },
  321. //取消充值
  322. cancel_recharge() {
  323. $this.close_err_pop();
  324. deleteOrder($this.order_sn).then(
  325. (res) => {
  326. let $res = res.data;
  327. },
  328. (err) => {
  329. console.log("删除订单错误", err);
  330. }
  331. );
  332. },
  333. // 打开充值成功窗口
  334. open_success_window() {
  335. $this.success_show = true;
  336. },
  337. //关闭充值成功窗口
  338. close_success_pop() {
  339. $this.success_show = false;
  340. },
  341. //再次付款
  342. repay() {
  343. $this.btn_disabled = true;
  344. let $payment = $this.payment_info;
  345. wx.requestPayment({
  346. timeStamp: $payment.timeStamp,
  347. nonceStr: $payment.nonceStr,
  348. package: $payment.package,
  349. signType: $payment.signType,
  350. paySign: $payment.sign,
  351. success(res) {
  352. //支付成功
  353. console.log("success支付成功调用:", res);
  354. //关闭确认订单窗口
  355. $this.close_order_confirm();
  356. $this.close_success_pop();
  357. //打开成功充值窗口
  358. $this.open_success_window();
  359. },
  360. fail(res) {
  361. console.log("success支付失败调用:", res);
  362. $this.cancel_recharge();
  363. $this.close_order_confirm();
  364. $this.err_show = true;
  365. },
  366. complete() {
  367. $this.btn_disabled = false;
  368. },
  369. });
  370. },
  371. to_index() {
  372. mpvue.reLaunch({
  373. url: "/pages/index/main",
  374. });
  375. },
  376. // 成功支付
  377. success_pay() {
  378. $this.btn_disabled = true;
  379. // 支付成功后得回调方法
  380. let $params = {
  381. goods_id: $this.selection_card.goods_id,
  382. buy_num: 1,
  383. };
  384. wx.login({
  385. success(res1) {
  386. console.log("微信登陆", res1.code);
  387. let $code = res1.code;
  388. $params["js_code"] = $code;
  389. createOrder($params).then(
  390. (res) => {
  391. let $data = res.data;
  392. let $payment = $data.data;
  393. $this.order_sn = $payment["sn"];
  394. $this.payment_info = $payment;
  395. wx.requestPayment({
  396. timeStamp: $payment.timeStamp,
  397. nonceStr: $payment.nonceStr,
  398. package: $payment.package,
  399. signType: $payment.signType,
  400. paySign: $payment.sign,
  401. success(res) {
  402. //支付成功
  403. console.log("success", res);
  404. //关闭确认订单窗口
  405. $this.close_order_confirm();
  406. $this.close_success_pop();
  407. //打开成功充值窗口
  408. $this.open_success_window();
  409. },
  410. fail(res) {
  411. console.log("fail", res);
  412. $this.cancel_recharge();
  413. $this.close_order_confirm();
  414. $this.err_show = true;
  415. },
  416. complete() {
  417. $this.btn_disabled = false;
  418. },
  419. });
  420. },
  421. (err) => {
  422. console.log(err);
  423. }
  424. );
  425. },
  426. });
  427. // 接收回调方法后弹出支付成功
  428. },
  429. //跳转填写地址
  430. to_write_address() {
  431. mpvue.navigateTo({
  432. url: "/pages/user_center/address/list/main",
  433. });
  434. },
  435. // 获取充值卡列表
  436. get_card_list() {
  437. goodsCardList().then((res) => {
  438. let $data = res.data.data;
  439. $this.time_cards = $data.time_card;
  440. let $bg = ["gold", "platina", "diamond"];
  441. $this.time_cards.forEach(($val, $index) => {
  442. $this.time_cards[$index]["bg"] = $bg[$index];
  443. $this.time_cards[$index]["price"] = Math.ceil($val["price"]);
  444. });
  445. $this.frequency_card = $data.frequency_card;
  446. $this.frequency_card.forEach(($val, $index) => {
  447. $this.frequency_card[$index]["bg"] = "normal";
  448. $this.frequency_card[$index]["price"] = Math.round($val["price"]);
  449. });
  450. });
  451. },
  452. to_orderlist() {
  453. mpvue.navigateTo({
  454. url: "/pages/user_center/orders/main",
  455. });
  456. },
  457. // 切换显示
  458. changeCardShow($id) {
  459. console.log($id);
  460. if ($this.card_action_show == $id) {
  461. $this.card_action_show = 0;
  462. } else {
  463. $this.card_action_show = $id;
  464. }
  465. },
  466. },
  467. mounted() {
  468. $this.get_card_list();
  469. $this.userinfo = wx.getStorageSync("userinfo");
  470. },
  471. created() {
  472. $this = this;
  473. },
  474. onLoad() {},
  475. onUnload() {
  476. $this.close_success_pop();
  477. $this.close_err_pop();
  478. },
  479. };
  480. </script>
  481. <style scoped>
  482. .uc_recharge_container {
  483. padding: 0px 10px;
  484. }
  485. .mine {
  486. width: 354px;
  487. height: 93px;
  488. background: rgba(242, 243, 255, 0.6);
  489. box-shadow: 0px 3px 7px 0px rgba(159, 159, 159, 0.84);
  490. border-radius: 0px 0px 11px 11px;
  491. margin: 0px auto;
  492. }
  493. .mine_min {
  494. font-size: 40px;
  495. }
  496. .line {
  497. width: 4px;
  498. height: 16px;
  499. background: #5d4db8;
  500. }
  501. /*会员*/
  502. .vip {
  503. width: 345px;
  504. height: 103px;
  505. background-position: center;
  506. background-size: 100% 100%;
  507. margin: 0px auto;
  508. }
  509. .gold {
  510. background-image: url("https://img.shuimuai.com/web/frame_huangjinhuiyuan.png");
  511. }
  512. .platina {
  513. background-image: url("https://img.shuimuai.com/web/frame_baijinhuiyuan.png");
  514. }
  515. .diamond {
  516. background-image: url("https://img.shuimuai.com/web/frame_zuanshihuiyuan.png");
  517. }
  518. .normal {
  519. background-image: url("https://img.shuimuai.com/web/frame_cika.png");
  520. }
  521. .card_body {
  522. padding: 5px 0px;
  523. }
  524. .check_detail {
  525. width: 73px;
  526. height: 22px;
  527. }
  528. .desc {
  529. width: 324px;
  530. /*height: 128px;*/
  531. margin: 10px auto;
  532. font-size: 10px;
  533. color: #6b6b6b;
  534. }
  535. .buy_button {
  536. text-align: center;
  537. }
  538. .order_confirm,
  539. .err_container {
  540. width: 344px;
  541. height: 312px;
  542. }
  543. .order_price_container {
  544. margin-top: 110px;
  545. }
  546. /*充值按钮*/
  547. .recharge_button {
  548. position: absolute;
  549. bottom: 20px;
  550. width: 90%;
  551. }
  552. /*标题*/
  553. .err_container .title {
  554. font-size: 20px;
  555. font-weight: bold;
  556. color: #4c4c4c;
  557. line-height: 24px;
  558. }
  559. .err_img {
  560. width: 73px;
  561. height: 83px;
  562. }
  563. .button_group {
  564. width: 100%;
  565. }
  566. /*子标题*/
  567. .err_container .sub-title {
  568. font-size: 12px;
  569. font-family: Microsoft YaHei;
  570. font-weight: 400;
  571. color: #4b4b4b;
  572. width: 200px;
  573. }
  574. .boy_logo {
  575. width: 167px;
  576. height: 184px;
  577. }
  578. .ext_container {
  579. height: 320px;
  580. /*background-image: url("https://img.shuimuai.com/web/boyya_bg.png");*/
  581. /*background-size: 100% 100%;*/
  582. /*background-position: center;*/
  583. background-color: rgba(255, 255, 255, 0);
  584. }
  585. </style>