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

站内调用原生方法

上级 291276fc
......@@ -7,7 +7,7 @@ import { mapGetters } from 'vuex';
module.exports = {
data: function () {
return {
token: 'weewfwefw'
token: '',
}
},
created: function () {
......@@ -235,7 +235,11 @@ module.exports = {
};
this.GET("campaign/admin/task/checkToken", param).then(res => {
if (res.code !== "000000") {
if(Window.__isWeb) {
this.goLogin();
} else {
rocNative.gotoLogin();
}
} else {
cb && cb()
}
......
此差异已折叠。
......@@ -78,12 +78,12 @@
</div>
<Loading v-show="showLoading" />
<!--去激活-->
<ChangeCard
<CouponSelectList
:changeErrorMsg="changeCardErrorMsg"
:isShow="showChangeCard"
@cancle="cancleChangeCard"
@confirm="changeCardAction">
</ChangeCard>
</CouponSelectList>
<CourseDialog
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>'
......@@ -101,10 +101,10 @@
import { Swipe, SwipeItem } from 'vant';
import Loading from "@/components/common/common-loading";
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 { getAPPID, getTradeType, getWebPageUrl, isWeiXin, wxOauth, debounce } from '@/utils';
import { getAPPID, getTradeType, getWebPageUrl, isWeiXin, wxOauth, debounce, getHactiveUrl } from '@/utils';
import { mapGetters } from "vuex";
const isWechat = isWeiXin();
// wxConfig(location.href);
......@@ -115,10 +115,12 @@ export default {
SwipeItem,
Loading,
CourseDialog,
ChangeCard
CouponSelectList
},
data() {
return {
token: "",
isWeb: Window.__isWeb,
goods: {
salePrice: {},
}, // 商品信息
......@@ -133,13 +135,10 @@ export default {
isShowDialog: false,
showChangeCard: false, //是否展示激活弹框,
changeCardErrorMsg: "",
courseUrl: "",
}
},
computed: {
...mapGetters(["logged"]),
// logged() {
// return this.$store.getters.logged;
// },
wxInfo() {
return this.$store.state.user.wxInfo;
},
......@@ -152,11 +151,13 @@ export default {
},
},
created() {
let _this = this;
console.log('in goods detail new', 111111111);
let href = location.href;
this.shareUrl = href;
this.projectId = this.$route.query.projectId;
this.goodsId = this.$route.query.goodsId || 74;
this.courseUrl = this.$route.query.courseUrl || ''; //
if (href.indexOf("singlemessage") >= 0 || href.indexOf("wx_code") >= 0) {
if(this.projectId) {
this.shareUrl = getWebPageUrl(`profexam/#/goods-detail?goodsId=${this.goodsId}&projectId=${this.projectId}`);
......@@ -166,24 +167,34 @@ export default {
location.replace(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() {
this.getGoodsInfo();
this.getTabW();
if(this.isWeb) {
const { token, info } = this.$store.state.user;
if (token && !info.id) {
this.$store.dispatch('getUserInfo');
}
// // 微信内先去授权
// if (isWechat && !this.wxInfo.openid) {
// if (location.search.indexOf('code') >= 0 || this.wxCode) {
// // 避免code中转页再次授权
// return;
// }
// wxOauth();
// return;
// }
} else {
this.getAppUserInfo();
}
// 数量加减
this.curtGoodsNum = this.goodsNum;
......@@ -192,6 +203,44 @@ export default {
sessionStorage.setItem('goodsDetailParams', JSON.stringify(this.$route.query))
},
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() {
this.showChangeCard = false;
},
......@@ -323,10 +372,7 @@ export default {
this.$sendBuriedData({
component_tag: `888#88801`
});
if (!this.logged) {
this.goLogin();
return;
}
this.commonCheckToken(() => {
let num = this.curtGoodsNum;
if (this.goods.limitPurchase && this.goods.limitPurchaseNum && num >= this.goods.limitPurchaseNum) {
this.$toast('已达最大限购数量')
......@@ -338,16 +384,16 @@ export default {
}
this.curtGoodsNum = num + 1;
this.countTotalPrice();
});
},
// 数量减
onReduce() {
this.$sendBuriedData({
component_tag: `888#88802`
});
if (!this.logged) {
this.goLogin();
return;
}
this.commonCheckToken(() => {
let num = this.curtGoodsNum;
if (num <= 1) {
this.$toast('最少购买一张哦')
......@@ -355,6 +401,7 @@ export default {
}
this.curtGoodsNum = num - 1;
this.countTotalPrice();
});
},
goLogin() {
this.$store.dispatch('goLogin');
......@@ -370,11 +417,8 @@ export default {
this.$sendBuriedData({
component_tag: `888#88803`
});
if (!this.logged) {
this.goLogin();
return;
}
this.commonCheckToken(() => {
// 微信内先去授权
if (isWechat && !this.wxInfo.openid) {
this.isShowDialog = true;
......@@ -403,11 +447,27 @@ export default {
this.POST('trade/center/order/createV2', orderData).then(res => {
if (res.code == "000000") {
const orderId = res.data.orderId;
// if (isWechat) {
// this.goWxPayInner(orderId);
// } else {
// this.goWxPayOut(orderId);
// }
// 在站外,则调用站外支付
if(isWeb) {
if (isWechat) {
this.goWxPayInner(orderId);
} else {
this.goWxPayOut(orderId);
}
} else {
// TODO 使用
rocNative.WXpay({
'__funcName': '__WXpay',
'orderId': String(orderId)
});
}
if (this.projectId) {
this.createRelation(this.projectId, orderId);
}
......@@ -421,6 +481,7 @@ export default {
}).catch(() => {
this.showLoading = false;
});
});
},
// 微信内支付
goWxPayInner(orderId) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册