yshop3.1正式发布
This commit is contained in:
@ -47,6 +47,7 @@ export default {
|
||||
return {
|
||||
page: 1,
|
||||
limit: 20,
|
||||
type:'collect',
|
||||
collectProductList: [],
|
||||
loadTitle: "",
|
||||
loading: false,
|
||||
@ -71,7 +72,7 @@ export default {
|
||||
if (that.loading) return; //阻止下次请求(false可以进行请求);
|
||||
if (that.loadend) return; //阻止结束当前请求(false可以进行请求);
|
||||
that.loading = true;
|
||||
getCollectUser(that.page, that.limit).then(res => {
|
||||
getCollectUser(that.page, that.limit,that.type).then(res => {
|
||||
that.loading = false;
|
||||
//apply();js将一个数组插入另一个数组;
|
||||
that.collectProductList.push.apply(that.collectProductList, res.data);
|
||||
|
File diff suppressed because it is too large
Load Diff
102
pages/shop/GoodsFoot/index.vue
Normal file
102
pages/shop/GoodsFoot/index.vue
Normal file
@ -0,0 +1,102 @@
|
||||
<template>
|
||||
<view ref="container">
|
||||
<view class="collectionGoods" v-if="collectProductList.length > 0">
|
||||
<view
|
||||
class="item acea-row row-between-wrapper"
|
||||
v-for="(item, collectProductListIndex) in collectProductList"
|
||||
:key="collectProductListIndex"
|
||||
@click="goGoodsCon(item)"
|
||||
>
|
||||
<view class="pictrue">
|
||||
<image :src="item.image" />
|
||||
</view>
|
||||
<view class="text acea-row row-column-between">
|
||||
<view class="infor line1">{{ item.storeName }}</view>
|
||||
<view class="acea-row row-between-wrapper">
|
||||
<view class="money font-color-red">¥{{ item.price }}</view>
|
||||
<view class="delete" @tap.stop="delCollection(collectProductListIndex)">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<Loading :loaded="loadend" :loading="loading"></Loading>
|
||||
<view
|
||||
class="noCommodity"
|
||||
style="background-color:#fff;"
|
||||
v-if="collectProductList.length < 1 && page > 1"
|
||||
>
|
||||
<view class="noPictrue">
|
||||
<image src="@/static/images/noCollection.png" class="image" />
|
||||
</view>
|
||||
<Recommend></Recommend>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import Recommend from "@/components/Recommend";
|
||||
import { getCollectUser, getCollectDel } from "@/api/user";
|
||||
import Loading from "@/components/Loading";
|
||||
export default {
|
||||
name: "GoodsFoot",
|
||||
components: {
|
||||
Recommend,
|
||||
Loading
|
||||
},
|
||||
props: {},
|
||||
data: function() {
|
||||
return {
|
||||
page: 1,
|
||||
limit: 20,
|
||||
type:'foot',
|
||||
collectProductList: [],
|
||||
loadTitle: "",
|
||||
loading: false,
|
||||
loadend: false
|
||||
};
|
||||
},
|
||||
mounted: function() {
|
||||
this.get_user_collect_product();
|
||||
},
|
||||
onReachBottom() {
|
||||
!this.loading && this.get_user_collect_product();
|
||||
},
|
||||
methods: {
|
||||
goGoodsCon(item) {
|
||||
this.$yrouter.push({
|
||||
path: "/pages/shop/GoodsCon/index",
|
||||
query: { id: item.pid }
|
||||
});
|
||||
},
|
||||
get_user_collect_product: function() {
|
||||
let that = this;
|
||||
if (that.loading) return; //阻止下次请求(false可以进行请求);
|
||||
if (that.loadend) return; //阻止结束当前请求(false可以进行请求);
|
||||
that.loading = true;
|
||||
getCollectUser(that.page, that.limit,that.type).then(res => {
|
||||
that.loading = false;
|
||||
//apply();js将一个数组插入另一个数组;
|
||||
that.collectProductList.push.apply(that.collectProductList, res.data);
|
||||
that.loadend = res.data.length < that.limit; //判断所有数据是否加载完成;
|
||||
that.page = that.page + 1;
|
||||
});
|
||||
},
|
||||
//删除收藏;
|
||||
delCollection: function(index) {
|
||||
let that = this,
|
||||
id = that.collectProductList[index].pid,
|
||||
category = that.collectProductList[index].category;
|
||||
getCollectDel(id, category).then(function() {
|
||||
uni.showToast({
|
||||
title: "删除成功",
|
||||
icon: "success",
|
||||
duration: 2000,
|
||||
complete: () => {
|
||||
that.collectProductList.splice(index, 1);
|
||||
that.$set(that, "collectProductList", that.collectProductList);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
182
pages/shop/Live/LiveList/index.vue
Normal file
182
pages/shop/Live/LiveList/index.vue
Normal file
@ -0,0 +1,182 @@
|
||||
<template>
|
||||
<view class="page_box">
|
||||
<view class="head_box">
|
||||
<view class="live-tab">
|
||||
<view class="live-tab__item" v-for="tab in liveTab" :key="tab.title" @tap="selTab(tab)">
|
||||
<view class="live-tab__item-name">{{ tab.name }}</view>
|
||||
<text class="live-tab__item--link" :class="{ 'live-tab__item--active': tabCur == tab.title }"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="content_box">
|
||||
<scroll-view scroll-y="true" @scrolltolower="loadMore" class="scroll-box">
|
||||
<view class="list-box">
|
||||
<block v-for="live in liveList" :key="live.roomId">
|
||||
<shop-live-card :detail="live"></shop-live-card>
|
||||
</block>
|
||||
</view>
|
||||
<view v-if="liveList.length" class="cu-load text-gray" :class="loadStatus"></view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<Loading :loaded="loaded" :loading="loading"></Loading>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
yxWechatLive
|
||||
} from "@/api/live";
|
||||
import ShopLiveCard from '@/components/ShopLiveCard.vue'
|
||||
import Loading from "@/components/Loading";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ShopLiveCard,
|
||||
Loading
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tabCur: 'all',
|
||||
liveStatus: '',
|
||||
loaded: false,
|
||||
loading: false,
|
||||
liveTab: [{
|
||||
title: 'all',
|
||||
name: '全部',
|
||||
code: ''
|
||||
},
|
||||
{
|
||||
title: 'prevue',
|
||||
name: '预告',
|
||||
code: '102'
|
||||
|
||||
},
|
||||
{
|
||||
title: 'living',
|
||||
name: '直播中',
|
||||
code: '101'
|
||||
|
||||
},
|
||||
{
|
||||
title: 'lived',
|
||||
name: '已结束',
|
||||
code: '103'
|
||||
|
||||
}
|
||||
],
|
||||
liveList: [],
|
||||
loadStatus: '', //loading,over
|
||||
currentPage: 0,
|
||||
size: 10,
|
||||
lastPage: 0
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
onLoad() {
|
||||
this.getLiveList();
|
||||
},
|
||||
onHide() {},
|
||||
methods: {
|
||||
// 切换tab
|
||||
selTab(tab) {
|
||||
console.log(tab)
|
||||
this.tabCur = tab.title;
|
||||
this.liveStatus = tab.code;
|
||||
this.liveList = [];
|
||||
this.loaded=false;
|
||||
this.loading=false;
|
||||
this.getLiveListTab();
|
||||
},
|
||||
|
||||
// 直播列表
|
||||
getLiveListTab() {
|
||||
let that = this;
|
||||
yxWechatLive({
|
||||
liveStatus: that.liveStatus,
|
||||
page: 0,
|
||||
size: that.size
|
||||
}).then(res => {
|
||||
that.liveList = [...that.liveList, ...res.data.content];
|
||||
that.lastPage = res.data.lastPage;
|
||||
this.loaded = res.data.content.length < that.size;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 直播列表
|
||||
getLiveList() {
|
||||
let that = this;
|
||||
if (this.loading || this.loaded) return;
|
||||
this.loading = true;
|
||||
yxWechatLive({
|
||||
liveStatus: this.liveStatus,
|
||||
page: this.currentPage,
|
||||
size: this.size
|
||||
}).then(res => {
|
||||
that.liveList = that.liveList.concat(res.data.content)
|
||||
this.currentPage++;
|
||||
this.loaded = res.data.content.length < that.size;
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
onReachBottom() {
|
||||
!this.loading && this.getLiveList();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
// tab
|
||||
.live-tab {
|
||||
width: 100%;
|
||||
height: 96rpx;
|
||||
background: #fff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
&__item {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__item-name {
|
||||
font-size: 28rpx;
|
||||
font-family: PingFang SC;
|
||||
font-weight: bold;
|
||||
color: rgba(51, 51, 51, 1);
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__item--link {
|
||||
width: 68rpx;
|
||||
height: 4rpx;
|
||||
background: transparent;
|
||||
border-radius: 2rpx;
|
||||
}
|
||||
|
||||
&__item--active {
|
||||
width: 68rpx;
|
||||
height: 4rpx;
|
||||
background: rgba(213, 166, 90, 1);
|
||||
border-radius: 2rpx;
|
||||
}
|
||||
}
|
||||
|
||||
// 瀑布流 list
|
||||
.scroll-box {
|
||||
.list-box {
|
||||
width: 100%;
|
||||
-moz-column-count: 2;
|
||||
-webkit-column-count: 2;
|
||||
column-count: 2;
|
||||
padding: 25rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
@ -17,19 +17,13 @@
|
||||
购物数量
|
||||
<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 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="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)">
|
||||
@ -46,31 +40,19 @@
|
||||
</view>
|
||||
<view class="text">
|
||||
<view class="line1">{{ item.productInfo.storeName }}</view>
|
||||
<view
|
||||
class="infor line1"
|
||||
v-if="item.productInfo.attrInfo"
|
||||
>属性:{{ item.productInfo.attrInfo.sku }}</view>
|
||||
<view class="infor line1" v-if="item.productInfo.attrInfo">属性:{{ item.productInfo.attrInfo.sku }}</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="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"
|
||||
<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
|
||||
@click.prevent="plus(cartListValidIndex)">+</view>
|
||||
<view class="plus" v-else
|
||||
:class="validList[cartListValidIndex].cartNum >= validList[cartListValidIndex].stock ? 'on' : ''"
|
||||
@click.prevent="plus(cartListValidIndex)"
|
||||
>+</view>
|
||||
@click.prevent="plus(cartListValidIndex)">+</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -78,25 +60,15 @@
|
||||
<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>失效商品
|
||||
<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 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" />
|
||||
@ -104,10 +76,8 @@
|
||||
</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.sku }}</view>
|
||||
<view class="infor line1" v-if="item.productInfo.attrInfo">属性:{{ item.productInfo.attrInfo.sku }}
|
||||
</view>
|
||||
<view class="acea-row row-between-wrapper">
|
||||
<view class="end">该商品已下架</view>
|
||||
</view>
|
||||
@ -160,77 +130,96 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<Authorization v-if="!$store.getters.token" />
|
||||
<Authorization v-else />
|
||||
</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: []
|
||||
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", "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) {
|
||||
if (user.uid) {
|
||||
this.carnum();
|
||||
this.countMoney();
|
||||
this.getCartList();
|
||||
this.gainCount();
|
||||
}
|
||||
},
|
||||
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) {
|
||||
if (user.uid) {
|
||||
this.carnum();
|
||||
this.countMoney();
|
||||
this.getCartList();
|
||||
this.gainCount();
|
||||
token(token) {
|
||||
if (this.userInfo.uid) {
|
||||
this.carnum();
|
||||
this.countMoney();
|
||||
this.getCartList();
|
||||
this.gainCount();
|
||||
}
|
||||
},
|
||||
cartList(list) {
|
||||
this.validList = list.valid;
|
||||
}
|
||||
},
|
||||
token(token) {
|
||||
onShow: function () {
|
||||
if (this.userInfo.uid) {
|
||||
this.carnum();
|
||||
this.countMoney();
|
||||
@ -238,297 +227,285 @@ export default {
|
||||
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;
|
||||
methods: {
|
||||
goGoodsCon(item) {
|
||||
this.$yrouter.push({
|
||||
path: "/pages/shop/GoodsCon/index",
|
||||
query: {
|
||||
id: item.productId
|
||||
}
|
||||
});
|
||||
if (checkedIds.length) {
|
||||
that.checkedIds = checkedIds;
|
||||
that.isAllSelect = checkedIds.length === this.cartList.valid.length;
|
||||
},
|
||||
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();
|
||||
}
|
||||
this.loaded = true;
|
||||
});
|
||||
},
|
||||
//删除商品;
|
||||
delgoods: function() {
|
||||
let that = this,
|
||||
id = [],
|
||||
valid = [],
|
||||
list = that.cartList.valid;
|
||||
list.forEach(function(val) {
|
||||
if (val.checked === true) {
|
||||
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;
|
||||
}
|
||||
});
|
||||
if (id.length === 0) {
|
||||
uni.showToast({
|
||||
title: "请选择产品",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
postCollectAll(data).then(function () {
|
||||
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]);
|
||||
},
|
||||
//立即下单;
|
||||
placeOrder: function () {
|
||||
let that = this,
|
||||
list = that.cartList.valid,
|
||||
id = [];
|
||||
list.forEach(function (val) {
|
||||
if (val.checked === true) {
|
||||
id.push(val.id);
|
||||
}
|
||||
});
|
||||
that.$set(that.cartList, "valid", valid);
|
||||
if (id.length === 0) {
|
||||
uni.showToast({
|
||||
title: "请选择产品",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
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.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;
|
||||
}
|
||||
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();
|
||||
this.gainCount();
|
||||
})
|
||||
.catch(error => {
|
||||
this.gainCount();
|
||||
uni.showToast({
|
||||
title: error.response.data.msg,
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
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
|
||||
});
|
||||
}
|
||||
},
|
||||
//单选
|
||||
switchSelect: function(index) {
|
||||
let that = this,
|
||||
cart = that.cartList.valid[index],
|
||||
i = this.checkedIds.indexOf(cart.id);
|
||||
cart.checked = !cart.checked;
|
||||
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();
|
||||
this.gainCount();
|
||||
})
|
||||
.catch(error => {
|
||||
this.gainCount();
|
||||
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);
|
||||
if (i !== -1) this.checkedIds.splice(i, 1);
|
||||
if (cart.checked) {
|
||||
this.checkedIds.push(cart.id);
|
||||
}
|
||||
}
|
||||
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.gainCount();
|
||||
that.countMoney();
|
||||
},
|
||||
//全选
|
||||
allChecked: function(e) {
|
||||
console.log(e);
|
||||
let that = this;
|
||||
let selectAllStatus = e.mp.detail.value[0] == "allSelect" ? true : false;
|
||||
console.log(selectAllStatus);
|
||||
// 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 len = that.cartList.valid.length;
|
||||
let selectnum = [];
|
||||
for (let i = 0; i < len; i++) {
|
||||
if (that.cartList.valid[i].checked === true) {
|
||||
selectnum.push(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
let cartList = {
|
||||
...that.cartList
|
||||
};
|
||||
that.cartList = [];
|
||||
that.cartList = cartList;
|
||||
console.log(this.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.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.gainCount();
|
||||
that.countMoney();
|
||||
},
|
||||
//全选
|
||||
allChecked: function (e) {
|
||||
console.log(e);
|
||||
let that = this;
|
||||
let selectAllStatus = e.mp.detail.value[0] == "allSelect" ? true : false;
|
||||
console.log(selectAllStatus);
|
||||
// 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;
|
||||
console.log(this.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.$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;
|
||||
}
|
||||
that.countmoney = carmoney;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
@ -16,7 +16,7 @@
|
||||
</view>
|
||||
<view class="row-right">
|
||||
<view>
|
||||
<a class="store-phone" :href="'tel:' + item.phone">
|
||||
<a class="store-phone" @click="telPhone(item.phone)">
|
||||
<text class="iconfont icon-dadianhua01"></text>
|
||||
</a>
|
||||
</view>
|
||||
@ -35,7 +35,7 @@
|
||||
<script>
|
||||
import Loading from "@/components/Loading";
|
||||
import { storeListApi } from "@/api/store";
|
||||
import { isWeixin } from "@/utils/index";
|
||||
import { isWeixin,tel } from "@/utils/index";
|
||||
import { wechatEvevt, wxShowLocation } from "@/libs/wechat";
|
||||
import { mapGetters } from "vuex";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
@ -79,6 +79,15 @@ export default {
|
||||
this.$yrouter.back();
|
||||
}
|
||||
},
|
||||
//拨打电话
|
||||
telPhone(phoneNumber) {
|
||||
uni.makePhoneCall({
|
||||
phoneNumber: phoneNumber,
|
||||
fail() {
|
||||
console.log("取消拨打");
|
||||
}
|
||||
});
|
||||
},
|
||||
// 获取门店列表数据
|
||||
getList: function() {
|
||||
if (this.loading || this.loaded) return;
|
||||
@ -98,7 +107,11 @@ export default {
|
||||
this.mapKey = res.data.mapKey;
|
||||
})
|
||||
.catch(err => {
|
||||
this.$dialog.error(err.msg);
|
||||
uni.showToast({
|
||||
title: err.msg,
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user