| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317 | 
							- <template>
 
-   <view>
 
-     <view class="top-bg"></view>
 
-     <view class="top-box">
 
-       <view class="top">
 
-         <text class="num">{{ account.totalMoney }}</text>
 
-         <text class="p">账户余额</text>
 
-       </view>
 
-       <view class="bottom">
 
-         <view class="t">
 
-           <view class="p">账户:</view>
 
-           <view class="num">{{ account.accountNo }}</view>
 
-         </view>
 
-       </view>
 
-     </view>
 
-     <view class="item">
 
-       <view class="l" style="margin-top: 15rpx;">
 
-         充值金额:
 
-       </view>
 
-       <view class="r">
 
-         <u-input type="number" style="border: 1rpx solid;margin-left: 8rpx;" placeholder="充值金额"
 
-                  v-model="form.money">
 
-         </u-input>
 
-       </view>
 
-     </view>
 
-     <view v-if="money&&money>0" class="pay-money">
 
-       支付金额:
 
-       <text>{{ money }} 元</text>
 
-     </view>
 
-     <view class="btn-box">
 
-       <view class="btn t" @click="chargeFn">立即充值</view>
 
-     </view>
 
-     <view class="discount" v-if="discountList.length>0">
 
-       活动:
 
-       <view v-for="(item,index) in discountList">
 
-         {{ index + 1 }}、充值满{{ item.money }}元
 
-         <text v-if="item.discount<10">打{{ item.discount }}折</text>
 
-         <text v-if="item.subtract">减{{ item.subtract }}元</text>
 
-       </view>
 
-     </view>
 
-   </view>
 
- </template>
 
- <script>
 
- var jweixin = require('@/components/jweixin-module/index.js');
 
- export default {
 
-   data() {
 
-     return {
 
-       account: {
 
-         totalMoney: 0,
 
-         lockMoney: 0,
 
-         activeMoney: 0,
 
-         deposit: 0
 
-       },
 
-       form: {
 
-         money: ''
 
-       },
 
-       code: '',
 
-       openid: '',
 
-       discountList: []
 
-     }
 
-   },
 
-   onLoad(options) {
 
-     this.code = options.code;
 
-     this.getOpenidByCode();
 
-   },
 
-   onBackPress() {
 
-     this.$common.to('/pages/index/index');
 
-     return true;
 
-   },
 
-   mounted() {
 
-     this.getAccountInfo();
 
-     this.getDiscountInfo();
 
-     this.getWxConfig();
 
-   },
 
-   computed: {
 
-     money() {
 
-       let chargeMoney = this.form.money;
 
-       if (chargeMoney) {
 
-         let discountList = this.discountList;
 
-         let sub = 999999;
 
-         let obj = null;
 
-         for (let i in discountList) {
 
-           let discount = discountList[i];
 
-           let m = discount.money;
 
-           let diff = chargeMoney - m;
 
-           if (diff < sub && diff >= 0) {
 
-             sub = diff;
 
-             obj = discount;
 
-           }
 
-         }
 
-         if (obj != null) {
 
-           if (obj.type == 1) {
 
-             return (chargeMoney * (obj.discount / 10)).toFixed(2)
 
-           }
 
-           return chargeMoney - obj.subtract
 
-         }
 
-       }
 
-     }
 
-   },
 
-   methods: {
 
-     getWxConfig() {
 
-       let url = window.location.href;
 
-       this.$api.getWxConfig({
 
-         url: url
 
-       }).then(resp => {
 
-         jweixin.config({
 
-           //debug: true,
 
-           appId: resp.data.appId,
 
-           timestamp: resp.data.timestamp, // 必填,生成签名的时间戳
 
-           nonceStr: resp.data.noncestr, // 必填,生成签名的随机串
 
-           signature: resp.data.sign, // 必填,签名
 
-           jsApiList: ['chooseWXPay'] // 必填,需要使用的JS接口列表
 
-         });
 
-         jweixin.ready(function () {
 
-         });
 
-         jweixin.error(function (res) {
 
-           console.log(res)
 
-         });
 
-       })
 
-     },
 
-     getOpenidByCode() {
 
-       let storeOpenid = uni.getStorageSync('openid');
 
-       this.$api.getOpenidByCode({
 
-         code: this.code,
 
-         openid: storeOpenid
 
-       }).then(resp => {
 
-         let openid = resp.data;
 
-         this.openid = openid;
 
-         if (openid) {
 
-           uni.setStorageSync('openid', openid)
 
-         }
 
-       })
 
-     },
 
-     getAccountInfo() {
 
-       this.$api.getAccountInfo().then(resp => {
 
-         this.account = resp.data;
 
-       })
 
-     },
 
-     getDiscountInfo() {
 
-       this.$api.getDiscountInfo().then(resp => {
 
-         this.discountList = resp.data;
 
-       })
 
-     },
 
-     chargeFn() {
 
-       let money = this.form.money;
 
-       if (!money) {
 
-         this.$common.toast('请输入充值金额');
 
-       }
 
-       let a = {
 
-         id: this.account.id,
 
-         c: money
 
-       }
 
-       let p = {
 
-         a: JSON.stringify(a),
 
-         money: this.money > 0 ? this.money : money,
 
-         tradeType: "JSAPI",
 
-         openid: this.openid
 
-       }
 
-       p.desc = "A1-账户充值";
 
-       this.$api.getPrePay(this.$common.removeNull(p)).then(resp => {
 
-         let data = resp.data;
 
-         let that = this;
 
-         jweixin.chooseWXPay({
 
-           timestamp: data
 
-               .timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
 
-           nonceStr: data.nonceStr, // 支付签名随机串,不长于 32 位
 
-           package: data.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
 
-           signType: data.signType, // 微信支付V3的传入RSA,微信支付V2的传入格式与V2统一下单的签名格式保持一致
 
-           paySign: data.paySign, // 支付签名
 
-           success: function (res) {
 
-             if (res.errMsg === "chooseWXPay:ok") {
 
-               that.$common.toast('支付成功')
 
-               that.cars = [];
 
-               that.item.list = [];
 
-               that.total = 0
 
-               // wx.closeWindow();
 
-             }
 
-           }
 
-         });
 
-       })
 
-     }
 
-   }
 
- }
 
