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