| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- <template>
- <view class="container">
- <view class="top">
- <image :src="info.details_image" mode=""></image>
- </view>
- <view class="main">
- <view class="title">
- <view class="title-left"></view>
- <view class="title-font">卡片详情</view>
- <view class="title-right"></view>
- </view>
- <view class="detail-desc"><rich-text :nodes="info.introduce"></rich-text></view>
- <view class="btn" @click="buy()">立即购买(¥{{ info.price }})</view>
- <view class="two">
- <label @click="checkboxChange">
- <radio style="transform:scale(0.7)" color="#5dbc7c" :checked="istype" />
- 已阅读并同意
- <text>《优惠卡服务协议》</text>
- </label>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- carddetails,
- wechat,
- routine
- } from '@/api/jdr.js';
- import {
- mapState,
- mapMutations
- } from 'vuex';
- export default {
- data() {
- return {
- id: '',
- info: '',
- istype: false,
- isbuy: false
- };
- },
- computed: {
- // #ifdef H5
- ...mapState(['weichatObj']),
- // #endif
- ...mapState('user', ['userInfo'])
- },
- onLoad(opt) {
- this.id = opt.id;
- this.loadData();
- },
- methods: {
- loadData() {
- carddetails({}, this.id).then(({
- data
- }) => {
- this.info = data;
- });
- },
- navTo(opt) {
- uni.navigateTo({
- url: '/pages/index/cardDetail?id='
- });
- },
- checkboxChange() {
- this.istype = !this.istype;
- console.log(this.istype);
- },
- buy() {
- const obj = this;
- if (!this.istype) {
- return this.$api.msg('请阅读并同意优惠卡服务协议');
- }
- if (this.isbuy) {
- return;
- }
- this.isbuy = true;
- // #ifdef H5
- wechat({
- card_id: this.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) {
- obj.isbuy = false;
- uni.showModal({
- title: '提示',
- content: '购买优惠卡成功是否前往卡券中心激活卡',
- cancelText: '保存卡券',
- confirmText: '立即激活',
- success: function(res) {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/user/coupon'
- });
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- });
- }
- });
- });
- // #endif
- // #ifdef MP-WEIXIN
- routine({
- card_id: this.id
- }).then(e => {
- let da = e.data;
- let data = {
- // #ifdef H5
- timestamp: da.timestamp,
- // #endif
- // #ifdef MP
- timeStamp: da.timestamp,
- // #endif
- nonceStr: da.nonceStr,
- package: da.package,
- signType: da.signType,
- paySign: da.paySign,
- success: function(res) {
- obj.isbuy = false;
- uni.showModal({
- title: '提示',
- content: '购买优惠卡成功是否前往卡券中心激活卡',
- success: function(res) {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/user/coupon'
- });
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- });
- },
- fail: () => {
- obj.isbuy = false;
- }
- };
- wx.requestPayment(data);
- });
- // #endif
- }
- }
- };
- </script>
- <style lang="scss">
- page,
- .container {
- min-height: 100%;
- height: auto;
- background: #ffffff;
- }
- .top {
- position: relative;
- height: 346rpx;
- width: 750rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .main {
- position: relative;
- z-index: 2;
- width: 750rpx;
- background: #ffffff;
- border-radius: 20rpx 20rpx 5rpx 5rpx;
- margin-top: -10rpx;
- padding: 46rpx 44rpx;
- .title {
- display: flex;
- justify-content: center;
- align-items: center;
- .title-font {
- font-size: 32rpx;
- font-family: ZhenyanGB;
- font-weight: 400;
- color: #bd9360;
- }
- }
- }
- .btn {
- width: 620rpx;
- height: 80rpx;
- background: linear-gradient(270deg, #ffe7c4, #ffce8a);
- border-radius: 40rpx;
- margin: 58rpx auto 0;
- font-size: 32rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #9f570e;
- line-height: 80rpx;
- text-align: center;
- }
- .two {
- margin: 26rpx 0 0;
- font-size: 28rpx;
- text-align: center;
- font-family: PingFang SC;
- font-weight: 500;
- color: #999999;
- text {
- color: #ff383e;
- }
- }
- </style>
|