index.vue 14 KB

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