123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- <template>
- <view>
- <u-navbar title="充值">
- </u-navbar>
- <view class="recharge">
- <view class="recharge-text">
- <p>账户余额(元)</p>
- <h1>{{detail.balance}}</h1>
- </view>
- <view
- @click="gotoUrl('pages/user/rechargeList')"
- class="recharge-btn">
- 账单
- </view>
- </view>
- <view class="charge">
- <view class="chargeTit">
- 选择充值金额
- </view>
- <view class="chargeMain">
- <template v-for="(item,i) in list">
-
- <view :key="i" :class="{
- 'active':chargingMarketingId==item.id
- }" @click="chargingMarketingId=item.id,selectItem=item"
- class="chargeMain-item "><p>{{item.rechargeAmount}}元</p> <span v-if="item.giftAmount">赠{{item.giftAmount}}元</span></view>
-
-
- </template>
- </view>
- </view>
- <view style=" padding-bottom: 120px; ">
- <view class="charge">
- <view class="chargeRadio">
- <view class="u-flex">
- <u-icon name="weixinzhifu" custom-prefix="custom-icon" color="#22ac38" size="80"></u-icon>
- <view class="chargeRadio-text">
- <h4>微信支付</h4>
- <p>推荐微信支付</p>
- </view>
- </view>
- <u-radio-group>
- <u-radio></u-radio>
- </u-radio-group>
- </view>
- </view>
-
- </view>
-
- <view class="foot-btn">
- <view class="foot-pirce">
- <u-icon name="tikuan" custom-prefix="custom-icon" color="#FF9502" size="48"></u-icon>
- <span>支付 ¥{{selectItem.rechargeAmount}}</span>
- </view>
- <u-button type="primary" @click="submit" :custom-style="customStyle" shape="square">确定充值</u-button>
- </view>
- </view>
- </template>
- <script>
- import * as Pay from '@/apis/weixin.js'
- import {
- wxPayJs
- } from '@/utils/wxpay'
- import * as API from '@/apis/index.js'
-
- export default {
- data() {
- return {
- isReady:false,
- customStyle: {
- background: '#1677ff'
- },
- detail:{},
- chargingMarketingId:'',
- selectItem:{},
- list:[],
- }
- },
- onReady() {
- this.init();
- },
- methods: {
- submit(){
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- Pay.wxpay(this.chargingMarketingId).then((response) => {
- if(!response.result){
- uni.showToast({
- title: response.message
- })
- return
- }
- var data = response.data
- uni.hideLoading()
- console.log("Pay+"+new Date().getTime())
- wxPayJs(data);
-
- }).catch(error => {
- this.$refs.common.showLoading(false, error);
-
- })
- },
- init1(){
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
-
- API.personalCenter().then((res) => {
- this.detail = res.data
- this.isReady=true;
- uni.hideLoading()
-
- }).catch(error => {
- uni.showToast({
- title: error
- })
- })
- },
- init(){
-
-
-
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- var data = {
-
- };
-
-
- API.marketingData(data).then((res) => {
-
- this.list = res.data.chargingMarketingList
- if(this.list.length>0){
- this.selectItem=this.list[0];
- this.chargingMarketingId=this.list[0].id
- }
- uni.hideLoading()
- this.init1()
- }).catch(error => {
- uni.showToast({
-
- title: error
- })
- })
- }
- },onShow(){
- if(this.isReady){
- this.init1()
- }
- }
- }
- </script>
- <style>
- page{
- background-color: #f7f7f7;
- }
- </style>
- <style lang="scss" scoped>
- .recharge{
- padding: 15px;
- background-color: #1677FF;
- margin-bottom: 10px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .recharge-text{
- color:#fff;
- }
- .recharge-btn{
- width: 60px;
- height: 30px;
- text-align: center;
- line-height: 30px;
- background-color: #589EFF;
- color:#fff;
- border-radius: 15px;
- }
- }
- .charge{
- padding: 15px;
- background-color: #fff;
- margin-bottom: 10px;
- }
- .chargeRadio{
- display: flex;
- justify-content: space-between;
- align-items: center;
- width: 100%;
- .chargeRadio-text{
- margin-left: 5px;
- h4{
- font-weight: normal;
- font-size: 15px;
- }
- p{
- font-size: 12px;
- color:#999;
- margin-top: 5px;
- }
- }
- }
- .chargeTit{
- border-bottom: 1px solid #f7f7f7;
- padding-bottom: 10px;
- font-size: 15px;
- }
- .chargeMain{
- display: flex;
- flex-wrap: wrap;
- justify-content: space-between;
- margin-top: 20px;
- .chargeMain-item{
- width: 48%;
- text-align: center;
- padding: 25px 10px;
- border: 2px solid #cacaca;
- margin-bottom: 10px;
- border-radius: 10px;
- color:#333;
- position: relative;
- p{
- font-size: 20px;
- }
- span{
- background-color: #ff8d00;
- color:#fff;
- padding: 2px 10px;
- border-radius:0 10px 0 10px;
- position: absolute;
- font-size: 12px;
- right: -2px;
- top: -2px;
- }
- }
- .active{
- border-color:#ff8d00;
- color:#ff8d00;
- }
- .fault{
- background-color:#e1e1e1;
- color:#666;
- border: 1px solid #ccc;
- }
- .occupy{
- color:#FF4F3F;
- border: 1px solid #FF4F3F;
- }
- }
- .foot-btn{
- padding: 10px;
- position: fixed;
- left: 0;
- right: 0;
- bottom: 0;
- background-color: #fff;
- .foot-pirce{
- display: flex;
- align-items: center;
- span{
- margin-left: 5px;
- font-size: 16px;
- }
- padding-bottom: 10px;
- border-bottom: 1px solid #f7f7f7;
- margin-bottom: 10px;
- }
- }
- </style>
|