index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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="8" offset="6">
  28. <div class="card_body">
  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. <view>
  37. <text class="text-white text-sm">{{ item.title2 }}</text>
  38. </view>
  39. </div>
  40. </van-col>
  41. <van-col span="5" offset="4">
  42. <div class="card_body">
  43. <view>
  44. <text class="text-white text-sm">价格</text>
  45. </view>
  46. <view>
  47. <text class="text-white mine_min">{{ item.price }}</text>
  48. </view>
  49. <img src="https://img.shuimuai.com/web/btn_seedetil_2.png" class="check_detail" alt=""
  50. @click="card_action_show = item.goods_id">
  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="8" offset="6">
  77. <div class="card_body">
  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. <view>
  86. <text class="text-white text-sm">{{ item.title2 }}</text>
  87. </view>
  88. </div>
  89. </van-col>
  90. <van-col span="5" offset="4">
  91. <div class="card_body">
  92. <view>
  93. <text class="text-white text-sm">价格</text>
  94. </view>
  95. <view>
  96. <text class="text-white mine_min">{{ item.price }}</text>
  97. </view>
  98. <img src="https://img.shuimuai.com/web/btn_seedetil_2.png" class="check_detail" alt=""
  99. @click="card_action_show = item.goods_id">
  100. </div>
  101. </van-col>
  102. </van-row>
  103. </div>
  104. <view v-if="card_action_show == item.goods_id">
  105. <!-- 描述-->
  106. <view class="desc" v-html="item.content">
  107. </view>
  108. <!-- 购买按钮-->
  109. <div class="buy_button">
  110. <button class="cu-btn lg bg-orange text-center margin " @click="open_order_confirm(item)">购买{{
  111. item.goods_name
  112. }}
  113. </button>
  114. </div>
  115. </view>
  116. </div>
  117. <!-- 确认订单 弹窗-->
  118. <van-popup :show="order_confirm" @close="close_order_confirm" round closeable>
  119. <div class="order_confirm padding">
  120. <view>
  121. <text class="text-sm text-gray">已选商品&emsp;水母星球-{{ selection_card.goods_name }}</text>
  122. <br>
  123. </view>
  124. <view>
  125. <text class="text-sm text-gray">商品价格&emsp;{{ selection_card.price }}元</text>
  126. <br>
  127. </view>
  128. <view>
  129. <text class="text-sm text-gray">支付方式&emsp;微信支付</text>
  130. <br>
  131. </view>
  132. <view v-if="selection_card.discount">
  133. <text class="text-sm text-gray">折扣&emsp;{{ selection_card.discount }}</text>
  134. <br>
  135. </view>
  136. <view class="order_price_container">
  137. <text class="text-sm text-gray">实付(元)&emsp;</text>
  138. <text class="mine_min">{{ selection_card.price * selection_card.discount }}</text>
  139. </view>
  140. <button class="cu-btn bg-primary lg text-white recharge_button" @click="success_pay">立即充值</button>
  141. </div>
  142. </van-popup>
  143. <!-- 充值失败-->
  144. <van-popup :show="err_show" @close="close_err_pop" round :close-on-click-overlay="false">
  145. <div class="err_container flex flex-direction align-center justify-around">
  146. <view>
  147. <text class="title">
  148. 充值失败,请再次尝试
  149. </text>
  150. </view>
  151. <img src="https://img.shuimuai.com/web/sign_notimeJfish.png" class="err_img" alt="">
  152. <div class="button_group flex justify-around">
  153. <button class="cu-btn bg-gray text-white lg" @click="cancel_recharge">取消支付</button>
  154. <button class="cu-btn bg-primary text-white lg" @click="repay">再次支付</button>
  155. </div>
  156. </div>
  157. </van-popup>
  158. <!-- 充值成功-->
  159. <van-popup :show="success_show" @close="close_success_pop" round :close-on-click-overlay="false">
  160. <div class="err_container flex flex-direction align-center justify-around ext_container">
  161. <img src="https://img.shuimuai.com/web/boyya.png" class="boy_logo" alt="">
  162. <view>
  163. <text class="title">
  164. 充值成功
  165. </text>
  166. </view>
  167. <view class="sub-title">
  168. <text class="text-gray">
  169. {{ selection_card.goods_name }},请到实体店店员处领取邀请卡
  170. </text>
  171. </view>
  172. <div class="button_group flex justify-around">
  173. <!-- <button class="cu-btn bg-gray text-white lg" @click="close_success_pop">以后再填</button>-->
  174. <!-- <button class="cu-btn bg-primary text-white lg" @click="to_write_address">填写地址</button>-->
  175. <button class="cu-btn bg-primary text-white lg" @click="to_index">充值成功</button>
  176. </div>
  177. </div>
  178. </van-popup>
  179. </div>
  180. </template>
  181. <script>
  182. import {goodsCardList} from "../../../requests/goods";
  183. import {createOrder} from "../../../requests/orders";
  184. var $this
  185. export default {
  186. name: "uc_recharge_container",
  187. components: {},
  188. data() {
  189. return {
  190. order: {},
  191. order_confirm: false,
  192. card_action_show: 1,
  193. err_show: false,
  194. success_show: false,
  195. //时间卡列表
  196. time_cards: [],
  197. //次卡列表
  198. frequency_card: [],
  199. //用户信息
  200. userinfo: {},
  201. // 选中的充值卡
  202. selection_card: {},
  203. //支付信息
  204. payment_info: {}
  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. },
  226. // 打开充值成功窗口
  227. open_success_window() {
  228. $this.success_show = true
  229. },
  230. //关闭充值成功窗口
  231. close_success_pop() {
  232. $this.success_show = false
  233. },
  234. //再次付款
  235. repay() {
  236. let $payment = $this.payment_info
  237. wx.requestPayment({
  238. timeStamp: $payment.timeStamp,
  239. nonceStr: $payment.nonceStr,
  240. package: $payment.package,
  241. signType: $payment.signType,
  242. paySign: $payment.sign,
  243. success(res) {
  244. //支付成功
  245. console.log('success', res)
  246. //关闭确认订单窗口
  247. $this.close_order_confirm()
  248. $this.close_success_pop()
  249. //打开成功充值窗口
  250. $this.open_success_window()
  251. },
  252. fail(res) {
  253. console.log('fail', res)
  254. $this.close_order_confirm()
  255. $this.err_show = true
  256. }
  257. })
  258. },
  259. to_index() {
  260. mpvue.reLaunch({
  261. url: "/pages/index/main"
  262. })
  263. },
  264. // 成功支付
  265. success_pay() {
  266. // 支付成功后得回调方法
  267. let $params = {
  268. goods_id: $this.selection_card.goods_id,
  269. buy_num: 1
  270. }
  271. createOrder($params).then((res) => {
  272. let $data = res.data
  273. let $payment = $data.data
  274. $this.payment_info = $payment
  275. wx.requestPayment({
  276. timeStamp: $payment.timeStamp,
  277. nonceStr: $payment.nonceStr,
  278. package: $payment.package,
  279. signType: $payment.signType,
  280. paySign: $payment.sign,
  281. success(res) {
  282. //支付成功
  283. console.log('success', res)
  284. //关闭确认订单窗口
  285. $this.close_order_confirm()
  286. $this.close_success_pop()
  287. //打开成功充值窗口
  288. $this.open_success_window()
  289. },
  290. fail(res) {
  291. console.log('fail', res)
  292. $this.close_order_confirm()
  293. $this.err_show = true
  294. }
  295. })
  296. },
  297. (err) => {
  298. console.log(err)
  299. }
  300. )
  301. // 接收回调方法后弹出支付成功
  302. },
  303. //跳转填写地址
  304. to_write_address() {
  305. mpvue.navigateTo({
  306. url: "/pages/user_center/address/list/main"
  307. })
  308. },
  309. // 获取充值卡列表
  310. get_card_list() {
  311. goodsCardList().then((res) => {
  312. let $data = res.data.data
  313. $this.time_cards = $data.time_card
  314. let $bg = ['gold', 'platina', 'diamond']
  315. $this.time_cards.forEach(($val, $index) => {
  316. $this.time_cards[$index]['bg'] = $bg[$index]
  317. $this.time_cards[$index]['price'] = Math.ceil($val['price'])
  318. })
  319. $this.frequency_card = $data.frequency_card
  320. $this.frequency_card.forEach(($val, $index) => {
  321. $this.frequency_card[$index]['bg'] = 'normal'
  322. $this.frequency_card[$index]['price'] = Math.round($val['price'])
  323. })
  324. })
  325. },
  326. to_orderlist() {
  327. mpvue.navigateTo({
  328. url: "/pages/user_center/orders/main"
  329. })
  330. }
  331. }
  332. ,
  333. mounted() {
  334. $this.get_card_list()
  335. $this.userinfo = wx.getStorageSync('userinfo')
  336. },
  337. created() {
  338. $this = this;
  339. },
  340. onLoad() {
  341. },
  342. onUnload() {
  343. $this.close_success_pop()
  344. }
  345. }
  346. </script>
  347. <style scoped>
  348. @import "index.css";
  349. </style>