提交 a948e3f7 编写于 作者: guangjun.yang's avatar guangjun.yang

站内调用原生方法

上级 291276fc
...@@ -7,7 +7,7 @@ import { mapGetters } from 'vuex'; ...@@ -7,7 +7,7 @@ import { mapGetters } from 'vuex';
module.exports = { module.exports = {
data: function () { data: function () {
return { return {
token: 'weewfwefw' token: '',
} }
}, },
created: function () { created: function () {
...@@ -235,7 +235,11 @@ module.exports = { ...@@ -235,7 +235,11 @@ module.exports = {
}; };
this.GET("campaign/admin/task/checkToken", param).then(res => { this.GET("campaign/admin/task/checkToken", param).then(res => {
if (res.code !== "000000") { if (res.code !== "000000") {
if(Window.__isWeb) {
this.goLogin(); this.goLogin();
} else {
rocNative.gotoLogin();
}
} else { } else {
cb && cb() cb && cb()
} }
......
此差异已折叠。
...@@ -78,12 +78,12 @@ ...@@ -78,12 +78,12 @@
</div> </div>
<Loading v-show="showLoading" /> <Loading v-show="showLoading" />
<!--去激活--> <!--去激活-->
<ChangeCard <CouponSelectList
:changeErrorMsg="changeCardErrorMsg" :changeErrorMsg="changeCardErrorMsg"
:isShow="showChangeCard" :isShow="showChangeCard"
@cancle="cancleChangeCard" @cancle="cancleChangeCard"
@confirm="changeCardAction"> @confirm="changeCardAction">
</ChangeCard> </CouponSelectList>
<CourseDialog <CourseDialog
content="微信授权" content="微信授权"
subContent='<p style="font-size: 16px; font-weight: bold; text-align: center;">云鹊医申请以下权限:</p><p style="font-size: 14px; color: #999; text-align: center; padding-bottom: 10px;">获得你的公开信息(头像,昵称等)</p>' subContent='<p style="font-size: 16px; font-weight: bold; text-align: center;">云鹊医申请以下权限:</p><p style="font-size: 14px; color: #999; text-align: center; padding-bottom: 10px;">获得你的公开信息(头像,昵称等)</p>'
...@@ -101,10 +101,10 @@ ...@@ -101,10 +101,10 @@
import { Swipe, SwipeItem } from 'vant'; import { Swipe, SwipeItem } from 'vant';
import Loading from "@/components/common/common-loading"; import Loading from "@/components/common/common-loading";
import CourseDialog from "@/components/course/course-dialog"; import CourseDialog from "@/components/course/course-dialog";
import ChangeCard from "@/components/coupon/coupon-select-list"; import CouponSelectList from "@/components/coupon/coupon-select-list";
import { wxConfig, chooseWXPay } from '@/utils/wxShare'; import { wxConfig, chooseWXPay } from '@/utils/wxShare';
import { getAPPID, getTradeType, getWebPageUrl, isWeiXin, wxOauth, debounce } from '@/utils'; import { getAPPID, getTradeType, getWebPageUrl, isWeiXin, wxOauth, debounce, getHactiveUrl } from '@/utils';
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
const isWechat = isWeiXin(); const isWechat = isWeiXin();
// wxConfig(location.href); // wxConfig(location.href);
...@@ -115,10 +115,12 @@ export default { ...@@ -115,10 +115,12 @@ export default {
SwipeItem, SwipeItem,
Loading, Loading,
CourseDialog, CourseDialog,
ChangeCard CouponSelectList
}, },
data() { data() {
return { return {
token: "",
isWeb: Window.__isWeb,
goods: { goods: {
salePrice: {}, salePrice: {},
}, // 商品信息 }, // 商品信息
...@@ -133,13 +135,10 @@ export default { ...@@ -133,13 +135,10 @@ export default {
isShowDialog: false, isShowDialog: false,
showChangeCard: false, //是否展示激活弹框, showChangeCard: false, //是否展示激活弹框,
changeCardErrorMsg: "", changeCardErrorMsg: "",
courseUrl: "",
} }
}, },
computed: { computed: {
...mapGetters(["logged"]),
// logged() {
// return this.$store.getters.logged;
// },
wxInfo() { wxInfo() {
return this.$store.state.user.wxInfo; return this.$store.state.user.wxInfo;
}, },
...@@ -152,11 +151,13 @@ export default { ...@@ -152,11 +151,13 @@ export default {
}, },
}, },
created() { created() {
let _this = this;
console.log('in goods detail new', 111111111); console.log('in goods detail new', 111111111);
let href = location.href; let href = location.href;
this.shareUrl = href; this.shareUrl = href;
this.projectId = this.$route.query.projectId; this.projectId = this.$route.query.projectId;
this.goodsId = this.$route.query.goodsId || 74; this.goodsId = this.$route.query.goodsId || 74;
this.courseUrl = this.$route.query.courseUrl || ''; //
if (href.indexOf("singlemessage") >= 0 || href.indexOf("wx_code") >= 0) { if (href.indexOf("singlemessage") >= 0 || href.indexOf("wx_code") >= 0) {
if(this.projectId) { if(this.projectId) {
this.shareUrl = getWebPageUrl(`profexam/#/goods-detail?goodsId=${this.goodsId}&projectId=${this.projectId}`); this.shareUrl = getWebPageUrl(`profexam/#/goods-detail?goodsId=${this.goodsId}&projectId=${this.projectId}`);
...@@ -166,24 +167,34 @@ export default { ...@@ -166,24 +167,34 @@ export default {
location.replace(this.shareUrl); location.replace(this.shareUrl);
} }
localStorage.setItem('returnUrl', this.shareUrl); localStorage.setItem('returnUrl', this.shareUrl);
window.__getUserInfo4GD = function(param) {
// appVersion 安卓 3.2.2 iOS
console.log("__getUserInfo4GD", param);
_this.token = param.userToken;
_this.setUserInfo(param);
};
window.__refresh = function() {
_this.getAppUserInfo();
};
window.__WXpay = function(params){
_this.paycallback(params)
};
}, },
mounted() { mounted() {
this.getGoodsInfo(); this.getGoodsInfo();
this.getTabW(); this.getTabW();
if(this.isWeb) {
const { token, info } = this.$store.state.user; const { token, info } = this.$store.state.user;
if (token && !info.id) { if (token && !info.id) {
this.$store.dispatch('getUserInfo'); this.$store.dispatch('getUserInfo');
} }
} else {
// // 微信内先去授权 this.getAppUserInfo();
// if (isWechat && !this.wxInfo.openid) { }
// if (location.search.indexOf('code') >= 0 || this.wxCode) {
// // 避免code中转页再次授权
// return;
// }
// wxOauth();
// return;
// }
// 数量加减 // 数量加减
this.curtGoodsNum = this.goodsNum; this.curtGoodsNum = this.goodsNum;
...@@ -192,6 +203,44 @@ export default { ...@@ -192,6 +203,44 @@ export default {
sessionStorage.setItem('goodsDetailParams', JSON.stringify(this.$route.query)) sessionStorage.setItem('goodsDetailParams', JSON.stringify(this.$route.query))
}, },
methods: { methods: {
//获取用户信息
getAppUserInfo() {
rocNative.getUserInfo({
__funcName: "__getUserInfo4GD"
});
},
// 微信支付回调
paycallback(params) {
// 0成功 -1错误 -2 用户取消 -3 没有安装微信
let url = getHactiveUrl() + `/order?orderBack=1&id=${this.orderId}&courseUrl=${this.courseUrl}`;
if(params.result == -3) {
this.$toast('您未安装微信,暂不能支付');
} else if(params.result == -2) {
this.POST(`/trade/center/order/pay_cancelled`, {orderId: this.orderId}).then(res => {
this.jumpToOrder(url);
}).catch((err) => {})
} else {
this.jumpToOrder(url);
}
},
// 跳转到指定页面
jumpToOrder(pageUrl) {
let paramList = [
{
key: "pageUrl",
value: pageUrl,
type: 4,
seqNo: 1
}
]
rocNative.dispatchEventByModuleCode({
modeCode: "M300",
jsonString: paramList
});
},
cancleChangeCard() { cancleChangeCard() {
this.showChangeCard = false; this.showChangeCard = false;
}, },
...@@ -323,10 +372,7 @@ export default { ...@@ -323,10 +372,7 @@ export default {
this.$sendBuriedData({ this.$sendBuriedData({
component_tag: `888#88801` component_tag: `888#88801`
}); });
if (!this.logged) { this.commonCheckToken(() => {
this.goLogin();
return;
}
let num = this.curtGoodsNum; let num = this.curtGoodsNum;
if (this.goods.limitPurchase && this.goods.limitPurchaseNum && num >= this.goods.limitPurchaseNum) { if (this.goods.limitPurchase && this.goods.limitPurchaseNum && num >= this.goods.limitPurchaseNum) {
this.$toast('已达最大限购数量') this.$toast('已达最大限购数量')
...@@ -338,16 +384,16 @@ export default { ...@@ -338,16 +384,16 @@ export default {
} }
this.curtGoodsNum = num + 1; this.curtGoodsNum = num + 1;
this.countTotalPrice(); this.countTotalPrice();
});
}, },
// 数量减 // 数量减
onReduce() { onReduce() {
this.$sendBuriedData({ this.$sendBuriedData({
component_tag: `888#88802` component_tag: `888#88802`
}); });
if (!this.logged) { this.commonCheckToken(() => {
this.goLogin();
return;
}
let num = this.curtGoodsNum; let num = this.curtGoodsNum;
if (num <= 1) { if (num <= 1) {
this.$toast('最少购买一张哦') this.$toast('最少购买一张哦')
...@@ -355,6 +401,7 @@ export default { ...@@ -355,6 +401,7 @@ export default {
} }
this.curtGoodsNum = num - 1; this.curtGoodsNum = num - 1;
this.countTotalPrice(); this.countTotalPrice();
});
}, },
goLogin() { goLogin() {
this.$store.dispatch('goLogin'); this.$store.dispatch('goLogin');
...@@ -370,11 +417,8 @@ export default { ...@@ -370,11 +417,8 @@ export default {
this.$sendBuriedData({ this.$sendBuriedData({
component_tag: `888#88803` component_tag: `888#88803`
}); });
if (!this.logged) {
this.goLogin();
return;
}
this.commonCheckToken(() => {
// 微信内先去授权 // 微信内先去授权
if (isWechat && !this.wxInfo.openid) { if (isWechat && !this.wxInfo.openid) {
this.isShowDialog = true; this.isShowDialog = true;
...@@ -403,11 +447,27 @@ export default { ...@@ -403,11 +447,27 @@ export default {
this.POST('trade/center/order/createV2', orderData).then(res => { this.POST('trade/center/order/createV2', orderData).then(res => {
if (res.code == "000000") { if (res.code == "000000") {
const orderId = res.data.orderId; const orderId = res.data.orderId;
// if (isWechat) {
// this.goWxPayInner(orderId);
// } else {
// this.goWxPayOut(orderId);
// }
// 在站外,则调用站外支付
if(isWeb) {
if (isWechat) { if (isWechat) {
this.goWxPayInner(orderId); this.goWxPayInner(orderId);
} else { } else {
this.goWxPayOut(orderId); this.goWxPayOut(orderId);
} }
} else {
// TODO 使用
rocNative.WXpay({
'__funcName': '__WXpay',
'orderId': String(orderId)
});
}
if (this.projectId) { if (this.projectId) {
this.createRelation(this.projectId, orderId); this.createRelation(this.projectId, orderId);
} }
...@@ -421,6 +481,7 @@ export default { ...@@ -421,6 +481,7 @@ export default {
}).catch(() => { }).catch(() => {
this.showLoading = false; this.showLoading = false;
}); });
});
}, },
// 微信内支付 // 微信内支付
goWxPayInner(orderId) { goWxPayInner(orderId) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册