| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- <template>
- <view class="content">
- <view class="store-info flex">
- <image :src="store_logo" mode="" class="store-logo"></image>
- <view class="store-name">
- {{store_name}}
- </view>
- </view>
- <view class="money-box">
- ¥
- <input type="text" value="" v-model="money" placeholder="请输入充值金额" placeholder-class="place"/>
- </view>
- <view class="sub" @click="!payLoding ? confirm() : ''" :class="{'disable': payLoding}">
- 确认付款
- </view>
- </view>
- </template>
- <script>
- // #ifdef H5
- import { rechargeWechat ,userBalance} from '@/api/wallet.js';
- // #endif
- // #ifdef MP
- import { rechargeRoutine ,userBalance} from '@/api/wallet.js';
- // #endif
- export default {
- data() {
- return {
- type: 'weixin',
- money: '',
- store_name: '',
- store_logo: '',
- store_id: '',
- payLoding: false
- }
- },
- onLoad(opt) {
- console.log(opt.store_name)
- this.store_name = opt.store_name
- this.store_logo = opt.store_logo
- this.store_id = opt.store_id
-
- },
- methods: {
- // 提交
- confirm() {
- let obj = this;
- if(obj.money == 0){
- return this.$api.msg('请输入充值金额');
- }
- console.log(obj.money,'ddddddddddddddddddddddddddddddddddddddddddd')
- // if(!this.isSect) {
- // return this.$api.msg('请选择支付方式');
- // }
- if (wx.requestSubscribeMessage) {
- wx.requestSubscribeMessage({
- tmplIds: ['HgPU5FHUTwqGNSkJ7IsAP0XkJZV3UUf9fjUWUD3ebZY'],
- success(res) {
- console.log(res,'订阅消息')
- },
- fail(err) {
- console.log(err)
- },
- complete() {
- obj.payLoding = true;
- // #ifdef H5
- console.log('H5++++++++++++++++')
- rechargeWechat({
- price: obj.money,
- from: obj.type,
- store_id: obj.store_id
- })
- .then(e => {
- let da = e.data.data;
- obj.weichatObj.chooseWXPay({
- timestamp: da.timestamp,
- nonceStr: da.nonceStr,
- package: da.package,
- signType: da.signType,
- paySign: da.paySign,
- success: function(res) {
- uni.showToast({
- title: '充值成功',
- duration: 2000,
- position: 'top'
- });
- }
- });
- obj.payLoding = false;
- })
- .catch(e => {
- obj.payLoding = false;
- console.log(e);
- });
- // #endif
- // #ifdef MP
- console.log('MP++++++++++++++++')
- rechargeRoutine({
- price: obj.money,
- store_id: obj.store_id
- })
- .then(e => {
- let da = e.data;
- wx.requestPayment({
- timeStamp: da.timestamp,
- nonceStr: da.nonceStr,
- package: da.package,
- signType: da.signType,
- paySign: da.paySign,
- success: function(res) {
- uni.redirectTo({
- url: '/pages/money/paySuccess?isshow=false'
- });
- }
- });
-
- obj.payLoding = false;
- })
- .catch(e => {
- obj.payLoding = false;
- console.log(e);
- });
- // #endif
- }
- })
- } else {
- obj.payLoding = true;
- // #ifdef H5
- console.log('H5++++++++++++++++')
- rechargeWechat({
- price: obj.money,
- from: obj.type,
- store_id: obj.store_id
- })
- .then(e => {
- let da = e.data.data;
- obj.weichatObj.chooseWXPay({
- timestamp: da.timestamp,
- nonceStr: da.nonceStr,
- package: da.package,
- signType: da.signType,
- paySign: da.paySign,
- success: function(res) {
- uni.showToast({
- title: '充值成功',
- duration: 2000,
- position: 'top'
- });
- }
- });
- obj.payLoding = false;
- })
- .catch(e => {
- obj.payLoding = false;
- console.log(e);
- });
- // #endif
- // #ifdef MP
- console.log('MP++++++++++++++++')
- rechargeRoutine({
- price: obj.money,
- store_id: obj.store_id
- })
- .then(e => {
- let da = e.data;
- wx.requestPayment({
- timeStamp: da.timestamp,
- nonceStr: da.nonceStr,
- package: da.package,
- signType: da.signType,
- paySign: da.paySign,
- success: function(res) {
- uni.redirectTo({
- url: '/pages/money/paySuccess?isshow=false'
- });
- }
- });
-
- obj.payLoding = false;
- })
- .catch(e => {
- obj.payLoding = false;
- console.log(e);
- });
- // #endif
- }
-
- },
- }
-
-
- }
- </script>
- <style lang="scss" scoped>
- .store-info {
- padding: 46rpx 30rpx;
- justify-content: flex-start;
- align-items: center;
- .store-logo {
- width: 82rpx;
- height: 82rpx;
- border-radius: 50%;
- background: #eee;
- border-radius: 5px;
- margin-right: 17rpx;
- }
- .store-name {
- font-size: 32rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #000000;
- }
- }
- .money-box {
- font-size: 60rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #000000;
- padding: 30rpx 30rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- input {
- flex-grow: 1;
- padding-left: 20rpx;
- font-size: 40rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #000000;
- // display: inline-block;
- }
- }
- .sub {
- margin:138rpx auto 0;
- width: 685rpx;
- line-height: 93rpx;
- background: #901B21;
- border-radius: 5px;
- text-align: center;
-
- font-size: 36rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #FFFFFF;
- }
- .disable {
- background-color: #999;
- }
- .place {
- font-size: 24rpx;
- }
- </style>
|