优化登录的逻辑,
This commit is contained in:
@ -47,7 +47,7 @@
|
||||
<view class="lack">
|
||||
<text>还差</text>
|
||||
<text class="font-color-red" v-text="item.count"></text>
|
||||
<text>人成团</text>
|
||||
<text>人成团</text>
|
||||
</view>
|
||||
<count-down
|
||||
:is-day="false"
|
||||
@ -200,7 +200,7 @@ export default {
|
||||
cart_num: 1
|
||||
}
|
||||
},
|
||||
cartNum:1
|
||||
cartNum: 1
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
@ -286,11 +286,11 @@ export default {
|
||||
var that = this;
|
||||
that.attr.productSelect.cart_num = 1;
|
||||
that.cartNum = 1;
|
||||
uni.showToast({
|
||||
title: "每人每次限购1" + that.storeInfo.unitName,
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
uni.showToast({
|
||||
title: "每人每次限购1" + that.storeInfo.unitName,
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
},
|
||||
setProductSelect: function() {
|
||||
var that = this;
|
||||
@ -322,9 +322,9 @@ export default {
|
||||
})
|
||||
.catch(err => {
|
||||
uni.showToast({
|
||||
title: err.msg || err.response.data.msg,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
title: err.msg || err.response.data.msg,
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -1,201 +1,192 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view v-if="!isAuthorization">
|
||||
<view class="getUserInfo">
|
||||
<view>您还未允许微信登录授权,请点击下方按钮允许微信授权登录。</text>
|
||||
<vant-button type="primary" open-type="getUserInfo" @getuserinfo="getUserInfo">允许微信登录授权</vant-button>
|
||||
<view class="sp-cell"></view>
|
||||
<vant-button type="default" @click="back">取消微信登录授权</vant-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="container">
|
||||
<view v-if="!isAuthorization">
|
||||
<view class="getUserInfo">
|
||||
<text>您还未允许微信登录授权,请点击下方按钮允许微信授权登录。</text>
|
||||
<view style="height:20rpx"></view>
|
||||
<button type="primary" open-type="getUserInfo" @getuserinfo="getUserInfo">允许微信登录授权</button>
|
||||
<view style="height:20rpx"></view>
|
||||
<button @click="back">取消微信登录授权</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
mapState,
|
||||
mapMutations,
|
||||
mapActions
|
||||
} from "vuex";
|
||||
// 组件
|
||||
// import request from "@//api/request";
|
||||
import {
|
||||
wxappAuth,
|
||||
getUser
|
||||
} from "@/api/user";
|
||||
import dayjs from "dayjs";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
import {
|
||||
login
|
||||
} from "@/utils";
|
||||
import { mapState, mapMutations, mapActions } from "vuex";
|
||||
// 组件
|
||||
// import request from "@//api/request";
|
||||
import { wxappAuth, getUser } from "@/api/user";
|
||||
import dayjs from "dayjs";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
import { login } from "@/utils";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
...mapState(["isAuthorization"])
|
||||
},
|
||||
onShow() {
|
||||
this.UPDATE_AUTHORIZATIONPAGE(false);
|
||||
},
|
||||
onHide() {
|
||||
this.changeAuthorization(false);
|
||||
},
|
||||
onUnload() {
|
||||
this.changeAuthorization(false);
|
||||
},
|
||||
methods: {
|
||||
...mapActions(["changeAuthorization", "changeUserInfo"]),
|
||||
...mapMutations(["UPDATE_AUTHORIZATIONPAGE", "CHANGE_TABTAR"]),
|
||||
back() {
|
||||
// if (this.$yroute.query.redirect) {
|
||||
// this.$yrouter.replace({
|
||||
// path: this.$yroute.query.redirect
|
||||
// });
|
||||
// } else {
|
||||
// this.$yrouter.replace({
|
||||
// path: "/pages/launch/index",
|
||||
// query: { type: 0 }
|
||||
// });
|
||||
// }
|
||||
this.CHANGE_TABTAR(0);
|
||||
this.$yrouter.replace({
|
||||
path: "/pages/home/index",
|
||||
query: {
|
||||
type: 0
|
||||
}
|
||||
});
|
||||
},
|
||||
getUserInfo(data) {
|
||||
uni.showLoading({
|
||||
title: "登录中"
|
||||
});
|
||||
login();
|
||||
}
|
||||
},
|
||||
onUnload() {},
|
||||
mounted() {}
|
||||
};
|
||||
export default {
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
...mapState(["isAuthorization"])
|
||||
},
|
||||
onShow() {
|
||||
this.UPDATE_AUTHORIZATIONPAGE(true);
|
||||
},
|
||||
onHide() {
|
||||
this.UPDATE_AUTHORIZATIONPAGE(false);
|
||||
this.changeAuthorization(false);
|
||||
},
|
||||
onUnload() {
|
||||
this.UPDATE_AUTHORIZATIONPAGE(false);
|
||||
this.changeAuthorization(false);
|
||||
},
|
||||
methods: {
|
||||
...mapActions(["changeAuthorization", "changeUserInfo"]),
|
||||
...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: () => {}
|
||||
});
|
||||
}
|
||||
},
|
||||
onUnload() {},
|
||||
mounted() {}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.sp-cell {
|
||||
height: 20rpx;
|
||||
}
|
||||
.sp-cell {
|
||||
height: 20rpx;
|
||||
}
|
||||
|
||||
.getUserInfo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
padding: 30px;
|
||||
.getUserInfo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
padding: 30px;
|
||||
|
||||
p {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
}
|
||||
p {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.container {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
position: relative;
|
||||
}
|
||||
.container {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tab-bar {
|
||||
font-size: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 99;
|
||||
border-top: 1px solid rgba(248, 248, 248, 1);
|
||||
.tab-bar {
|
||||
font-size: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 99;
|
||||
border-top: 1px solid rgba(248, 248, 248, 1);
|
||||
|
||||
.tab-bar-item {
|
||||
flex: 1;
|
||||
height: 49px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
.tab-bar-item {
|
||||
flex: 1;
|
||||
height: 49px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
|
||||
&.active {
|
||||
text {
|
||||
color: #ee7559;
|
||||
}
|
||||
&.active {
|
||||
text {
|
||||
color: #ee7559;
|
||||
}
|
||||
|
||||
.tab-bar-pic {
|
||||
display: none;
|
||||
background: #f9f9f9;
|
||||
.tab-bar-pic {
|
||||
display: none;
|
||||
background: #f9f9f9;
|
||||
|
||||
&.active {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.active {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tab-bar-pic {
|
||||
display: block;
|
||||
background: #f9f9f9;
|
||||
.tab-bar-pic {
|
||||
display: block;
|
||||
background: #f9f9f9;
|
||||
|
||||
&.active {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.active {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tab-bar-pic {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
background: #f9f9f9;
|
||||
.tab-bar-pic {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
background: #f9f9f9;
|
||||
|
||||
image {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
}
|
||||
}
|
||||
image {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
}
|
||||
}
|
||||
|
||||
.tab-bar-pic-active {}
|
||||
.tab-bar-pic-active {
|
||||
}
|
||||
|
||||
text {
|
||||
font-size: 10px;
|
||||
color: rgb(160, 160, 160);
|
||||
line-height: 10px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
}
|
||||
text {
|
||||
font-size: 10px;
|
||||
color: rgb(160, 160, 160);
|
||||
line-height: 10px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.tab-bar-bg {
|
||||
padding-top: 46px;
|
||||
width: 100%;
|
||||
}
|
||||
.tab-bar-bg {
|
||||
padding-top: 46px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.view-item {
|
||||
display: none;
|
||||
width: 100%;
|
||||
}
|
||||
.view-item {
|
||||
display: none;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.view-item-active {
|
||||
display: block;
|
||||
}
|
||||
.view-item-active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.getUserInfo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
padding: 30px;
|
||||
.getUserInfo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
padding: 30px;
|
||||
|
||||
p {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
}
|
||||
p {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
._van-dialog {
|
||||
z-index: 99999999999;
|
||||
}
|
||||
</style>
|
||||
._van-dialog {
|
||||
z-index: 99999999999;
|
||||
}
|
||||
</style>
|
||||
|
@ -254,6 +254,9 @@ export default {
|
||||
},
|
||||
mounted: function() {
|
||||
let that = this;
|
||||
uni.showLoading({
|
||||
title:'加载中'
|
||||
})
|
||||
getHomeData().then(res => {
|
||||
that.logoUrl = res.data.logoUrl;
|
||||
that.$set(that, "banner", res.data.banner);
|
||||
@ -269,6 +272,7 @@ export default {
|
||||
that.$set(that, "lovely", res.data.lovely);
|
||||
that.$set(that, "benefit", res.data.benefit);
|
||||
that.$set(that, "couponList", res.data.couponList);
|
||||
uni.hideLoading()
|
||||
that.setOpenShare();
|
||||
});
|
||||
},
|
||||
|
@ -43,22 +43,18 @@ export default {
|
||||
...mapState(["tabtarIndex"])
|
||||
},
|
||||
methods: {
|
||||
...mapActions(["changeTabtar"])
|
||||
},
|
||||
mounted() {
|
||||
let type = this.$yroute.query.type;
|
||||
console.log(2222)
|
||||
if (type) {
|
||||
this.changeTabtar(type);
|
||||
}
|
||||
|
||||
// if (!this.tabtarIndex) {
|
||||
// this.changeTabtar(0);
|
||||
// }
|
||||
},
|
||||
onHide() {
|
||||
console.log("清除状态");
|
||||
// this.changeTabtar(0);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -495,7 +495,8 @@
|
||||
},
|
||||
methods: {
|
||||
copyClipboard,
|
||||
showChang: function() {
|
||||
showChang: function() {
|
||||
// 这里判断是不是微信小程序
|
||||
if (isWeixin()) {
|
||||
let config = {
|
||||
latitude: this.system_store.latitude,
|
||||
@ -503,14 +504,6 @@
|
||||
name: this.system_store.name,
|
||||
address: this.system_store._detailed_address
|
||||
};
|
||||
// wechatEvevt("openLocation", config)
|
||||
// .then(res => {
|
||||
// })
|
||||
// .catch(res => {
|
||||
// if (res.is_ready) {
|
||||
// res.wx.openLocation(config);
|
||||
// }
|
||||
// });
|
||||
} else {
|
||||
if (!this.mapKey)
|
||||
uni.showToast({
|
||||
|
@ -151,44 +151,8 @@
|
||||
});
|
||||
},
|
||||
openQRCode: function() {
|
||||
let that = this;
|
||||
// wechatEvevt("scanQRCode", {
|
||||
// needResult: 1,
|
||||
// scanType: ["qrCode", "barCode"]
|
||||
// })
|
||||
// .then(res => {
|
||||
// if (res.resultStr) {
|
||||
// that.verify_code = res.resultStr;
|
||||
// that.storeCancellation();
|
||||
// } else {
|
||||
// uni.showToast({
|
||||
// title: '没有扫描到什么!',
|
||||
// icon: "none",
|
||||
// duration: 2000
|
||||
// });
|
||||
// }
|
||||
// })
|
||||
// .catch(res => {
|
||||
// if (res.is_ready) {
|
||||
// res.wx.scanQRCode({
|
||||
// needResult: 1,
|
||||
// scanType: ["qrCode", "barCode"],
|
||||
// success: function(res) {
|
||||
// that.verify_code = res.resultStr;
|
||||
// that.storeCancellation();
|
||||
// },
|
||||
// fail: function(res) {
|
||||
// if (res.errMsg == "scanQRCode:permission denied") {
|
||||
// uni.showToast({
|
||||
// title: '没有权限',
|
||||
// icon: "none",
|
||||
// duration: 2000
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
let that = this;
|
||||
// 这里需要调用扫码功能
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -288,14 +288,6 @@ export default {
|
||||
name: this.system_store.name,
|
||||
address: this.system_store._detailed_address
|
||||
};
|
||||
// wechatEvevt("openLocation", config)
|
||||
// .then(res => {
|
||||
// })
|
||||
// .catch(res => {
|
||||
// if (res.is_ready) {
|
||||
// res.wx.openLocation(config);
|
||||
// }
|
||||
// });
|
||||
} else {
|
||||
if (!this.mapKey) {
|
||||
uni.showToast({
|
||||
|
@ -1,98 +1,135 @@
|
||||
<template>
|
||||
<view class="shoppingCart">
|
||||
<view class="labelNav acea-row row-around row-middle">
|
||||
<view class="item">
|
||||
<text class="iconfont icon-xuanzhong"></text>100%正品保证
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="iconfont icon-xuanzhong"></text>所有商品精挑细选
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="iconfont icon-xuanzhong"></text>售后无忧
|
||||
</view>
|
||||
</view>
|
||||
<view class="nav acea-row row-between-wrapper">
|
||||
<view>
|
||||
购物数量
|
||||
<text class="num font-color-red">{{ count }}</text>
|
||||
</view>
|
||||
<view v-if="cartList.valid.length > 0" class="administrate acea-row row-center-wrapper" @click="manage">{{ footerswitch ? "取消" : "管理" }}</view>
|
||||
</view>
|
||||
<view v-if="validList.length > 0 || cartList.invalid.length > 0">
|
||||
<view class="list">
|
||||
<view class="item acea-row row-between-wrapper" v-for="(item, cartListValidIndex) in validList" :key="cartListValidIndex">
|
||||
<view class="select-btn">
|
||||
<view class="checkbox-wrapper">
|
||||
<checkbox-group @change="switchSelect(cartListValidIndex)">
|
||||
<label class="well-check">
|
||||
<checkbox value :checked="item.checked"></checkbox>
|
||||
</label>
|
||||
</checkbox-group>
|
||||
</view>
|
||||
</view>
|
||||
<view class="picTxt acea-row row-between-wrapper">
|
||||
<view class="pictrue" @click="goGoodsCon(item)">
|
||||
<image :src="item.productInfo.attrInfo.image" v-if="item.productInfo.attrInfo" />
|
||||
<image :src="item.productInfo.image" v-else />
|
||||
</view>
|
||||
<view class="text">
|
||||
<view class="line1">{{ item.productInfo.storeName }}</view>
|
||||
<view class="infor line1" v-if="item.productInfo.attrInfo">属性:{{ item.productInfo.attrInfo.suk }}</view>
|
||||
<view class="money">¥{{ item.truePrice }}</view>
|
||||
</view>
|
||||
<view class="carnum acea-row row-center-wrapper">
|
||||
<view class="reduce" :class="validList[cartListValidIndex].cartNum <= 1 ? 'on' : ''" @click.prevent="reduce(cartListValidIndex)">-</view>
|
||||
<view class="num">{{ item.cartNum }}</view>
|
||||
<view class="plus" v-if="validList[cartListValidIndex].attrInfo" :class="validList[cartListValidIndex].cartNum >=validList[cartListValidIndex].attrInfo.stock? 'on': ''"
|
||||
@click.prevent="plus(cartListValidIndex)">+</view>
|
||||
<view class="plus" v-else :class="validList[cartListValidIndex].cartNum >= validList[cartListValidIndex].stock? 'on': ''"
|
||||
@click.prevent="plus(cartListValidIndex)">+</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="invalidGoods" v-if="cartList.invalid.length > 0">
|
||||
<view class="goodsNav acea-row row-between-wrapper">
|
||||
<view @click="goodsOpen">
|
||||
<text class="iconfont" :class="goodsHidden === true ? 'icon-xiangyou' : 'icon-xiangxia'"></text>失效商品
|
||||
</view>
|
||||
<view class="del" @click="delInvalidGoods">
|
||||
<text class="iconfont icon-shanchu1"></text>清空
|
||||
</view>
|
||||
</view>
|
||||
<view class="goodsList" :hidden="goodsHidden">
|
||||
<view v-for="(item, cartListinvalidIndex) in cartList.invalid" :key="cartListinvalidIndex">
|
||||
<view @click="goGoodsCon(item)" class="item acea-row row-between-wrapper" v-if="item.productInfo">
|
||||
<view class="invalid acea-row row-center-wrapper">失效</view>
|
||||
<view class="pictrue">
|
||||
<image :src="item.productInfo.attrInfo.image" v-if="item.productInfo.attrInfo" />
|
||||
<image :src="item.productInfo.image" v-else />
|
||||
</view>
|
||||
<view class="text acea-row row-column-between">
|
||||
<view class="line1">{{ item.productInfo.storeName }}</view>
|
||||
<view class="infor line1" v-if="item.productInfo.attrInfo">属性:{{ item.productInfo.attrInfo.suk }}</view>
|
||||
<view class="acea-row row-between-wrapper">
|
||||
<view class="end">该商品已下架</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!--购物车暂无商品-->
|
||||
<view class="noCart" v-if="cartList.valid.length === 0 && cartList.invalid.length === 0">
|
||||
<view class="pictrue">
|
||||
<image :src="$VUE_APP_RESOURCES_URL+'/images/noCart.png'" />
|
||||
</view>
|
||||
<Recommend></Recommend>
|
||||
</view>
|
||||
<view style="height:2.1rem"></view>
|
||||
<view :class="['footer acea-row row-between-wrapper']" v-if="cartList.valid.length > 0">
|
||||
<view>
|
||||
<view class="select-btn">
|
||||
<view class="checkbox-wrapper">
|
||||
<!-- <label class="well-check">
|
||||
<view class="shoppingCart">
|
||||
<view class v-if="userInfo.uid">
|
||||
<view class="labelNav acea-row row-around row-middle">
|
||||
<view class="item">
|
||||
<text class="iconfont icon-xuanzhong"></text>100%正品保证
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="iconfont icon-xuanzhong"></text>所有商品精挑细选
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="iconfont icon-xuanzhong"></text>售后无忧
|
||||
</view>
|
||||
</view>
|
||||
<view class="nav acea-row row-between-wrapper">
|
||||
<view>
|
||||
购物数量
|
||||
<text class="num font-color-red">{{ count }}</text>
|
||||
</view>
|
||||
<view
|
||||
v-if="cartList.valid.length > 0"
|
||||
class="administrate acea-row row-center-wrapper"
|
||||
@click="manage"
|
||||
>{{ footerswitch ? "取消" : "管理" }}</view>
|
||||
</view>
|
||||
<view v-if="validList.length > 0 || cartList.invalid.length > 0">
|
||||
<view class="list">
|
||||
<view
|
||||
class="item acea-row row-between-wrapper"
|
||||
v-for="(item, cartListValidIndex) in validList"
|
||||
:key="cartListValidIndex"
|
||||
>
|
||||
<view class="select-btn">
|
||||
<view class="checkbox-wrapper">
|
||||
<checkbox-group @change="switchSelect(cartListValidIndex)">
|
||||
<label class="well-check">
|
||||
<checkbox value :checked="item.checked"></checkbox>
|
||||
</label>
|
||||
</checkbox-group>
|
||||
</view>
|
||||
</view>
|
||||
<view class="picTxt acea-row row-between-wrapper">
|
||||
<view class="pictrue" @click="goGoodsCon(item)">
|
||||
<image :src="item.productInfo.attrInfo.image" v-if="item.productInfo.attrInfo" />
|
||||
<image :src="item.productInfo.image" v-else />
|
||||
</view>
|
||||
<view class="text">
|
||||
<view class="line1">{{ item.productInfo.storeName }}</view>
|
||||
<view
|
||||
class="infor line1"
|
||||
v-if="item.productInfo.attrInfo"
|
||||
>属性:{{ item.productInfo.attrInfo.suk }}</view>
|
||||
<view class="money">¥{{ item.truePrice }}</view>
|
||||
</view>
|
||||
<view class="carnum acea-row row-center-wrapper">
|
||||
<view
|
||||
class="reduce"
|
||||
:class="validList[cartListValidIndex].cartNum <= 1 ? 'on' : ''"
|
||||
@click.prevent="reduce(cartListValidIndex)"
|
||||
>-</view>
|
||||
<view class="num">{{ item.cartNum }}</view>
|
||||
<view
|
||||
class="plus"
|
||||
v-if="validList[cartListValidIndex].attrInfo"
|
||||
:class="validList[cartListValidIndex].cartNum >=validList[cartListValidIndex].attrInfo.stock? 'on': ''"
|
||||
@click.prevent="plus(cartListValidIndex)"
|
||||
>+</view>
|
||||
<view
|
||||
class="plus"
|
||||
v-else
|
||||
:class="validList[cartListValidIndex].cartNum >= validList[cartListValidIndex].stock? 'on': ''"
|
||||
@click.prevent="plus(cartListValidIndex)"
|
||||
>+</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="invalidGoods" v-if="cartList.invalid.length > 0">
|
||||
<view class="goodsNav acea-row row-between-wrapper">
|
||||
<view @click="goodsOpen">
|
||||
<text
|
||||
class="iconfont"
|
||||
:class="goodsHidden === true ? 'icon-xiangyou' : 'icon-xiangxia'"
|
||||
></text>失效商品
|
||||
</view>
|
||||
<view class="del" @click="delInvalidGoods">
|
||||
<text class="iconfont icon-shanchu1"></text>清空
|
||||
</view>
|
||||
</view>
|
||||
<view class="goodsList" :hidden="goodsHidden">
|
||||
<view
|
||||
v-for="(item, cartListinvalidIndex) in cartList.invalid"
|
||||
:key="cartListinvalidIndex"
|
||||
>
|
||||
<view
|
||||
@click="goGoodsCon(item)"
|
||||
class="item acea-row row-between-wrapper"
|
||||
v-if="item.productInfo"
|
||||
>
|
||||
<view class="invalid acea-row row-center-wrapper">失效</view>
|
||||
<view class="pictrue">
|
||||
<image :src="item.productInfo.attrInfo.image" v-if="item.productInfo.attrInfo" />
|
||||
<image :src="item.productInfo.image" v-else />
|
||||
</view>
|
||||
<view class="text acea-row row-column-between">
|
||||
<view class="line1">{{ item.productInfo.storeName }}</view>
|
||||
<view
|
||||
class="infor line1"
|
||||
v-if="item.productInfo.attrInfo"
|
||||
>属性:{{ item.productInfo.attrInfo.suk }}</view>
|
||||
<view class="acea-row row-between-wrapper">
|
||||
<view class="end">该商品已下架</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!--购物车暂无商品-->
|
||||
<view class="noCart" v-if="cartList.valid.length === 0 && cartList.invalid.length === 0">
|
||||
<view class="pictrue">
|
||||
<image :src="$VUE_APP_RESOURCES_URL+'/images/noCart.png'" />
|
||||
</view>
|
||||
<Recommend></Recommend>
|
||||
</view>
|
||||
<view style="height:2.1rem"></view>
|
||||
<view :class="['footer acea-row row-between-wrapper']" v-if="cartList.valid.length > 0">
|
||||
<view>
|
||||
<view class="select-btn">
|
||||
<view class="checkbox-wrapper">
|
||||
<!-- <label class="well-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
name
|
||||
@ -102,377 +139,385 @@
|
||||
/>
|
||||
<i class="icon"></i>
|
||||
<text class="checkAll">全选 ({{ cartCount }})</text>
|
||||
</label>-->
|
||||
</label>-->
|
||||
|
||||
<checkbox-group @change="allChecked">
|
||||
<label class="well-check">
|
||||
<checkbox value :checked="isAllSelect && cartCount > 0"></checkbox>
|
||||
<text class="checkAll">全选 ({{ cartCount }})</text>
|
||||
</label>
|
||||
</checkbox-group>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="money acea-row row-middle" v-if="footerswitch === false">
|
||||
<text class="font-color-red">¥{{ countmoney }}</text>
|
||||
<view class="placeOrder bg-color-red" @click="placeOrder">立即下单</view>
|
||||
</view>
|
||||
<view class="button acea-row row-middle" v-else>
|
||||
<view class="bnt cart-color" @click="collectAll">收藏</view>
|
||||
<view class="bnt" @click="delgoods">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<checkbox-group @change="allChecked">
|
||||
<label class="well-check">
|
||||
<checkbox value :checked="isAllSelect && cartCount > 0"></checkbox>
|
||||
<text class="checkAll">全选 ({{ cartCount }})</text>
|
||||
</label>
|
||||
</checkbox-group>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="money acea-row row-middle" v-if="footerswitch === false">
|
||||
<text class="font-color-red">¥{{ countmoney }}</text>
|
||||
<view class="placeOrder bg-color-red" @click="placeOrder">立即下单</view>
|
||||
</view>
|
||||
<view class="button acea-row row-middle" v-else>
|
||||
<view class="bnt cart-color" @click="collectAll">收藏</view>
|
||||
<view class="bnt" @click="delgoods">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<Authorization v-else />
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import Recommend from "@/components/Recommend";
|
||||
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 debounce from "lodash.debounce";
|
||||
import Recommend from "@/components/Recommend";
|
||||
import Authorization from "@/pages/authorization/index";
|
||||
import { mapGetters } from "vuex";
|
||||
|
||||
const CHECKED_IDS = "cart_checked";
|
||||
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 debounce from "lodash.debounce";
|
||||
|
||||
export default {
|
||||
name: "ShoppingCart",
|
||||
components: {
|
||||
Recommend
|
||||
},
|
||||
props: {},
|
||||
data: function() {
|
||||
return {
|
||||
isIpx: false,
|
||||
cartList: {
|
||||
invalid: [],
|
||||
valid: []
|
||||
},
|
||||
validList: [],
|
||||
isAllSelect: false,
|
||||
cartCount: 0,
|
||||
countmoney: 0,
|
||||
goodsHidden: true,
|
||||
footerswitch: false,
|
||||
count: 0,
|
||||
checkedIds: [],
|
||||
loaded: false
|
||||
};
|
||||
},
|
||||
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;
|
||||
}
|
||||
},
|
||||
mounted: function() {
|
||||
let that = this;
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
that.getCartList();
|
||||
that.gainCount();
|
||||
wx.getSystemInfo({
|
||||
success: function(res) {
|
||||
console.log(res);
|
||||
var name = "iPhone X";
|
||||
if (res.model.indexOf(name) > -1) {
|
||||
that.isIpx = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
goGoodsCon(item) {
|
||||
this.$yrouter.push({
|
||||
path: "/pages/shop/GoodsCon/index",
|
||||
query: {
|
||||
id: item.productId
|
||||
}
|
||||
});
|
||||
},
|
||||
getCartList: function() {
|
||||
let that = this;
|
||||
getCartList().then(res => {
|
||||
that.cartList = res.data;
|
||||
let checkedIds = cookie.get(CHECKED_IDS) || [];
|
||||
if (!Array.isArray(checkedIds)) checkedIds = [];
|
||||
this.cartList.valid.forEach(cart => {
|
||||
if (checkedIds.indexOf(cart.id) !== -1) cart.checked = true;
|
||||
});
|
||||
if (checkedIds.length) {
|
||||
that.checkedIds = checkedIds;
|
||||
that.isAllSelect = checkedIds.length === this.cartList.valid.length;
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
}
|
||||
this.loaded = true;
|
||||
});
|
||||
},
|
||||
//删除商品;
|
||||
delgoods: function() {
|
||||
let that = this,
|
||||
id = [],
|
||||
valid = [],
|
||||
list = that.cartList.valid;
|
||||
list.forEach(function(val) {
|
||||
if (val.checked === true) {
|
||||
id.push(val.id);
|
||||
}
|
||||
});
|
||||
if (id.length === 0) {
|
||||
uni.showToast({
|
||||
title: "请选择产品",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
postCartDel(id).then(function() {
|
||||
list.forEach(function(val, i) {
|
||||
if (val.checked === false || val.checked === undefined)
|
||||
valid.push(list[i]);
|
||||
});
|
||||
that.$set(that.cartList, "valid", valid);
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
that.gainCount();
|
||||
that.getCartList();
|
||||
});
|
||||
},
|
||||
// //获取数量
|
||||
gainCount: function() {
|
||||
let that = this;
|
||||
getCartCount().then(res => {
|
||||
that.count = res.data.count;
|
||||
});
|
||||
},
|
||||
//清除失效产品;
|
||||
delInvalidGoods: function() {
|
||||
let that = this,
|
||||
id = [],
|
||||
list = that.cartList.invalid;
|
||||
list.forEach(function(val) {
|
||||
id.push(val.id);
|
||||
});
|
||||
postCartDel(id).then(function() {
|
||||
list.splice(0, list.length);
|
||||
that.gainCount();
|
||||
that.getCartList();
|
||||
});
|
||||
},
|
||||
//批量收藏;
|
||||
collectAll: function() {
|
||||
let that = this,
|
||||
data = {
|
||||
id: [],
|
||||
category: ""
|
||||
},
|
||||
list = that.cartList.valid;
|
||||
list.forEach(function(val) {
|
||||
if (val.checked === true) {
|
||||
data.id.push(val.product_id);
|
||||
data.category = val.type;
|
||||
}
|
||||
});
|
||||
if (data.id.length === 0) {
|
||||
uni.showToast({
|
||||
title: "请选择产品",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
postCollectAll(data).then(function() {
|
||||
uni.showToast({
|
||||
title: "收藏成功!",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
});
|
||||
},
|
||||
//立即下单;
|
||||
placeOrder: function() {
|
||||
let that = this,
|
||||
list = that.cartList.valid,
|
||||
id = [];
|
||||
list.forEach(function(val) {
|
||||
if (val.checked === true) {
|
||||
id.push(val.id);
|
||||
}
|
||||
});
|
||||
if (id.length === 0) {
|
||||
uni.showToast({
|
||||
title: "请选择产品",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
console.log(id);
|
||||
this.$yrouter.push({
|
||||
path: "/pages/order/OrderSubmission/index",
|
||||
query: {
|
||||
id: id.join(",")
|
||||
}
|
||||
});
|
||||
},
|
||||
manage: function() {
|
||||
let that = this;
|
||||
that.footerswitch = !that.footerswitch;
|
||||
},
|
||||
goodsOpen: function() {
|
||||
let that = this;
|
||||
that.goodsHidden = !that.goodsHidden;
|
||||
},
|
||||
//加
|
||||
plus: function(index) {
|
||||
let that = this;
|
||||
let list = that.cartList.valid[index];
|
||||
list.cartNum++;
|
||||
if (list.attrInfo) {
|
||||
if (list.cartNum >= list.attrInfo.stock) {
|
||||
that.$set(list, "cart_num", list.attrInfo.stock);
|
||||
}
|
||||
} else {
|
||||
if (list.cartNum >= list.stock) {
|
||||
that.$set(list, "cart_num", list.stock);
|
||||
}
|
||||
}
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
that.syncCartNum(list);
|
||||
},
|
||||
//减
|
||||
reduce: function(index) {
|
||||
let that = this;
|
||||
let list = that.cartList.valid[index];
|
||||
if (list.cartNum <= 1) {
|
||||
uni.showToast({
|
||||
title: "已经是底线啦!",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
list.cartNum--;
|
||||
if (list.cartNum < 1) {
|
||||
that.$set(list, "cart_num", 1);
|
||||
}
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
that.syncCartNum(list);
|
||||
},
|
||||
syncCartNum(cart) {
|
||||
if (!cart.sync) {
|
||||
changeCartNum(cart.id, Math.max(cart.cartNum, 1) || 1)
|
||||
.then(res => {
|
||||
this.getCartList();
|
||||
})
|
||||
.catch(error => {
|
||||
uni.showToast({
|
||||
title: error.response.data.msg,
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
//单选
|
||||
switchSelect: function(index) {
|
||||
let that = this,
|
||||
cart = that.cartList.valid[index],
|
||||
i = this.checkedIds.indexOf(cart.id);
|
||||
cart.checked = !cart.checked;
|
||||
const CHECKED_IDS = "cart_checked";
|
||||
|
||||
if (i !== -1) this.checkedIds.splice(i, 1);
|
||||
if (cart.checked) {
|
||||
this.checkedIds.push(cart.id);
|
||||
}
|
||||
let len = that.cartList.valid.length;
|
||||
let selectnum = [];
|
||||
for (let i = 0; i < len; i++) {
|
||||
if (that.cartList.valid[i].checked === true) {
|
||||
selectnum.push(true);
|
||||
}
|
||||
}
|
||||
that.isAllSelect = selectnum.length === len;
|
||||
that.$set(that, "cartList", that.cartList);
|
||||
that.$set(that, "isAllSelect", that.isAllSelect);
|
||||
cookie.set(CHECKED_IDS, that.checkedIds);
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
},
|
||||
//全选
|
||||
allChecked: function(e) {
|
||||
let that = this;
|
||||
let selectAllStatus = e.mp.detail.value[0] ? true : false;
|
||||
// let selectAllStatus = that.isAllSelect;
|
||||
let checkedIds = [];
|
||||
// for (let i = 0; i < array.length; i++) {
|
||||
// array[i].checked = selectAllStatus;
|
||||
// checked.push()
|
||||
// }
|
||||
that.cartList.valid.forEach(cart => {
|
||||
cart.checked = selectAllStatus;
|
||||
if (selectAllStatus) {
|
||||
checkedIds.push(cart.id);
|
||||
}
|
||||
});
|
||||
let cartList = {
|
||||
...that.cartList
|
||||
};
|
||||
that.cartList = [];
|
||||
that.cartList = cartList;
|
||||
this.$set(this, "cartList", this.cartList);
|
||||
this.$set(this, "isAllSelect", selectAllStatus);
|
||||
this.checkedIds = checkedIds;
|
||||
cookie.set(CHECKED_IDS, checkedIds);
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
this.$forceUpdate();
|
||||
},
|
||||
//数量
|
||||
carnum: function() {
|
||||
let that = this;
|
||||
var carnum = 0;
|
||||
var array = that.cartList.valid;
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (array[i].checked === true) {
|
||||
carnum += parseInt(array[i].cartNum);
|
||||
}
|
||||
}
|
||||
that.$set(that, "cartCount", carnum);
|
||||
},
|
||||
//总共价钱;
|
||||
countMoney: function() {
|
||||
let that = this;
|
||||
let carmoney = 0;
|
||||
let array = that.cartList.valid;
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (array[i].checked === true) {
|
||||
carmoney = add(carmoney, mul(array[i].cartNum, array[i].truePrice));
|
||||
}
|
||||
}
|
||||
that.countmoney = carmoney;
|
||||
}
|
||||
}
|
||||
};
|
||||
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"]),
|
||||
|
||||
// watch: {
|
||||
// $yroute(n) {
|
||||
// if (n.name === "ShoppingCart") {
|
||||
// this.carnum();
|
||||
// this.countMoney();
|
||||
// this.getCartList();
|
||||
// this.gainCount();
|
||||
// this.goodsHidden = true;
|
||||
// this.footerswitch = false;
|
||||
// }
|
||||
// },
|
||||
// cartList(list) {
|
||||
// this.validList = list.valid;
|
||||
// }
|
||||
// },
|
||||
watch: {
|
||||
userInfo(user) {
|
||||
console.log(user);
|
||||
if (user.uid) {
|
||||
this.carnum();
|
||||
this.countMoney();
|
||||
this.getCartList();
|
||||
this.gainCount();
|
||||
}
|
||||
},
|
||||
cartList(list) {
|
||||
this.validList = list.valid;
|
||||
}
|
||||
},
|
||||
onShow: function() {
|
||||
if (this.userInfo.uid) {
|
||||
this.carnum();
|
||||
this.countMoney();
|
||||
this.getCartList();
|
||||
this.gainCount();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
goGoodsCon(item) {
|
||||
this.$yrouter.push({
|
||||
path: "/pages/shop/GoodsCon/index",
|
||||
query: {
|
||||
id: item.productId
|
||||
}
|
||||
});
|
||||
},
|
||||
getCartList: function() {
|
||||
let that = this;
|
||||
getCartList().then(res => {
|
||||
that.cartList = res.data;
|
||||
let checkedIds = cookie.get(CHECKED_IDS) || [];
|
||||
if (!Array.isArray(checkedIds)) checkedIds = [];
|
||||
this.cartList.valid.forEach(cart => {
|
||||
if (checkedIds.indexOf(cart.id) !== -1) cart.checked = true;
|
||||
});
|
||||
if (checkedIds.length) {
|
||||
that.checkedIds = checkedIds;
|
||||
that.isAllSelect = checkedIds.length === this.cartList.valid.length;
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
}
|
||||
this.loaded = true;
|
||||
});
|
||||
},
|
||||
//删除商品;
|
||||
delgoods: function() {
|
||||
let that = this,
|
||||
id = [],
|
||||
valid = [],
|
||||
list = that.cartList.valid;
|
||||
list.forEach(function(val) {
|
||||
if (val.checked === true) {
|
||||
id.push(val.id);
|
||||
}
|
||||
});
|
||||
if (id.length === 0) {
|
||||
uni.showToast({
|
||||
title: "请选择产品",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
postCartDel(id).then(function() {
|
||||
list.forEach(function(val, i) {
|
||||
if (val.checked === false || val.checked === undefined)
|
||||
valid.push(list[i]);
|
||||
});
|
||||
that.$set(that.cartList, "valid", valid);
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
that.gainCount();
|
||||
that.getCartList();
|
||||
});
|
||||
},
|
||||
// //获取数量
|
||||
gainCount: function() {
|
||||
let that = this;
|
||||
getCartCount().then(res => {
|
||||
that.count = res.data.count;
|
||||
});
|
||||
},
|
||||
//清除失效产品;
|
||||
delInvalidGoods: function() {
|
||||
let that = this,
|
||||
id = [],
|
||||
list = that.cartList.invalid;
|
||||
list.forEach(function(val) {
|
||||
id.push(val.id);
|
||||
});
|
||||
postCartDel(id).then(function() {
|
||||
list.splice(0, list.length);
|
||||
that.gainCount();
|
||||
that.getCartList();
|
||||
});
|
||||
},
|
||||
//批量收藏;
|
||||
collectAll: function() {
|
||||
let that = this,
|
||||
data = {
|
||||
id: [],
|
||||
category: ""
|
||||
},
|
||||
list = that.cartList.valid;
|
||||
list.forEach(function(val) {
|
||||
if (val.checked === true) {
|
||||
data.id.push(val.product_id);
|
||||
data.category = val.type;
|
||||
}
|
||||
});
|
||||
if (data.id.length === 0) {
|
||||
uni.showToast({
|
||||
title: "请选择产品",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
postCollectAll(data).then(function() {
|
||||
uni.showToast({
|
||||
title: "收藏成功!",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
});
|
||||
},
|
||||
//立即下单;
|
||||
placeOrder: function() {
|
||||
let that = this,
|
||||
list = that.cartList.valid,
|
||||
id = [];
|
||||
list.forEach(function(val) {
|
||||
if (val.checked === true) {
|
||||
id.push(val.id);
|
||||
}
|
||||
});
|
||||
if (id.length === 0) {
|
||||
uni.showToast({
|
||||
title: "请选择产品",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
console.log(id);
|
||||
this.$yrouter.push({
|
||||
path: "/pages/order/OrderSubmission/index",
|
||||
query: {
|
||||
id: id.join(",")
|
||||
}
|
||||
});
|
||||
},
|
||||
manage: function() {
|
||||
let that = this;
|
||||
that.footerswitch = !that.footerswitch;
|
||||
},
|
||||
goodsOpen: function() {
|
||||
let that = this;
|
||||
that.goodsHidden = !that.goodsHidden;
|
||||
},
|
||||
//加
|
||||
plus: function(index) {
|
||||
let that = this;
|
||||
let list = that.cartList.valid[index];
|
||||
list.cartNum++;
|
||||
if (list.attrInfo) {
|
||||
if (list.cartNum >= list.attrInfo.stock) {
|
||||
that.$set(list, "cart_num", list.attrInfo.stock);
|
||||
}
|
||||
} else {
|
||||
if (list.cartNum >= list.stock) {
|
||||
that.$set(list, "cart_num", list.stock);
|
||||
}
|
||||
}
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
that.syncCartNum(list);
|
||||
},
|
||||
//减
|
||||
reduce: function(index) {
|
||||
let that = this;
|
||||
let list = that.cartList.valid[index];
|
||||
if (list.cartNum <= 1) {
|
||||
uni.showToast({
|
||||
title: "已经是底线啦!",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
list.cartNum--;
|
||||
if (list.cartNum < 1) {
|
||||
that.$set(list, "cart_num", 1);
|
||||
}
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
that.syncCartNum(list);
|
||||
},
|
||||
syncCartNum(cart) {
|
||||
if (!cart.sync) {
|
||||
changeCartNum(cart.id, Math.max(cart.cartNum, 1) || 1)
|
||||
.then(res => {
|
||||
this.getCartList();
|
||||
})
|
||||
.catch(error => {
|
||||
uni.showToast({
|
||||
title: error.response.data.msg,
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
//单选
|
||||
switchSelect: function(index) {
|
||||
let that = this,
|
||||
cart = that.cartList.valid[index],
|
||||
i = this.checkedIds.indexOf(cart.id);
|
||||
cart.checked = !cart.checked;
|
||||
|
||||
if (i !== -1) this.checkedIds.splice(i, 1);
|
||||
if (cart.checked) {
|
||||
this.checkedIds.push(cart.id);
|
||||
}
|
||||
let len = that.cartList.valid.length;
|
||||
let selectnum = [];
|
||||
for (let i = 0; i < len; i++) {
|
||||
if (that.cartList.valid[i].checked === true) {
|
||||
selectnum.push(true);
|
||||
}
|
||||
}
|
||||
that.isAllSelect = selectnum.length === len;
|
||||
that.$set(that, "cartList", that.cartList);
|
||||
that.$set(that, "isAllSelect", that.isAllSelect);
|
||||
cookie.set(CHECKED_IDS, that.checkedIds);
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
},
|
||||
//全选
|
||||
allChecked: function(e) {
|
||||
let that = this;
|
||||
let selectAllStatus = e.mp.detail.value[0] ? true : false;
|
||||
// let selectAllStatus = that.isAllSelect;
|
||||
let checkedIds = [];
|
||||
// for (let i = 0; i < array.length; i++) {
|
||||
// array[i].checked = selectAllStatus;
|
||||
// checked.push()
|
||||
// }
|
||||
that.cartList.valid.forEach(cart => {
|
||||
cart.checked = selectAllStatus;
|
||||
if (selectAllStatus) {
|
||||
checkedIds.push(cart.id);
|
||||
}
|
||||
});
|
||||
let cartList = {
|
||||
...that.cartList
|
||||
};
|
||||
that.cartList = [];
|
||||
that.cartList = cartList;
|
||||
this.$set(this, "cartList", this.cartList);
|
||||
this.$set(this, "isAllSelect", selectAllStatus);
|
||||
this.checkedIds = checkedIds;
|
||||
cookie.set(CHECKED_IDS, checkedIds);
|
||||
that.carnum();
|
||||
that.countMoney();
|
||||
this.$forceUpdate();
|
||||
},
|
||||
//数量
|
||||
carnum: function() {
|
||||
let that = this;
|
||||
var carnum = 0;
|
||||
var array = that.cartList.valid;
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (array[i].checked === true) {
|
||||
carnum += parseInt(array[i].cartNum);
|
||||
}
|
||||
}
|
||||
that.$set(that, "cartCount", carnum);
|
||||
},
|
||||
//总共价钱;
|
||||
countMoney: function() {
|
||||
let that = this;
|
||||
let carmoney = 0;
|
||||
let array = that.cartList.valid;
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (array[i].checked === true) {
|
||||
carmoney = add(carmoney, mul(array[i].cartNum, array[i].truePrice));
|
||||
}
|
||||
}
|
||||
that.countmoney = carmoney;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -121,11 +121,6 @@ export default {
|
||||
userIndex: 0
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
$yroute(n) {
|
||||
if (n.name === "PersonalData") this.$store.dispatch("USERINFO", true);
|
||||
}
|
||||
},
|
||||
computed: mapGetters(["userInfo"]),
|
||||
mounted: function() {
|
||||
this.avatar = this.userInfo.avatar;
|
||||
|
@ -63,14 +63,14 @@ export default {
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
return
|
||||
return;
|
||||
} else if (price < 0.01) {
|
||||
uni.showToast({
|
||||
title: "转入金额不能低于0.01",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
uni.showModal({
|
||||
|
@ -1,157 +1,161 @@
|
||||
<template>
|
||||
<view class="user">
|
||||
<view class="header bg-color-red acea-row row-between-wrapper">
|
||||
<view class="picTxt acea-row row-between-wrapper">
|
||||
<view class="pictrue">
|
||||
<image :src="userInfo.avatar" />
|
||||
</view>
|
||||
<view class="text">
|
||||
<view class="acea-row row-middle">
|
||||
<view class="name line1">{{ userInfo.nickname }}</view>
|
||||
<view class="member acea-row row-middle" v-if="userInfo.vip">
|
||||
<image :src="userInfo.vipIcon" />
|
||||
<text>{{ userInfo.vipName }}</text>
|
||||
</view>
|
||||
<view v-if="userInfo.uid">
|
||||
<view class="header bg-color-red acea-row row-between-wrapper">
|
||||
<view class="picTxt acea-row row-between-wrapper">
|
||||
<view class="pictrue">
|
||||
<image :src="userInfo.avatar" />
|
||||
</view>
|
||||
<view @click="goPersonalData()" class="id" v-if="userInfo.phone">
|
||||
<text>ID:{{ userInfo.uid || 0}}</text>
|
||||
<text class="iconfont icon-bianji1"></text>
|
||||
</view>
|
||||
<button
|
||||
open-type="getPhoneNumber"
|
||||
@getphonenumber="getPhoneNumber"
|
||||
class="binding"
|
||||
v-else
|
||||
>
|
||||
<text>绑定手机号</text>
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
<text class="iconfont icon-shezhi" @click="goPersonalData()"></text>
|
||||
</view>
|
||||
<view class="wrapper">
|
||||
<view class="nav acea-row row-middle">
|
||||
<view @click="goUserAccount()" class="item">
|
||||
<text>我的余额</text>
|
||||
<text class="num">{{ userInfo.nowMoney || 0 }}</text>
|
||||
</view>
|
||||
<view
|
||||
@click="goUserPromotion()"
|
||||
class="item"
|
||||
v-if="userInfo.isPromoter === 1 || userInfo.statu === 2"
|
||||
>
|
||||
<text>当前佣金</text>
|
||||
<text class="num">{{ userInfo.brokeragePrice || 0 }}</text>
|
||||
</view>
|
||||
<view @click="goIntegral()" class="item" v-else>
|
||||
<text>当前积分</text>
|
||||
<text class="num">{{ userInfo.integral || 0 }}</text>
|
||||
</view>
|
||||
<view @click="goUserCoupon()" class="item">
|
||||
<text>优惠券</text>
|
||||
<text class="num">{{ userInfo.couponCount || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="myOrder">
|
||||
<view class="title acea-row row-between-wrapper">
|
||||
<text>我的订单</text>
|
||||
<text @click="goMyOrder()" class="allOrder">
|
||||
全部订单
|
||||
<text class="iconfont icon-jiantou"></text>
|
||||
</text>
|
||||
</view>
|
||||
<view class="orderState acea-row row-middle">
|
||||
<view @click="goMyOrder(0)" class="item">
|
||||
<view class="pictrue">
|
||||
<image :src="$VUE_APP_RESOURCES_URL + '/images/dfk.png'" />
|
||||
<text
|
||||
class="order-status-num"
|
||||
v-if="orderStatusNum.unpaidCount > 0"
|
||||
>{{ orderStatusNum.unpaidCount }}</text>
|
||||
</view>
|
||||
<view>待付款</view>
|
||||
</view>
|
||||
<view @click="goMyOrder(1)" class="item">
|
||||
<view class="pictrue">
|
||||
<image :src="$VUE_APP_RESOURCES_URL+'/images/dfh.png'" />
|
||||
<text
|
||||
class="order-status-num"
|
||||
v-if="orderStatusNum.unshippedCount > 0"
|
||||
>{{ orderStatusNum.unshippedCount }}</text>
|
||||
</view>
|
||||
<view>待发货</view>
|
||||
</view>
|
||||
<view @click="goMyOrder(2)" class="item">
|
||||
<view class="pictrue">
|
||||
<image :src="$VUE_APP_RESOURCES_URL+'/images/dsh.png'" />
|
||||
<text
|
||||
class="order-status-num"
|
||||
v-if="orderStatusNum.receivedCount > 0"
|
||||
>{{ orderStatusNum.receivedCount }}</text>
|
||||
</view>
|
||||
<text>待收货</text>
|
||||
</view>
|
||||
<view @click="goMyOrder(3)" class="item">
|
||||
<view class="pictrue">
|
||||
<image :src="$VUE_APP_RESOURCES_URL+'/images/dpj.png'" />
|
||||
<text
|
||||
class="order-status-num"
|
||||
v-if="orderStatusNum.evaluatedCount > 0"
|
||||
>{{ orderStatusNum.evaluatedCount }}</text>
|
||||
</view>
|
||||
<text>待评价</text>
|
||||
</view>
|
||||
<view @click="goReturnList()" class="item">
|
||||
<view class="pictrue">
|
||||
<image :src="$VUE_APP_RESOURCES_URL+'/images/sh.png'" />
|
||||
<text
|
||||
class="order-status-num"
|
||||
v-if="orderStatusNum.refundCount > 0"
|
||||
>{{ orderStatusNum.refundCount }}</text>
|
||||
</view>
|
||||
<text>售后/退款</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="myService">
|
||||
<view class="title acea-row row-middle">
|
||||
<text>我的服务</text>
|
||||
</view>
|
||||
<view class="serviceList acea-row row-middle">
|
||||
<template v-for="(item, MyMenusIndex) in MyMenus">
|
||||
<view class="item" :key="MyMenusIndex" @click="goPages(MyMenusIndex)" v-if="item.url">
|
||||
<view class="pictrue">
|
||||
<image :src="item.pic" />
|
||||
<view class="text">
|
||||
<view class="acea-row row-middle">
|
||||
<view class="name line1">{{ userInfo.nickname }}</view>
|
||||
<view class="member acea-row row-middle" v-if="userInfo.vip">
|
||||
<image :src="userInfo.vipIcon" />
|
||||
<text>{{ userInfo.vipName }}</text>
|
||||
</view>
|
||||
<view>{{ item.name }}</view>
|
||||
</view>
|
||||
</template>
|
||||
<view @click="goPersonalData()" class="id" v-if="userInfo.phone">
|
||||
<text>ID:{{ userInfo.uid || 0}}</text>
|
||||
<text class="iconfont icon-bianji1"></text>
|
||||
</view>
|
||||
<button
|
||||
open-type="getPhoneNumber"
|
||||
@getphonenumber="getPhoneNumber"
|
||||
class="binding"
|
||||
v-else
|
||||
>
|
||||
<text>绑定手机号</text>
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
<text class="iconfont icon-shezhi" @click="goPersonalData()"></text>
|
||||
</view>
|
||||
<!--<view -->
|
||||
<!--class="item"-->
|
||||
<!--@click="changeswitch(true)"-->
|
||||
<!--v-if="userInfo.phone && isWeixin"-->
|
||||
<!-->-->
|
||||
<!--<view class="pictrue"><image :src="$VUE_APP_RESOURCES_URL+'/images/switch.png'" /></view>-->
|
||||
<!--<view>账号切换</!--<view>-->
|
||||
<!--</!--<view>-->
|
||||
<!-- </view>
|
||||
</view>-->
|
||||
<view class="wrapper">
|
||||
<view class="nav acea-row row-middle">
|
||||
<view @click="goUserAccount()" class="item">
|
||||
<text>我的余额</text>
|
||||
<text class="num">{{ userInfo.nowMoney || 0 }}</text>
|
||||
</view>
|
||||
<view
|
||||
@click="goUserPromotion()"
|
||||
class="item"
|
||||
v-if="userInfo.isPromoter === 1 || userInfo.statu === 2"
|
||||
>
|
||||
<text>当前佣金</text>
|
||||
<text class="num">{{ userInfo.brokeragePrice || 0 }}</text>
|
||||
</view>
|
||||
<view @click="goIntegral()" class="item" v-else>
|
||||
<text>当前积分</text>
|
||||
<text class="num">{{ userInfo.integral || 0 }}</text>
|
||||
</view>
|
||||
<view @click="goUserCoupon()" class="item">
|
||||
<text>优惠券</text>
|
||||
<text class="num">{{ userInfo.couponCount || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="myOrder">
|
||||
<view class="title acea-row row-between-wrapper">
|
||||
<text>我的订单</text>
|
||||
<text @click="goMyOrder()" class="allOrder">
|
||||
全部订单
|
||||
<text class="iconfont icon-jiantou"></text>
|
||||
</text>
|
||||
</view>
|
||||
<view class="orderState acea-row row-middle">
|
||||
<view @click="goMyOrder(0)" class="item">
|
||||
<view class="pictrue">
|
||||
<image :src="$VUE_APP_RESOURCES_URL + '/images/dfk.png'" />
|
||||
<text
|
||||
class="order-status-num"
|
||||
v-if="orderStatusNum.unpaidCount > 0"
|
||||
>{{ orderStatusNum.unpaidCount }}</text>
|
||||
</view>
|
||||
<view>待付款</view>
|
||||
</view>
|
||||
<view @click="goMyOrder(1)" class="item">
|
||||
<view class="pictrue">
|
||||
<image :src="$VUE_APP_RESOURCES_URL+'/images/dfh.png'" />
|
||||
<text
|
||||
class="order-status-num"
|
||||
v-if="userInfo.orderStatusNum.unshippedCount > 0"
|
||||
>{{ userInfo.orderStatusNum.unshippedCount }}</text>
|
||||
</view>
|
||||
<view>待发货</view>
|
||||
</view>
|
||||
<view @click="goMyOrder(2)" class="item">
|
||||
<view class="pictrue">
|
||||
<image :src="$VUE_APP_RESOURCES_URL+'/images/dsh.png'" />
|
||||
<text
|
||||
class="order-status-num"
|
||||
v-if="userInfo.orderStatusNum.receivedCount > 0"
|
||||
>{{ userInfo.orderStatusNum.receivedCount }}</text>
|
||||
</view>
|
||||
<text>待收货</text>
|
||||
</view>
|
||||
<view @click="goMyOrder(3)" class="item">
|
||||
<view class="pictrue">
|
||||
<image :src="$VUE_APP_RESOURCES_URL+'/images/dpj.png'" />
|
||||
<text
|
||||
class="order-status-num"
|
||||
v-if="userInfo.orderStatusNum.evaluatedCount > 0"
|
||||
>{{ userInfo.orderStatusNum.evaluatedCount }}</text>
|
||||
</view>
|
||||
<text>待评价</text>
|
||||
</view>
|
||||
<view @click="goReturnList()" class="item">
|
||||
<view class="pictrue">
|
||||
<image :src="$VUE_APP_RESOURCES_URL+'/images/sh.png'" />
|
||||
<text
|
||||
class="order-status-num"
|
||||
v-if="userInfo.orderStatusNum.refundCount > 0"
|
||||
>{{ userInfo.orderStatusNum.refundCount }}</text>
|
||||
</view>
|
||||
<text>售后/退款</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="myService">
|
||||
<view class="title acea-row row-middle">
|
||||
<text>我的服务</text>
|
||||
</view>
|
||||
<view class="serviceList acea-row row-middle">
|
||||
<template v-for="(item, MyMenusIndex) in MyMenus">
|
||||
<view class="item" :key="MyMenusIndex" @click="goPages(MyMenusIndex)" v-if="item.url">
|
||||
<view class="pictrue">
|
||||
<image :src="item.pic" />
|
||||
</view>
|
||||
<view>{{ item.name }}</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
<!--<view -->
|
||||
<!--class="item"-->
|
||||
<!--@click="changeswitch(true)"-->
|
||||
<!--v-if="userInfo.phone && isWeixin"-->
|
||||
<!-->-->
|
||||
<!--<view class="pictrue"><image :src="$VUE_APP_RESOURCES_URL+'/images/switch.png'" /></view>-->
|
||||
<!--<view>账号切换</!--<view>-->
|
||||
<!--</!--<view>-->
|
||||
<!-- </view>
|
||||
</view>-->
|
||||
</view>
|
||||
<view style="text-align: center;margin-top: 1rem">By@意象</view>
|
||||
<view class="footer-line-height"></view>
|
||||
<SwitchWindow
|
||||
v-on:changeswitch="changeswitch"
|
||||
:switchActive="switchActive"
|
||||
:login_type="userInfo.login_type"
|
||||
></SwitchWindow>
|
||||
</view>
|
||||
<view style="text-align: center;margin-top: 1rem">By@意象</view>
|
||||
<view class="footer-line-height"></view>
|
||||
<SwitchWindow
|
||||
v-on:changeswitch="changeswitch"
|
||||
:switchActive="switchActive"
|
||||
:login_type="userInfo.login_type"
|
||||
></SwitchWindow>
|
||||
<Authorization v-else />
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import { getUser, getMenuUser, bindingPhone } from "@/api/user";
|
||||
import { isWeixin, VUE_APP_RESOURCES_URL } from "@/utils";
|
||||
import SwitchWindow from "@/components/SwitchWindow";
|
||||
import Authorization from "@/pages/authorization/index";
|
||||
import { mapGetters } from "vuex";
|
||||
|
||||
const NAME = "User";
|
||||
@ -159,30 +163,18 @@ const NAME = "User";
|
||||
export default {
|
||||
name: NAME,
|
||||
components: {
|
||||
SwitchWindow
|
||||
SwitchWindow,
|
||||
Authorization
|
||||
},
|
||||
props: {},
|
||||
data: function() {
|
||||
return {
|
||||
userInfo: {},
|
||||
MyMenus: [],
|
||||
orderStatusNum: {},
|
||||
switchActive: false,
|
||||
isWeixin: false
|
||||
};
|
||||
},
|
||||
computed: mapGetters(["wxCode"]),
|
||||
watch: {
|
||||
$yroute(n) {
|
||||
if (n.name === NAME) this.User();
|
||||
}
|
||||
},
|
||||
mounted: function() {
|
||||
console.log("这个是个人中心");
|
||||
this.User();
|
||||
this.MenuUser();
|
||||
this.isWeixin = isWeixin();
|
||||
},
|
||||
computed: mapGetters(["userInfo"]),
|
||||
methods: {
|
||||
goReturnList() {
|
||||
this.$yrouter.push("/pages/order/ReturnList/index");
|
||||
@ -214,33 +206,44 @@ export default {
|
||||
},
|
||||
getPhoneNumber: function(e) {
|
||||
console.log(e.mp.detail);
|
||||
// 判断一下这里是不是小程序 如果是小程序,走获取微信手机号进行绑定
|
||||
if (e.mp.detail.errMsg == "getPhoneNumber:ok") {
|
||||
uni.showLoading({
|
||||
title: "绑定中"
|
||||
});
|
||||
wx.login({
|
||||
success: loginRes => {
|
||||
bindingPhone({
|
||||
code: loginRes.code,
|
||||
encryptedData: e.mp.detail.encryptedData,
|
||||
iv: e.mp.detail.iv
|
||||
})
|
||||
.then(res => {
|
||||
this.User();
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: "success",
|
||||
duration: 2000
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
uni.showToast({
|
||||
title: error.msg || error.response.data.msg,
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
// 获取当前环境的服务商
|
||||
uni.getProvider({
|
||||
service: "oauth",
|
||||
success: function(res) {
|
||||
console.log(res.provider);
|
||||
// 此处可以排除h5
|
||||
if (res.provider) {
|
||||
uni.login({
|
||||
success: loginRes => {
|
||||
bindingPhone({
|
||||
code: loginRes.code,
|
||||
encryptedData: e.mp.detail.encryptedData,
|
||||
iv: e.mp.detail.iv
|
||||
})
|
||||
.then(res => {
|
||||
this.User();
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: "success",
|
||||
duration: 2000
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
uni.showToast({
|
||||
title: error.msg || error.response.data.msg,
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@ -256,10 +259,10 @@ export default {
|
||||
},
|
||||
User: function() {
|
||||
let that = this;
|
||||
getUser().then(res => {
|
||||
that.userInfo = res.data;
|
||||
that.orderStatusNum = res.data.orderStatusNum;
|
||||
});
|
||||
// getUser().then(res => {
|
||||
// that.user = res.data;
|
||||
// that.orderStatusNum = res.data.orderStatusNum;
|
||||
// });
|
||||
},
|
||||
MenuUser: function() {
|
||||
let that = this;
|
||||
@ -287,12 +290,12 @@ export default {
|
||||
url === "/pages/orderAdmin/OrderIndex/index" &&
|
||||
!this.userInfo.adminid
|
||||
) {
|
||||
uni.showToast({
|
||||
title: "您还不是管理员!!",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
uni.showToast({
|
||||
title: "您还不是管理员!!",
|
||||
icon: "none",
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.$yrouter.push({
|
||||
@ -300,10 +303,18 @@ export default {
|
||||
});
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
userInfo() {
|
||||
this.MenuUser();
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
this.User();
|
||||
this.MenuUser();
|
||||
this.isWeixin = isWeixin();
|
||||
console.log(this.userInfo);
|
||||
if (this.userInfo.uid) {
|
||||
this.User();
|
||||
this.MenuUser();
|
||||
this.isWeixin = isWeixin();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -73,23 +73,6 @@ export default {
|
||||
);
|
||||
},
|
||||
downloadIamge: function(imgsrc, name) {
|
||||
// let image = new Image();
|
||||
// image.setAttribute("crossOrigin", "anonymous");
|
||||
// image.onload = function() {
|
||||
// // let canvas = document.createElement("canvas");
|
||||
// // canvas.width = image.width;
|
||||
// // canvas.height = image.height;
|
||||
// // let context = canvas.getContext("2d");
|
||||
// // context.drawImage(image, 0, 0, image.width, image.height);
|
||||
// // let url = canvas.toDataURL("image/png"); //得到图片的base64编码数据
|
||||
// // let a = document.createElement("a"); // 生成一个a元素
|
||||
// // let event = new MouseEvent("click"); // 创建一个单击事件
|
||||
// // a.download = name || "photo"; // 设置图片名称
|
||||
// // a.href = url; // 将生成的URL设置为a.href属性
|
||||
// // a.dispatchEvent(event); // 触发a的单击事件
|
||||
// };
|
||||
// image.src = imgsrc;
|
||||
|
||||
var that = this;
|
||||
this.isDown = true;
|
||||
var downloadUrl = imgsrc;
|
||||
|
Reference in New Issue
Block a user