|
|
|
|
@ -341,7 +341,7 @@
|
|
|
|
|
</button>
|
|
|
|
|
<view
|
|
|
|
|
class="item car"
|
|
|
|
|
@tap="$u.route({ url: '/package_sub/pages/Shop/Cart' })"
|
|
|
|
|
@tap="goCart"
|
|
|
|
|
>
|
|
|
|
|
<u-badge
|
|
|
|
|
class="car-num"
|
|
|
|
|
@ -373,6 +373,8 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { getToken, promptLogin } from '@/common/auth.js'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
@ -416,6 +418,9 @@ export default {
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
token() {
|
|
|
|
|
return getToken(this)
|
|
|
|
|
},
|
|
|
|
|
menuButtonLeft() {
|
|
|
|
|
return (
|
|
|
|
|
uni.getSystemInfoSync().windowWidth -
|
|
|
|
|
@ -472,6 +477,10 @@ export default {
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
async getCartNum() {
|
|
|
|
|
if (!this.token) {
|
|
|
|
|
this.cartNum = 0
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
const res = await this.$u.api.cartList({
|
|
|
|
|
page: 1,
|
|
|
|
|
@ -480,6 +489,17 @@ export default {
|
|
|
|
|
this.cartNum = res.total;
|
|
|
|
|
} catch (err) {}
|
|
|
|
|
},
|
|
|
|
|
goCart() {
|
|
|
|
|
if (!this.token) {
|
|
|
|
|
promptLogin(this, { content: '登录后可查看购物车,是否前往登录?' })
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.$u.route({ url: '/package_sub/pages/Shop/Cart' })
|
|
|
|
|
},
|
|
|
|
|
async ensureLoginForPurchase() {
|
|
|
|
|
if (this.token) return true
|
|
|
|
|
return promptLogin(this, { content: '登录后可购买商品,是否前往登录?' })
|
|
|
|
|
},
|
|
|
|
|
async getComment() {
|
|
|
|
|
this.commentList = [
|
|
|
|
|
{
|
|
|
|
|
@ -604,6 +624,7 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
async confirm() {
|
|
|
|
|
try {
|
|
|
|
|
if (!(await this.ensureLoginForPurchase())) return
|
|
|
|
|
if (this.isSkuSubmit) {
|
|
|
|
|
if (!this.form.product_sku_id) {
|
|
|
|
|
this.$refs.uToast.show({
|
|
|
|
|
@ -637,7 +658,9 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.getRecommendPro();
|
|
|
|
|
this.getCartNum();
|
|
|
|
|
if (this.token) {
|
|
|
|
|
this.getCartNum();
|
|
|
|
|
}
|
|
|
|
|
this.getComment();
|
|
|
|
|
},
|
|
|
|
|
onLoad(option) {
|
|
|
|
|
@ -646,6 +669,11 @@ export default {
|
|
|
|
|
this.getDetail(option.id);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onShow() {
|
|
|
|
|
if (this.token) {
|
|
|
|
|
this.getCartNum();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onPageScroll({ scrollTop }) {
|
|
|
|
|
if (this.timer) return;
|
|
|
|
|
this.timer = setTimeout(() => {
|
|
|
|
|
|