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

优化代码逻辑

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