12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- import {
- mapMutations,
- mapActions
- } from 'vuex';
- import {
- getOptions,
- getPayInfo
- } from "@/common/apis/recharge.js"
- import {
- getUserInfo
- } from "@/common/apis/my.js";
- export default {
- data() {
- return {
- pay_select_id: 0,
- user_info: {},
- payVideoInfo: {},
- payOptions: []
- }
- },
- created() {
- // mixin的created生命周期钩子
- console.log('mixin created');
- },
- methods: {
- getPayInfo(originIndex) {
- getUserInfo().then(res => {
- this.user_info = res.data
- });
- getOptions().then(res => {
- this.payOptions = res.data;
- console.log(res, 'getPayInfogetPayInfogetPayInfogetPayInfo')
- this.payOptions.forEach((item, index) => {
- if (item.is_default == 1) {
- this.pay_select_id = item.id;
- }
- })
- this.payVideoInfo = {
- video_id: this.video_id,
- video_series_sequence: originIndex
- };
- });
- },
- selectPayItem(item) {
- this.pay_select_id = item.id;
- let params = {
- video_id: this.payVideoInfo.video_id,
- video_series_sequence: this.payVideoInfo.video_series_sequence,
- pay_proudct_id: item.id,
- is_first_pay: item.is_first_pay,
- }
- getPayInfo(params).then(res => {
- if (res.data) {
- // #ifdef MP-WEIXIN
- this.wxMinPay(res.data);
- // #endif
- }
- });
- },
- wxMinPay(param) {
- wx.requestPayment({
- timeStamp: param.timeStamp,
- nonceStr: param.nonceStr,
- package: param.package,
- signType: param.signType,
- paySign: param.paySign,
- success(res) {
- this.pay_success = true;
- uni.showToast({
- title: '支付成功',
- icon: "none"
- });
- // console.log('success:' + JSON.stringify(res));
- },
- fail(e) {
- if (e.errMsg == "requestPayment:fail cancel") {
- uni.showToast({
- title: '取消支付',
- icon: "none"
- });
- } else {
- uni.showToast({
- title: '支付失败',
- icon: "none"
- });
- }
- }
- })
- }
- },
- }
|