index.vue 14 KB

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