123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362 |
- <template>
- <view>
- <u-navbar title="兑换详情" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
- <view class="detail">
- <view class="detail-top">
- <u-swiper :list="picUrlArr" height="348" :indicator="true" :circular="true"></u-swiper>
- </view>
- <view class="detail-title">
- <view class="txt">{{ info.title }}</view>
- <view class="coin">
- <image src="../../static/logo.png" mode=""></image>
- <view>x {{ info.exchangePrice }}</view>
- </view>
- </view>
- <view class="detail-goods">商品详情</view>
- <view class="detail-description">
- <view class="" v-html="description"></view>
- </view>
- </view>
- <view class="footer-fixed">
- <view class="flex btn">
- <button type="default" @click="exChange">立即兑换</button>
- </view>
- </view>
- <!-- 兑换选择 -->
- <u-popup :show="choiceShow" mode="bottom" @close="close" :closeable="true">
- <view class="choiceShow-wrap">
- <view class="flex goods">
- <view class="flex image-wrap">
- <image src="../../static/logo.png" mode="aspectFill"></image>
- </view>
- <view class="info">
- <view class="info-title">Apple iPhone 13 (A2634) 128GB 星光色 支持移动联通电信5G 双卡双待手机</view>
- <view class="info-coin">
- <image src="../../static/logo.png" mode=""></image>
- <view>x 6800</view>
- </view>
- <view class="info-stock">库存:234</view>
- </view>
- </view>
- <view class="sku">
- <view class="sku-title">颜色</view>
- <view class="flex sku-list">
- <view class="sku-list-item">红色</view>
- <view class="sku-list-item">黑色</view>
- </view>
- </view>
- <view class="sku">
- <view class="sku-title">颜色</view>
- <view class="flex sku-list">
- <view class="sku-list-item">红色</view>
- <view class="sku-list-item">黑色</view>
- </view>
- </view>
- <view class="flex quantity">
- <view class="quantity-title">兑换数量</view>
- <view class="quantity-title">
- <u-number-box v-model="value" :min="1" @change="valChange"></u-number-box>
- </view>
- </view>
- <view class="flex btn">
- <view class="flex btn-left">
- <view class="title">应付:</view>
- <view class="flex coin">
- <image src="../../static/logo.png" mode=""></image>
- <view>x 6800</view>
- </view>
- </view>
- <view class="btn-right">
- <view class="confirm">立即兑换</view>
- </view>
- </view>
- </view>
- </u-popup>
- </view>
- </template>
- <script>
- import env from '../../config/env.js'
- import $http from '@/utils/request.js'
- export default {
- data() {
- return {
- boxId: '',
- picUrlArr: [],
- info: {},
- prizeList: [],
- description: '',
- choiceShow: false,
- value: 1,
- };
- },
- onLoad(opthios) {
- this.getDetail(opthios.id)
- },
- methods: {
- getDetail(id) {
- $http.post('/api/v1/mp/user/exchange/goods/detail', {
- goodsId: id
- }).then(res => {
- if (res.code == 0) {
- this.info = res.data
- let picUrlArr = res.data.picUrl.split(',')
- picUrlArr.forEach(item => {
- this.picUrlArr.push(env.filePublic + item)
- })
- // 处理富文本
- this.description = this.formatRichText(res.data.description);
- }
- })
- },
- exChange() {
- this.choiceShow = true
- },
- close() {
- this.choiceShow = false
- },
- valChange(e) {
- console.log(e);
- },
-
- /**
- * 处理富文本里的图片宽度自适应
- * 1.去掉img标签里的style、width、height属性
- * 2.img标签添加style属性:max-width:100%;height:auto
- * 3.修改所有style里的width属性为max-width:100%
- * 4.去掉<br/>标签
- * @param html
- * @returns {void|string|*}
- */
- formatRichText(html) { //控制小程序中图片大小
- let newContent = html.replace(/<img[^>]*>/gi, function(match, capture) {
- match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
- match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
- match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
- return match;
- });
- newContent = newContent.replace(/style="[^"]+"/gi, function(match, capture) {
- match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi,
- 'max-width:100%;');
- return match;
- });
- newContent = newContent.replace(/<br[^>]*\/>/gi, '');
- newContent = newContent.replace(/\<img/gi,
- '<img style="max-width:100%;height:auto;margin:10rpx auto;"');
- return newContent;
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- </style>
- <style lang="scss" scoped>
- .detail {
- padding-bottom: 100rpx;
- &-top {
- height: 696rpx;
- background-color: #FFFFFF;
- }
- &-title {
- padding: 24rpx;
- background-color: #FFFFFF;
- margin-bottom: 10rpx;
- .txt {
- font-size: 32rpx;
- line-height: 44rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- margin-bottom: 24rpx;
- font-weight: bold;
- }
- .coin {
- display: flex;
- align-items: center;
- font-size: 32rpx;
- line-height: 44rpx;
- color: rgba(235, 112, 9, 100);
- }
- image {
- width: 42rpx;
- height: 42rpx;
- margin-right: 20rpx;
- }
- }
- &-goods {
- height: 88rpx;
- text-align: center;
- line-height: 88rpx;
- font-weight: bold;
- background-color: #FFFFFF;
- }
-
- &-description {
- image{
- width: 100%;
- }
- }
- }
- .choiceShow-wrap {
- min-height: 400rpx;
- padding: 80rpx 20rpx 60rpx;
- .goods {
- justify-content: space-between;
- margin-bottom: 20rpx;
- .image-wrap {
- width: 220rpx;
- height: 220rpx;
- border: 1px solid rgba(236, 236, 236, 100);
- border-radius: 10rpx;
- image {
- width: 174rpx;
- height: 174rpx;
- }
- }
- .info {
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- padding-left: 26rpx;
- &-title {
- font-size: 32rpx;
- line-height: 44rpx;
- font-weight: bold;
- }
- &-coin {
- display: flex;
- align-items: center;
- font-size: 32rpx;
- line-height: 44rpx;
- color: rgba(235, 112, 9, 100);
- font-weight: bold;
- image {
- width: 42rpx;
- height: 42rpx;
- margin-right: 20rpx;
- }
- }
- &-stock {
- line-height: 44rpx;
- }
- }
- }
- .sku {
- margin-bottom: 30rpx;
- &-title {
- line-height: 42rpx;
- }
- &-list {
- justify-content: flex-start;
- &-item {
- line-height: 44rpx;
- padding: 0 20rpx;
- border: 1px solid rgba(187, 187, 187, 100);
- margin-left: 36rpx;
- }
- &-item:first-child {
- margin-left: 0;
- }
- }
- }
- .quantity {
- justify-content: space-between;
- margin-bottom: 40rpx;
- }
- .btn {
- justify-content: space-between;
- &-left {
- .coin {
- display: flex;
- align-items: center;
- font-size: 32rpx;
- line-height: 44rpx;
- color: rgba(235, 112, 9, 100);
- font-weight: bold;
- margin-left: 20rpx;
- image {
- width: 42rpx;
- height: 42rpx;
- margin-right: 20rpx;
- }
- }
- }
- &-right {
- .confirm {
- width: 250rpx;
- height: 60rpx;
- line-height: 60rpx;
- border-radius: 8px;
- background-color: rgba(235, 112, 9, 100);
- color: rgba(255, 255, 255, 100);
- font-size: 28rpx;
- text-align: center;
- }
- }
- }
- }
- .footer-fixed {
- position: fixed;
- bottom: var(--window-bottom);
- left: 0;
- right: 0;
- z-index: 11;
- box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
- background: #fff;
- // 设置ios刘海屏底部横线安全区域
- padding-bottom: constant(safe-area-inset-bottom);
- padding-bottom: env(safe-area-inset-bottom);
- .btn {
- padding: 20rpx 40rpx;
- /deep/ button {
- width: 100%;
- line-height: 60rpx;
- font-size: 28rpx;
- height: 60rpx;
- color: #fff;
- background-color: $uni-bg-color;
- border: none;
- border-radius: 100rpx;
- }
- }
- }
- </style>
|