- </script>
 
- <style lang="scss">
 
- page {
 
-   background-color: #fff;
 
- }
 
- .top-bg {
 
-   width: 100%;
 
-   height: 400rpx;
 
-   position: absolute;
 
-   z-index: 0;
 
-   background-image: linear-gradient(0deg, #fff 0%, #0080ff 40%);
 
- }
 
- .top-box {
 
-   position: relative;
 
-   z-index: 1;
 
-   .top {
 
-     display: flex;
 
-     flex-direction: column;
 
-     align-items: center;
 
-     justify-content: center;
 
-     .num {
 
-       color: #fff;
 
-       font-size: 60rpx;
 
-       margin-top: 50rpx;
 
-     }
 
-     .p {
 
-       color: rgba(255, 255, 255, .7);
 
-       margin-top: 10rpx;
 
-     }
 
-   }
 
-   .bottom {
 
-     display: flex;
 
-     background-color: #fff;
 
-     border-radius: 20rpx;
 
-     margin: 40rpx;
 
-     flex-direction: column;
 
-     align-items: center;
 
-     justify-content: center;
 
-     .t {
 
-       display: flex;
 
-       width: 100%;
 
-       padding: 40rpx 30rpx;
 
-       box-sizing: border-box;
 
-       border-bottom: 1px solid #eee;
 
-       .p,
 
-       .num {
 
-         font-size: 30rpx;
 
-         color: #191919;
 
-       }
 
-       .num {
 
-         margin-left: 30rpx;
 
-       }
 
-     }
 
-     .b {
 
-       display: flex;
 
-       width: 100%;
 
-       padding-bottom: 60rpx;
 
-     }
 
-   }
 
- }
 
- .item {
 
-   display: flex;
 
-   margin-top: 100rpx;
 
-   margin-left: 60rpx;
 
- }
 
- .btn-box {
 
-   position: relative;
 
-   z-index: 1;
 
-   display: flex;
 
-   border-radius: 20rpx;
 
-   display: flex;
 
-   margin: 30rpx;
 
-   padding: 30rpx;
 
-   flex-direction: column;
 
-   .btn {
 
-     height: 88rpx;
 
-     width: 70%;
 
-     color: #fff;
 
-     margin: 20rpx auto;
 
-     display: flex;
 
-     align-items: center;
 
-     justify-content: center;
 
-     border-radius: 10rpx;
 
-   }
 
-   .t {
 
-     background-color: #0080ff;
 
-   }
 
-   .b {
 
-     background-color: #ffb400;
 
-   }
 
- }
 
- .pay-money {
 
-   margin: 20rpx 0 0 120rpx;
 
-   font-size: 30rpx;
 
-   text {
 
-     color: red;
 
-     font-weight: bold;
 
-   }
 
- }
 
- .discount {
 
-   margin: 0 0 0 60rpx;
 
-   font-size: 27rpx;
 
-   view {
 
-     margin-left: 20rpx;
 
-     padding-top: 10rpx;
 
-   }
 
- }
 
- </style>
 
 
  |