123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328 |
- <template>
- <view class="giftDetail">
- <view class="bannerContainer">
- <swiper class="banner" v-if="type==1">
- <swiper-item v-if="item"><view v-if="item.gift_info.imgurl" class="img" :style="{ backgroundImage: `url(${item.gift_info.imgurl})` }" /></swiper-item>
- </swiper>
- <swiper class="banner" v-else>
- <swiper-item v-if="item"><view v-if="item.img" class="img" :style="{ backgroundImage: `url(${item.img})` }" /></swiper-item>
- </swiper>
- <view class="num">
- <text class="spec">1</text>
- <text>/</text>
- <text>1</text>
- </view>
- </view>
- <view class="good">
- <view class="top">
- <view class="title" v-if="item">{{ item.name }}</view>
- <view class="surplus" v-if="item">限量
- <text v-if="type==1">{{ item.gift_info.gift_num }}份</text>
- <text v-else>{{ item.total }}份</text>
- </view>
- </view>
- <view class="bottom">
- <view class="num">
- <text class="spec">{{ totalPrice }}</text>
- <text>奖学金</text>
- </view>
- <!-- <view class="countNum" v-if="type == 1"><custom-counter :count-num.sync="item.num"></custom-counter></view> -->
- <view class="countNum"><custom-counter :count-num.sync="num"></custom-counter></view>
- </view>
- </view>
- <view class="desc">
- <view class="fixed">产品参数</view>
- <view class="content">本产品由大卫博士平台提供。本页面的信息以及服务由大卫博士交易平台提供,请确保账号处于正常状态。 全部使用奖学金形式兑换!</view>
- </view>
- <view class="submitBtn" @click="submit" v-if="type == 1">确认修改</view>
- <view class="submitBtn" :class="item.surplus === 0 ? 'disable' : ''" @click="submit" v-else>{{ item.surplus ? '立即兑换' : '已兑完' }}</view>
- <toast-confirm :show.sync="toastInfo.show" :title="toastInfo.title" :content="toastInfo.content" @confirm="exchangeConfirm" />
- </view>
- </template>
- <script>
- import { api_getAddress, api_submitExchange ,editGiftOrder, GetBonus } from '../../api.js';
- import customCounter from './components/count2';
- export default {
- components: {
- customCounter
- },
- data() {
- return {
- pageTitle: '礼品详情',
- item: {},
- num: 1,
- type:'',
- requesting: false,
- userServerInfo: {
- bonus: ''
- },
- toastInfo: {
- show: false,
- title: '',
- content: ''
- }
- };
- },
-
-
-
-
-
-
-
-
-
-
-
- computed: {
- totalPrice() {
- if (this.item) {
- return this.item.price * this.num;
- }
- },
-
-
-
-
- },
- onShow() {
- this.getBound()
- },
- methods: {
- getBound(){
- this.$ajax.get(GetBonus).then(([, { data: res }]) => {
-
- this.userServerInfo.bonus = res.data.bonus
- });
- },
- closeToast() {
- this.toastInfo.title = '';
- this.toastInfo.content = '';
- this.toastInfo.show = false;
- },
- exchangeConfirm(flag) {
- const _this = this;
- if (flag) {
- if (!this.requesting) {
- this.requesting = true;
- this.closeToast();
- uni.showLoading();
- this.$ajax.get(`${api_submitExchange}?gift_id=${this.item.id}&num=${this.num}&address_id=123`).then(([, { data: res }]) => {
- uni.hideLoading();
- this.requesting = false;
- if (res.code == 200) {
- uni.navigateTo({
- url:'./success?totalPrice='+this.totalPrice
- })
-
-
-
-
-
-
-
-
-
- } else {
- uni.hideLoading();
- this.requesting = false;
- uni.showModal({
- content: res.msg || '兑换失败:库存不足',
- showCancel: false
- });
- }
- })
- }
- } else {
- this.closeToast();
- }
- },
- submit() {
- if (!this.item.surplus) {
- uni.showModal({
- content: '商品已兑换完',
- showCancel: false
- });
- return false;
- }
- if (this.num) {
- if (this.userServerInfo.bonus >= this.totalPrice) {
- this.toastInfo.title = '温馨提醒';
- this.toastInfo.content = `您确定兑换${this.num}件商品吗?`;
- this.toastInfo.show = true;
- }
- else {
- uni.showModal({
- content: '奖学金余额不足',
- showCancel: false
- });
- }
- } else {
- uni.showModal({
- content: '数量不能为空',
- showCancel: false
- });
- }
- }
- },
- created() {
-
- this.item = getApp().globalData.detail;
- }
- };
- </script>
- <style lang="scss" scoped>
- page {
- display: flex;
- flex-direction: column;
- .giftDetail {
- flex: 1;
- overflow: hidden;
- .bannerContainer {
- width: 100%;
- height: 628rpx;
- position: relative;
- .banner {
- height: 100%;
- width: 100%;
- .img {
- width: 100%;
- height: 100%;
- background-position: center;
- background-repeat: no-repeat;
- background-size: 100%;
- }
- }
- .num {
- position: absolute;
- width: 112rpx;
- height: 48rpx;
- border-radius: 48rpx;
- line-height: 48rpx;
- color: #ffffff;
- font-size: 24rpx;
- bottom: 54rpx;
- right: 44rpx;
- background-color: rgba(0, 0, 0, 0.24);
- text-align: center;
- .spec {
- font-size: 28rpx !important;
- }
- }
- }
- .good {
- width: 100%;
- height: 264rpx;
- background: linear-gradient(94deg, #f97c55 0%, #f44545 100%);
- margin-bottom: 30rpx;
- padding: 10rpx;
- box-sizing: border-box;
- position: relative;
- &::after {
- content: '';
- display: block;
- position: absolute;
- top: 10rpx;
- right: 10rpx;
- width: 174rpx;
- height: 218rpx;
- background-position: top;
- background-size: 100%;
- background-repeat: no-repeat;
- background-image: url(../../static/gift/5.png);
- }
- .top {
- margin-bottom: 20rpx;
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: space-between;
- height: 72rpx;
- padding: 0 20rpx;
- .title {
- color: #ffffff;
- font-size: 40rpx;
- line-height: 56rpx;
- }
- .surplus {
- color: #ffffff;
- font-size: 28rpx;
- align-self: flex-end;
- }
- }
- .bottom {
- width: 100%;
- height: 120rpx;
- border-radius: 8rpx;
- background-color: #ffffff;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 20rpx;
- box-sizing: border-box;
- position: relative;
- z-index: 3;
- overflow: hidden;
- .num {
- color: #ea4a41;
- font-size: 24rpx;
- .spec {
- font-size: 40rpx;
- }
- }
- .countNum {
- width: 180rpx;
- }
- &::before {
- content: '';
- display: block;
- width: 114rpx;
- height: 144rpx;
- position: absolute;
- top: 50%;
- left: 16rpx;
- transform: translateY(-50%);
- background-image: url(../../static/gift/5.png);
- background-position: center;
- background-size: 100%;
- background-repeat: no-repeat;
- }
- }
- }
- .desc {
- width: 100%;
- padding: 30rpx;
- box-sizing: border-box;
- margin-bottom: 100rpx;
- .fixed {
- color: #333333;
- font-size: 32rpx;
- font-weight: bold;
- margin-bottom: 20rpx;
- }
- .content {
- color: #333333;
- font-size: 28rpx;
- line-height: 48rpx;
- }
- }
- .submitBtn {
- width: 530rpx;
- height: 88rpx;
- line-height: 88rpx;
- text-align: center;
- background: linear-gradient(93deg, #f97c55 0%, #f44545 100%);
- color: #ffffff;
- font-size: 32rpx;
- border-radius: 88rpx;
- margin: 0 auto 40rpx auto;
- &.disable {
- background: #999999 !important;
- color: #f8f8f8 !important;
- }
- }
- }
- }
- </style>
|