2023-02-23
功能完善
This commit is contained in:
@@ -313,6 +313,7 @@ export default {
|
|||||||
return res.data.data;
|
return res.data.data;
|
||||||
} else {
|
} else {
|
||||||
console.log(">>>>>=");
|
console.log(">>>>>=");
|
||||||
|
console.log(">>>>>=",res.data);
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
if (!res.data.msg) {
|
if (!res.data.msg) {
|
||||||
res.data.msg = res.data.data;
|
res.data.msg = res.data.data;
|
||||||
@@ -321,7 +322,7 @@ export default {
|
|||||||
title: res.data.msg,
|
title: res.data.msg,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
this.$api.msg(res.data.msg);
|
// this.$api.msg(res.data.msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,10 @@
|
|||||||
<view class="demand">满{{ item.minPoint }} 减 {{ item.amount }}</view>
|
<view class="demand">满{{ item.minPoint }} 减 {{ item.amount }}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="get-btn" v-if="!types" :style="{color:color, borderColor:color, background:solid}"
|
<view class="get-btn" :style="{color:color, borderColor:color, background:solid}"
|
||||||
@click="acceptCoupon(item)">立即领取</view>
|
@click="acceptCoupon(item)">立即领取</view>
|
||||||
<navigator class="get-btn" v-if="types" :style="{color:color, borderColor:color, background:solid}"
|
<!-- <navigator class="get-btn" v-if="types" :style="{color:color, borderColor:color, background:solid}"
|
||||||
:url='item.url' @click="useCoupon(item)">立即使用</navigator>
|
:url='item.url' @click="useCoupon(item)">立即使用</navigator> -->
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -21,6 +21,9 @@
|
|||||||
import {
|
import {
|
||||||
formatDate
|
formatDate
|
||||||
} from '@/common/date';
|
} from '@/common/date';
|
||||||
|
import {
|
||||||
|
mapState
|
||||||
|
} from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -54,25 +57,34 @@
|
|||||||
return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
|
return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState(['hasLogin', 'userInfo']),
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async acceptCoupon(item) {
|
async acceptCoupon(item) {
|
||||||
this.types = !this.types
|
if (this.hasLogin) {
|
||||||
uni.showLoading({
|
this.types = !this.types
|
||||||
title: '请稍后'
|
uni.showLoading({
|
||||||
});
|
title: '请稍后'
|
||||||
|
});
|
||||||
|
|
||||||
let params = {
|
let params = {
|
||||||
couponId: item.id
|
couponId: item.id
|
||||||
};
|
};
|
||||||
let data = await Api.apiCall('post', Api.index.acceptCoupon, params);
|
|
||||||
console.log(data);
|
|
||||||
if (data) {
|
|
||||||
this.$api.msg(data);
|
|
||||||
this.clickSubMethod(item)
|
this.clickSubMethod(item)
|
||||||
|
// let data = await Api.apiCall('post', Api.index.acceptCoupon, params);
|
||||||
|
// console.log("data?????", data);
|
||||||
|
// if (data) {
|
||||||
|
// // this.$api.msg(data);
|
||||||
|
// this.clickSubMethod(item)
|
||||||
|
|
||||||
|
// }
|
||||||
|
uni.hideLoading();
|
||||||
|
} else {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/public/login'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
uni.hideLoading();
|
|
||||||
|
|
||||||
},
|
},
|
||||||
clickSubMethod(vel) {
|
clickSubMethod(vel) {
|
||||||
console.log('clickSubMethod')
|
console.log('clickSubMethod')
|
||||||
|
|||||||
@@ -360,19 +360,35 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState(['hasLogin', 'userInfo']),
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
clickParentMethod() {
|
clickParentMethod() {
|
||||||
console.log('clickParentMethod')
|
console.log('clickParentMethod')
|
||||||
this.$refs.SubComponent.callSubMethod()
|
this.$refs.SubComponent.callSubMethod()
|
||||||
},
|
},
|
||||||
callParentMethod(val) {
|
callParentMethod(val) {
|
||||||
|
let info = val
|
||||||
console.log('callParentMethod: ' + val)
|
console.log('callParentMethod: ' + val)
|
||||||
|
console.log('val: ' + val.id)
|
||||||
|
console.log('val: ' + info.id)
|
||||||
// 默认去遍历list集合,将集合中的每个元素传入到function的item里,
|
// 默认去遍历list集合,将集合中的每个元素传入到function的item里,
|
||||||
var index = this.couponList.findIndex(function(item) {
|
var index = this.couponList.findIndex(
|
||||||
return item.id == val.id;
|
// function(item) {
|
||||||
})
|
// console.log('item: ' + JSON.stringify(item))
|
||||||
|
// console.log('val: ' + val)
|
||||||
|
// return item.id == val.id;
|
||||||
|
item => {
|
||||||
|
console.log('item: ' + JSON.stringify(item).id)
|
||||||
|
console.log('val: ' + val.id)
|
||||||
|
if (item == val) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
console.log('index: ' + index)
|
||||||
this.couponList.splice(index, 1);
|
this.couponList.splice(index, 1);
|
||||||
|
// this.getCouponList();
|
||||||
},
|
},
|
||||||
|
|
||||||
async sysInfoMethod() {
|
async sysInfoMethod() {
|
||||||
@@ -526,7 +542,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 获取轮播图
|
* 获取优惠券
|
||||||
*/
|
*/
|
||||||
async getCouponList() {
|
async getCouponList() {
|
||||||
let params = {
|
let params = {
|
||||||
@@ -536,7 +552,9 @@
|
|||||||
if (data) {
|
if (data) {
|
||||||
console.log("优惠券")
|
console.log("优惠券")
|
||||||
console.log("优惠券", data)
|
console.log("优惠券", data)
|
||||||
this.couponList = data || [];
|
console.log("优惠券id",data[0].id)
|
||||||
|
this.couponList = []
|
||||||
|
this.couponList = this.couponList.concat(data) || [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -20,8 +20,8 @@
|
|||||||
<view class="image-wrapper"><image :src="item.pic" mode="aspectFill"></image></view>
|
<view class="image-wrapper"><image :src="item.pic" mode="aspectFill"></image></view>
|
||||||
<text class="title clamp">{{ item.name }}</text>
|
<text class="title clamp">{{ item.name }}</text>
|
||||||
<view class="price-box" >
|
<view class="price-box" >
|
||||||
<text class="price">{{ item.price }}</text>
|
<text class="price">{{ item.originalPrice }}</text>
|
||||||
<text class="price2">市场价 ¥{{ item.originalPrice }}</text>
|
<text class="price2">市场价 ¥{{ item.price }}</text>
|
||||||
</view>
|
</view>
|
||||||
<!-- <view class="price-box" v-if="item.isVip == 1">
|
<!-- <view class="price-box" v-if="item.isVip == 1">
|
||||||
<text class="price">会员价{{ item.vipPrice }}</text>
|
<text class="price">会员价{{ item.vipPrice }}</text>
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ import Api from '@/common/api';
|
|||||||
filters: {
|
filters: {
|
||||||
formatCreateTime(time) {
|
formatCreateTime(time) {
|
||||||
let date = new Date(time);
|
let date = new Date(time);
|
||||||
return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
|
return formatDate(date, 'yyyy-MM-dd')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -6,13 +6,16 @@ Vue.use(Vuex)
|
|||||||
const store = new Vuex.Store({
|
const store = new Vuex.Store({
|
||||||
state: {
|
state: {
|
||||||
hasLogin: false,
|
hasLogin: false,
|
||||||
|
hasVip: false,
|
||||||
userInfo: ''
|
userInfo: ''
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
login(state, provider) {
|
login(state, provider) {
|
||||||
console.log(provider);
|
console.log(provider);
|
||||||
if (provider && provider != undefined) {
|
if (provider && provider != undefined) {
|
||||||
|
console.log("provider",provider);
|
||||||
state.hasLogin = true;
|
state.hasLogin = true;
|
||||||
|
state.hasVip = true;
|
||||||
uni.setStorage({ //缓存用户登陆状态
|
uni.setStorage({ //缓存用户登陆状态
|
||||||
key: 'userInfo',
|
key: 'userInfo',
|
||||||
data: provider.userInfo
|
data: provider.userInfo
|
||||||
@@ -24,6 +27,7 @@ const store = new Vuex.Store({
|
|||||||
},
|
},
|
||||||
logout(state) {
|
logout(state) {
|
||||||
state.hasLogin = false;
|
state.hasLogin = false;
|
||||||
|
state.hasVip = false;
|
||||||
state.userInfo = '';
|
state.userInfo = '';
|
||||||
uni.removeStorage({
|
uni.removeStorage({
|
||||||
key: 'userInfo'
|
key: 'userInfo'
|
||||||
|
|||||||
Reference in New Issue
Block a user