提交 31fa7065 编写于 作者: changdi.hao's avatar changdi.hao

优化代码逻辑

上级 450146a2
......@@ -8,12 +8,12 @@ export const envConfig = {
// baseUrl: 'http://10.177.15.180:10202/',
// baseUrl: 'http://192.168.140.14:10201/',
baseUrl: 'https://test1-sc.yunqueyi.com/',
apiUrl: 'https://dev-api.yunqueyi.com/',
webPageUrl: 'https://dev-phome.yunqueyi.com/',
hactiveUrl: 'https://dev-hactive.yunqueyi.com',
fileUrl: 'https://dev-www.yunqueyi.com',
appId: 'wx2c577552a2d28550', // 用于微信授权登录
baseUrl: "https://dev-sc.yunqueyi.com/",
apiUrl: "https://dev-api.yunqueyi.com/",
webPageUrl: "https://dev-phome.yunqueyi.com/",
hactiveUrl: "https://dev-hactive.yunqueyi.com",
fileUrl: "https://dev-www.yunqueyi.com",
appId: "wx2c577552a2d28550", // 用于微信授权登录
wxType: 15, // 分享、用户信息对应的appid
tradeType: 4,
......@@ -47,49 +47,48 @@ export const envConfig = {
// appId: 'wx2c577552a2d28550', // 用于微信授权登录
// wxType: 15, // 分享、用户信息对应的appid
// tradeType: 4,
},
dev: {
baseUrl: 'https://dev-sc.yunqueyi.com/',
apiUrl: 'https://dev-api.yunqueyi.com/',
webPageUrl: 'https://dev-phome.yunqueyi.com/',
hactiveUrl: 'https://dev-hactive.yunqueyi.com',
fileUrl: 'https://dev-www.yunqueyi.com',
appId: 'wx2c577552a2d28550', // 用于微信授权登录
baseUrl: "https://dev-sc.yunqueyi.com/",
apiUrl: "https://dev-api.yunqueyi.com/",
webPageUrl: "https://dev-phome.yunqueyi.com/",
hactiveUrl: "https://dev-hactive.yunqueyi.com",
fileUrl: "https://dev-www.yunqueyi.com",
appId: "wx2c577552a2d28550", // 用于微信授权登录
wxType: 15, // 分享、用户信息对应的appid
tradeType: 4,
},
test: {
baseUrl: 'https://test1-sc.yunqueyi.com/',
apiUrl: 'https://test1-api.yunqueyi.com/',
webPageUrl: 'https://test1-phome.yunqueyi.com/',
hactiveUrl: 'https://test1-hactive.yunqueyi.com',
fileUrl: 'https://test1-www.yunqueyi.com',
baseUrl: "https://test1-sc.yunqueyi.com/",
apiUrl: "https://test1-api.yunqueyi.com/",
webPageUrl: "https://test1-phome.yunqueyi.com/",
hactiveUrl: "https://test1-hactive.yunqueyi.com",
fileUrl: "https://test1-www.yunqueyi.com",
// appId: 'wxcaad75b7fff5659c', // 用于微信授权登录
// appId: 'wx2c577552a2d28550', // 用于微信授权登录
appId: 'wx85f38ae09d22b12e', // 用于微信授权登录
appId: "wx85f38ae09d22b12e", // 用于微信授权登录
wxType: 30,
tradeType: 5,
},
uat: {
baseUrl: 'https://uat-sc.yunqueyi.com/',
apiUrl: 'https://uat-api.yunqueyi.com/',
webPageUrl: 'https://uat-phome.yunqueyi.com/',
hactiveUrl: 'https://uat-hactive.yunqueyi.com',
fileUrl: 'https://uat-www.yunqueyi.com',
baseUrl: "https://uat-sc.yunqueyi.com/",
apiUrl: "https://uat-api.yunqueyi.com/",
webPageUrl: "https://uat-phome.yunqueyi.com/",
hactiveUrl: "https://uat-hactive.yunqueyi.com",
fileUrl: "https://uat-www.yunqueyi.com",
// appId: 'wx342ef0e5afee54a7', // 用于微信授权登录
appId: 'wx2c577552a2d28550', // 用于微信授权登录
appId: "wx2c577552a2d28550", // 用于微信授权登录
wxType: 15,
tradeType: 4,
},
pro: {
baseUrl: 'https://sc.yunqueyi.com/',
apiUrl: 'https://api.yunqueyi.com/',
webPageUrl: 'https://phome.yunqueyi.com/',
hactiveUrl: 'https://hactive.yunqueyi.com',
fileUrl: 'https://www.yunqueyi.com',
appId: 'wx2c577552a2d28550', // 用于微信授权登录
baseUrl: "https://sc.yunqueyi.com/",
apiUrl: "https://api.yunqueyi.com/",
webPageUrl: "https://phome.yunqueyi.com/",
hactiveUrl: "https://hactive.yunqueyi.com",
fileUrl: "https://www.yunqueyi.com",
appId: "wx2c577552a2d28550", // 用于微信授权登录
wxType: 15,
tradeType: 4,
}
}
},
};
......@@ -11,18 +11,20 @@
borderStyle="1px solid #fff"
></CommonNavbar>
<CouponList
v-if="dataList.length"
v-if="dataList.length && done"
:dataList="dataList"
@revieveOrUse="revieveOrUse"
:fromPage="fromPage"
></CouponList>
<no-coupon v-else></no-coupon>
<no-coupon v-if="done && !(dataList.length && dataList)"></no-coupon>
<Loading v-show="!done" />
</section>
</template>
<script>
import CommonNavbar from "@/components/common/common-navbar";
import CouponList from "@/components/coupon/component-list";
import NoCoupon from "@/components/coupon/no-coupon";
import Loading from "@/components/common/common-loading";
import { getWebPageUrl, getHactiveUrl } from "@/utils";
import { mapGetters, mapActions } from "vuex";
import { Toast } from "vant";
......@@ -32,7 +34,8 @@ export default {
components: {
CommonNavbar,
CouponList,
NoCoupon
NoCoupon,
Loading
},
data() {
return {
......@@ -46,7 +49,8 @@ export default {
dataList: [],
provinceId: "",
fromPage: "",
isInMergeDetail: false
isInMergeDetail: false,
done: false
};
},
computed: {
......@@ -87,6 +91,8 @@ export default {
});
}
this.init();
window.__getUserInfo4CouponList = function(param) {
console.log("__getUserInfo4CouponList", param);
_this.token = param.userToken;
......@@ -98,32 +104,35 @@ export default {
_this.getUserInfo();
};
},
mounted() {
// 如果在浏览器或微信里
if (this.isWeb) {
const { token, info } = this.$store.state.user;
this.token =
token ||
this.couponToken ||
localStorage.getItem("couponToken") ||
getCookie("couponToken");
if (this.token && !info.id) {
console.log("4444 this.token", this.token);
// this.$store.dispatch('setToken', this.token);
this.commonCheckToken(() => {
this.$store.dispatch("setToken", this.token);
// this.$store.dispatch("getUserInfo");
});
return;
}
// 从登陆页面过来的
this.getAllCoupons();
} else {
this.getUserInfo();
}
},
methods: {
...mapActions(["setUserInfo"]),
init() {
// 如果在浏览器或微信里
if (this.isWeb) {
const { token, info } = this.$store.state.user;
this.token =
token ||
this.couponToken ||
localStorage.getItem("couponToken") ||
getCookie("couponToken");
if (this.token && !info.id) {
console.log("4444 this.token", this.token);
// this.$store.dispatch('setToken', this.token);
this.commonCheckToken(() => {
this.$store.dispatch("setToken", this.token);
// this.$store.dispatch("getUserInfo");
});
return;
}
// 从登陆页面过来的
this.getAllCoupons();
} else {
this.getUserInfo();
}
},
//获取用户信息
getUserInfo() {
rocNative.getUserInfo({
......@@ -133,33 +142,34 @@ export default {
// 获取我的优惠券列表
getMyCoupons() {
this.commonCheckToken(() => {
this.GET(`trade/coupon/app/myCoupons`, {}).then(res => {
if (res.code == "000000") {
this.provinceId = res.data.provinceId;
this.dataList = this.handlerAllCouponList(
res.data.baseCouponModelList || [],
false
);
}
});
this.GET(`trade/coupon/app/myCoupons`, {}).then(res => {
if (res.code == "000000") {
this.provinceId = res.data.provinceId;
this.done = true;
this.dataList = this.handlerAllCouponList(
res.data.baseCouponModelList || [],
false
);
} else if (res.code == "200000" || res.code == "200006") {
rocNative.gotoLogin();
}
});
},
// 主动领取优惠券
// 状态码:1已下架,请领取其他优惠券 2优惠券已失效 3已领取,快去使用优惠券 4优惠券已领完 5成功领取
receiveCouponByid(couponId) {
this.commonCheckToken(() => {
this.POST(`trade/coupon/app/receive/${couponId}`, {}).then(
({ code, data }) => {
if (code == "000000") {
console.log("data.description", data.description);
data.description && Toast(data.description);
this.searchCoupons();
}
this.POST(`trade/coupon/app/receive/${couponId}`, {}).then(
({ code, data }) => {
if (code == "000000") {
console.log("data.description", data.description);
data.description && Toast(data.description);
this.searchCoupons();
} else if (res.code == "200000" || res.code == "200006") {
rocNative.gotoLogin();
}
);
});
}
);
},
// 处理(所有)列表数据
......@@ -187,23 +197,23 @@ export default {
// 获取所有优惠券列表
getAllCoupons() {
console.log("getAllCoupons");
this.commonCheckToken(() => {
let couponId = this.couponId;
if (couponId) {
this.POST(`trade/coupon/app/receive/${couponId}`, {}).then(
({ code, data }) => {
if (code == "000000") {
if (data.description) {
this.$toast({ message: data.description, duration: 5000 });
}
let couponId = this.couponId;
if (couponId) {
this.POST(`trade/coupon/app/receive/${couponId}`, {}).then(
({ code, data }) => {
if (code == "000000") {
if (data.description) {
this.$toast({ message: data.description, duration: 5000 });
}
this.searchCoupons();
} else if (res.code == "200000" || res.code == "200006") {
rocNative.gotoLogin();
}
);
} else {
this.searchCoupons();
}
});
this.searchCoupons();
}
);
} else {
this.searchCoupons();
}
},
// 区分是否是我的优惠券
......@@ -238,6 +248,7 @@ export default {
this.POST(`trade/coupon/app/searchCoupons`, params).then(res => {
if (res.code == "000000") {
this.provinceId = res.data.provinceId;
this.done = true;
this.dataList = this.handlerAllCouponList(
res.data.baseCouponModelList || [],
true
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册