|
|
@@ -42,8 +42,21 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <buy-foot @buy="showPopup" @goShop="goShopIndex()" />
|
|
|
- <sel-popup :show="popupShow" :info="productInfo" :buyNum="buyNum" @change="changeNum" @close="hidePopup" @nextFn="nextFn" />
|
|
|
+ <buy-foot
|
|
|
+ @buy="openBuyPopup"
|
|
|
+ @addCart="openCartPopup"
|
|
|
+ @goShop="goShopIndex"
|
|
|
+ @goCart="goCartPage"
|
|
|
+ />
|
|
|
+ <sel-popup
|
|
|
+ :show="popupShow"
|
|
|
+ :info="productInfo"
|
|
|
+ :buyNum="buyNum"
|
|
|
+ :action-type="popupAction"
|
|
|
+ @change="changeNum"
|
|
|
+ @close="hidePopup"
|
|
|
+ @nextFn="onPopupConfirm"
|
|
|
+ />
|
|
|
<app-share-mask :show="showShare" text="分享商品" @click="hideShare" />
|
|
|
</view>
|
|
|
</template>
|
|
|
@@ -78,6 +91,7 @@ export default {
|
|
|
imgList: [],
|
|
|
buyNum: 1,
|
|
|
popupShow: false,
|
|
|
+ popupAction: 'buy',
|
|
|
loginShow: false,
|
|
|
showShare: false,
|
|
|
isShare:true,
|
|
|
@@ -110,13 +124,80 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- nextFn(num){
|
|
|
- let customData = {...this.productInfo,bigCount: Number(num),smallCount:0,itemPrice:this.productInfo.price,bigPrice:this.productInfo.price,smallPrice:0}
|
|
|
+ getAffirmUrl() {
|
|
|
+ const ghsId = this.option.ghsId || ''
|
|
|
+ return `/admin/billing/affirmGhs?id=${ghsId}`
|
|
|
+ },
|
|
|
+ onPopupConfirm(num) {
|
|
|
+ const customData = {
|
|
|
+ ...this.productInfo,
|
|
|
+ bigCount: Number(num),
|
|
|
+ smallCount: 0,
|
|
|
+ itemPrice: this.productInfo.price,
|
|
|
+ bigPrice: this.productInfo.price,
|
|
|
+ smallPrice: 0
|
|
|
+ }
|
|
|
this.addItemEvent(customData)
|
|
|
- this.$util.pageTo({url:"/admin/billing/affirmGhs?id="+this.option.ghsId,type:2})
|
|
|
+ this.hidePopup()
|
|
|
+ if (this.popupAction === 'buy') {
|
|
|
+ this.$util.pageTo({ url: this.getAffirmUrl(), type: 2 })
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '已加入购物车',
|
|
|
+ duration: 1500
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ goShopIndex() {
|
|
|
+ this.$util.pageTo({ url: `/pagesPurchase/ghsProduct?id=${this.option.ghsId}`, type: 2 })
|
|
|
+ },
|
|
|
+ goCartPage() {
|
|
|
+ if (!this.checkLogin()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.$util.pageTo({ url: this.getAffirmUrl(), type: 2 })
|
|
|
+ },
|
|
|
+ checkLogin() {
|
|
|
+ if (this.notOpenShop) {
|
|
|
+ const that = this
|
|
|
+ that.$util.confirmModal({ content: '请先注册登录哦', okText: '好的' }, () => {
|
|
|
+ that.pageTo({ url: `/admin/home/login?itemId=${that.id}&ghsShopId=${that.shopId}`, type: 2 })
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ },
|
|
|
+ openCartPopup() {
|
|
|
+ if (!this.checkLogin()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!this.productInfo || !this.productInfo.id) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const stock = Number(this.productInfo.stock) || 0
|
|
|
+ if (stock <= 0) {
|
|
|
+ this.$msg('暂无库存')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.popupAction = 'cart'
|
|
|
+ this.buyNum = 1
|
|
|
+ this.popupShow = true
|
|
|
},
|
|
|
- goShopIndex(){
|
|
|
- this.$util.pageTo({url:'/pagesPurchase/ghsProduct?id='+this.option.ghsId,type:2})
|
|
|
+ openBuyPopup() {
|
|
|
+ if (!this.checkLogin()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!this.productInfo || !this.productInfo.id) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const stock = Number(this.productInfo.stock) || 0
|
|
|
+ if (stock <= 0) {
|
|
|
+ this.$msg('暂无库存')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.popupAction = 'buy'
|
|
|
+ this.buyNum = 1
|
|
|
+ this.popupShow = true
|
|
|
},
|
|
|
init() {
|
|
|
let that = this
|
|
|
@@ -210,18 +291,6 @@ export default {
|
|
|
changeNum(e) {
|
|
|
this.buyNum = e.value;
|
|
|
},
|
|
|
- showPopup() {
|
|
|
- let that = this
|
|
|
- if(this.notOpenShop == true){
|
|
|
-
|
|
|
- that.$util.confirmModal({content:'请先注册登录哦',okText:'好的'},() => {
|
|
|
- that.pageTo({url:'/admin/home/login?itemId='+this.id+'&ghsShopId='+this.shopId,type:2})
|
|
|
- })
|
|
|
-
|
|
|
- return false;
|
|
|
- }
|
|
|
- this.popupShow = true
|
|
|
- },
|
|
|
hidePopup() {
|
|
|
this.popupShow = false;
|
|
|
},
|