| | |
| | | |
| | | const typeList = ref([ |
| | | // {value:'1',name:'全部分类',active:1}, |
| | | // {value:'2',name:'零食',active:0}, |
| | | // {value:'3',name:'电子设备',active:0}, |
| | | // {value:'4',name:'洗护用品',active:0}, |
| | | // {value:'5',name:'其他',active:0}, |
| | | // {value:'5',name:'其他',active:0}, |
| | | // {value:'5',name:'其他',active:0}, |
| | | // {value:'5',name:'其他',active:0}, |
| | | ]) |
| | | const goodsList = ref([ |
| | | // {id:'1',imageUrl:'',name:'商品名称',price:'50.00',useIntegral:'1000',stock:102}, |
| | |
| | | async function changeType(typeId,active,e){ |
| | | typeList.value.forEach((item,index) =>{ |
| | | if(index == e){ |
| | | item.active = 1 |
| | | item.active = true |
| | | }else{ |
| | | item.active = 0 |
| | | item.active = false |
| | | } |
| | | }) |
| | | await getGoodsList(typeId) |
| | | } |
| | | //积分兑换 |
| | | async function integralConvert(goodsId,goodsIntegral){ |
| | | if(goodsIntegral <= Number(userInfo.value.integral)){ |
| | | await integralConvertApi({userId:userInfo.value.id,goodsId:goodsId}).then((res) =>{ |
| | | async function confirm(){ |
| | | await integralConvertApi({userId:userInfo.value.id,goodsId:checkedGoodsId.value}).then(async(res) =>{ |
| | | if(res.code == 200){ |
| | | uni.showToast({ |
| | | title:'兑换成功!', |
| | | icon:'none' |
| | | duration:1000 |
| | | }) |
| | | await updateUserInfo() |
| | | await getGoodsList('') |
| | | setGoodsType() |
| | | setTimeout(() =>{ |
| | | uni.navigateTo({ |
| | | url:'/pages/pointsMall/pointsExchangeRecord/index' |
| | | }) |
| | | },1000) |
| | | } |
| | | }) |
| | | } |
| | | //打开确认弹窗 |
| | | const alertDialog = ref() |
| | | const checkedGoodsId = ref() |
| | | async function integralConvert(goodsId,goodsIntegral){ |
| | | if(goodsIntegral <= Number(userInfo.value.integral)){ |
| | | checkedGoodsId.value = goodsId |
| | | alertDialog.value.open() |
| | | }else{ |
| | | uni.showToast({ |
| | | title:'积分余额不足!', |
| | |
| | | } |
| | | }) |
| | | } |
| | | onMounted(async() =>{ |
| | | await getGoodsTypeList() |
| | | await getGoodsList('') |
| | | console.log('onMounted') |
| | | }) |
| | | onShow(async() =>{ |
| | | await getGoodsList('') |
| | | //设置选中商品为全部 |
| | | function setGoodsType(){ |
| | | typeList.value.forEach((item,index) =>{ |
| | | if(index == 0){ |
| | | item.active = 1 |
| | |
| | | item.active = 0 |
| | | } |
| | | }) |
| | | } |
| | | onMounted(async() =>{ |
| | | await getGoodsTypeList() |
| | | await getGoodsList('') |
| | | console.log('onMounted') |
| | | }) |
| | | onShow(async() =>{ |
| | | await getGoodsList('') |
| | | setGoodsType() |
| | | await updateUserInfo() |
| | | console.log('onShow') |
| | | }) |
| | |
| | | <image src="../../static/images/pointMall/nav1.svg"></image> |
| | | </view> |
| | | <view class="nav-item" @click="navTo('/pages/pointsMall/pointsExchangeRecord/index')"> |
| | | <text>兑换记录</text> |
| | | <text>兑换订单</text> |
| | | <image src="../../static/images/pointMall/nav2.svg"></image> |
| | | </view> |
| | | </view> |
| | |
| | | </view> |
| | | <view class="goods-box"> |
| | | <view v-for="(item,index) in goodsList" :key="index" class="goods-item"> |
| | | <image @click="navTo(`/pages/pointsMall/pointsGoodsDetail/index?goodsId=${item.id}`)" class="goods-item-img" :src="baseUrl + '/upload' + item.imageUrl" mode="widthFix"></image> |
| | | <image @click="navTo(`/pages/pointsMall/pointsGoodsDetail/index?goodsId=${item.id}`)" class="goods-item-img" :src="baseUrl + '/upload' + item.imageUrl" mode="aspectFit"></image> |
| | | |
| | | <view class="goods-item-name" @click="navTo(`/pages/pointsMall/pointsGoodsDetail/index?goodsId=${item.id}`)"> |
| | | <text>{{item.name}}</text> |
| | |
| | | </view> |
| | | </view> |
| | | </view> |
| | | <!-- 提示窗 --> |
| | | <uni-popup ref="alertDialog" type="dialog"> |
| | | <uni-popup-dialog type="info" title="提示" :showClose = 'true' content="确认兑换该商品!" @confirm="confirm"></uni-popup-dialog> |
| | | </uni-popup> |
| | | </view> |
| | | </template> |
| | | |
| | |
| | | .goods-item{ |
| | | display: inline-block; |
| | | width:48%; |
| | | max-height:800rpx; |
| | | height:600rpx; |
| | | background: #fff; |
| | | overflow:hidden; |
| | | margin-bottom:20rpx; |
| | |
| | | background:linear-gradient(#fff,#e8e8e8); |
| | | .goods-item-img{ |
| | | width:80%; |
| | | min-height:280rpx; |
| | | margin: 0 auto; |
| | | margin-bottom:50rpx; |
| | | } |