|
|
@@ -57,9 +57,16 @@
|
|
|
@goShop="goShopIndex"
|
|
|
@goCart="goCartPage"
|
|
|
/>
|
|
|
+ <!-- 按需弹出:仅购物车/加购/购买触发,浏览详情默认不弹 -->
|
|
|
+ <wangCg :loginStyle.sync="globalLoginStyle" @goToLogin="loginTo" @loginSuccess="loginSuccess" />
|
|
|
</view>
|
|
|
</template>
|
|
|
<script>
|
|
|
+/**
|
|
|
+ * 花材详情:游客可浏览 get-mall-item-info;
|
|
|
+ * 点「我的购物车 / 加入购物车 / 立即购买」再弹 wangCg;
|
|
|
+ * 登录成功后 refreshShopInfoAfterLogin,新客走 shop/info 建客并绑定邀请关系。
|
|
|
+ */
|
|
|
import AppImg from "@/components/app-img";
|
|
|
import AppSwiper from "@/components/app-swiper";
|
|
|
import AppTag from "@/components/module/app-tag.vue";
|
|
|
@@ -67,10 +74,11 @@ import AppTrademark from "@/components/module/app-trademark";
|
|
|
import RichMediaViewer from "@/components/RichMediaViewer/index.vue";
|
|
|
import BuyFoot from "./components/buy-foot.vue";
|
|
|
import SelPopup from "./components/sel-popup.vue";
|
|
|
+import wangCg from "@/components/wangCg";
|
|
|
import { mapGetters } from "vuex";
|
|
|
import { getMallItemInfo } from "@/api/item";
|
|
|
import { getHdInfo } from "@/api/hd";
|
|
|
-import { getInfo } from "@/api/shop";
|
|
|
+import { getInfo, refreshShopInfoAfterLogin } from "@/api/shop";
|
|
|
import productMins from "@/mixins/cgProduct";
|
|
|
import { share } from "@/mixins";
|
|
|
export default {
|
|
|
@@ -83,7 +91,8 @@ export default {
|
|
|
BuyFoot,
|
|
|
SelPopup,
|
|
|
AppImg,
|
|
|
- RichMediaViewer
|
|
|
+ RichMediaViewer,
|
|
|
+ wangCg
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -97,26 +106,22 @@ export default {
|
|
|
pageType: "cg",
|
|
|
autoLoad:false,
|
|
|
hdId:0,
|
|
|
+ account: 0,
|
|
|
/** 分享 path 追加 inviterCustomId 用,不改变进入页 query(除 hdId) */
|
|
|
myCustomId: 0,
|
|
|
- previewContent: []
|
|
|
+ previewContent: [],
|
|
|
+ /** wangCg:1=隐藏,0=显示;覆盖全局 mixin 默认 0,避免进页即弹 */
|
|
|
+ globalLoginStyle: 1
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
|
- loginInfo(newVal) {
|
|
|
- if(!this.$util.isEmpty(newVal)){
|
|
|
- this.globalLoginStyle = 1
|
|
|
- }else{
|
|
|
- this.globalLoginStyle = 0
|
|
|
- }
|
|
|
+ loginInfo() {
|
|
|
+ // 已登录则收起弹层;未登录不主动弹出(由 ensureLogin 触发)
|
|
|
+ this.syncLoginStyle()
|
|
|
}
|
|
|
},
|
|
|
onShow () {
|
|
|
- if(!this.$util.isEmpty(this.loginInfo)){
|
|
|
- this.globalLoginStyle = 1
|
|
|
- }else{
|
|
|
- this.globalLoginStyle = 0
|
|
|
- }
|
|
|
+ this.syncLoginStyle()
|
|
|
},
|
|
|
onShareAppMessage() {
|
|
|
const path = this.buildItemSharePath()
|
|
|
@@ -135,8 +140,57 @@ export default {
|
|
|
...mapGetters({ shopUser: "getShopUser",loginInfo:"getLoginInfo" })
|
|
|
},
|
|
|
methods: {
|
|
|
+ /**
|
|
|
+ * 同步 wangCg:仅在已登录时强制关闭;未登录保持现状(由操作入口 ensureLogin 弹出)
|
|
|
+ */
|
|
|
+ syncLoginStyle() {
|
|
|
+ if (!this.$util.isEmpty(this.loginInfo)) {
|
|
|
+ this.globalLoginStyle = 1
|
|
|
+ }
|
|
|
+ },
|
|
|
+ loginTo() {
|
|
|
+ const account = this.account || (this.option && this.option.account) || uni.getStorageSync('account') || ''
|
|
|
+ this.$util.pageTo({
|
|
|
+ url: '/pages/login/index',
|
|
|
+ query: { needBack: 1, account }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * wangCg 登录成功:重拉 shop/info 建客/拉新绑定,再刷新花材详情
|
|
|
+ */
|
|
|
+ loginSuccess() {
|
|
|
+ this.globalLoginStyle = 1
|
|
|
+ const account = this.account || (this.option && this.option.account) || uni.getStorageSync('account') || ''
|
|
|
+ refreshShopInfoAfterLogin(account).then((data) => {
|
|
|
+ if (data && data.custom && data.custom.id) {
|
|
|
+ this.myCustomId = Number(data.custom.id)
|
|
|
+ }
|
|
|
+ if (data && data.hd && (data.hd.id || data.hd.hdId)) {
|
|
|
+ const hdId = Number(data.hd.id || data.hd.hdId) || 0
|
|
|
+ if (hdId > 0) {
|
|
|
+ this.hdId = hdId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const id = (this.option && this.option.id) || (this.data && this.data.id) || 0
|
|
|
+ if (id) {
|
|
|
+ this.getItemDetail(id, account)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 我的购物车 / 加入购物车 / 立即购买前校验:未登录弹 wangCg
|
|
|
+ * @returns {boolean}
|
|
|
+ */
|
|
|
+ ensureLogin() {
|
|
|
+ if (!this.$util.isEmpty(this.loginInfo)) {
|
|
|
+ this.globalLoginStyle = 1
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ this.globalLoginStyle = 0
|
|
|
+ return false
|
|
|
+ },
|
|
|
getAffirmUrl() {
|
|
|
- const account = this.option.account || ''
|
|
|
+ const account = this.account || (this.option && this.option.account) || ''
|
|
|
return `/pages/billing/affirmMix?account=${account}&hdId=${this.hdId}`
|
|
|
},
|
|
|
onPopupConfirm(num) {
|
|
|
@@ -160,10 +214,11 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
goShopIndex() {
|
|
|
- this.$util.pageTo({ url: `/pages/item/item?account=${this.option.account}&hdId=${this.hdId}`, type: 2 })
|
|
|
+ const account = this.account || (this.option && this.option.account) || ''
|
|
|
+ this.$util.pageTo({ url: `/pages/item/item?account=${account}&hdId=${this.hdId}`, type: 2 })
|
|
|
},
|
|
|
goCartPage() {
|
|
|
- if (!this.checkLogin()) {
|
|
|
+ if (!this.ensureLogin()) {
|
|
|
return
|
|
|
}
|
|
|
this.$util.pageTo({ url: this.getAffirmUrl(), type: 2 })
|
|
|
@@ -177,6 +232,7 @@ export default {
|
|
|
|
|
|
const id = this.option.id ? this.option.id : 0
|
|
|
const account = this.option.account ? this.option.account : 0
|
|
|
+ this.account = account
|
|
|
|
|
|
// 太阳码参数已在 App / globalMixins 中展开为 account、id
|
|
|
if (Number(id) > 0 && Number(account) > 0) {
|
|
|
@@ -285,25 +341,8 @@ export default {
|
|
|
changeNum(e) {
|
|
|
this.buyNum = e.value;
|
|
|
},
|
|
|
- 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
|
|
|
- }
|
|
|
- return true
|
|
|
- },
|
|
|
openCartPopup() {
|
|
|
- if (!this.checkLogin()) {
|
|
|
+ if (!this.ensureLogin()) {
|
|
|
return
|
|
|
}
|
|
|
if (!this.data || !this.data.id) {
|
|
|
@@ -319,7 +358,7 @@ export default {
|
|
|
this.popupShow = true
|
|
|
},
|
|
|
openBuyPopup() {
|
|
|
- if (!this.checkLogin()) {
|
|
|
+ if (!this.ensureLogin()) {
|
|
|
return
|
|
|
}
|
|
|
if (!this.data || !this.data.id) {
|