修改个人中心,购物车空白区域的问题
This commit is contained in:
@ -2,6 +2,6 @@
|
|||||||
// export const VUE_APP_API_URL = 'http://natapp.xinxintuan.co/api';
|
// export const VUE_APP_API_URL = 'http://natapp.xinxintuan.co/api';
|
||||||
// export const VUE_APP_API_URL = 'https://wxapi.yixiang.co/api';
|
// export const VUE_APP_API_URL = 'https://wxapi.yixiang.co/api';
|
||||||
// export const VUE_APP_API_URL = 'http://192.168.31.223:8008/api';
|
// export const VUE_APP_API_URL = 'http://192.168.31.223:8008/api';
|
||||||
export const VUE_APP_API_URL = 'http://h5api.xinxintuan.co/api';
|
export const VUE_APP_API_URL = 'https://h5api.xinxintuan.co/api';
|
||||||
export const VUE_APP_RESOURCES_URL = 'https://wx.yixiang.co/static';
|
export const VUE_APP_RESOURCES_URL = 'https://wx.yixiang.co/static';
|
||||||
|
|
||||||
|
@ -21,9 +21,6 @@
|
|||||||
<view class="qr" @click="startQr()">
|
<view class="qr" @click="startQr()">
|
||||||
<image src="@/static/images/qr.png" />
|
<image src="@/static/images/qr.png" />
|
||||||
</view>
|
</view>
|
||||||
<view class="qr" @click="$yrouter.push({path:'/pages/shop/GoodsEvaluate/index'})">
|
|
||||||
<image src="@/static/images/qr.png" />
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
<Banner :banner="banner" @getbgcolor="getbgcolor"></Banner>
|
<Banner :banner="banner" @getbgcolor="getbgcolor"></Banner>
|
||||||
<uni-notice-bar scrollable="true" @click="goRoll(singNew)" single="true" :speed="10" showIcon="true"
|
<uni-notice-bar scrollable="true" @click="goRoll(singNew)" single="true" :speed="10" showIcon="true"
|
||||||
|
@ -17,19 +17,13 @@
|
|||||||
购物数量
|
购物数量
|
||||||
<text class="num font-color-red">{{ count }}</text>
|
<text class="num font-color-red">{{ count }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view v-if="cartList.valid.length > 0" class="administrate acea-row row-center-wrapper" @click="manage">
|
||||||
v-if="cartList.valid.length > 0"
|
{{ footerswitch ? '取消' : '管理' }}</view>
|
||||||
class="administrate acea-row row-center-wrapper"
|
|
||||||
@click="manage"
|
|
||||||
>{{ 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
|
<view class="item acea-row row-between-wrapper" v-for="(item, cartListValidIndex) in validList"
|
||||||
class="item acea-row row-between-wrapper"
|
:key="cartListValidIndex">
|
||||||
v-for="(item, cartListValidIndex) in validList"
|
|
||||||
:key="cartListValidIndex"
|
|
||||||
>
|
|
||||||
<view class="select-btn">
|
<view class="select-btn">
|
||||||
<view class="checkbox-wrapper">
|
<view class="checkbox-wrapper">
|
||||||
<checkbox-group @change="switchSelect(cartListValidIndex)">
|
<checkbox-group @change="switchSelect(cartListValidIndex)">
|
||||||
@ -46,31 +40,19 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="text">
|
<view class="text">
|
||||||
<view class="line1">{{ item.productInfo.storeName }}</view>
|
<view class="line1">{{ item.productInfo.storeName }}</view>
|
||||||
<view
|
<view class="infor line1" v-if="item.productInfo.attrInfo">属性:{{ item.productInfo.attrInfo.sku }}</view>
|
||||||
class="infor line1"
|
|
||||||
v-if="item.productInfo.attrInfo"
|
|
||||||
>属性:{{ item.productInfo.attrInfo.sku }}</view>
|
|
||||||
<view class="money">¥{{ item.truePrice }}</view>
|
<view class="money">¥{{ item.truePrice }}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="carnum acea-row row-center-wrapper">
|
<view class="carnum acea-row row-center-wrapper">
|
||||||
<view
|
<view class="reduce" :class="validList[cartListValidIndex].cartNum <= 1 ? 'on' : ''"
|
||||||
class="reduce"
|
@click.prevent="reduce(cartListValidIndex)">-</view>
|
||||||
:class="validList[cartListValidIndex].cartNum <= 1 ? 'on' : ''"
|
|
||||||
@click.prevent="reduce(cartListValidIndex)"
|
|
||||||
>-</view>
|
|
||||||
<view class="num">{{ item.cartNum }}</view>
|
<view class="num">{{ item.cartNum }}</view>
|
||||||
<view
|
<view class="plus" v-if="validList[cartListValidIndex].attrInfo"
|
||||||
class="plus"
|
|
||||||
v-if="validList[cartListValidIndex].attrInfo"
|
|
||||||
:class="validList[cartListValidIndex].cartNum >= validList[cartListValidIndex].attrInfo.stock ? 'on' : ''"
|
:class="validList[cartListValidIndex].cartNum >= validList[cartListValidIndex].attrInfo.stock ? 'on' : ''"
|
||||||
@click.prevent="plus(cartListValidIndex)"
|
@click.prevent="plus(cartListValidIndex)">+</view>
|
||||||
>+</view>
|
<view class="plus" v-else
|
||||||
<view
|
|
||||||
class="plus"
|
|
||||||
v-else
|
|
||||||
:class="validList[cartListValidIndex].cartNum >= validList[cartListValidIndex].stock ? 'on' : ''"
|
:class="validList[cartListValidIndex].cartNum >= validList[cartListValidIndex].stock ? 'on' : ''"
|
||||||
@click.prevent="plus(cartListValidIndex)"
|
@click.prevent="plus(cartListValidIndex)">+</view>
|
||||||
>+</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -78,25 +60,15 @@
|
|||||||
<view class="invalidGoods" v-if="cartList.invalid.length > 0">
|
<view class="invalidGoods" v-if="cartList.invalid.length > 0">
|
||||||
<view class="goodsNav acea-row row-between-wrapper">
|
<view class="goodsNav acea-row row-between-wrapper">
|
||||||
<view @click="goodsOpen">
|
<view @click="goodsOpen">
|
||||||
<text
|
<text class="iconfont" :class="goodsHidden === true ? 'icon-xiangyou' : 'icon-xiangxia'"></text>失效商品
|
||||||
class="iconfont"
|
|
||||||
:class="goodsHidden === true ? 'icon-xiangyou' : 'icon-xiangxia'"
|
|
||||||
></text>失效商品
|
|
||||||
</view>
|
</view>
|
||||||
<view class="del" @click="delInvalidGoods">
|
<view class="del" @click="delInvalidGoods">
|
||||||
<text class="iconfont icon-shanchu1"></text>清空
|
<text class="iconfont icon-shanchu1"></text>清空
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="goodsList" :hidden="goodsHidden">
|
<view class="goodsList" :hidden="goodsHidden">
|
||||||
<view
|
<view v-for="(item, cartListinvalidIndex) in cartList.invalid" :key="cartListinvalidIndex">
|
||||||
v-for="(item, cartListinvalidIndex) in cartList.invalid"
|
<view @click="goGoodsCon(item)" class="item acea-row row-between-wrapper" v-if="item.productInfo">
|
||||||
: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="invalid acea-row row-center-wrapper">失效</view>
|
||||||
<view class="pictrue">
|
<view class="pictrue">
|
||||||
<image :src="item.productInfo.attrInfo.image" v-if="item.productInfo.attrInfo" />
|
<image :src="item.productInfo.attrInfo.image" v-if="item.productInfo.attrInfo" />
|
||||||
@ -104,10 +76,8 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="text acea-row row-column-between">
|
<view class="text acea-row row-column-between">
|
||||||
<view class="line1">{{ item.productInfo.storeName }}</view>
|
<view class="line1">{{ item.productInfo.storeName }}</view>
|
||||||
<view
|
<view class="infor line1" v-if="item.productInfo.attrInfo">属性:{{ item.productInfo.attrInfo.sku }}
|
||||||
class="infor line1"
|
</view>
|
||||||
v-if="item.productInfo.attrInfo"
|
|
||||||
>属性:{{ item.productInfo.attrInfo.sku }}</view>
|
|
||||||
<view class="acea-row row-between-wrapper">
|
<view class="acea-row row-between-wrapper">
|
||||||
<view class="end">该商品已下架</view>
|
<view class="end">该商品已下架</view>
|
||||||
</view>
|
</view>
|
||||||
@ -160,77 +130,96 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<Authorization v-if="!$store.getters.token" />
|
<Authorization v-else />
|
||||||
</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,
|
getCartList,
|
||||||
postCartDel,
|
postCartDel,
|
||||||
changeCartNum,
|
changeCartNum,
|
||||||
getCartCount
|
getCartCount
|
||||||
} from "@/api/store";
|
} from "@/api/store";
|
||||||
import { postCollectAll } from "@/api/user";
|
import {
|
||||||
import { mul, add } from "@/utils/bc";
|
postCollectAll
|
||||||
import cookie from "@/utils/store/cookie";
|
} 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: [],
|
||||||
|
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: [],
|
token(token) {
|
||||||
isAllSelect: false,
|
if (this.userInfo.uid) {
|
||||||
cartCount: 0,
|
this.carnum();
|
||||||
countmoney: 0,
|
this.countMoney();
|
||||||
goodsHidden: true,
|
this.getCartList();
|
||||||
footerswitch: false,
|
this.gainCount();
|
||||||
count: 0,
|
}
|
||||||
checkedIds: [],
|
},
|
||||||
loaded: false
|
cartList(list) {
|
||||||
};
|
this.validList = list.valid;
|
||||||
},
|
|
||||||
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) {
|
onShow: function () {
|
||||||
if (this.userInfo.uid) {
|
if (this.userInfo.uid) {
|
||||||
this.carnum();
|
this.carnum();
|
||||||
this.countMoney();
|
this.countMoney();
|
||||||
@ -238,297 +227,285 @@ export default {
|
|||||||
this.gainCount();
|
this.gainCount();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cartList(list) {
|
methods: {
|
||||||
this.validList = list.valid;
|
goGoodsCon(item) {
|
||||||
}
|
this.$yrouter.push({
|
||||||
},
|
path: "/pages/shop/GoodsCon/index",
|
||||||
onShow: function() {
|
query: {
|
||||||
if (this.userInfo.uid) {
|
id: item.productId
|
||||||
this.carnum();
|
}
|
||||||
this.countMoney();
|
|
||||||
this.getCartList();
|
|
||||||
this.gainCount();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
goGoodsCon(item) {
|
|
||||||
this.$yrouter.push({
|
|
||||||
path: "/pages/shop/GoodsCon/index",
|
|
||||||
query: {
|
|
||||||
id: item.productId
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
getCartList: function() {
|
|
||||||
let that = this;
|
|
||||||
getCartList().then(res => {
|
|
||||||
that.cartList = res.data;
|
|
||||||
let checkedIds = cookie.get(CHECKED_IDS) || [];
|
|
||||||
if (!Array.isArray(checkedIds)) checkedIds = [];
|
|
||||||
this.cartList.valid.forEach(cart => {
|
|
||||||
if (checkedIds.indexOf(cart.id) !== -1) cart.checked = true;
|
|
||||||
});
|
});
|
||||||
if (checkedIds.length) {
|
},
|
||||||
that.checkedIds = checkedIds;
|
getCartList: function () {
|
||||||
that.isAllSelect = checkedIds.length === this.cartList.valid.length;
|
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.carnum();
|
||||||
that.countMoney();
|
that.countMoney();
|
||||||
}
|
that.gainCount();
|
||||||
this.loaded = true;
|
that.getCartList();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
//删除商品;
|
// //获取数量
|
||||||
delgoods: function() {
|
gainCount: function () {
|
||||||
let that = this,
|
let that = this;
|
||||||
id = [],
|
getCartCount().then(res => {
|
||||||
valid = [],
|
that.count = res.data.count;
|
||||||
list = that.cartList.valid;
|
});
|
||||||
list.forEach(function(val) {
|
},
|
||||||
if (val.checked === true) {
|
//清除失效产品;
|
||||||
|
delInvalidGoods: function () {
|
||||||
|
let that = this,
|
||||||
|
id = [],
|
||||||
|
list = that.cartList.invalid;
|
||||||
|
list.forEach(function (val) {
|
||||||
id.push(val.id);
|
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 () {
|
||||||
if (id.length === 0) {
|
uni.showToast({
|
||||||
uni.showToast({
|
title: "收藏成功!",
|
||||||
title: "请选择产品",
|
icon: "none",
|
||||||
icon: "none",
|
duration: 2000
|
||||||
duration: 2000
|
});
|
||||||
});
|
});
|
||||||
return;
|
},
|
||||||
}
|
//立即下单;
|
||||||
postCartDel(id).then(function() {
|
placeOrder: function () {
|
||||||
list.forEach(function(val, i) {
|
let that = this,
|
||||||
if (val.checked === false || val.checked === undefined)
|
list = that.cartList.valid,
|
||||||
valid.push(list[i]);
|
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.carnum();
|
||||||
that.countMoney();
|
that.countMoney();
|
||||||
that.gainCount();
|
that.syncCartNum(list);
|
||||||
that.getCartList();
|
},
|
||||||
});
|
//减
|
||||||
},
|
reduce: function (index) {
|
||||||
// //获取数量
|
let that = this;
|
||||||
gainCount: function() {
|
let list = that.cartList.valid[index];
|
||||||
let that = this;
|
if (list.cartNum <= 1) {
|
||||||
getCartCount().then(res => {
|
uni.showToast({
|
||||||
that.count = res.data.count;
|
title: "已经是底线啦!",
|
||||||
});
|
icon: "none",
|
||||||
},
|
duration: 2000
|
||||||
//清除失效产品;
|
|
||||||
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
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
return;
|
||||||
},
|
}
|
||||||
//单选
|
list.cartNum--;
|
||||||
switchSelect: function(index) {
|
if (list.cartNum < 1) {
|
||||||
let that = this,
|
that.$set(list, "cart_num", 1);
|
||||||
cart = that.cartList.valid[index],
|
}
|
||||||
i = this.checkedIds.indexOf(cart.id);
|
that.carnum();
|
||||||
cart.checked = !cart.checked;
|
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 (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 selectnum = [];
|
|
||||||
for (let i = 0; i < len; i++) {
|
|
||||||
if (that.cartList.valid[i].checked === true) {
|
|
||||||
selectnum.push(true);
|
|
||||||
}
|
}
|
||||||
}
|
let len = that.cartList.valid.length;
|
||||||
that.isAllSelect = selectnum.length === len;
|
let selectnum = [];
|
||||||
that.$set(that, "cartList", that.cartList);
|
for (let i = 0; i < len; i++) {
|
||||||
that.$set(that, "isAllSelect", that.isAllSelect);
|
if (that.cartList.valid[i].checked === true) {
|
||||||
cookie.set(CHECKED_IDS, that.checkedIds);
|
selectnum.push(true);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
});
|
that.isAllSelect = selectnum.length === len;
|
||||||
let cartList = {
|
that.$set(that, "cartList", that.cartList);
|
||||||
...that.cartList
|
that.$set(that, "isAllSelect", that.isAllSelect);
|
||||||
};
|
cookie.set(CHECKED_IDS, that.checkedIds);
|
||||||
that.cartList = [];
|
that.carnum();
|
||||||
that.cartList = cartList;
|
that.gainCount();
|
||||||
console.log(this.cartList);
|
that.countMoney();
|
||||||
this.$set(this, "cartList", this.cartList);
|
},
|
||||||
this.$set(this, "isAllSelect", selectAllStatus);
|
//全选
|
||||||
this.checkedIds = checkedIds;
|
allChecked: function (e) {
|
||||||
cookie.set(CHECKED_IDS, checkedIds);
|
console.log(e);
|
||||||
that.carnum();
|
let that = this;
|
||||||
that.countMoney();
|
let selectAllStatus = e.mp.detail.value[0] == "allSelect" ? true : false;
|
||||||
this.$forceUpdate();
|
console.log(selectAllStatus);
|
||||||
},
|
// let selectAllStatus = that.isAllSelect;
|
||||||
//数量
|
let checkedIds = [];
|
||||||
carnum: function() {
|
// for (let i = 0; i < array.length; i++) {
|
||||||
let that = this;
|
// array[i].checked = selectAllStatus;
|
||||||
var carnum = 0;
|
// checked.push()
|
||||||
var array = that.cartList.valid;
|
// }
|
||||||
for (let i = 0; i < array.length; i++) {
|
that.cartList.valid.forEach(cart => {
|
||||||
if (array[i].checked === true) {
|
cart.checked = selectAllStatus;
|
||||||
carnum += parseInt(array[i].cartNum);
|
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);
|
||||||
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>
|
||||||
|
@ -133,7 +133,7 @@
|
|||||||
:login_type="userInfo.login_type"
|
:login_type="userInfo.login_type"
|
||||||
></SwitchWindow>-->
|
></SwitchWindow>-->
|
||||||
</view>
|
</view>
|
||||||
<Authorization v-if="!$store.getters.token" />
|
<Authorization v-else />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
@ -185,7 +185,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
goBindPhone(){
|
goBindPhone() {
|
||||||
this.$yrouter.push({
|
this.$yrouter.push({
|
||||||
path: "/pages/user/BindingPhone/index",
|
path: "/pages/user/BindingPhone/index",
|
||||||
});
|
});
|
||||||
|
6
剩余问题.js
6
剩余问题.js
@ -5,7 +5,7 @@
|
|||||||
// ? 未测试出该问题
|
// ? 未测试出该问题
|
||||||
|
|
||||||
// 页面都多了一个头部
|
// 页面都多了一个头部
|
||||||
// ~~延后处理
|
// ~~ 需要打包h5的时候单独修改配置
|
||||||
|
|
||||||
// 6、评价图片上传不了
|
// 6、评价图片上传不了
|
||||||
// ?接口报错,反馈给老徐了
|
// ?接口报错,反馈给老徐了
|
||||||
@ -14,10 +14,10 @@
|
|||||||
// ?接口报错,反馈给老徐了
|
// ?接口报错,反馈给老徐了
|
||||||
|
|
||||||
// 12、h5分享关系没形成,看下你那登陆怎么处理的参考下以前的h5
|
// 12、h5分享关系没形成,看下你那登陆怎么处理的参考下以前的h5
|
||||||
// ~~ 延后处理
|
// ?前端功能修改完,后台交给老徐了
|
||||||
|
|
||||||
// 13、海报分享,分享分享调整没问题,因为是首页,但是,商品详情海报,拼团海报,砍价海报路由跳转会有问题
|
// 13、海报分享,分享分享调整没问题,因为是首页,但是,商品详情海报,拼团海报,砍价海报路由跳转会有问题
|
||||||
// ?商品拼团海报生成的不是小程序码
|
// ?前端功能修改完,后台交给老徐了
|
||||||
// 海报相关页面
|
// 海报相关页面
|
||||||
// components/StorePoster.vue 商品详情
|
// components/StorePoster.vue 商品详情
|
||||||
// > 根据用户来源生成二维码
|
// > 根据用户来源生成二维码
|
||||||
|
Reference in New Issue
Block a user