add
This commit is contained in:
@ -2135,7 +2135,7 @@ flex: 0 2.4*100rpx;
|
||||
.shoppingCart .footer .checkAll {
|
||||
font-size: 0.28*100rpx;
|
||||
color: #282828;
|
||||
margin-left: 0.6*100rpx;
|
||||
margin-left: 0.1*100rpx;
|
||||
}
|
||||
|
||||
.shoppingCart .footer .money {
|
||||
|
32
main.js
32
main.js
@ -76,28 +76,32 @@ Object.defineProperty(Vue.prototype, '$yroute', {
|
||||
Vue.prototype.$VUE_APP_RESOURCES_URL = VUE_APP_RESOURCES_URL
|
||||
Vue.prototype.$VUE_APP_API_URL = VUE_APP_API_URL
|
||||
|
||||
|
||||
|
||||
// #ifdef H5
|
||||
// H5编译的代码
|
||||
Vue.prototype.$deviceType = 'h5'
|
||||
Vue.prototype.$deviceType = 'h5'
|
||||
store.commit('UPDATE_DEVICETYPE','h5')
|
||||
// #endif
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
// App平台编译的代码
|
||||
Vue.prototype.$deviceType = 'app'
|
||||
// App平台编译的代码
|
||||
console.log('App平台编译的代码')
|
||||
Vue.prototype.$deviceType = 'app'
|
||||
store.commit('UPDATE_DEVICETYPE','app')
|
||||
Vue.prototype.$platform = uni.getSystemInfoSync().platform
|
||||
// #endif
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
// 微信小程序编译的代码
|
||||
Vue.prototype.$deviceType = 'weixin'
|
||||
// 微信小程序编译的代码
|
||||
console.log('微信小程序编译的代码')
|
||||
Vue.prototype.$deviceType = 'weixin'
|
||||
store.commit('UPDATE_DEVICETYPE','weixin')
|
||||
// #endif
|
||||
|
||||
console.log(wx,121212)
|
||||
console.log(Vue.prototype.$deviceType)
|
||||
// if(wx){
|
||||
// Vue.prototype.$deviceType = 'weixin'
|
||||
// }
|
||||
|
||||
|
||||
// !!! ps 不建议在 template 中使用 $deviceType 去判断当前环境,很有可能出现 $deviceType 为 undefined 导致判断出错的问题,可以在 script 模块中正常使用
|
||||
// 建议通过 store 去获取 $deviceType 可以保证 template 中取到的值有效
|
||||
// import { mapState, mapMutations, mapActions } from 'vuex';
|
||||
// computed: {
|
||||
// ...mapState(['$deviceType'])
|
||||
// },
|
||||
|
||||
app.$mount()
|
||||
|
@ -1,223 +1,201 @@
|
||||
<template>
|
||||
<view class="flash-sale" ref="container">
|
||||
<view class="header" v-if="headerImg">
|
||||
<image :src="headerImg" />
|
||||
</view>
|
||||
<vant-tabs
|
||||
:active="active"
|
||||
@change="setTime"
|
||||
:sticky="sticky"
|
||||
animated
|
||||
line-height="2"
|
||||
:ellipsis="false"
|
||||
>
|
||||
<vant-tab
|
||||
:ellipsis="false"
|
||||
:title="[title[index]]"
|
||||
v-for="(item, index) in timeList"
|
||||
:key="index"
|
||||
>
|
||||
<view slot="title" class="timeItem">
|
||||
<view class="time">{{ item.time }}</view>
|
||||
<view class="state">{{ item.state }}</view>
|
||||
</view>
|
||||
<view class="countDown font-color-red acea-row row-center-wrapper">
|
||||
<view v-if="item.status === 0" class="activity">活动已结束</view>
|
||||
<count-down
|
||||
:is-day="false"
|
||||
:tip-text="'距结束仅剩 '"
|
||||
:day-text="''"
|
||||
:hour-text="' : '"
|
||||
:minute-text="' : '"
|
||||
:second-text="''"
|
||||
:datatime="datatime"
|
||||
v-if="item.status === 1"
|
||||
></count-down>
|
||||
<view v-if="item.status === 2" class="activity">活动即将开始</view>
|
||||
</view>
|
||||
<view class="list">
|
||||
<view
|
||||
class="item acea-row row-between-wrapper"
|
||||
v-for="(itemSeckill, indexSeckill) in seckillList"
|
||||
:key="indexSeckill"
|
||||
>
|
||||
<view class="pictrue">
|
||||
<image :src="itemSeckill.image" />
|
||||
</view>
|
||||
<view class="text acea-row row-column-around">
|
||||
<view class="line1" v-text="itemSeckill.title"></view>
|
||||
<view class="money">
|
||||
限时价
|
||||
<text class="num font-color-red" v-text="'¥' + itemSeckill.price"></text>
|
||||
</view>
|
||||
<view class="progress cart-color">
|
||||
<view class="bg-red" :style="{ width: loading ? itemSeckill.percent + '%' : '' }"></view>
|
||||
<view class="piece font-color-red" v-text="'仅剩' + itemSeckill.stock + '件'"></view>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
class="grab bg-color-red"
|
||||
v-if="item.status === 1 && itemSeckill.stock > 0"
|
||||
@click="goDetail(itemSeckill.id)"
|
||||
>马上抢</view>
|
||||
<view class="grab" v-if="item.status === 1 && itemSeckill.stock <= 0">已售磬</view>
|
||||
<view class="grab bg-color-red" v-if="item.status === 2">即将开始</view>
|
||||
<view class="grab bg-color-red" v-if="item.status === 0">已结束</view>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
class="noCommodity"
|
||||
style="background-color: #fff;"
|
||||
v-if="seckillList.length === 0 && page > 1"
|
||||
>
|
||||
<view class="noPictrue">
|
||||
<image :src="$VUE_APP_RESOURCES_URL+'/images/noGood.png'" class="image" />
|
||||
</view>
|
||||
</view>
|
||||
</vant-tab>
|
||||
</vant-tabs>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import { getSeckillConfig, getSeckillList } from "@/api/activity";
|
||||
import CountDown from "@/components/CountDown";
|
||||
// import { Tab, Tabs } from "vant-weapp";
|
||||
import Loading from "@/components/Loading";
|
||||
|
||||
export default {
|
||||
name: "GoodsSeckill",
|
||||
components: {
|
||||
CountDown
|
||||
},
|
||||
props: {},
|
||||
data: function() {
|
||||
return {
|
||||
headerImg: "",
|
||||
timeList: [],
|
||||
sticky: false,
|
||||
loading: false,
|
||||
datatime: 0,
|
||||
active: 0,
|
||||
seckillList: [],
|
||||
status: false, //砍价列表是否获取完成 false 未完成 true 完成
|
||||
loadingList: false, //当前接口是否请求完成 false 完成 true 未完成
|
||||
page: 1, //页码
|
||||
limit: 5, //数量
|
||||
title: []
|
||||
};
|
||||
},
|
||||
mounted: function() {
|
||||
this.mountedStart();
|
||||
},
|
||||
onReachBottom() {
|
||||
!this.loadingList && this.getSeckillList();
|
||||
},
|
||||
methods: {
|
||||
mountedStart: function() {
|
||||
var that = this;
|
||||
uni.showLoading();
|
||||
getSeckillConfig().then(res => {
|
||||
that.$set(that, "headerImg", res.data.lovely);
|
||||
that.$set(that, "timeList", res.data.seckillTime);
|
||||
that.$set(that, "active", res.data.seckillTimeIndex);
|
||||
|
||||
let title = [];
|
||||
title = res.data.seckillTime.map((item, index) => {
|
||||
return {
|
||||
name: "div",
|
||||
attrs: {
|
||||
class: "timeItem"
|
||||
},
|
||||
children: [
|
||||
{
|
||||
name: "div",
|
||||
attrs: {
|
||||
class: "time"
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: "text",
|
||||
text: item.time
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "div",
|
||||
attrs: {
|
||||
class: "state"
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: "text",
|
||||
text: item.state
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
});
|
||||
that.$set(that, "title", title);
|
||||
that.datatime = that.timeList[that.active].stop;
|
||||
that.getSeckillList();
|
||||
that.$nextTick(function() {
|
||||
that.sticky = true;
|
||||
uni.hideLoading();
|
||||
});
|
||||
});
|
||||
},
|
||||
setTime: function(event) {
|
||||
var that = this;
|
||||
that.active = event.mp.detail.index;
|
||||
that.datatime = that.timeList[that.active].stop;
|
||||
that.getSeckillList();
|
||||
},
|
||||
getSeckillList: function() {
|
||||
var that = this;
|
||||
if (that.loadingList) return;
|
||||
if (that.status) return;
|
||||
var time = that.timeList[that.active].id;
|
||||
getSeckillList(time, { page: that.page, limit: that.limit }).then(res => {
|
||||
that.status = res.data.length < that.limit;
|
||||
that.seckillList.push.apply(that.seckillList, res.data);
|
||||
that.page++;
|
||||
uni.hideLoading();
|
||||
});
|
||||
},
|
||||
goDetail: function(id) {
|
||||
var that = this;
|
||||
var time = that.timeList[that.active].stop;
|
||||
this.$yrouter.push({
|
||||
path: "/pages/activity/SeckillDetails/index",
|
||||
query: { id, time }
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped lang="less">
|
||||
.timeItem {
|
||||
font-size: 0.22*100rpx;
|
||||
color: #282828;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
padding: 0.11*100rpx 0;
|
||||
height: 0.96*100rpx;
|
||||
background-color: #efc58f;
|
||||
}
|
||||
.timeItem .time {
|
||||
font-size: 0.32*100rpx;
|
||||
font-weight: bold;
|
||||
height: 0.37*100rpx;
|
||||
line-height: 0.37*100rpx;
|
||||
}
|
||||
.timeItem .state {
|
||||
height: 0.37*100rpx;
|
||||
line-height: 0.37*100rpx;
|
||||
}
|
||||
.activity {
|
||||
color: #333;
|
||||
}
|
||||
.flash-sale .list .item .grab {
|
||||
background-color: #999;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<view class="flash-sale" ref="container">
|
||||
<view class="header" v-if="headerImg"><image :src="headerImg" /></view>
|
||||
<view class="" v-for="(item, index) in timeList" :key="index">
|
||||
<view class="timeItem">
|
||||
<view class="time">{{ item.time }}</view>
|
||||
<view class="state">{{ item.state }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="" v-for="(item, index) in timeList" :key="index">
|
||||
<view v-if="active == index">
|
||||
<view class="countDown font-color-red acea-row row-center-wrapper">
|
||||
<view v-if="item.status === 0" class="activity">活动已结束</view>
|
||||
<count-down
|
||||
:is-day="false"
|
||||
:tip-text="'距结束仅剩 '"
|
||||
:day-text="''"
|
||||
:hour-text="' : '"
|
||||
:minute-text="' : '"
|
||||
:second-text="''"
|
||||
:datatime="datatime"
|
||||
v-if="item.status === 1"
|
||||
></count-down>
|
||||
<view v-if="item.status === 2" class="activity">活动即将开始</view>
|
||||
</view>
|
||||
<view class="list">
|
||||
<view class="item acea-row row-between-wrapper" v-for="(itemSeckill, indexSeckill) in seckillList" :key="indexSeckill">
|
||||
<view class="pictrue"><image :src="itemSeckill.image" /></view>
|
||||
<view class="text acea-row row-column-around">
|
||||
<view class="line1" v-text="itemSeckill.title"></view>
|
||||
<view class="money">
|
||||
限时价
|
||||
<text class="num font-color-red" v-text="'¥' + itemSeckill.price"></text>
|
||||
</view>
|
||||
<view class="progress cart-color">
|
||||
<view class="bg-red" :style="{ width: loading ? itemSeckill.percent + '%' : '' }"></view>
|
||||
<view class="piece font-color-red" v-text="'仅剩' + itemSeckill.stock + '件'"></view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="grab bg-color-red" v-if="item.status === 1 && itemSeckill.stock > 0" @click="goDetail(itemSeckill.id)">马上抢</view>
|
||||
<view class="grab" v-if="item.status === 1 && itemSeckill.stock <= 0">已售磬</view>
|
||||
<view class="grab bg-color-red" v-if="item.status === 2">即将开始</view>
|
||||
<view class="grab bg-color-red" v-if="item.status === 0">已结束</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="noCommodity" style="background-color: #fff;" v-if="seckillList.length === 0 && page > 1">
|
||||
<view class="noPictrue"><image :src="$VUE_APP_RESOURCES_URL + '/images/noGood.png'" class="image" /></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!--
|
||||
<vant-tabs :active="active" @change="setTime" :sticky="sticky" animated line-height="2" :ellipsis="false">
|
||||
<vant-tab :ellipsis="false" :title="[title[index]]">
|
||||
|
||||
</vant-tab>
|
||||
</vant-tabs> -->
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import { getSeckillConfig, getSeckillList } from '@/api/activity';
|
||||
import CountDown from '@/components/CountDown';
|
||||
// import { Tab, Tabs } from "vant-weapp";
|
||||
import Loading from '@/components/Loading';
|
||||
|
||||
export default {
|
||||
name: 'GoodsSeckill',
|
||||
components: {
|
||||
CountDown
|
||||
},
|
||||
props: {},
|
||||
data: function() {
|
||||
return {
|
||||
headerImg: '',
|
||||
timeList: [],
|
||||
sticky: false,
|
||||
loading: false,
|
||||
datatime: 0,
|
||||
active: 0,
|
||||
seckillList: [],
|
||||
status: false, //砍价列表是否获取完成 false 未完成 true 完成
|
||||
loadingList: false, //当前接口是否请求完成 false 完成 true 未完成
|
||||
page: 1, //页码
|
||||
limit: 5, //数量
|
||||
title: []
|
||||
};
|
||||
},
|
||||
mounted: function() {
|
||||
this.mountedStart();
|
||||
},
|
||||
onReachBottom() {
|
||||
!this.loadingList && this.getSeckillList();
|
||||
},
|
||||
methods: {
|
||||
mountedStart: function() {
|
||||
var that = this;
|
||||
uni.showLoading();
|
||||
getSeckillConfig().then(res => {
|
||||
that.$set(that, 'headerImg', res.data.lovely);
|
||||
that.$set(that, 'timeList', res.data.seckillTime);
|
||||
that.$set(that, 'active', res.data.seckillTimeIndex);
|
||||
|
||||
let title = [];
|
||||
title = res.data.seckillTime.map((item, index) => {
|
||||
return {
|
||||
name: 'div',
|
||||
attrs: {
|
||||
class: 'timeItem'
|
||||
},
|
||||
children: [
|
||||
{
|
||||
name: 'div',
|
||||
attrs: {
|
||||
class: 'time'
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'text',
|
||||
text: item.time
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'div',
|
||||
attrs: {
|
||||
class: 'state'
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'text',
|
||||
text: item.state
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
});
|
||||
that.$set(that, 'title', title);
|
||||
that.datatime = that.timeList[that.active].stop;
|
||||
that.getSeckillList();
|
||||
that.$nextTick(function() {
|
||||
that.sticky = true;
|
||||
uni.hideLoading();
|
||||
});
|
||||
});
|
||||
},
|
||||
setTime: function(event) {
|
||||
var that = this;
|
||||
that.active = event.mp.detail.index;
|
||||
that.datatime = that.timeList[that.active].stop;
|
||||
that.getSeckillList();
|
||||
},
|
||||
getSeckillList: function() {
|
||||
var that = this;
|
||||
if (that.loadingList) return;
|
||||
if (that.status) return;
|
||||
var time = that.timeList[that.active].id;
|
||||
getSeckillList(time, { page: that.page, limit: that.limit }).then(res => {
|
||||
that.status = res.data.length < that.limit;
|
||||
that.seckillList.push.apply(that.seckillList, res.data);
|
||||
that.page++;
|
||||
uni.hideLoading();
|
||||
});
|
||||
},
|
||||
goDetail: function(id) {
|
||||
var that = this;
|
||||
var time = that.timeList[that.active].stop;
|
||||
this.$yrouter.push({
|
||||
path: '/pages/activity/SeckillDetails/index',
|
||||
query: { id, time }
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped lang="less">
|
||||
.timeItem {
|
||||
font-size: 0.22 * 100rpx;
|
||||
color: #282828;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
padding: 0.11 * 100rpx 0;
|
||||
height: 0.96 * 100rpx;
|
||||
background-color: #efc58f;
|
||||
}
|
||||
.timeItem .time {
|
||||
font-size: 0.32 * 100rpx;
|
||||
font-weight: bold;
|
||||
height: 0.37 * 100rpx;
|
||||
line-height: 0.37 * 100rpx;
|
||||
}
|
||||
.timeItem .state {
|
||||
height: 0.37 * 100rpx;
|
||||
line-height: 0.37 * 100rpx;
|
||||
}
|
||||
.activity {
|
||||
color: #333;
|
||||
}
|
||||
.flash-sale .list .item .grab {
|
||||
background-color: #999;
|
||||
}
|
||||
</style>
|
||||
|
@ -1,214 +1,209 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view v-if="!$store.getters.token&&$deviceType=='weixin'">
|
||||
<view class="getUserInfo">
|
||||
<text>您还未允许微信登录授权,请点击下方按钮允许微信授权登录。</text>
|
||||
<button type="primary" open-type="getUserInfo" @getuserinfo="getUserInfo">允许微信登录授权</button>
|
||||
<view style="height:20rpx"></view>
|
||||
<button @click="back">取消微信登录授权</button>
|
||||
<view v-if="!token">
|
||||
<view v-if="$deviceType == 'weixin'">
|
||||
<view class="getUserInfo">
|
||||
<text>您还未允许微信登录授权,请点击下方按钮允许微信授权登录。</text>
|
||||
<button type="primary" open-type="getUserInfo" @getuserinfo="getUserInfo">允许微信登录授权</button>
|
||||
<view style="height:20rpx"></view>
|
||||
<button @click="back">取消微信登录授权</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="!$store.getters.token&&$deviceType!='weixin'&&$deviceType=='app'">
|
||||
<view class="getUserInfo">
|
||||
<text>请先登录</text>
|
||||
<button type="primary" @click="this.toLogin">去登录</button>
|
||||
<view v-if="$deviceType == 'app'">
|
||||
<view class="getUserInfo">
|
||||
<text>请先登录</text>
|
||||
<button type="primary" @click="this.toLogin">去登录</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
mapState,
|
||||
mapMutations,
|
||||
mapActions
|
||||
} from "vuex";
|
||||
// 组件
|
||||
// import request from "@//api/request";
|
||||
import {
|
||||
wxappAuth,
|
||||
getUser
|
||||
} from "@/api/user";
|
||||
import dayjs from "dayjs";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
import {
|
||||
login
|
||||
} from "@/utils";
|
||||
import { mapState, mapMutations, mapActions } from 'vuex';
|
||||
// 组件
|
||||
// import request from "@//api/request";
|
||||
import { wxappAuth, getUser } from '@/api/user';
|
||||
import dayjs from 'dayjs';
|
||||
import cookie from '@/utils/store/cookie';
|
||||
import { login } from '@/utils';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {};
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState(['isAuthorization','$deviceType','token'])
|
||||
},
|
||||
onShow() {
|
||||
this.UPDATE_AUTHORIZATIONPAGE(true);
|
||||
},
|
||||
onHide() {
|
||||
this.UPDATE_AUTHORIZATIONPAGE(false);
|
||||
this.changeAuthorization(false);
|
||||
},
|
||||
onUnload() {
|
||||
this.UPDATE_AUTHORIZATIONPAGE(false);
|
||||
this.changeAuthorization(false);
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['changeAuthorization', 'setUserInfo']),
|
||||
...mapMutations(['UPDATE_AUTHORIZATIONPAGE', 'CHANGE_TABTAR']),
|
||||
back() {
|
||||
this.$yrouter.switchTab({
|
||||
path: '/pages/home/index',
|
||||
query: {}
|
||||
});
|
||||
},
|
||||
computed: {
|
||||
...mapState(["isAuthorization"])
|
||||
},
|
||||
onShow() {
|
||||
|
||||
this.UPDATE_AUTHORIZATIONPAGE(true);
|
||||
},
|
||||
onHide() {
|
||||
this.UPDATE_AUTHORIZATIONPAGE(false);
|
||||
this.changeAuthorization(false);
|
||||
},
|
||||
onUnload() {
|
||||
this.UPDATE_AUTHORIZATIONPAGE(false);
|
||||
this.changeAuthorization(false);
|
||||
},
|
||||
methods: {
|
||||
...mapActions(["changeAuthorization", "setUserInfo"]),
|
||||
...mapMutations(["UPDATE_AUTHORIZATIONPAGE", "CHANGE_TABTAR"]),
|
||||
back() {
|
||||
this.$yrouter.switchTab({
|
||||
path: "/pages/home/index",
|
||||
query: {}
|
||||
});
|
||||
},
|
||||
getUserInfo(data) {
|
||||
if (data.detail.errMsg == "getUserInfo:fail auth deny") {
|
||||
uni.showToast({
|
||||
title: "取消授权",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
uni.showLoading({
|
||||
title: "登录中"
|
||||
});
|
||||
login({
|
||||
success: () => {}
|
||||
});
|
||||
},
|
||||
toLogin() {
|
||||
this.$yrouter.push({
|
||||
path: "/pages/user/Login/index",
|
||||
query: {}
|
||||
getUserInfo(data) {
|
||||
if (data.detail.errMsg == 'getUserInfo:fail auth deny') {
|
||||
uni.showToast({
|
||||
title: '取消授权',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '登录中'
|
||||
});
|
||||
login({
|
||||
success: () => {}
|
||||
});
|
||||
},
|
||||
onUnload() {},
|
||||
mounted() {}
|
||||
};
|
||||
toLogin() {
|
||||
this.$yrouter.push({
|
||||
path: '/pages/user/Login/index',
|
||||
query: {}
|
||||
});
|
||||
}
|
||||
},
|
||||
onUnload() {},
|
||||
mounted() {
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.sp-cell {
|
||||
height: 20rpx;
|
||||
.sp-cell {
|
||||
height: 20rpx;
|
||||
}
|
||||
|
||||
.getUserInfo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
padding: 30px;
|
||||
|
||||
text {
|
||||
font-size: 30rpx;
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.getUserInfo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
padding: 30px;
|
||||
.container {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
text {
|
||||
font-size: 30rpx;
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
}
|
||||
.tab-bar {
|
||||
font-size: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 99;
|
||||
border-top: 1px solid rgba(248, 248, 248, 1);
|
||||
|
||||
.container {
|
||||
.tab-bar-item {
|
||||
flex: 1;
|
||||
height: 49px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tab-bar {
|
||||
font-size: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 99;
|
||||
border-top: 1px solid rgba(248, 248, 248, 1);
|
||||
flex-direction: column;
|
||||
|
||||
.tab-bar-item {
|
||||
flex: 1;
|
||||
height: 49px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
|
||||
&.active {
|
||||
text {
|
||||
color: #ee7559;
|
||||
}
|
||||
|
||||
.tab-bar-pic {
|
||||
display: none;
|
||||
background: #f9f9f9;
|
||||
|
||||
&.active {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
&.active {
|
||||
text {
|
||||
color: #ee7559;
|
||||
}
|
||||
|
||||
.tab-bar-pic {
|
||||
display: block;
|
||||
display: none;
|
||||
background: #f9f9f9;
|
||||
|
||||
&.active {
|
||||
display: none;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tab-bar-pic {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
display: block;
|
||||
background: #f9f9f9;
|
||||
|
||||
image {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
&.active {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tab-bar-pic-active {}
|
||||
.tab-bar-pic {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
background: #f9f9f9;
|
||||
|
||||
text {
|
||||
font-size: 10px;
|
||||
color: rgb(160, 160, 160);
|
||||
line-height: 10px;
|
||||
margin-top: 5px;
|
||||
image {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
}
|
||||
}
|
||||
|
||||
.tab-bar-bg {
|
||||
padding-top: 46px;
|
||||
width: 100%;
|
||||
.tab-bar-pic-active {
|
||||
}
|
||||
|
||||
.view-item {
|
||||
display: none;
|
||||
width: 100%;
|
||||
text {
|
||||
font-size: 10px;
|
||||
color: rgb(160, 160, 160);
|
||||
line-height: 10px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.view-item-active {
|
||||
display: block;
|
||||
.tab-bar-bg {
|
||||
padding-top: 46px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.view-item {
|
||||
display: none;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.view-item-active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.getUserInfo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
padding: 30px;
|
||||
|
||||
p {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.getUserInfo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
padding: 30px;
|
||||
|
||||
p {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
._van-dialog {
|
||||
z-index: 99999999999;
|
||||
}
|
||||
._van-dialog {
|
||||
z-index: 99999999999;
|
||||
}
|
||||
</style>
|
||||
|
@ -1,313 +1,269 @@
|
||||
<template>
|
||||
<view class="index">
|
||||
<view class="header acea-row row-center-wrapper">
|
||||
<view @click="goGoodSearch()" class="search acea-row row-middle">
|
||||
<text class="iconfont icon-xiazai5"></text>搜索商品
|
||||
</view>
|
||||
</view>
|
||||
<view class="slider-banner banner">
|
||||
<swiper indicatorDots="true" v-if="banner.length > 0">
|
||||
<block v-for="(item, bannerIndex) in banner" :key="bannerIndex">
|
||||
<swiper-item>
|
||||
<view @click="item.url?$yrouter.push('/'+item.url) : ''" class="swiper-item">
|
||||
<image :src="item.pic" />
|
||||
</view>
|
||||
</swiper-item>
|
||||
</block>
|
||||
</swiper>
|
||||
</view>
|
||||
<view class="news acea-row row-between-wrapper">
|
||||
<view class="pictrue" v-if="$VUE_APP_RESOURCES_URL">
|
||||
<image :src="$VUE_APP_RESOURCES_URL+'/images/news.png'" />
|
||||
</view>
|
||||
<view class="swiper-no-swiping new-banner">
|
||||
<swiper
|
||||
class="swiper-wrapper"
|
||||
v-if="roll.length > 0"
|
||||
:indicator-dots="false"
|
||||
autoplay
|
||||
circular
|
||||
vertical
|
||||
>
|
||||
<block v-for="(item, rollIndex) in roll" :key="rollIndex">
|
||||
<swiper-item class="swiper-slide">
|
||||
<view
|
||||
@click="item.uniapp_url?$yrouter.push(item.uniapp_url) : ''"
|
||||
class="swiper-item acea-row row-between-wrapper"
|
||||
>
|
||||
<view class="text acea-row row-between-wrapper">
|
||||
<view class="label" v-if="item.show === '是'">最新</view>
|
||||
<view class="newsTitle line1">{{ item.info }}</view>
|
||||
</view>
|
||||
<view class="iconfont icon-xiangyou"></view>
|
||||
</view>
|
||||
</swiper-item>
|
||||
</block>
|
||||
</swiper>
|
||||
</view>
|
||||
</view>
|
||||
<view class="nav acea-row">
|
||||
<view
|
||||
@click="goWxappUrl(item)"
|
||||
class="item"
|
||||
v-for="(item, menusIndex) in menus"
|
||||
:key="menusIndex"
|
||||
>
|
||||
<view class="pictrue">
|
||||
<image :src="item.pic" />
|
||||
</view>
|
||||
<view>{{ item.name }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="wrapper hot" v-if="bastList.length > 0">
|
||||
<image class="bg" src="../../static/images/index-bg.png" mode="widthFix" ></image>
|
||||
<view class="title acea-row row-between-wrapper">
|
||||
<view class="text">
|
||||
<view class="name line1">热门榜单</view>
|
||||
</view>
|
||||
<view @click="goHotNewGoods()" class="more">
|
||||
更多
|
||||
<text class="iconfont icon-jiantou"></text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="newProducts">
|
||||
<scroll-view scroll-y="false" scroll-x="true">
|
||||
<view class="newProductsScroll">
|
||||
<view
|
||||
@click="goGoodsCon(item)"
|
||||
class="newProductsItem"
|
||||
v-for="(item, likeInfoIndex) in likeInfo"
|
||||
:key="likeInfoIndex"
|
||||
>
|
||||
<view class="img-box">
|
||||
<image :src="item.image" />
|
||||
</view>
|
||||
<view class="pro-info line1">{{ item.storeName }}</view>
|
||||
<view class="money font-color-red">¥{{ item.price }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="wrapper" v-if="bastList.length > 0">
|
||||
<view class="title acea-row row-between-wrapper">
|
||||
<view class="text">
|
||||
<view class="name line1">精品推荐</view>
|
||||
</view>
|
||||
<view @click="goHotNewGoods(1)" class="more">
|
||||
更多
|
||||
<text class="iconfont icon-jiantou"></text>
|
||||
</view>
|
||||
</view>
|
||||
<Good-list :good-list="bastList" :is-sort="false"></Good-list>
|
||||
</view>
|
||||
<view class="index">
|
||||
<view class="header acea-row row-center-wrapper">
|
||||
<view @click="goGoodSearch()" class="search acea-row row-middle">
|
||||
<text class="iconfont icon-xiazai5"></text>
|
||||
搜索商品
|
||||
</view>
|
||||
</view>
|
||||
<view class="slider-banner banner">
|
||||
<swiper indicatorDots="true" v-if="banner.length > 0">
|
||||
<block v-for="(item, bannerIndex) in banner" :key="bannerIndex">
|
||||
<swiper-item>
|
||||
<view @click="item.url ? $yrouter.push('/' + item.url) : ''" class="swiper-item"><image :src="item.pic" /></view>
|
||||
</swiper-item>
|
||||
</block>
|
||||
</swiper>
|
||||
</view>
|
||||
<view class="news acea-row row-between-wrapper">
|
||||
<view class="pictrue" v-if="$VUE_APP_RESOURCES_URL"><image :src="$VUE_APP_RESOURCES_URL + '/images/news.png'" /></view>
|
||||
<view class="swiper-no-swiping new-banner">
|
||||
<swiper class="swiper-wrapper" v-if="roll.length > 0" :indicator-dots="false" autoplay circular vertical>
|
||||
<block v-for="(item, rollIndex) in roll" :key="rollIndex">
|
||||
<swiper-item class="swiper-slide">
|
||||
<view @click="item.uniapp_url ? $yrouter.push(item.uniapp_url) : ''" class="swiper-item acea-row row-between-wrapper">
|
||||
<view class="text acea-row row-between-wrapper">
|
||||
<view class="label" v-if="item.show === '是'">最新</view>
|
||||
<view class="newsTitle line1">{{ item.info }}</view>
|
||||
</view>
|
||||
<view class="iconfont icon-xiangyou"></view>
|
||||
</view>
|
||||
</swiper-item>
|
||||
</block>
|
||||
</swiper>
|
||||
</view>
|
||||
</view>
|
||||
<view class="nav acea-row">
|
||||
<view @click="goWxappUrl(item)" class="item" v-for="(item, menusIndex) in menus" :key="menusIndex">
|
||||
<view class="pictrue"><image :src="item.pic" /></view>
|
||||
<view>{{ item.name }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="wrapper hot" v-if="bastList.length > 0">
|
||||
<image class="bg" src="../../static/images/index-bg.png" mode="widthFix"></image>
|
||||
<view class="title acea-row row-between-wrapper">
|
||||
<view class="text"><view class="name line1">热门榜单</view></view>
|
||||
<view @click="goHotNewGoods()" class="more">
|
||||
更多
|
||||
<text class="iconfont icon-jiantou"></text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="newProducts">
|
||||
<scroll-view scroll-y="false" scroll-x="true">
|
||||
<view class="newProductsScroll">
|
||||
<view @click="goGoodsCon(item)" class="newProductsItem" v-for="(item, likeInfoIndex) in likeInfo" :key="likeInfoIndex">
|
||||
<view class="img-box"><image :src="item.image" /></view>
|
||||
<view class="pro-info line1">{{ item.storeName }}</view>
|
||||
<view class="money font-color-red">¥{{ item.price }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="wrapper" v-if="bastList.length > 0">
|
||||
<view class="title acea-row row-between-wrapper">
|
||||
<view class="text"><view class="name line1">精品推荐</view></view>
|
||||
<view @click="goHotNewGoods(1)" class="more">
|
||||
更多
|
||||
<text class="iconfont icon-jiantou"></text>
|
||||
</view>
|
||||
</view>
|
||||
<Good-list :good-list="bastList" :is-sort="false"></Good-list>
|
||||
</view>
|
||||
|
||||
<view class="wrapper" v-if="firstList.length > 0">
|
||||
<view class="title acea-row row-between-wrapper">
|
||||
<view class="text">
|
||||
<view class="name line1">
|
||||
首发新品
|
||||
<text class="new font-color-red">NEW~</text>
|
||||
</view>
|
||||
</view>
|
||||
<view @click="goHotNewGoods(3)" class="more">
|
||||
更多
|
||||
<text class="iconfont icon-jiantou"></text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="newProducts">
|
||||
<scroll-view scroll-y="false" scroll-x="true">
|
||||
<view class="newProductsScroll">
|
||||
<view
|
||||
@click="goGoodsCon(item)"
|
||||
class="newProductsItem"
|
||||
v-for="(item, firstListIndex) in firstList"
|
||||
:key="firstListIndex"
|
||||
>
|
||||
<view class="img-box">
|
||||
<image :src="item.image" />
|
||||
</view>
|
||||
<view class="pro-info line1">{{ item.storeName }}</view>
|
||||
<view class="money font-color-red">¥{{ item.price }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="wrapper" v-if="benefit.length > 0">
|
||||
<view class="title acea-row row-between-wrapper">
|
||||
<view class="text">
|
||||
<view class="name line1">促销单品</view>
|
||||
</view>
|
||||
<view @click="goGoodsPromotion()" class="more">
|
||||
更多
|
||||
<text class="iconfont icon-jiantou"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<PromotionGood :benefit="benefit"></PromotionGood>
|
||||
<Coupon-window
|
||||
:coupon-list="couponList"
|
||||
v-if="showCoupon"
|
||||
@checked="couponClose"
|
||||
@close="couponClose"
|
||||
></Coupon-window>
|
||||
</view>
|
||||
<view class="wrapper" v-if="firstList.length > 0">
|
||||
<view class="title acea-row row-between-wrapper">
|
||||
<view class="text">
|
||||
<view class="name line1">
|
||||
首发新品
|
||||
<text class="new font-color-red">NEW~</text>
|
||||
</view>
|
||||
</view>
|
||||
<view @click="goHotNewGoods(3)" class="more">
|
||||
更多
|
||||
<text class="iconfont icon-jiantou"></text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="newProducts">
|
||||
<scroll-view scroll-y="false" scroll-x="true">
|
||||
<view class="newProductsScroll">
|
||||
<view @click="goGoodsCon(item)" class="newProductsItem" v-for="(item, firstListIndex) in firstList" :key="firstListIndex">
|
||||
<view class="img-box"><image :src="item.image" /></view>
|
||||
<view class="pro-info line1">{{ item.storeName }}</view>
|
||||
<view class="money font-color-red">¥{{ item.price }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="wrapper" v-if="benefit.length > 0">
|
||||
<view class="title acea-row row-between-wrapper">
|
||||
<view class="text"><view class="name line1">促销单品</view></view>
|
||||
<view @click="goGoodsPromotion()" class="more">
|
||||
更多
|
||||
<text class="iconfont icon-jiantou"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<PromotionGood :benefit="benefit"></PromotionGood>
|
||||
<Coupon-window :coupon-list="couponList" v-if="showCoupon" @checked="couponClose" @close="couponClose"></Coupon-window>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
// import { swiper, swiperSlide } from "vue-awesome-swiper";
|
||||
|
||||
import GoodList from "@/components/GoodList";
|
||||
import PromotionGood from "@/components/PromotionGood";
|
||||
import CouponWindow from "@/components/CouponWindow";
|
||||
import { getHomeData, getShare } from "@/api/public";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
import { isWeixin } from "@/utils/index";
|
||||
import GoodList from '@/components/GoodList';
|
||||
import PromotionGood from '@/components/PromotionGood';
|
||||
import CouponWindow from '@/components/CouponWindow';
|
||||
import { getHomeData, getShare } from '@/api/public';
|
||||
import cookie from '@/utils/store/cookie';
|
||||
import { isWeixin } from '@/utils/index';
|
||||
|
||||
const HAS_COUPON_WINDOW = "has_coupon_window";
|
||||
const HAS_COUPON_WINDOW = 'has_coupon_window';
|
||||
|
||||
export default {
|
||||
name: "Index",
|
||||
components: {
|
||||
// swiper,
|
||||
// swiperSlide,
|
||||
GoodList,
|
||||
PromotionGood,
|
||||
CouponWindow
|
||||
},
|
||||
props: {},
|
||||
data: function() {
|
||||
return {
|
||||
showCoupon: false,
|
||||
logoUrl: "",
|
||||
banner: [],
|
||||
menus: [],
|
||||
roll: [],
|
||||
activity: [],
|
||||
activityOne: {},
|
||||
bastList: [],
|
||||
firstList: [],
|
||||
info: {
|
||||
fastList: [],
|
||||
bastBanner: [],
|
||||
name: 'Index',
|
||||
components: {
|
||||
// swiper,
|
||||
// swiperSlide,
|
||||
GoodList,
|
||||
PromotionGood,
|
||||
CouponWindow
|
||||
},
|
||||
props: {},
|
||||
data: function() {
|
||||
return {
|
||||
showCoupon: false,
|
||||
logoUrl: '',
|
||||
banner: [],
|
||||
menus: [],
|
||||
roll: [],
|
||||
activity: [],
|
||||
activityOne: {},
|
||||
bastList: [],
|
||||
firstList: [],
|
||||
info: {
|
||||
fastList: [],
|
||||
bastBanner: [],
|
||||
|
||||
bastList: []
|
||||
},
|
||||
likeInfo: [],
|
||||
lovely: [],
|
||||
benefit: [],
|
||||
couponList: [],
|
||||
swiperOption: {
|
||||
pagination: {
|
||||
el: ".swiper-pagination",
|
||||
clickable: true
|
||||
},
|
||||
autoplay: {
|
||||
disableOnInteraction: false,
|
||||
delay: 2000
|
||||
},
|
||||
loop: true,
|
||||
speed: 1000,
|
||||
observer: true,
|
||||
observeParents: true
|
||||
},
|
||||
swiperRoll: {
|
||||
direction: "vertical",
|
||||
autoplay: {
|
||||
disableOnInteraction: false,
|
||||
delay: 2000
|
||||
},
|
||||
loop: true,
|
||||
speed: 1000,
|
||||
observer: true,
|
||||
observeParents: true
|
||||
},
|
||||
swiperScroll: {
|
||||
freeMode: true,
|
||||
freeModeMomentum: false,
|
||||
slidesPerView: "auto",
|
||||
observer: true,
|
||||
observeParents: true
|
||||
},
|
||||
swiperBoutique: {
|
||||
pagination: {
|
||||
el: ".swiper-pagination",
|
||||
clickable: true
|
||||
},
|
||||
autoplay: {
|
||||
disableOnInteraction: false,
|
||||
delay: 2000
|
||||
},
|
||||
loop: true,
|
||||
speed: 1000,
|
||||
observer: true,
|
||||
observeParents: true
|
||||
},
|
||||
swiperProducts: {
|
||||
freeMode: true,
|
||||
freeModeMomentum: false,
|
||||
slidesPerView: "auto",
|
||||
observer: true,
|
||||
observeParents: true
|
||||
}
|
||||
};
|
||||
},
|
||||
onShow: function() {
|
||||
let that = this;
|
||||
uni.showLoading({
|
||||
title:'加载中'
|
||||
})
|
||||
getHomeData().then(res => {
|
||||
that.logoUrl = res.data.logoUrl;
|
||||
that.$set(that, "banner", res.data.banner);
|
||||
that.$set(that, "menus", res.data.menus);
|
||||
that.$set(that, "roll", res.data.roll);
|
||||
that.$set(that, "activity", res.data.activity);
|
||||
var activityOne = res.data.activity.shift();
|
||||
that.$set(that, "activityOne", activityOne);
|
||||
that.$set(that, "info", res.data.info);
|
||||
that.$set(that, "firstList", res.data.firstList);
|
||||
that.$set(that, "bastList", res.data.bastList);
|
||||
that.$set(that, "likeInfo", res.data.likeInfo);
|
||||
that.$set(that, "lovely", res.data.lovely);
|
||||
that.$set(that, "benefit", res.data.benefit);
|
||||
that.$set(that, "couponList", res.data.couponList);
|
||||
uni.hideLoading()
|
||||
that.setOpenShare();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
goGoodSearch() {
|
||||
this.$yrouter.push("/pages/shop/GoodSearch/index");
|
||||
},
|
||||
goWxappUrl(item) {
|
||||
this.$yrouter.push(item.uniapp_url);
|
||||
},
|
||||
goHotNewGoods(type) {
|
||||
this.$yrouter.push({
|
||||
path: "/pages/shop/HotNewGoods/index",
|
||||
query: { type }
|
||||
});
|
||||
},
|
||||
goGoodsCon(item) {
|
||||
console.log(item)
|
||||
this.$yrouter.push({
|
||||
path: "/pages/shop/GoodsCon/index",
|
||||
query: { id: item.id }
|
||||
});
|
||||
},
|
||||
goGoodsPromotion() {
|
||||
this.$yrouter.push("/pages/shop/GoodsPromotion/index");
|
||||
},
|
||||
setOpenShare: function() {}
|
||||
}
|
||||
bastList: []
|
||||
},
|
||||
likeInfo: [],
|
||||
lovely: [],
|
||||
benefit: [],
|
||||
couponList: [],
|
||||
swiperOption: {
|
||||
pagination: {
|
||||
el: '.swiper-pagination',
|
||||
clickable: true
|
||||
},
|
||||
autoplay: {
|
||||
disableOnInteraction: false,
|
||||
delay: 2000
|
||||
},
|
||||
loop: true,
|
||||
speed: 1000,
|
||||
observer: true,
|
||||
observeParents: true
|
||||
},
|
||||
swiperRoll: {
|
||||
direction: 'vertical',
|
||||
autoplay: {
|
||||
disableOnInteraction: false,
|
||||
delay: 2000
|
||||
},
|
||||
loop: true,
|
||||
speed: 1000,
|
||||
observer: true,
|
||||
observeParents: true
|
||||
},
|
||||
swiperScroll: {
|
||||
freeMode: true,
|
||||
freeModeMomentum: false,
|
||||
slidesPerView: 'auto',
|
||||
observer: true,
|
||||
observeParents: true
|
||||
},
|
||||
swiperBoutique: {
|
||||
pagination: {
|
||||
el: '.swiper-pagination',
|
||||
clickable: true
|
||||
},
|
||||
autoplay: {
|
||||
disableOnInteraction: false,
|
||||
delay: 2000
|
||||
},
|
||||
loop: true,
|
||||
speed: 1000,
|
||||
observer: true,
|
||||
observeParents: true
|
||||
},
|
||||
swiperProducts: {
|
||||
freeMode: true,
|
||||
freeModeMomentum: false,
|
||||
slidesPerView: 'auto',
|
||||
observer: true,
|
||||
observeParents: true
|
||||
}
|
||||
};
|
||||
},
|
||||
onShow: function() {
|
||||
let that = this;
|
||||
uni.showLoading({
|
||||
title: '加载中'
|
||||
});
|
||||
getHomeData().then(res => {
|
||||
console.log(res);
|
||||
that.logoUrl = res.data.logoUrl;
|
||||
that.$set(that, 'banner', res.data.banner);
|
||||
that.$set(that, 'menus', res.data.menus);
|
||||
that.$set(that, 'roll', res.data.roll);
|
||||
that.$set(that, 'activity', res.data.activity);
|
||||
var activityOne = res.data.activity.shift();
|
||||
that.$set(that, 'activityOne', activityOne);
|
||||
that.$set(that, 'info', res.data.info);
|
||||
that.$set(that, 'firstList', res.data.firstList);
|
||||
that.$set(that, 'bastList', res.data.bastList);
|
||||
that.$set(that, 'likeInfo', res.data.likeInfo);
|
||||
that.$set(that, 'lovely', res.data.lovely);
|
||||
that.$set(that, 'benefit', res.data.benefit);
|
||||
that.$set(that, 'couponList', res.data.couponList);
|
||||
uni.hideLoading();
|
||||
that.setOpenShare();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
goGoodSearch() {
|
||||
this.$yrouter.push('/pages/shop/GoodSearch/index');
|
||||
},
|
||||
goWxappUrl(item) {
|
||||
this.$yrouter.push(item.uniapp_url);
|
||||
},
|
||||
goHotNewGoods(type) {
|
||||
this.$yrouter.push({
|
||||
path: '/pages/shop/HotNewGoods/index',
|
||||
query: { type }
|
||||
});
|
||||
},
|
||||
goGoodsCon(item) {
|
||||
console.log(item);
|
||||
this.$yrouter.push({
|
||||
path: '/pages/shop/GoodsCon/index',
|
||||
query: { id: item.id }
|
||||
});
|
||||
},
|
||||
goGoodsPromotion() {
|
||||
this.$yrouter.push('/pages/shop/GoodsPromotion/index');
|
||||
},
|
||||
setOpenShare: function() {}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped lang="less">
|
||||
.index {
|
||||
background-color: #fff;
|
||||
background-color: #fff;
|
||||
}
|
||||
.swiper-item {
|
||||
height: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
@ -1,135 +1,110 @@
|
||||
<template>
|
||||
<view class="shoppingCart">
|
||||
<view class v-if="userInfo.uid">
|
||||
<view class="labelNav acea-row row-around row-middle">
|
||||
<view class="item">
|
||||
<text class="iconfont icon-xuanzhong"></text>100%正品保证
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="iconfont icon-xuanzhong"></text>所有商品精挑细选
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="iconfont icon-xuanzhong"></text>售后无忧
|
||||
</view>
|
||||
</view>
|
||||
<view class="nav acea-row row-between-wrapper">
|
||||
<view>
|
||||
购物数量
|
||||
<text class="num font-color-red">{{ count }}</text>
|
||||
</view>
|
||||
<view
|
||||
v-if="cartList.valid.length > 0"
|
||||
class="administrate acea-row row-center-wrapper"
|
||||
@click="manage"
|
||||
>{{ footerswitch ? "取消" : "管理" }}</view>
|
||||
</view>
|
||||
<view v-if="validList.length > 0 || cartList.invalid.length > 0">
|
||||
<view class="list">
|
||||
<view
|
||||
class="item acea-row row-between-wrapper"
|
||||
v-for="(item, cartListValidIndex) in validList"
|
||||
:key="cartListValidIndex"
|
||||
>
|
||||
<view class="select-btn">
|
||||
<view class="checkbox-wrapper">
|
||||
<checkbox-group @change="switchSelect(cartListValidIndex)">
|
||||
<label class="well-check">
|
||||
<checkbox value :checked="item.checked"></checkbox>
|
||||
</label>
|
||||
</checkbox-group>
|
||||
</view>
|
||||
</view>
|
||||
<view class="picTxt acea-row row-between-wrapper">
|
||||
<view class="pictrue" @click="goGoodsCon(item)">
|
||||
<image :src="item.productInfo.attrInfo.image" v-if="item.productInfo.attrInfo" />
|
||||
<image :src="item.productInfo.image" v-else />
|
||||
</view>
|
||||
<view class="text">
|
||||
<view class="line1">{{ item.productInfo.storeName }}</view>
|
||||
<view
|
||||
class="infor line1"
|
||||
v-if="item.productInfo.attrInfo"
|
||||
>属性:{{ item.productInfo.attrInfo.suk }}</view>
|
||||
<view class="money">¥{{ item.truePrice }}</view>
|
||||
</view>
|
||||
<view class="carnum acea-row row-center-wrapper">
|
||||
<view
|
||||
class="reduce"
|
||||
:class="validList[cartListValidIndex].cartNum <= 1 ? 'on' : ''"
|
||||
@click.prevent="reduce(cartListValidIndex)"
|
||||
>-</view>
|
||||
<view class="num">{{ item.cartNum }}</view>
|
||||
<view
|
||||
class="plus"
|
||||
v-if="validList[cartListValidIndex].attrInfo"
|
||||
:class="validList[cartListValidIndex].cartNum >=validList[cartListValidIndex].attrInfo.stock? 'on': ''"
|
||||
@click.prevent="plus(cartListValidIndex)"
|
||||
>+</view>
|
||||
<view
|
||||
class="plus"
|
||||
v-else
|
||||
:class="validList[cartListValidIndex].cartNum >= validList[cartListValidIndex].stock? 'on': ''"
|
||||
@click.prevent="plus(cartListValidIndex)"
|
||||
>+</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="invalidGoods" v-if="cartList.invalid.length > 0">
|
||||
<view class="goodsNav acea-row row-between-wrapper">
|
||||
<view @click="goodsOpen">
|
||||
<text
|
||||
class="iconfont"
|
||||
:class="goodsHidden === true ? 'icon-xiangyou' : 'icon-xiangxia'"
|
||||
></text>失效商品
|
||||
</view>
|
||||
<view class="del" @click="delInvalidGoods">
|
||||
<text class="iconfont icon-shanchu1"></text>清空
|
||||
</view>
|
||||
</view>
|
||||
<view class="goodsList" :hidden="goodsHidden">
|
||||
<view
|
||||
v-for="(item, cartListinvalidIndex) in cartList.invalid"
|
||||
:key="cartListinvalidIndex"
|
||||
>
|
||||
<view
|
||||
@click="goGoodsCon(item)"
|
||||
class="item acea-row row-between-wrapper"
|
||||
v-if="item.productInfo"
|
||||
>
|
||||
<view class="invalid acea-row row-center-wrapper">失效</view>
|
||||
<view class="pictrue">
|
||||
<image :src="item.productInfo.attrInfo.image" v-if="item.productInfo.attrInfo" />
|
||||
<image :src="item.productInfo.image" v-else />
|
||||
</view>
|
||||
<view class="text acea-row row-column-between">
|
||||
<view class="line1">{{ item.productInfo.storeName }}</view>
|
||||
<view
|
||||
class="infor line1"
|
||||
v-if="item.productInfo.attrInfo"
|
||||
>属性:{{ item.productInfo.attrInfo.suk }}</view>
|
||||
<view class="acea-row row-between-wrapper">
|
||||
<view class="end">该商品已下架</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!--购物车暂无商品-->
|
||||
<view class="noCart" v-if="cartList.valid.length === 0 && cartList.invalid.length === 0">
|
||||
<view class="pictrue">
|
||||
<image :src="$VUE_APP_RESOURCES_URL+'/images/noCart.png'" />
|
||||
</view>
|
||||
<Recommend></Recommend>
|
||||
</view>
|
||||
<view style="height:210rpx"></view>
|
||||
<view :class="['footer acea-row row-between-wrapper']" v-if="cartList.valid.length > 0">
|
||||
<view>
|
||||
<view class="select-btn">
|
||||
<view class="checkbox-wrapper">
|
||||
<!-- <label class="well-check">
|
||||
<view class="shoppingCart">
|
||||
<view class v-if="userInfo.uid">
|
||||
<view class="labelNav acea-row row-around row-middle">
|
||||
<view class="item">
|
||||
<text class="iconfont icon-xuanzhong"></text>
|
||||
100%正品保证
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="iconfont icon-xuanzhong"></text>
|
||||
所有商品精挑细选
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="iconfont icon-xuanzhong"></text>
|
||||
售后无忧
|
||||
</view>
|
||||
</view>
|
||||
<view class="nav acea-row row-between-wrapper">
|
||||
<view>
|
||||
购物数量
|
||||
<text class="num font-color-red">{{ count }}</text>
|
||||
</view>
|
||||
<view v-if="cartList.valid.length > 0" class="administrate acea-row row-center-wrapper" @click="manage">{{ footerswitch ? '取消' : '管理' }}</view>
|
||||
</view>
|
||||
<view v-if="validList.length > 0 || cartList.invalid.length > 0">
|
||||
<view class="list">
|
||||
<view class="item acea-row row-between-wrapper" v-for="(item, cartListValidIndex) in validList" :key="cartListValidIndex">
|
||||
<view class="select-btn">
|
||||
<view class="checkbox-wrapper">
|
||||
<checkbox-group @change="switchSelect(cartListValidIndex)">
|
||||
<label class="well-check"><checkbox value :checked="item.checked"></checkbox></label>
|
||||
</checkbox-group>
|
||||
</view>
|
||||
</view>
|
||||
<view class="picTxt acea-row row-between-wrapper">
|
||||
<view class="pictrue" @click="goGoodsCon(item)">
|
||||
<image :src="item.productInfo.attrInfo.image" v-if="item.productInfo.attrInfo" />
|
||||
<image :src="item.productInfo.image" v-else />
|
||||
</view>
|
||||
<view class="text">
|
||||
<view class="line1">{{ item.productInfo.storeName }}</view>
|
||||
<view class="infor line1" v-if="item.productInfo.attrInfo">属性:{{ item.productInfo.attrInfo.suk }}</view>
|
||||
<view class="money">¥{{ item.truePrice }}</view>
|
||||
</view>
|
||||
<view class="carnum acea-row row-center-wrapper">
|
||||
<view class="reduce" :class="validList[cartListValidIndex].cartNum <= 1 ? 'on' : ''" @click.prevent="reduce(cartListValidIndex)">-</view>
|
||||
<view class="num">{{ item.cartNum }}</view>
|
||||
<view
|
||||
class="plus"
|
||||
v-if="validList[cartListValidIndex].attrInfo"
|
||||
:class="validList[cartListValidIndex].cartNum >= validList[cartListValidIndex].attrInfo.stock ? 'on' : ''"
|
||||
@click.prevent="plus(cartListValidIndex)"
|
||||
>
|
||||
+
|
||||
</view>
|
||||
<view
|
||||
class="plus"
|
||||
v-else
|
||||
:class="validList[cartListValidIndex].cartNum >= validList[cartListValidIndex].stock ? 'on' : ''"
|
||||
@click.prevent="plus(cartListValidIndex)"
|
||||
>
|
||||
+
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="invalidGoods" v-if="cartList.invalid.length > 0">
|
||||
<view class="goodsNav acea-row row-between-wrapper">
|
||||
<view @click="goodsOpen">
|
||||
<text class="iconfont" :class="goodsHidden === true ? 'icon-xiangyou' : 'icon-xiangxia'"></text>
|
||||
失效商品
|
||||
</view>
|
||||
<view class="del" @click="delInvalidGoods">
|
||||
<text class="iconfont icon-shanchu1"></text>
|
||||
清空
|
||||
</view>
|
||||
</view>
|
||||
<view class="goodsList" :hidden="goodsHidden">
|
||||
<view v-for="(item, cartListinvalidIndex) in cartList.invalid" :key="cartListinvalidIndex">
|
||||
<view @click="goGoodsCon(item)" class="item acea-row row-between-wrapper" v-if="item.productInfo">
|
||||
<view class="invalid acea-row row-center-wrapper">失效</view>
|
||||
<view class="pictrue">
|
||||
<image :src="item.productInfo.attrInfo.image" v-if="item.productInfo.attrInfo" />
|
||||
<image :src="item.productInfo.image" v-else />
|
||||
</view>
|
||||
<view class="text acea-row row-column-between">
|
||||
<view class="line1">{{ item.productInfo.storeName }}</view>
|
||||
<view class="infor line1" v-if="item.productInfo.attrInfo">属性:{{ item.productInfo.attrInfo.suk }}</view>
|
||||
<view class="acea-row row-between-wrapper"><view class="end">该商品已下架</view></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!--购物车暂无商品-->
|
||||
<view class="noCart" v-if="cartList.valid.length === 0 && cartList.invalid.length === 0">
|
||||
<view class="pictrue"><image :src="$VUE_APP_RESOURCES_URL + '/images/noCart.png'" /></view>
|
||||
<Recommend></Recommend>
|
||||
</view>
|
||||
<view style="height:210rpx"></view>
|
||||
<view :class="['footer acea-row row-between-wrapper']" v-if="cartList.valid.length > 0">
|
||||
<view>
|
||||
<view class="select-btn">
|
||||
<view class="checkbox-wrapper">
|
||||
<!-- <label class="well-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
name
|
||||
@ -141,382 +116,385 @@
|
||||
<text class="checkAll">全选 ({{ cartCount }})</text>
|
||||
</label>-->
|
||||
|
||||
<checkbox-group @change="allChecked">
|
||||
<label class="well-check">
|
||||
<checkbox value :checked="isAllSelect && cartCount > 0"></checkbox>
|
||||
<text class="checkAll">全选 ({{ cartCount }})</text>
|
||||
</label>
|
||||
</checkbox-group>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="money acea-row row-middle" v-if="footerswitch === false">
|
||||
<text class="font-color-red">¥{{ countmoney }}</text>
|
||||
<view class="placeOrder bg-color-red" @click="placeOrder">立即下单</view>
|
||||
</view>
|
||||
<view class="button acea-row row-middle" v-else>
|
||||
<view class="bnt cart-color" @click="collectAll">收藏</view>
|
||||
<view class="bnt" @click="delgoods">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<Authorization v-if="!$store.getters.token" />
|
||||
</view>
|
||||
<checkbox-group @change="allChecked">
|
||||
<label class="well-check">
|
||||
<checkbox value :checked="isAllSelect && cartCount > 0"></checkbox>
|
||||
<text class="checkAll">全选 ({{ cartCount }})</text>
|
||||
</label>
|
||||
</checkbox-group>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="money acea-row row-middle" v-if="footerswitch === false">
|
||||
<text class="font-color-red">¥{{ countmoney }}</text>
|
||||
<view class="placeOrder bg-color-red" @click="placeOrder">立即下单</view>
|
||||
</view>
|
||||
<view class="button acea-row row-middle" v-else>
|
||||
<view class="bnt cart-color" @click="collectAll">收藏</view>
|
||||
<view class="bnt" @click="delgoods">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<Authorization v-if="!$store.getters.token" />
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import Recommend from "@/components/Recommend";
|
||||
import Authorization from "@/pages/authorization/index";
|
||||
import { mapGetters } from "vuex";
|
||||
import Recommend from '@/components/Recommend';
|
||||
import Authorization from '@/pages/authorization/index';
|
||||
import { mapGetters } from 'vuex';
|
||||
|
||||
import {
|
||||
getCartList,
|
||||
postCartDel,
|
||||
changeCartNum,
|
||||
getCartCount
|
||||
} from "@/api/store";
|
||||
import { postCollectAll } from "@/api/user";
|
||||
import { mul, add } from "@/utils/bc";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
import { getCartList, postCartDel, changeCartNum, getCartCount } from '@/api/store';
|
||||
import { postCollectAll } from '@/api/user';
|
||||
import { mul, add } from '@/utils/bc';
|
||||
import cookie from '@/utils/store/cookie';
|
||||
|
||||
const CHECKED_IDS = "cart_checked";
|
||||
const CHECKED_IDS = 'cart_checked';
|
||||
|
||||
export default {
|
||||
name: "ShoppingCart",
|
||||
components: {
|
||||
Recommend,
|
||||
Authorization
|
||||
},
|
||||
props: {},
|
||||
data: function() {
|
||||
return {
|
||||
cartList: {
|
||||
invalid: [],
|
||||
valid: []
|
||||
},
|
||||
validList: [],
|
||||
isAllSelect: false,
|
||||
cartCount: 0,
|
||||
countmoney: 0,
|
||||
goodsHidden: true,
|
||||
footerswitch: false,
|
||||
count: 0,
|
||||
checkedIds: [],
|
||||
loaded: false
|
||||
};
|
||||
},
|
||||
computed: mapGetters(["userInfo"]),
|
||||
name: 'ShoppingCart',
|
||||
components: {
|
||||
Recommend,
|
||||
Authorization
|
||||
},
|
||||
props: {},
|
||||
data: function() {
|
||||
return {
|
||||
cartList: {
|
||||
invalid: [],
|
||||
valid: []
|
||||
},
|
||||
validList: [],
|
||||
isAllSelect: false,
|
||||
cartCount: 0,
|
||||
countmoney: 0,
|
||||
goodsHidden: true,
|
||||
footerswitch: false,
|
||||
count: 0,
|
||||
checkedIds: [],
|
||||
loaded: false
|
||||
};
|
||||
},
|
||||
computed: mapGetters(['userInfo', 'token']),
|
||||
|
||||
// watch: {
|
||||
// $yroute(n) {
|
||||
// if (n.name === "ShoppingCart") {
|
||||
// this.carnum();
|
||||
// this.countMoney();
|
||||
// this.getCartList();
|
||||
// this.gainCount();
|
||||
// this.goodsHidden = true;
|
||||
// this.footerswitch = false;
|
||||
// }
|
||||
// },
|
||||
// cartList(list) {
|
||||
// this.validList = list.valid;
|
||||
// }
|
||||
// },
|
||||
watch: {
|
||||
userInfo(user) {
|
||||
console.log(user);
|
||||
if (user.uid) {
|
||||
this.carnum();
|
||||
this.countMoney();
|
||||
this.getCartList();
|
||||
this.gainCount();
|
||||
}
|
||||
},
|
||||
cartList(list) {
|
||||
this.validList = list.valid;
|
||||
}
|
||||
},
|
||||
onShow: function() {
|
||||
if (this.userInfo.uid) {
|
||||
this.carnum();
|
||||
this.countMoney();
|
||||
this.getCartList();
|
||||
this.gainCount();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
goGoodsCon(item) {
|
||||
this.$yrouter.push({
|
||||
path: "/pages/shop/GoodsCon/index",
|
||||
query: {
|
||||
id: item.productId
|
||||
}
|
||||
});
|
||||
},
|
||||
getCartList: function() {
|
||||
let that = this;
|
||||
getCartList().then(res => {
|
||||
that.cartList = res.data;
|
||||
let checkedIds = cookie.get(CHECKED_IDS) || [];
|
||||
if (!Array.isArray(checkedIds)) checkedIds = [];
|
||||
this.cartList.valid.forEach(cart => {
|
||||
if (checkedIds.indexOf(cart.id) !== -1) cart.checked = true;
|
||||
});
|
||||
if (checkedIds.length) {
|
||||
that.checkedIds = checkedIds;
|
||||
that.isAllSelect = checkedIds.length === this.cartList.valid.length;
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
}
|
||||
this.loaded = true;
|
||||
});
|
||||
},
|
||||
//删除商品;
|
||||
delgoods: function() {
|
||||
let that = this,
|
||||
id = [],
|
||||
valid = [],
|
||||
list = that.cartList.valid;
|
||||
list.forEach(function(val) {
|
||||
if (val.checked === true) {
|
||||
id.push(val.id);
|
||||
}
|
||||
});
|
||||
if (id.length === 0) {
|
||||
uni.showToast({
|
||||
title: "请选择产品",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
postCartDel(id).then(function() {
|
||||
list.forEach(function(val, i) {
|
||||
if (val.checked === false || val.checked === undefined)
|
||||
valid.push(list[i]);
|
||||
});
|
||||
that.$set(that.cartList, "valid", valid);
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
that.gainCount();
|
||||
that.getCartList();
|
||||
});
|
||||
},
|
||||
// //获取数量
|
||||
gainCount: function() {
|
||||
let that = this;
|
||||
getCartCount().then(res => {
|
||||
that.count = res.data.count;
|
||||
});
|
||||
},
|
||||
//清除失效产品;
|
||||
delInvalidGoods: function() {
|
||||
let that = this,
|
||||
id = [],
|
||||
list = that.cartList.invalid;
|
||||
list.forEach(function(val) {
|
||||
id.push(val.id);
|
||||
});
|
||||
postCartDel(id).then(function() {
|
||||
list.splice(0, list.length);
|
||||
that.gainCount();
|
||||
that.getCartList();
|
||||
});
|
||||
},
|
||||
//批量收藏;
|
||||
collectAll: function() {
|
||||
let that = this,
|
||||
data = {
|
||||
id: [],
|
||||
category: ""
|
||||
},
|
||||
list = that.cartList.valid;
|
||||
list.forEach(function(val) {
|
||||
if (val.checked === true) {
|
||||
data.id.push(val.product_id);
|
||||
data.category = val.type;
|
||||
}
|
||||
});
|
||||
if (data.id.length === 0) {
|
||||
uni.showToast({
|
||||
title: "请选择产品",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
postCollectAll(data).then(function() {
|
||||
uni.showToast({
|
||||
title: "收藏成功!",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
});
|
||||
},
|
||||
//立即下单;
|
||||
placeOrder: function() {
|
||||
let that = this,
|
||||
list = that.cartList.valid,
|
||||
id = [];
|
||||
list.forEach(function(val) {
|
||||
if (val.checked === true) {
|
||||
id.push(val.id);
|
||||
}
|
||||
});
|
||||
if (id.length === 0) {
|
||||
uni.showToast({
|
||||
title: "请选择产品",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
console.log(id);
|
||||
this.$yrouter.push({
|
||||
path: "/pages/order/OrderSubmission/index",
|
||||
query: {
|
||||
id: id.join(",")
|
||||
}
|
||||
});
|
||||
},
|
||||
manage: function() {
|
||||
let that = this;
|
||||
that.footerswitch = !that.footerswitch;
|
||||
},
|
||||
goodsOpen: function() {
|
||||
let that = this;
|
||||
that.goodsHidden = !that.goodsHidden;
|
||||
},
|
||||
//加
|
||||
plus: function(index) {
|
||||
let that = this;
|
||||
let list = that.cartList.valid[index];
|
||||
list.cartNum++;
|
||||
if (list.attrInfo) {
|
||||
if (list.cartNum >= list.attrInfo.stock) {
|
||||
that.$set(list, "cart_num", list.attrInfo.stock);
|
||||
}
|
||||
} else {
|
||||
if (list.cartNum >= list.stock) {
|
||||
that.$set(list, "cart_num", list.stock);
|
||||
}
|
||||
}
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
that.syncCartNum(list);
|
||||
},
|
||||
//减
|
||||
reduce: function(index) {
|
||||
let that = this;
|
||||
let list = that.cartList.valid[index];
|
||||
if (list.cartNum <= 1) {
|
||||
uni.showToast({
|
||||
title: "已经是底线啦!",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
list.cartNum--;
|
||||
if (list.cartNum < 1) {
|
||||
that.$set(list, "cart_num", 1);
|
||||
}
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
that.syncCartNum(list);
|
||||
},
|
||||
syncCartNum(cart) {
|
||||
if (!cart.sync) {
|
||||
changeCartNum(cart.id, Math.max(cart.cartNum, 1) || 1)
|
||||
.then(res => {
|
||||
this.getCartList();
|
||||
})
|
||||
.catch(error => {
|
||||
uni.showToast({
|
||||
title: error.response.data.msg,
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
//单选
|
||||
switchSelect: function(index) {
|
||||
let that = this,
|
||||
cart = that.cartList.valid[index],
|
||||
i = this.checkedIds.indexOf(cart.id);
|
||||
cart.checked = !cart.checked;
|
||||
// watch: {
|
||||
// $yroute(n) {
|
||||
// if (n.name === "ShoppingCart") {
|
||||
// this.carnum();
|
||||
// this.countMoney();
|
||||
// this.getCartList();
|
||||
// this.gainCount();
|
||||
// this.goodsHidden = true;
|
||||
// this.footerswitch = false;
|
||||
// }
|
||||
// },
|
||||
// cartList(list) {
|
||||
// this.validList = list.valid;
|
||||
// }
|
||||
// },
|
||||
watch: {
|
||||
userInfo(user) {
|
||||
console.log(user, '用户信息,8585');
|
||||
if (user.uid) {
|
||||
this.carnum();
|
||||
this.countMoney();
|
||||
this.getCartList();
|
||||
this.gainCount();
|
||||
}
|
||||
},
|
||||
token(token) {
|
||||
console.log(token, '用户token,8585');
|
||||
if (this.userInfo.uid) {
|
||||
this.carnum();
|
||||
this.countMoney();
|
||||
this.getCartList();
|
||||
this.gainCount();
|
||||
}
|
||||
},
|
||||
cartList(list) {
|
||||
this.validList = list.valid;
|
||||
}
|
||||
},
|
||||
onShow: function() {
|
||||
if (this.userInfo.uid) {
|
||||
this.carnum();
|
||||
this.countMoney();
|
||||
this.getCartList();
|
||||
this.gainCount();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
goGoodsCon(item) {
|
||||
this.$yrouter.push({
|
||||
path: '/pages/shop/GoodsCon/index',
|
||||
query: {
|
||||
id: item.productId
|
||||
}
|
||||
});
|
||||
},
|
||||
getCartList: function() {
|
||||
let that = this;
|
||||
getCartList().then(res => {
|
||||
that.cartList = res.data;
|
||||
let checkedIds = cookie.get(CHECKED_IDS) || [];
|
||||
if (!Array.isArray(checkedIds)) checkedIds = [];
|
||||
this.cartList.valid.forEach(cart => {
|
||||
if (checkedIds.indexOf(cart.id) !== -1) cart.checked = true;
|
||||
});
|
||||
if (checkedIds.length) {
|
||||
that.checkedIds = checkedIds;
|
||||
that.isAllSelect = checkedIds.length === this.cartList.valid.length;
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
}
|
||||
this.loaded = true;
|
||||
});
|
||||
},
|
||||
//删除商品;
|
||||
delgoods: function() {
|
||||
let that = this,
|
||||
id = [],
|
||||
valid = [],
|
||||
list = that.cartList.valid;
|
||||
list.forEach(function(val) {
|
||||
if (val.checked === true) {
|
||||
id.push(val.id);
|
||||
}
|
||||
});
|
||||
if (id.length === 0) {
|
||||
uni.showToast({
|
||||
title: '请选择产品',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
postCartDel(id).then(function() {
|
||||
list.forEach(function(val, i) {
|
||||
if (val.checked === false || val.checked === undefined) valid.push(list[i]);
|
||||
});
|
||||
that.$set(that.cartList, 'valid', valid);
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
that.gainCount();
|
||||
that.getCartList();
|
||||
});
|
||||
},
|
||||
// //获取数量
|
||||
gainCount: function() {
|
||||
let that = this;
|
||||
getCartCount().then(res => {
|
||||
that.count = res.data.count;
|
||||
});
|
||||
},
|
||||
//清除失效产品;
|
||||
delInvalidGoods: function() {
|
||||
let that = this,
|
||||
id = [],
|
||||
list = that.cartList.invalid;
|
||||
list.forEach(function(val) {
|
||||
id.push(val.id);
|
||||
});
|
||||
postCartDel(id).then(function() {
|
||||
list.splice(0, list.length);
|
||||
that.gainCount();
|
||||
that.getCartList();
|
||||
});
|
||||
},
|
||||
//批量收藏;
|
||||
collectAll: function() {
|
||||
let that = this,
|
||||
data = {
|
||||
id: [],
|
||||
category: ''
|
||||
},
|
||||
list = that.cartList.valid;
|
||||
list.forEach(function(val) {
|
||||
if (val.checked === true) {
|
||||
data.id.push(val.product_id);
|
||||
data.category = val.type;
|
||||
}
|
||||
});
|
||||
if (data.id.length === 0) {
|
||||
uni.showToast({
|
||||
title: '请选择产品',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
postCollectAll(data).then(function() {
|
||||
uni.showToast({
|
||||
title: '收藏成功!',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
});
|
||||
},
|
||||
//立即下单;
|
||||
placeOrder: function() {
|
||||
let that = this,
|
||||
list = that.cartList.valid,
|
||||
id = [];
|
||||
list.forEach(function(val) {
|
||||
if (val.checked === true) {
|
||||
id.push(val.id);
|
||||
}
|
||||
});
|
||||
if (id.length === 0) {
|
||||
uni.showToast({
|
||||
title: '请选择产品',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
console.log(id);
|
||||
this.$yrouter.push({
|
||||
path: '/pages/order/OrderSubmission/index',
|
||||
query: {
|
||||
id: id.join(',')
|
||||
}
|
||||
});
|
||||
},
|
||||
manage: function() {
|
||||
let that = this;
|
||||
that.footerswitch = !that.footerswitch;
|
||||
},
|
||||
goodsOpen: function() {
|
||||
let that = this;
|
||||
that.goodsHidden = !that.goodsHidden;
|
||||
},
|
||||
//加
|
||||
plus: function(index) {
|
||||
let that = this;
|
||||
let list = that.cartList.valid[index];
|
||||
list.cartNum++;
|
||||
if (list.attrInfo) {
|
||||
if (list.cartNum >= list.attrInfo.stock) {
|
||||
that.$set(list, 'cart_num', list.attrInfo.stock);
|
||||
}
|
||||
} else {
|
||||
if (list.cartNum >= list.stock) {
|
||||
that.$set(list, 'cart_num', list.stock);
|
||||
}
|
||||
}
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
that.syncCartNum(list);
|
||||
},
|
||||
//减
|
||||
reduce: function(index) {
|
||||
let that = this;
|
||||
let list = that.cartList.valid[index];
|
||||
if (list.cartNum <= 1) {
|
||||
uni.showToast({
|
||||
title: '已经是底线啦!',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
list.cartNum--;
|
||||
if (list.cartNum < 1) {
|
||||
that.$set(list, 'cart_num', 1);
|
||||
}
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
that.syncCartNum(list);
|
||||
},
|
||||
syncCartNum(cart) {
|
||||
if (!cart.sync) {
|
||||
changeCartNum(cart.id, Math.max(cart.cartNum, 1) || 1)
|
||||
.then(res => {
|
||||
this.getCartList();
|
||||
})
|
||||
.catch(error => {
|
||||
uni.showToast({
|
||||
title: error.response.data.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
//单选
|
||||
switchSelect: function(index) {
|
||||
let that = this,
|
||||
cart = that.cartList.valid[index],
|
||||
i = this.checkedIds.indexOf(cart.id);
|
||||
cart.checked = !cart.checked;
|
||||
|
||||
if (i !== -1) this.checkedIds.splice(i, 1);
|
||||
if (cart.checked) {
|
||||
this.checkedIds.push(cart.id);
|
||||
}
|
||||
let len = that.cartList.valid.length;
|
||||
let selectnum = [];
|
||||
for (let i = 0; i < len; i++) {
|
||||
if (that.cartList.valid[i].checked === true) {
|
||||
selectnum.push(true);
|
||||
}
|
||||
}
|
||||
that.isAllSelect = selectnum.length === len;
|
||||
that.$set(that, "cartList", that.cartList);
|
||||
that.$set(that, "isAllSelect", that.isAllSelect);
|
||||
cookie.set(CHECKED_IDS, that.checkedIds);
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
},
|
||||
//全选
|
||||
allChecked: function(e) {
|
||||
let that = this;
|
||||
let selectAllStatus = e.mp.detail.value[0] ? true : false;
|
||||
// let selectAllStatus = that.isAllSelect;
|
||||
let checkedIds = [];
|
||||
// for (let i = 0; i < array.length; i++) {
|
||||
// array[i].checked = selectAllStatus;
|
||||
// checked.push()
|
||||
// }
|
||||
that.cartList.valid.forEach(cart => {
|
||||
cart.checked = selectAllStatus;
|
||||
if (selectAllStatus) {
|
||||
checkedIds.push(cart.id);
|
||||
}
|
||||
});
|
||||
let cartList = {
|
||||
...that.cartList
|
||||
};
|
||||
that.cartList = [];
|
||||
that.cartList = cartList;
|
||||
this.$set(this, "cartList", this.cartList);
|
||||
this.$set(this, "isAllSelect", selectAllStatus);
|
||||
this.checkedIds = checkedIds;
|
||||
cookie.set(CHECKED_IDS, checkedIds);
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
this.$forceUpdate();
|
||||
},
|
||||
//数量
|
||||
carnum: function() {
|
||||
let that = this;
|
||||
var carnum = 0;
|
||||
var array = that.cartList.valid;
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (array[i].checked === true) {
|
||||
carnum += parseInt(array[i].cartNum);
|
||||
}
|
||||
}
|
||||
that.$set(that, "cartCount", carnum);
|
||||
},
|
||||
//总共价钱;
|
||||
countMoney: function() {
|
||||
let that = this;
|
||||
let carmoney = 0;
|
||||
let array = that.cartList.valid;
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (array[i].checked === true) {
|
||||
carmoney = add(carmoney, mul(array[i].cartNum, array[i].truePrice));
|
||||
}
|
||||
}
|
||||
that.countmoney = carmoney;
|
||||
}
|
||||
}
|
||||
if (i !== -1) this.checkedIds.splice(i, 1);
|
||||
if (cart.checked) {
|
||||
this.checkedIds.push(cart.id);
|
||||
}
|
||||
let len = that.cartList.valid.length;
|
||||
let selectnum = [];
|
||||
for (let i = 0; i < len; i++) {
|
||||
if (that.cartList.valid[i].checked === true) {
|
||||
selectnum.push(true);
|
||||
}
|
||||
}
|
||||
that.isAllSelect = selectnum.length === len;
|
||||
that.$set(that, 'cartList', that.cartList);
|
||||
that.$set(that, 'isAllSelect', that.isAllSelect);
|
||||
cookie.set(CHECKED_IDS, that.checkedIds);
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
},
|
||||
//全选
|
||||
allChecked: function(e) {
|
||||
let that = this;
|
||||
let selectAllStatus = e.mp.detail.value[0] ? true : false;
|
||||
// let selectAllStatus = that.isAllSelect;
|
||||
let checkedIds = [];
|
||||
// for (let i = 0; i < array.length; i++) {
|
||||
// array[i].checked = selectAllStatus;
|
||||
// checked.push()
|
||||
// }
|
||||
that.cartList.valid.forEach(cart => {
|
||||
cart.checked = selectAllStatus;
|
||||
if (selectAllStatus) {
|
||||
checkedIds.push(cart.id);
|
||||
}
|
||||
});
|
||||
let cartList = {
|
||||
...that.cartList
|
||||
};
|
||||
that.cartList = [];
|
||||
that.cartList = cartList;
|
||||
this.$set(this, 'cartList', this.cartList);
|
||||
this.$set(this, 'isAllSelect', selectAllStatus);
|
||||
this.checkedIds = checkedIds;
|
||||
cookie.set(CHECKED_IDS, checkedIds);
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
this.$forceUpdate();
|
||||
},
|
||||
//数量
|
||||
carnum: function() {
|
||||
let that = this;
|
||||
var carnum = 0;
|
||||
var array = that.cartList.valid;
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (array[i].checked === true) {
|
||||
carnum += parseInt(array[i].cartNum);
|
||||
}
|
||||
}
|
||||
that.$set(that, 'cartCount', carnum);
|
||||
},
|
||||
//总共价钱;
|
||||
countMoney: function() {
|
||||
let that = this;
|
||||
let carmoney = 0;
|
||||
let array = that.cartList.valid;
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (array[i].checked === true) {
|
||||
carmoney = add(carmoney, mul(array[i].cartNum, array[i].truePrice));
|
||||
}
|
||||
}
|
||||
that.countmoney = carmoney;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</script>
|
||||
|
211
store/index.js
211
store/index.js
@ -5,105 +5,126 @@ Vue.use(Vuex);
|
||||
const debug = process.env.NODE_ENV !== "production";
|
||||
|
||||
import store from "@/utils/store/cookie";
|
||||
import { getUserInfo } from "@/api/user";
|
||||
import {
|
||||
getUserInfo
|
||||
} from "@/api/user";
|
||||
import dialog from "@/utils/dialog";
|
||||
|
||||
const LOGIN_KEY = "login_status";
|
||||
|
||||
const vuexStore = new Vuex.Store({
|
||||
state: {
|
||||
// 是否已经在授权页面
|
||||
isAuthorizationPage: false,
|
||||
// 是否授权
|
||||
isAuthorization: false,
|
||||
token: store.get(LOGIN_KEY) || null,
|
||||
userInfo: store.get('userInfo')
|
||||
},
|
||||
mutations: {
|
||||
SHOW_FOOTER(state) {
|
||||
state.footer = true;
|
||||
},
|
||||
HIDE_FOOTER(state) {
|
||||
state.footer = false;
|
||||
},
|
||||
SHOW_HOME(state) {
|
||||
state.home = true;
|
||||
},
|
||||
HIDE_HOME(state) {
|
||||
state.home = false;
|
||||
},
|
||||
OPEN_HOME(state) {
|
||||
state.homeActive = true;
|
||||
},
|
||||
CLOSE_HOME(state) {
|
||||
state.homeActive = false;
|
||||
},
|
||||
CHANGE_TABTAR(state, index) {
|
||||
state.tabtarIndex = index;
|
||||
},
|
||||
LOGIN(state, token, expires_time) {
|
||||
state.token = token;
|
||||
store.set(LOGIN_KEY, token, expires_time);
|
||||
},
|
||||
LOGOUT(state) {
|
||||
state.token = null;
|
||||
state.userInfo = null
|
||||
store.clearAll()
|
||||
},
|
||||
BACKGROUND_COLOR(state, color) {
|
||||
state.color = color;
|
||||
// document.body.style.backgroundColor = color;
|
||||
},
|
||||
UPDATE_USERINFO(state, userInfo) {
|
||||
state.userInfo = userInfo;
|
||||
},
|
||||
UPDATE_AUTHORIZATIONPAGE(state, isAuthorizationPage) {
|
||||
state.isAuthorizationPage = isAuthorizationPage;
|
||||
},
|
||||
UPDATE_AUTHORIZATION(state, isAuthorization) {
|
||||
state.isAuthorization = isAuthorization;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
USERINFO({ state, commit }, force) {
|
||||
if (state.userInfo !== null && !force)
|
||||
return Promise.resolve(state.userInfo);
|
||||
else
|
||||
return new Promise(reslove => {
|
||||
getUserInfo().then(res => {
|
||||
commit("UPDATE_USERINFO", res.data);
|
||||
reslove(res.data);
|
||||
});
|
||||
}).catch(() => {
|
||||
dialog.error("获取信息失败!");
|
||||
});
|
||||
},
|
||||
changeLogin({ state, commit }, data, date) {
|
||||
commit("LOGIN", data, date);
|
||||
},
|
||||
setUserInfo({ state, commit }, user) {
|
||||
commit("UPDATE_USERINFO", user);
|
||||
if (user) {
|
||||
store.set('userInfo', user)
|
||||
} else {
|
||||
store.set('userInfo', null)
|
||||
}
|
||||
},
|
||||
changeAuthorizationPage({ state, commit }, index) {
|
||||
commit("UPDATE_AUTHORIZATIONPAGE", index);
|
||||
},
|
||||
changeAuthorization({ state, commit }, index) {
|
||||
commit("UPDATE_AUTHORIZATION", index);
|
||||
},
|
||||
},
|
||||
getters: {
|
||||
isAuthorizationPage: state => state.isAuthorizationPage,
|
||||
isAuthorization: state => state.isAuthorization,
|
||||
token: state => state.token,
|
||||
isLogin: state => !!state.token,
|
||||
userInfo: state => state.userInfo || {},
|
||||
},
|
||||
strict: debug
|
||||
state: {
|
||||
// 是否已经在授权页面
|
||||
isAuthorizationPage: false,
|
||||
// 是否授权
|
||||
isAuthorization: false,
|
||||
token: store.get(LOGIN_KEY) || null,
|
||||
userInfo: store.get('userInfo'),
|
||||
$deviceType: null,
|
||||
},
|
||||
mutations: {
|
||||
SHOW_FOOTER(state) {
|
||||
state.footer = true;
|
||||
},
|
||||
HIDE_FOOTER(state) {
|
||||
state.footer = false;
|
||||
},
|
||||
SHOW_HOME(state) {
|
||||
state.home = true;
|
||||
},
|
||||
HIDE_HOME(state) {
|
||||
state.home = false;
|
||||
},
|
||||
OPEN_HOME(state) {
|
||||
state.homeActive = true;
|
||||
},
|
||||
CLOSE_HOME(state) {
|
||||
state.homeActive = false;
|
||||
},
|
||||
CHANGE_TABTAR(state, index) {
|
||||
state.tabtarIndex = index;
|
||||
},
|
||||
LOGIN(state, token, expires_time) {
|
||||
state.token = token;
|
||||
store.set(LOGIN_KEY, token, expires_time);
|
||||
},
|
||||
LOGOUT(state) {
|
||||
state.token = null;
|
||||
state.userInfo = null
|
||||
store.clearAll()
|
||||
},
|
||||
BACKGROUND_COLOR(state, color) {
|
||||
state.color = color;
|
||||
// document.body.style.backgroundColor = color;
|
||||
},
|
||||
UPDATE_USERINFO(state, userInfo) {
|
||||
state.userInfo = userInfo;
|
||||
},
|
||||
UPDATE_AUTHORIZATIONPAGE(state, isAuthorizationPage) {
|
||||
state.isAuthorizationPage = isAuthorizationPage;
|
||||
},
|
||||
UPDATE_AUTHORIZATION(state, isAuthorization) {
|
||||
state.isAuthorization = isAuthorization;
|
||||
},
|
||||
UPDATE_DEVICETYPE(state, $deviceType) {
|
||||
state.$deviceType = $deviceType;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
USERINFO({
|
||||
state,
|
||||
commit
|
||||
}, force) {
|
||||
if (state.userInfo !== null && !force)
|
||||
return Promise.resolve(state.userInfo);
|
||||
else
|
||||
return new Promise(reslove => {
|
||||
getUserInfo().then(res => {
|
||||
commit("UPDATE_USERINFO", res.data);
|
||||
reslove(res.data);
|
||||
});
|
||||
}).catch(() => {
|
||||
dialog.error("获取信息失败!");
|
||||
});
|
||||
},
|
||||
changeLogin({
|
||||
state,
|
||||
commit
|
||||
}, data, date) {
|
||||
commit("LOGIN", data, date);
|
||||
},
|
||||
setUserInfo({
|
||||
state,
|
||||
commit
|
||||
}, user) {
|
||||
commit("UPDATE_USERINFO", user);
|
||||
if (user) {
|
||||
store.set('userInfo', user)
|
||||
} else {
|
||||
store.set('userInfo', null)
|
||||
}
|
||||
},
|
||||
changeAuthorizationPage({
|
||||
state,
|
||||
commit
|
||||
}, index) {
|
||||
commit("UPDATE_AUTHORIZATIONPAGE", index);
|
||||
},
|
||||
changeAuthorization({
|
||||
state,
|
||||
commit
|
||||
}, index) {
|
||||
commit("UPDATE_AUTHORIZATION", index);
|
||||
},
|
||||
},
|
||||
getters: {
|
||||
isAuthorizationPage: state => state.isAuthorizationPage,
|
||||
isAuthorization: state => state.isAuthorization,
|
||||
token: state => state.token,
|
||||
isLogin: state => !!state.token,
|
||||
userInfo: state => state.userInfo || {},
|
||||
},
|
||||
strict: debug
|
||||
});
|
||||
|
||||
export default vuexStore
|
||||
export default vuexStore
|
||||
|
@ -117,7 +117,6 @@ export const replaceLogin = (msg) => {
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
console.log(Vue.prototype.$deviceType)
|
||||
// 这里代表已经失去登录状态以及401强制推出登录了
|
||||
store.commit('LOGOUT')
|
||||
console.log(uni, 989)
|
||||
|
@ -45,7 +45,7 @@ function baseRequest(options) {
|
||||
...option
|
||||
}).then(res => {
|
||||
console.log(res)
|
||||
console.log(url,params,data, ...option)
|
||||
// console.log(url,params,data, ...option)
|
||||
const data = res.data || {};
|
||||
if (res.status !== 200)
|
||||
return Promise.reject({ msg: "请求失败", res, data });
|
||||
|
Reference in New Issue
Block a user