This commit is contained in:
2021-09-18 13:02:56 +08:00
parent 0fa8736ed3
commit 05c7870f99
10 changed files with 659 additions and 105 deletions

View File

@@ -0,0 +1,217 @@
<template>
<view class="can-use-list">
<view v-for="(item,index) in lists" v-if="lists.length>0" :key="index" style="padding: 0 30rpx;">
<view class="goods-item">
<image class="goods-img" hover-class="none" mode="aspectFill" @click="goDetail(item.goods_id)"
:src="item.cover" />
<view class="goods-info">
<view class="goods-title ellipsis-2">{{item.name}}</view>
<view class="flexrow">
<view class="goods-price"><span></span>{{item.price}}/权证</view>
<view :class="['right',selectSkuId===item.goods_sku_id?'selcetRight':'']"
@click="selectSkuId = item.goods_sku_id"> 兑换该商品</view>
</view>
</view>
</view>
</view>
<!-- 没有收藏的店铺 -->
<no-list name='no-goods' v-else txt="没有任何可兑换商品~" />
<view class="nowExchange" ><view class="btn" @click="verifiyCoupon('post')">确认兑换</view></view>
<!-- <u-toast ref="uToast" /> -->
<u-toast ref="uToast" />
</view>
</template>
<script>
import {
scanInfo
} from '@/apis/interfaces/scan'
export default {
data() {
return {
lists: [],
page: 1,
exchangeShow: false, // false不显示立即兑换按钮
has_more: true,
code: '2109141403335626',
selectSkuId: ''
};
},
onLoad(e) {
if (e.code) {
// this.code = e.code
}
this.verifiyCoupon('get')
},
methods: {
// 获取列表
verifiyCoupon(method) {
let apiUrl = 'coupons/verify/coupon'
let data = {
code: this.code
}
if(method === 'post'){
data.goods_sku_id = this.selectSkuId
}
scanInfo(apiUrl, data, method).then(res => {
console.log(res)
if(method === 'get'){
this.lists = res.goods
}else{
this.$refs.uToast.show({
title: '优惠券核销成功',
type: 'error',
icon: false,
duration: 3000
})
setTimeout(res=>{
uni.navigateBack({})
},3000)
}
}).catch(err => {
this.$refs.uToast.show({
title: err.message,
type: 'error',
icon: false,
duration: 3000
})
})
},
goDetail(id) {
console.log(id)
uni.navigateTo({
url: '/pages/goods/details?id=' + id
})
}
}
}
</script>
<style lang="scss" scoped>
.can-use-list {
padding-bottom: 120rpx;
}
.goods-item {
width: calc(100% - 20rpx);
box-shadow: 0 0 20rpx 4rpx rgba($color: $main-color, $alpha: 0.1);
border-radius: 16rpx;
// margin-left: 20rpx;
margin: 40rpx 0 0 20rpx;
display: flex;
flex-direction: row;
align-items: flex-start;
justify-content: flex-start;
box-sizing: border-box;
position: relative;
.exchange {
position: absolute;
bottom: 30rpx;
right: 30rpx;
padding: 6rpx 16rpx;
border-radius: 20rpx 0 20rpx 0;
background-color: $main-color;
color: #fff;
font-size: 20rpx;
z-index: 1;
}
.goods-img {
width: 180rpx;
height: 180rpx;
position: relative;
top: 0;
left: -20rpx;
box-shadow: 0 0 10rpx 4rpx rgba($color: $main-color, $alpha: 0.1);
border-radius: 8rpx;
}
.goods-info {
flex: 1;
height: 180rpx;
padding: 20rpx 20rpx 20rpx 0;
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: space-around;
box-sizing: border-box;
.goods-title {
width: 100%;
font-size: 28rpx;
}
.goods-price {
color: #039bfe;
padding-top: 10rpx;
font-weight: bold;
font-size: 32rpx;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-sizing: border-box;
span {
font-size: 26rpx;
// padding-right: 10rpx;
font-weight: normal;
&:nth-child(2) {
padding-left: 30rpx;
}
}
}
}
}
.flexrow {
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
.right {
padding: 20rpx 20rpx;
border-radius: 20rpx;
background-color: #cacaca;
color: #666;
}
.selcetRight {
background-color: #039bfe;
color: #fff;
font-weight: bold;
}
}
.nowExchange {
height: 90rpx;
background-color: #fff;
position: fixed;
bottom: 40rpx;
width: 100%;
padding:20rpx 30rpx;
.btn {
background-color: #039bfe;
font-size: 34rpx;
font-weight: bold;
color: #FFF;
padding: 20rpx 30rpx;
box-sizing: border-box;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-sizing: border-box;
border-radius: 8rpx;
}
}
</style>

