|
|
@@ -42,8 +42,21 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <sel-popup :show="popupShow" :info="data" :buyNum="buyNum" @change="changeNum" @close="hidePopup" @nextFn="nextFn" />
|
|
|
- <buy-foot @buy="showPopup" :stock="data.stock" @goShop="goShopIndex()" />
|
|
|
+ <sel-popup
|
|
|
+ :show="popupShow"
|
|
|
+ :info="data"
|
|
|
+ :buyNum="buyNum"
|
|
|
+ :action-type="popupAction"
|
|
|
+ @change="changeNum"
|
|
|
+ @close="hidePopup"
|
|
|
+ @nextFn="onPopupConfirm"
|
|
|
+ />
|
|
|
+ <buy-foot
|
|
|
+ @buy="openBuyPopup"
|
|
|
+ @addCart="openCartPopup"
|
|
|
+ @goShop="goShopIndex"
|
|
|
+ @goCart="goCartPage"
|
|
|
+ />
|
|
|
</view>
|
|
|
</template>
|
|
|
<script>
|
|
|
@@ -77,6 +90,7 @@ export default {
|
|
|
imgList: [],
|
|
|
buyNum: 1,
|
|
|
popupShow: false,
|
|
|
+ popupAction: 'buy',
|
|
|
loginShow: false,
|
|
|
showShare: false,
|
|
|
pageType: "cg",
|
|
|
@@ -105,13 +119,38 @@ export default {
|
|
|
...mapGetters({ shopUser: "getShopUser",loginInfo:"getLoginInfo" })
|
|
|
},
|
|
|
methods: {
|
|
|
- nextFn(num){
|
|
|
- let customData = {...this.data,bigCount: Number(num),smallCount:0,itemPrice:this.data.skPrice,bigPrice:this.data.skPrice,smallPrice:0}
|
|
|
+ getAffirmUrl() {
|
|
|
+ const account = this.option.account || ''
|
|
|
+ return `/pages/billing/affirmGhs?account=${account}&hdId=${this.hdId}`
|
|
|
+ },
|
|
|
+ onPopupConfirm(num) {
|
|
|
+ const customData = {
|
|
|
+ ...this.data,
|
|
|
+ bigCount: Number(num),
|
|
|
+ smallCount: 0,
|
|
|
+ itemPrice: this.data.skPrice,
|
|
|
+ bigPrice: this.data.skPrice,
|
|
|
+ smallPrice: 0
|
|
|
+ }
|
|
|
this.addItemEvent(customData)
|
|
|
- this.$util.pageTo({url:"/pages/billing/affirmGhs?account="+this.option.account+'&hdId='+this.hdId,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:"/pages/item/item?account="+this.option.account+'&hdId='+this.hdId,type:2})
|
|
|
+ goShopIndex() {
|
|
|
+ this.$util.pageTo({ url: `/pages/item/item?account=${this.option.account}&hdId=${this.hdId}`, type: 2 })
|
|
|
+ },
|
|
|
+ goCartPage() {
|
|
|
+ if (!this.checkLogin()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.$util.pageTo({ url: this.getAffirmUrl(), type: 2 })
|
|
|
},
|
|
|
init() {
|
|
|
let that = this
|
|
|
@@ -170,22 +209,54 @@ export default {
|
|
|
changeNum(e) {
|
|
|
this.buyNum = e.value;
|
|
|
},
|
|
|
- showPopup() {
|
|
|
- if(this.globalLoginStyle == 0){
|
|
|
- let that = this
|
|
|
- uni.showModal({
|
|
|
- title: '提示',
|
|
|
- content: '请先注册登录哦',
|
|
|
- confirmText: "好的",
|
|
|
- success: function(res) {
|
|
|
- if (res.confirm) {
|
|
|
- that.pageTo({url:'/pages/login/index',type:2})
|
|
|
- }
|
|
|
+ checkLogin() {
|
|
|
+ if (this.globalLoginStyle == 0) {
|
|
|
+ const that = this
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '请先注册登录哦',
|
|
|
+ confirmText: '好的',
|
|
|
+ success(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ that.pageTo({ url: '/pages/login/index', type: 2 })
|
|
|
}
|
|
|
- })
|
|
|
- return false;
|
|
|
- }
|
|
|
- this.popupShow = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ },
|
|
|
+ openCartPopup() {
|
|
|
+ if (!this.checkLogin()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!this.data || !this.data.id) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const stock = Number(this.data.stock) || 0
|
|
|
+ if (stock <= 0) {
|
|
|
+ this.$msg('暂无库存')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.popupAction = 'cart'
|
|
|
+ this.buyNum = 1
|
|
|
+ this.popupShow = true
|
|
|
+ },
|
|
|
+ openBuyPopup() {
|
|
|
+ if (!this.checkLogin()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!this.data || !this.data.id) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const stock = Number(this.data.stock) || 0
|
|
|
+ if (stock <= 0) {
|
|
|
+ this.$msg('暂无库存')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.popupAction = 'buy'
|
|
|
+ this.buyNum = 1
|
|
|
+ this.popupShow = true
|
|
|
},
|
|
|
hidePopup() {
|
|
|
this.popupShow = false;
|