| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521 |
- <template>
- <view class="content">
- <view class="cont-box">
- <view class="goods-banner" @click="showImg()">
- <view class="cartbox x-c" @click.stop="goCart()">
- <view class="box">
- <u-badge type="error" max="99" :value="cartNum" bgColor="#2583EB"></u-badge>
- </view>
- <u-icon name="shopping-cart" color="#2583EB" size="68rpx"></u-icon>
- </view>
- <swiper
- class="swiper"
- :indicator-dots="false"
- :circular="true"
- :autoplay="true"
- :interval="3000"
- :duration="1000"
- indicator-color="rgba(255, 255, 255, 0.6)"
- indicator-active-color="#ffffff"
- @change="swiperChange"
- >
- <swiper-item class="swiper-item" v-for="(item,index) in imgs" :key="index">
- <image :src="item" mode="aspectFit"></image>
- </swiper-item>
- </swiper>
- <!-- 数量 -->
- <view class="num-box">{{ activeImg }}/{{ imgs.length }}</view>
- </view>
- <view class="integral-box">
- <view class="title">{{item.goodsName}}</view>
- <view class="num-box">
- <view class="price" >{{item.integral}} 健康币</view>
- <view class="count">原价:{{item.otPrice.toFixed(2)}}元</view>
- </view>
-
- </view>
- <view class="desc-box">
- <view class="desc" v-html="item.descs" >
-
- </view>
- </view>
- </view>
- <view class="btn-foot">
- <view class="p-price-box">
- <view class="p-name">兑换健康币</view>
- <view class="p-price" >{{item.integral}}</view>
- </view>
- <view class="btn-box">
- <view class="btn add" @click="openPop">
- 加入购物车
- </view>
- <view class="btn buy" @click="submit()" >
- 立即兑换
- </view>
- </view>
- </view>
- <u-popup :show="show" mode="bottom" closeable @close="close">
- <view class="popbox">
- <view class="x-f">
- <image class="popbox-img" :src="item.imgUrl" mode="aspectFill"></image>
- <view class="info-text">
- <view class="price">
- <text class="unit">¥</text>
- <text class="num">{{item.otPrice}}</text>
- <!-- <text class="oldprice"> ¥{{item.otPrice}}</text> -->
- </view>
- <view class="text es-mt-16">所需积分:{{item.integral}}</view>
- <view class="desc-box es-mt-16">
- <text class="text">库存:{{item.stock>0?item.stock:'售罄'}} </text>
- </view>
- </view>
- </view>
- <!-- 数量 -->
- <view class="price-num x-bc" style="margin-top: 30rpx;">
- <view class="label">数量</view>
- <view class="num-box">
- <u-number-box v-model="num" integer :step="1" :min="1" :max="100000"></u-number-box>
- </view>
- </view>
- <view class="es-max-btn x-c" @click="addCart">
- 加入购物车
- </view>
- </view>
- </u-popup>
- </view>
- </template>
- <script>
- import {getIntegralGoodsById,createOrder,addGoodsIntoCart,getFsIntegralCartList} from '@/api/integral.js'
- export default {
- data() {
- return {
- imgs:[],
- activeImg: 1,
- goodsId:null,
- item: {
- cash: 0,
- otPrice: 0,
- integral: 0,
- goodsName: '',
- imgUrl: '',
- stock: 0,
- descs: ''
- },
- show: false,
- num: 1,
- cartNum: 0
- };
- },
- onLoad(option) {
- this.goodsId=option.goodsId;
-
- },
- onShow() {
- this.getIntegralGoodsById();
- this.getcartNum()
- },
- methods:{
- goCart() {
- uni.navigateTo({
- url: '/pages/user/integral/cart'
- })
- },
- getcartNum() {
- var data={
- pageNum: 1,
- pageSize: 10
- }
- getFsIntegralCartList().then(res => {
- if (res.code == 200) {
- this.cartNum = res.data.total ||0
- }
- })
- },
- close() {
- this.show = false
- },
- openPop() {
- this.num = 1
- this.show = true
- },
- addCart() {
- if(this.cartNum>=this.item.stock){
- uni.showToast({
- title: '库存不足',
- icon: 'none'
- })
- this.show = false
- return;
- }
- uni.showLoading({
- title: '处理中'
- })
- addGoodsIntoCart({
- quantity: this.num,
- goodsId: this.goodsId,
- isSelected: 0
- }).then(res => {
- uni.hideLoading()
- if (res.code == 200) {
- this.show = false
- uni.showToast({
- title: "添加成功",
- icon: 'none'
- })
- this.getcartNum()
- } else {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- }
- })
- },
- submit(){
- uni.navigateTo({
- url: "./integralOrderPay?goodsId="+this.goodsId
- })
- },
- swiperChange(event) {
- this.activeImg = event.detail.current + 1
- },
-
- showImg() {
- //预览图片
- uni.previewImage({
- urls: this.imgs,
- current: this.imgs[0]
- });
- },
- getIntegralGoodsById(){
- let data = {goodsId:this.goodsId};
- getIntegralGoodsById(data).then(
- res => {
- if(res.code==200){
- this.item=res.data;
- if(res.data.images!=null){
- this.imgs=res.data.images.split(",")
- }
- else{
- this.activeImg=0;
- }
- console.log(this.imgs)
- }else{
- uni.showToast({
- icon:'none',
- title: "请求失败",
- });
- }
- },
- rej => {}
- );
- },
- }
- }
- </script>
- <style lang="scss">
- page{
- height: 100%;
- }
- .cartbox {
- position: fixed;
- bottom: 180rpx;
- right: 20rpx;
- z-index: 99;
- background-color: #fff;
- box-shadow: 0 2px 4px rgba(150, 150, 150, 0.6);
- padding: 10rpx;
- border-radius: 50%;
-
- .box {
- position: absolute;
- top: -10rpx;
- right: 0;
- z-index: 99;
- }
- }
- .content{
- height: 100%;
- display: flex;
- flex-direction: column;
-
- .cont-box{
- padding-bottom: 121rpx;
- .integral-box{
- background-color: #fff;
- padding: 20rpx;
- width: 100%;
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- justify-content: flex-start;
-
- .title{
- font-weight: bold;
- font-size: 34upx;
- font-family: PingFang SC;
- color: #111;
- }
- .desc{
- margin-top: 15rpx;
- display: flex;
- align-items: flex-start;
- justify-content: flex-start;
- .cycle{
- background-color: #eee;
- border-radius: 30rpx;
- padding: 5rpx 15rpx;
- font-size: 26upx;
- font-family: PingFang SC;
- color: #2583EB;
- }
- .duration{
- margin-left: 10rpx;
- background-color: #eee;
- border-radius: 30rpx;
- padding: 5rpx 15rpx;
- font-size: 26upx;
- font-family: PingFang SC;
- color: #2583EB;
- }
-
- }
- .num-box{
- margin-top: 15rpx;
- flex: 1;
- display: flex;
- align-items: flex-end;
- justify-content: space-between;
- width: 100%;
- .price{
- padding: 5rpx 10rpx;
- background-color: #2583EB;
- border-radius: 30rpx;
- font-size: 20upx;
- font-family: PingFang SC;
- color: #ffffff;
- }
-
- .count{
- font-size: 24upx;
- font-family: PingFang SC;
- color: #333333;
- }
-
- }
-
-
- }
- .desc-box{
- background-color: #fff;
- padding: 20rpx;
- margin-top: 10rpx;
- .title-box{
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: flex-start;
- .title{
- font-size: 32upx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #111111;
- }
- .line{
- margin-right: 15rpx;
- height: 30rpx;
- width: 6rpx;
- background-color: #2583EB;
-
- }
-
- }
- .desc{
- margin-top: 15rpx;
- font-size: 28upx;
- font-family: PingFang SC;
- color: #9a9a9c;
- }
- }
-
- }
- }
-
- .btn-foot{
- box-sizing: border-box;
- width: 100%;
- height: 121upx;
- background: #FFFFFF;
- padding: 0 32upx 0 28upx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- position: fixed;
- left: 0;
- bottom: 0;
- z-index: 99;
- .p-price-box{
- display: flex;
- align-items:flex-start;
- flex-direction: column;
- .p-name{
- font-size: 28upx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #666666;
- }
- .p-price{
- //margin-left: 10rpx;
- color: #FF6633;
- font-size: 32upx;
- font-family: PingFang SC;
- font-weight: bold;
-
- }
- }
-
- .btn-box{
- display: flex;
- align-items: center;
- .btn{
- width: 200upx;
- height: 88upx;
- line-height: 88upx;
- text-align: center;
- border-radius: 44upx;
- margin-left: 20upx;
- font-size: 30upx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #FFFFFF;
- &:first-child{
- margin-left: 0;
- }
-
- &.buy{
- background: #2583EB;
- }
- &.add{
- color:#2583EB !important;
- border: 1rpx solid #2583EB;
- }
- }
-
- }
- }
-
- .goods-banner{
- height: 756upx;
- background-color: #FFFFFF;
- position: relative;
- .swiper-item{
- box-sizing: border-box;
- }
- .swiper,
- .swiper-item,
- .swiper-item image{
- width: 100%;
- height: 100%;
- }
- .num-box{
- width: 80upx;
- height: 44upx;
- line-height: 44upx;
- text-align: center;
- font-size: 24upx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #FFFFFF;
- background: rgba(0, 0, 0, .3);
- border-radius: 22upx;
- position: absolute;
- right: 30upx;
- bottom: 30upx;
- z-index: 10;
- }
- }
- .popbox {
- padding: 40rpx 32rpx;
-
- &-img {
- width: 200rpx;
- height: 200rpx;
- border-radius: 20rpx;
- margin-right: 24rpx;
- }
-
- .oldprice {
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #999999;
- margin-top: 27rpx;
- line-height: 1;
- text-decoration: line-through;
- margin-left: 24rpx;
- }
-
- .info-text {
- height: 200rpx;
-
- .price {
- display: flex;
- align-items: flex-end;
-
- .unit {
- font-size: 32rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #2583EB;
- line-height: 1.2;
- margin-right: 10rpx;
- }
-
- .num {
- font-size: 50rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #2583EB;
- line-height: 1;
- }
- }
-
- .text {
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: 400;
- color: #2583EB;
- }
-
- .desc-box {
- display: flex;
- flex-direction: column;
- padding-bottom: 9rpx;
-
- .text {
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #999999;
- margin-top: 27rpx;
- line-height: 1;
-
- &:first-child {
- margin-top: 0;
- }
- }
- }
- }
- }
- .es-max-btn {
- width: 100%;
- background-color: #2583EB;
- border-radius: 60rpx;
- margin-top: 50rpx;
- color: #fff;
- padding: 20rpx 0;
- box-sizing: border-box;
- }
- </style>
|