123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711 |
- <template>
- <view class="content">
- <uni-popup class="popup" ref="popup" type="bottom" background-color="#F8F8F8">
- <view class="popupContent">
- <view class="title">
- 购买卡牌
- <uni-icons class="close" @click="close()" type="closeempty" size="20"></uni-icons>
- </view>
- <view class="row">
- <view class="label">单价</view>
- <view class="value price">¥{{ info.price || 0 }}</view>
- </view>
- <view class="row" v-if="info.type == 1">
- <view class="label">数量</view>
- <view class="value number">
- <view :class="['item', params.raffleNum == 1 ? 'numBerActive' : '']" @click="numChange(1)">一发</view>
- <view :class="['item', params.raffleNum == 3 ? 'numBerActive' : '']" @click="numChange(3)">三发</view>
- <view :class="['item', params.raffleNum == 5 ? 'numBerActive' : '']" @click="numChange(5)">五发</view>
- <view :class="['item', params.raffleNum == 10 ? 'numBerActive' : '']" @click="numChange(10)">十发</view>
- </view>
- </view>
- <view class="row" v-if="[2, 3, 5].includes(info.type)">
- <view class="label">选中卡牌号码</view>
- <view class="value number">
- <view class="item" v-for="(item, index) in params.raffleNumList">
- {{ item }}
- </view>
- </view>
- </view>
- <view class="row">
- <view class="label">优惠券</view>
- <view class="value">
- <view v-if="!selestCouponId && couponList.length > 0" class="hasCoupon" @click="showPopup3">
- 选择优惠券
- <uni-icons type="right" color="#FF2C43" size="20"></uni-icons>
- </view>
- <view
- v-if="!selestCouponId && couponList.length == 0 && unusableList.length > 0"
- class="noCoupon"
- @click="showPopup3"
- >
- 暂无可用优惠券
- <uni-icons type="right" color="#8c8c8c" size="20"></uni-icons>
- </view>
- <view v-if="!selestCouponId && couponList.length == 0 && unusableList.length == 0" class="noCoupon">
- 没有优惠券
- </view>
- <view class="coupon price" @click="showPopup3" v-if="selestCouponId">-¥{{ selestCoupon.discount }}</view>
- </view>
- </view>
- <view class="row">
- <view class="label">
- 抵扣(余额
- <span class="price">0</span>
- )
- </view>
- <view class="value price">¥0</view>
- </view>
- <view class="row">
- <view class="label"></view>
- <view class="value">
- 小计:
- <span class="price">¥{{ priceAll }}</span>
- </view>
- </view>
- <view class="tip">
- <radio class="radio" :checked="checkbox1" @click="checkbox1 = !checkbox1" />
- <span>
- 我已阅读并同意
- <span style="color: #ff8e21">《用户协议》</span>
- </span>
- </view>
- <view class="tip">
- <radio class="radio" :checked="checkbox2" @click="checkbox2 = !checkbox2" />
- <span>本人已满18岁且具备完全行为能力</span>
- </view>
- <image
- @click="submit"
- class="button"
- :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/first/button5.png'"
- mode="widthFix"
- ></image>
- </view>
- </uni-popup>
- <!-- 抽赏结果 -->
- <uni-popup class="popup2" ref="popup2" type="center">
- <image
- class="bk"
- :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/winningLottery/bk.png'"
- mode="widthFix"
- ></image>
- <view class="lotteryResults">
- <view class="title">
- 中奖详情
- <!-- <uni-icons class="close" @click="close2()" type="closeempty" size="20"></uni-icons> -->
- </view>
- <view class="prizes">
- <view class="item" v-for="(item, index) in prizes">
- <image class="img" :src="item.prizeIcon" mode="aspectFill"></image>
- <view class="info">
- <view class="row name">
- <span style="margin-right: 20rpx">{{ item.prizeName }}</span>
- <span v-if="item.prizeType == 4">随机</span>
- <span>{{ item.prizeNum }}张</span>
- </view>
- <view class="row type">
- {{ $selectDictLabel(rewardType, item.prizeType) }}
- </view>
- </view>
- </view>
- <Mloading class="loading" text="抽奖中..." v-if="prizes.length == 0" />
- </view>
- <image
- class="Rectangle"
- :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/winningLottery/Rectangle.png'"
- mode="widthFix"
- ></image>
- <view class="text">已放入背包,可前往背包查看~</view>
- <image
- class="close"
- @click="close2"
- :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/winningLottery/icon.png'"
- mode="widthFix"
- ></image>
- </view>
- </uni-popup>
- <!-- 选则优惠券 -->
- <uni-popup class="popup" ref="popup3" type="bottom" background-color="#F8F8F8">
- <view class="popupContent">
- <view class="title">
- <!-- 选择优惠券 -->
- <uni-icons class="close" @click="close3()" type="closeempty" size="20"></uni-icons>
- </view>
- </view>
- <view class="popupList">
- <view class="tip">可用优惠券</view>
- <view class="card" v-for="(item, index) in couponList" @click="clickSelestCoupon(item)">
- <view class="leftIcon"></view>
- <view class="left">
- ¥
- <span style="font-size: 36rpx">{{ item.discount }}</span>
- </view>
- <view class="right">
- <view class="row title">
- {{ item.name }}
- </view>
- <view class="row endTime">{{ item.endTime }}到期</view>
- <view class="row desc">
- {{ item.desc }}
- </view>
- </view>
- </view>
- <view class="tip">以下优惠券本单暂不适用</view>
- <view class="card unusable" v-for="(item, index) in unusableList">
- <view class="leftIcon"></view>
- <view class="left">
- ¥
- <span style="font-size: 36rpx">{{ item.discount }}</span>
- </view>
- <view class="right">
- <view class="row title">
- {{ item.name }}
- </view>
- <view class="row endTime">{{ item.endTime }}到期</view>
- <view class="row desc">
- {{ item.desc }}
- <span class="reason" v-show="item.reason">({{ item.reason }})</span>
- </view>
- </view>
- </view>
- </view>
- </uni-popup>
- </view>
- </template>
- <script>
- import { rewardType } from '@/utils/commonConfig.js'
- import { buyCouponListApi } from '@/api/coupon.js'
- import { drawCardSubmitApi, submittResultApi, orderPriceApi } from '@/api/drawCard.js'
- import Mloading from '@/component/Mloading.vue'
- export default {
- components: {
- Mloading,
- },
- emits: ['callBack'],
- props: {
- value: {
- type: Object,
- default: {},
- },
- },
- computed: {},
- data() {
- return {
- priceAll: 0,
- rewardType: rewardType,
- checkbox1: false,
- checkbox2: false,
- params: {
- raffleNumList: [],
- raffleNum: null,
- raffleId: null,
- },
- orderId: null,
- prizes: [],
- // prizes: [
- // {
- // prizeType: 1,
- // prizeIcon: 'https://mall.rongtongh.cn/storage/raffle1.jpg',
- // prizeName: 'S赏',
- // prizeNum: 12
- // },
- // {
- // prizeType: 4,
- // prizeIcon: 'https://mall.rongtongh.cn/storage/raffle1.jpg',
- // prizeName: 'S赏',
- // prizeNum: 12
- // },
- // {
- // prizeType: 1,
- // prizeIcon: 'https://mall.rongtongh.cn/storage/raffle1.jpg',
- // prizeName: 'S赏',
- // prizeNum: 12
- // }
- // ],
- getApiNum: 0,
- info: {},
- // 优惠券
- couponList: [],
- // 不可用优惠券
- unusableList: [],
- // 选中的优惠券
- selestCouponId: null,
- selestCoupon: {},
- }
- },
- mounted() {
- // this.$refs.popup2.open('center')
- // this.getLotteryResults()
- },
- methods: {
- getPrice() {
- let params = {
- orderNum: this.params.raffleNumList.length || this.params.raffleNum,
- orderThirdId: this.params.raffleId,
- orderType: 1,
- userCouponId: this.selestCouponId || '',
- }
- orderPriceApi(params).then(res => {
- console.log(res, '订单价格')
- this.priceAll = res.data
- })
- },
- numChange(num) {
- this.params.raffleNum = num
- //计算订单价格
- this.getPrice()
- // 获取优惠券
- this.getCoupon()
- },
- show(params, list, info) {
- console.log(info, 'info')
- this.refresh()
- console.log(list, 'list')
- this.params = {
- ...this.params,
- ...params,
- }
- console.log(toString.call(list), 'toString')
- if (toString.call(list) == '[object Array]') {
- this.params.raffleNumList = list
- } else if (toString.call(list) == '[object Number]') {
- this.params.raffleNum = list
- }
- this.info = info
- this.$refs.popup.open('bottom')
- //计算订单价格
- this.getPrice()
- // 获取优惠券列表
- this.getCoupon()
- },
- refresh() {
- // 刷新组件状态
- this.selestCouponId = null
- this.selestCoupon = {}
- this.prizes = []
- this.checkbox1 = false
- this.checkbox2 = false
- this.orderId = null
- },
- close() {
- this.$refs.popup.close()
- },
- close2() {
- this.$refs.popup2.close()
- },
- showPopup3() {
- // if (this.couponList.length > 0) {
- this.$refs.popup3.open()
- // }
- },
- close3() {
- this.$refs.popup3.close()
- },
- // 获取优惠券
- getCoupon() {
- let params = {
- orderNum: this.params.raffleNumList.length || this.params.raffleNum,
- orderThirdId: this.params.raffleId,
- orderType: 1,
- }
- buyCouponListApi(params).then(res => {
- console.log(res, 'res')
- this.couponList = res.data.usableList
- this.unusableList = res.data.unusableList
- })
- },
- // 选择优惠券
- clickSelestCoupon(item) {
- this.selestCoupon = item
- this.selestCouponId = item.id
- this.getPrice()
- this.close3()
- },
- submit() {
- let _this = this
- if (!this.checkbox1) {
- wx.showModal({
- title: '提示',
- content: '请阅完整读用户协议并勾选。',
- })
- return
- }
- if (!this.checkbox2) {
- wx.showModal({
- title: '提示',
- content: '请确认本人已满18岁且具备完全行为能力并勾选。',
- })
- return
- }
- if (this.selestCouponId) {
- this.params.couponId = this.selestCouponId
- }
- drawCardSubmitApi(this.params).then(res => {
- console.log(res, '提交购买卡牌')
- this.orderId = res.data.orderId
- // 如果不需要付钱,直接进入抽卡结果
- if (res.data.orderStatus == 201) {
- _this.close()
- _this.$refs.popup2.open('center')
- _this.getLotteryResults(res)
- _this.$emit('callBack')
- return
- }
- // 唤起支付
- this.wxPayment(res.data)
- })
- },
- getLotteryResults() {
- let params = {
- orderId: this.orderId,
- raffleId: this.params.raffleId,
- }
- submittResultApi(params).then(res => {
- console.log(res, 'res抽奖结果')
- this.prizes = res.data
- })
- },
- wxPayment(data) {
- let _this = this
- wx.requestPayment({
- timeStamp: data.timeStamp,
- nonceStr: data.nonceStr,
- package: data.packageValue,
- signType: data.signType,
- paySign: data.paySign,
- success: function (res) {
- console.log(res, '支付过程成功')
- _this.close()
- if (_this.info.type == 3) {
- wx.showModal({
- title: '抽奖成功',
- content: '请耐心等待开奖结果。',
- })
- } else {
- _this.$refs.popup2.open('center')
- _this.getLotteryResults(res)
- }
- _this.$emit('callBack')
- },
- fail: function (res) {
- console.log('支付过程失败')
- util.showErrorToast('支付失败')
- },
- complete: function (res) {
- console.log('支付过程结束')
- },
- })
- },
- },
- }
- </script>
- <style scoped lang="scss">
- .popupContent {
- background-color: #f8f8f8;
- border-radius: 20rpx 20rpx 0 0;
- > .row {
- margin: 20rpx 40rpx 0 40rpx;
- display: flex;
- justify-content: space-between;
- padding: 24rpx;
- background: #fff;
- border-radius: 12rpx;
- font-size: 28rpx;
- color: #666666;
- .price {
- color: #ff2c43;
- font-weight: 600;
- }
- .label {
- margin-right: 20rpx;
- }
- .number {
- display: flex;
- flex: 1;
- overflow: auto;
- max-width: 70%;
- // justify-content: flex-end;
- .item {
- width: 96rpx;
- height: 48rpx;
- background: #dddddd;
- border-radius: 102rpx;
- color: #000000;
- line-height: 48rpx;
- text-align: center;
- font-size: 24rpx;
- margin-right: 10rpx;
- flex-grow: 0;
- flex-shrink: 0;
- }
- .numBerActive {
- background: linear-gradient(180deg, #ffad3d 0%, #ff740a 100%);
- color: #fff;
- }
- }
- .value {
- .hasCoupon {
- display: flex;
- align-items: center;
- color: #ff2c43;
- font-size: 24rpx;
- }
- .noCoupon {
- display: flex;
- align-items: center;
- color: #8c8c8c;
- font-size: 24rpx;
- }
- }
- }
- > .title {
- text-align: center;
- padding: 30rpx;
- font-weight: 600;
- .close {
- position: absolute;
- right: 30rpx;
- top: 30rpx;
- }
- }
- }
- .tip {
- margin: 20rpx 40rpx 0 40rpx;
- color: #000000;
- font-size: 24rpx;
- display: flex;
- align-items: center;
- .radio {
- transform: scale(0.7);
- }
- }
- .button {
- margin: 20rpx auto;
- width: 420rpx;
- }
- .popup2 {
- .bk {
- position: relative;
- top: -10vh;
- width: 100vw;
- }
- }
- .lotteryResults {
- width: 76vw;
- padding-top: 124rpx;
- // background: #fff;
- border-radius: 20rpx;
- position: absolute;
- top: -10vh;
- left: 50%;
- transform: translateX(-50%);
- > .title {
- text-align: center;
- padding: 32rpx;
- height: 40rpx;
- font-weight: 600;
- color: #fff;
- .close {
- position: absolute;
- right: 30rpx;
- top: 30rpx;
- }
- }
- .Rectangle {
- width: calc(100% - 2rpx);
- position: absolute;
- bottom: 90rpx;
- left: 6rpx;
- }
- .text {
- width: calc(100% - 2rpx);
- height: 100rpx;
- line-height: 100rpx;
- position: absolute;
- bottom: 90rpx;
- left: 6rpx;
- text-align: center;
- color: #fff;
- text-shadow: 0rpx 2rpx 0rpx rgba(0, 0, 0, 0.5);
- font-size: 24rpx;
- }
- .close {
- width: 60rpx;
- height: 60rpx;
- margin-top: 100rpx;
- position: relative;
- z-index: 4;
- left: 50%;
- transform: translateX(-50%);
- }
- .prizes {
- margin: 60rpx 30rpx 20rpx 38rpx;
- position: relative;
- height: calc(85vw - 60rpx);
- background: linear-gradient(180deg, #f77d4d 0%, #feae81 100%);
- border-radius: 16rpx;
- padding: 20rpx 30rpx;
- overflow: auto;
- .loading {
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translateY(-50%) translateX(-50%);
- }
- .item {
- display: flex;
- // flex-direction: column;
- align-items: center;
- justify-content: center;
- text-align: center;
- // margin-right: 10rpx;
- background: #fff;
- padding: 26rpx 30rpx;
- margin-bottom: 20rpx;
- border-radius: 16rpx;
- .img {
- width: 15vw;
- height: 15vw;
- border-radius: 10rpx;
- }
- .info {
- display: flex;
- flex-direction: column;
- // align-items: center;
- justify-content: center;
- flex: 1;
- .row {
- // width: 100%;
- }
- .name {
- font-size: 28rpx;
- }
- }
- }
- }
- }
- .popupList {
- max-height: 50vh;
- min-height: 30vh;
- overflow: auto;
- background: #f8f8f8;
- padding: 20rpx;
- .tip {
- color: #8c8c8c;
- margin-bottom: 10px;
- text-align: center;
- }
- .card {
- background: #fff;
- border-radius: 16rpx;
- overflow: hidden;
- display: flex;
- margin-bottom: 20rpx;
- .leftIcon {
- height: auto;
- width: 16rpx;
- background: #ff2c43;
- }
- .left {
- width: 160rpx;
- display: inline-flex;
- justify-content: center;
- align-items: center;
- color: #ff2c43;
- font-weight: 600;
- }
- .right {
- padding: 20rpx;
- color: #8e4a21;
- .row {
- margin-bottom: 8rpx;
- font-size: 24rpx;
- }
- .title {
- font-size: 28rpx;
- font-weight: 600;
- }
- .endTime {
- color: #ff2c43;
- }
- .desc {
- margin-top: 10rpx;
- color: #8c8c8c;
- }
- }
- }
- .unusable {
- .leftIcon {
- background: #ffc1c8;
- }
- .left {
- color: #ffc1c8;
- }
- .right {
- padding: 20rpx;
- color: #bf977f;
- .endTime {
- color: #ffc1c8;
- }
- .desc {
- color: #b7b7b7;
- }
- }
- }
- }
- </style>
- <style scoped>
- .popup2 >>> .uni-popup__wrapper {
- top: -8vh;
- }
- </style>
|