|
@@ -108,6 +108,7 @@
|
|
|
|
|
|
<script>
|
|
|
import { mapGetters } from "vuex";
|
|
|
+import { getQueryString } from "../../common/navTo";
|
|
|
import ClassTimeTip from "../../components/common/ClassTimeTip.vue";
|
|
|
export default {
|
|
|
data() {
|
|
@@ -138,65 +139,65 @@ export default {
|
|
|
fromCart: "",
|
|
|
hasPaying: false,
|
|
|
showConfirmButton: false,
|
|
|
- totalPrice: 0,
|
|
|
confirmText: "",
|
|
|
- optObj: {},
|
|
|
};
|
|
|
},
|
|
|
onPullDownRefresh() {},
|
|
|
onLoad(option) {
|
|
|
- let self = this;
|
|
|
this.fromCart = option.fromCart;
|
|
|
- let list = self.shoppingCartList;
|
|
|
this.isBK = option.isBK;
|
|
|
- for (let i = 0; i < list.length; i++) {
|
|
|
- this.totalPrice += Number(list[i].standPrice);
|
|
|
- }
|
|
|
},
|
|
|
onShow() {
|
|
|
// #ifdef H5
|
|
|
- if (location.search.includes("code")) {
|
|
|
- let arrs = location.search.slice(1).split("&");
|
|
|
- for (let i = 0; i < arrs.length; i++) {
|
|
|
- this.optObj[arrs[i].split("=")[0]] = arrs[i].split("=")[1];
|
|
|
- }
|
|
|
- this.$store.commit("setShoppingCartList", {
|
|
|
- shoppingCartList: uni.getStorageSync("shopList"),
|
|
|
- });
|
|
|
- uni.setStorageSync("h5_code", this.optObj.code);
|
|
|
- this.OfficialLogin();
|
|
|
- } else {
|
|
|
- // 没有code,就重定向到地址https://www.xyyxt.net?ask_type=https://api.xyyxt.net/pages2/order/confirm_pay 去获取code,授权后就会把code带上然后访问域名
|
|
|
- // ?fromCart=&code=061F5a1w3aolh03SLe1w3sMsCF4F5a16&state=STATE
|
|
|
- this.$api.checkBindGzh().then((res) => {
|
|
|
- if (!res.data.data && process.env.NODE_ENV !== "development") {
|
|
|
- uni.setStorageSync("shopList", this.shoppingCartList);
|
|
|
- location.replace(
|
|
|
- "https://www.xyyxt.net/?ask_type=" +
|
|
|
- window.location.host +
|
|
|
- "/pages2/order/confirm_pay"
|
|
|
- );
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ this.authorize();
|
|
|
// #endif
|
|
|
},
|
|
|
methods: {
|
|
|
- OfficialLogin() {
|
|
|
- console.log(this.optObj,this.optObj.code, "上传code");
|
|
|
+ authorize() {
|
|
|
+ if (location.search.includes("code")) {
|
|
|
+ const code = getQueryString("code");
|
|
|
+ this.$store.commit("setShoppingCartList", {
|
|
|
+ shoppingCartList: uni.getStorageSync("shopList"),
|
|
|
+ });
|
|
|
+ uni.setStorageSync("h5_code", code);
|
|
|
+ this.OfficialLogin(code);
|
|
|
+ } else {
|
|
|
+ // 没有code,就重定向到地址https://www.xyyxt.net?ask_type=https://api.xyyxt.net/pages2/order/confirm_pay 去获取code,授权后就会把code带上然后访问域名
|
|
|
+ // ?fromCart=&code=061F5a1w3aolh03SLe1w3sMsCF4F5a16&state=STATE
|
|
|
+ this.$api.checkBindGzh().then((res) => {
|
|
|
+ if (!res.data.data && process.env.NODE_ENV !== "development") {
|
|
|
+ uni.setStorageSync("shopList", this.shoppingCartList);
|
|
|
+ const url = window.location.host + "/pages2/order/confirm_pay";
|
|
|
+ // 跳自己授权
|
|
|
+ if (this.config.gzhSelfLicense) {
|
|
|
+ this.$api.getWxConfig().then((res) => {
|
|
|
+ location.replace(
|
|
|
+ `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${
|
|
|
+ res.data.data.gzhAppId
|
|
|
+ }&redirect_uri=${encodeURIComponent(
|
|
|
+ "https://" + url
|
|
|
+ )}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
|
|
|
+ );
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ location.replace("https://www.xyyxt.net/?ask_type=" + url);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ OfficialLogin(code) {
|
|
|
this.$api
|
|
|
.OfficialLogin({
|
|
|
- code: this.optObj.code,
|
|
|
+ code,
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- console.log(res, "接口返回");
|
|
|
if (res.data.code !== 200) {
|
|
|
this.$u.toast(res.data.msg);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
postOrder() {
|
|
|
- console.log(12312312321);
|
|
|
let list = this.shoppingCartList;
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
let item = list[i];
|
|
@@ -440,7 +441,15 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
onReachBottom() {},
|
|
|
- computed: { ...mapGetters(["userInfo", "shoppingCartList", "sac"]) },
|
|
|
+ computed: {
|
|
|
+ ...mapGetters(["userInfo", "shoppingCartList", "sac", "config"]),
|
|
|
+ totalPrice() {
|
|
|
+ return this.shoppingCartList.reduce(
|
|
|
+ (a, b) => a + Number(b.standPrice),
|
|
|
+ 0
|
|
|
+ );
|
|
|
+ },
|
|
|
+ },
|
|
|
components: { ClassTimeTip },
|
|
|
};
|
|
|
</script>
|