View File

@@ -38,7 +38,7 @@
<view class="showCode " v-if="showCode">
<view class="showCodeBg" @click="showCode = false"></view>
<view :class="['showCodeContent', showCode?'showCodeContentSelect':'showCodeContentSelectNo']">
<view class="showCodeTitle">商品兑换码</view>
<view class="showCodeTitle">优惠券兑换码</view>
<image :src="code" mode="widthFix"></image>
</view>
</view>
@@ -70,6 +70,14 @@
this.coupon_grant_id = e.id
this.getList()
},
// 监听弹窗页面为false时候重新请求当前页面
watch: {
showCode(newVal, oldVal) {
if(!newVal && oldVal){
uni.setStorageSync('refresh',true)
}
}
},
methods: {
// 获取列表
getList() {

View File

@@ -155,6 +155,15 @@
this.getInfo(e.symbol)
// this.getInfo('G22S20')
},
// 监听弹窗页面为false时候重新请求当前页面
watch: {
showCode(newVal, oldVal) {
if(!newVal && oldVal){
this.getInfo(this.symbol)
uni.setStorageSync('refresh',true)
}
}
},
methods: {
getInfo(symbol) {
mallWarrantsList(symbol).then(res => {
@@ -174,6 +183,7 @@
duration: 3000
})
setTimeout(res => {
uni.setStorageSync('refresh',true)
uni.navigateBack({})
}, 2000)
})

View File

@@ -59,11 +59,6 @@
}
},
onShow() {
wx.login({
success: res => {
this.loginCode = res.code
}
})
this.getUserInfo()
},
onPullDownRefresh() {
@@ -85,86 +80,6 @@
})
})
},
// 点击绑定用户得授权信息,且绑定带修改
getUser() {
uni.getUserProfile({
desc: "获取你的昵称、头像、地区及性别",
success: e => {
console.log(e)
if (e.errMsg == "getUserProfile:ok") {
this.userInfo = e.userInfo
// // 检查用户登录Code是否过期
wx.checkSession({
success: res => {
this.userLogin(e)
},
fail: err => {
// 登录过期重新获取code
uni.login({
success: res => {
this.loginCode = res.code
// 登录
this.userLogin()
}
})
}
})
} else {
uni.showToast({
duration: 1500,
title: "绑定手机号失败了",
icon: 'none'
})
}
},
fail() {
uni.showToast({
duration: 1500,
title: "您拒绝了请求",
icon: 'none'
})
}
})
},
// 登陆接口
userLogin(info) {
let that = this
uni.login({
success: res => {
let data = {
iv: info.iv,
encryptedData: info.encryptedData,
code: res.code
}
uni.showLoading({
title: '绑定中'
})
wechatbind(data).then(res => {
setTimeout(res => {
uni.hideLoading()
}, 1000)
this.$refs.uToast.show({
title: '绑定成功',
type: 'primary',
duration: 3000
})
setTimeout(res => {
this.getUserInfo()
}, 3000)
}).catch(err => {
this.$refs.uToast.show({
title: err.message,
type: 'primary',
duration: 3000
})
uni.hideLoading()
})
},
fail: () => {},
complete: () => {}
});
},
loginOut() {
uni.removeStorageSync('token')
uni.reLaunch({