|
@@ -48,8 +48,8 @@
|
|
</view>
|
|
</view>
|
|
<!-- 底部浮动按钮 -->
|
|
<!-- 底部浮动按钮 -->
|
|
<view class="bottom-btns" v-if="goodContent&&goodContent.inventoryQty > 0&&goodContent.state==1">
|
|
<view class="bottom-btns" v-if="goodContent&&goodContent.inventoryQty > 0&&goodContent.state==1">
|
|
- <view><u-button :custom-style="addCartButton" type="warning" @click="addCart">加入购物车</u-button></view>
|
|
|
|
- <view><u-button :custom-style="toOrderButton" type="error" @click="toOrder()">立即下单</u-button></view>
|
|
|
|
|
|
+ <view><u-button :custom-style="addCartButton" type="warning" @click="checkLogin(0)">加入购物车</u-button></view>
|
|
|
|
+ <view><u-button :custom-style="toOrderButton" type="error" @click="checkLogin(1)">立即下单</u-button></view>
|
|
</view>
|
|
</view>
|
|
<!-- 购物车 -->
|
|
<!-- 购物车 -->
|
|
<uni-cart-fix :closeCurPage="true" :dragPic="dragPic"></uni-cart-fix>
|
|
<uni-cart-fix :closeCurPage="true" :dragPic="dragPic"></uni-cart-fix>
|
|
@@ -63,6 +63,7 @@
|
|
import {
|
|
import {
|
|
addGoodsToCart
|
|
addGoodsToCart
|
|
} from '@/api/shoppingCart.js'
|
|
} from '@/api/shoppingCart.js'
|
|
|
|
+ import {checkLogin} from '@/api/login.js'
|
|
import jyfParser from "@/components/jyf-parser/jyf-parser";
|
|
import jyfParser from "@/components/jyf-parser/jyf-parser";
|
|
export default {
|
|
export default {
|
|
components: {
|
|
components: {
|
|
@@ -83,7 +84,8 @@
|
|
goodContent: null,
|
|
goodContent: null,
|
|
goldLimit: 0,
|
|
goldLimit: 0,
|
|
dragPic: '/static/cart.png', // 购物车图标
|
|
dragPic: '/static/cart.png', // 购物车图标
|
|
- userData: null
|
|
|
|
|
|
+ userData: null,
|
|
|
|
+ hasLogin: false
|
|
};
|
|
};
|
|
},
|
|
},
|
|
onLoad(opts) {
|
|
onLoad(opts) {
|
|
@@ -141,6 +143,34 @@
|
|
let row = list.find(item=> item.goodsTypeNo == data.goodsTypeNo)
|
|
let row = list.find(item=> item.goodsTypeNo == data.goodsTypeNo)
|
|
return row
|
|
return row
|
|
},
|
|
},
|
|
|
|
+ // 是否登录 flag: 0 加入购物车 1 立即下单
|
|
|
|
+ checkLogin(flag) {
|
|
|
|
+ // 是否登录
|
|
|
|
+ checkLogin().then(res => {
|
|
|
|
+ this.hasLogin = res.status == 200
|
|
|
|
+ if(this.hasLogin) {
|
|
|
|
+ if(flag) {
|
|
|
|
+ this.toOrder()
|
|
|
|
+ } else {
|
|
|
|
+ this.addCart()
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ uni.showModal({
|
|
|
|
+ title: '提示',
|
|
|
|
+ content: '您尚未登录或登录已过期,请先进行登录',
|
|
|
|
+ success (res) {
|
|
|
|
+ if (res.confirm) {
|
|
|
|
+ uni.navigateTo({
|
|
|
|
+ url: '/pages/login/login'
|
|
|
|
+ });
|
|
|
|
+ } else if (res.cancel) {
|
|
|
|
+ console.log('用户点击取消');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
// 加入购物车
|
|
// 加入购物车
|
|
addCart() {
|
|
addCart() {
|
|
let item = this.goodContent
|
|
let item = this.goodContent
|