diff --git a/src/api/poster.js b/src/api/poster.js
index 43b99b5..fbf2314 100644
--- a/src/api/poster.js
+++ b/src/api/poster.js
@@ -9,5 +9,15 @@ export default {
createPoster:{
method: 'GET',
url: '/mall/web/recommend/:merchantNo/poster'
+ },
+
+ //sourceType == 2
+ getPoster2: {
+ method: 'GET',
+ url: '/mall/web/recommend/consumer_add/:no',
+ },
+ createPoster2:{
+ method: 'GET',
+ url: '/mall/web/recommend/poster'
}
}
\ No newline at end of file
diff --git a/src/models/poster-model.js b/src/models/poster-model.js
index 13de586..3c75df6 100644
--- a/src/models/poster-model.js
+++ b/src/models/poster-model.js
@@ -16,6 +16,20 @@ export default {
.request({
}),
+
+ getPoster2: (no) =>
+ utilsModel
+ .config(posterApi.getPoster2,{no: no})
+ .request({
+
+ }),
+
+ createPoster2: (params) =>
+ utilsModel
+ .config(posterApi.createPoster2,)
+ .request({
+ params:params
+ }),
}
diff --git a/src/router/index.js b/src/router/index.js
index 76787b7..881f9fc 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -55,10 +55,11 @@ let router = new Router({
path: '/demo',
name: 'demo',
component: demo
- },{
- path:"/",
- redirect:"/home"
}
+// {
+// path:"/",
+// redirect:"/home"
+// }
]
})
diff --git a/src/view/poster.vue b/src/view/poster.vue
index 2cea0c6..3368539 100644
--- a/src/view/poster.vue
+++ b/src/view/poster.vue
@@ -9,8 +9,8 @@
{{defaultCity}}
-
![]()
-
+
![]()
+
@@ -37,12 +37,13 @@
imgSrc: "",
merchantNo: "", //商户编号
isAuthorize: false,
- authorizeSrc : '',
+ authorizeSrc : "",
ImgFix: true,
defaultCity: '天河区',
addressData: [],
addressValue: [],
- imghost: "http://medou.oss-cn-shenzhen.aliyuncs.com/",
+ no: "",
+ sourceType : ""
};
},
components: {
@@ -69,10 +70,8 @@
},
getPoster (){
- var merchantNo = this.merchantNo
- //console.log(merchantNo)
+ let merchantNo = this.merchantNo
posterApi.getPoster(merchantNo).then(res => {
- console.log("res",res)
if ( res.code == 0 ){
this.authorizeSrc = res.data.oauthUrl || ''
if ( res.data.hasOAuth == 1 ){
@@ -86,7 +85,7 @@
location.href = res.data.oauthUrl
return
} else {
- createPoster()
+ this.createPoster()
}
}
@@ -95,13 +94,13 @@
if ( res.code == 667 ){
setTimeout(function(){
location.href = '/mall/web/user/login'
- })
+ },3000)
}
}
})
},
- createPoster (status){
- console.log(111,this.authorizeSrc)
+ createPoster (){
+ //console.log(111,this.authorizeSrc)
if ( !this.isAuthorize ){
location.href = this.authorizeSrc
return;
@@ -109,9 +108,55 @@
var merchantNo = this.merchantNo
posterApi.createPoster(merchantNo).then(res => {
if ( res.code == 0 ){
- if ( status ){
- this.$vux.toast.text(res.msg,"middle");
+ this.imgSrc = res.response
+ } else {
+ this.$vux.toast.text(res.msg,"middle");
+ if ( res.code == 666 ){
+ setTimeout(function(){
+ location.href = '/mall/web/user/login'
+ },3000)
+ }
+ }
+ })
+ },
+ getPoster2 (){
+
+ posterApi.getPoster2(this.no).then(res => {
+ if ( res.code == 0 ){
+ this.authorizeSrc = res.data.oauthUrl || ''
+ if ( res.data.hasOAuth == 1 ){
+ this.isAuthorize = true
+ }
+
+ if ( res.data.imageUrl ){
+ this.imgSrc = res.data.imageUrl
+ } else {
+ if ( res.data.hasOAuth == 0 ){
+ location.href = res.data.oauthUrl
+ return
+ } else {
+ this.createPoster2()
+ }
+
+ }
+ } else {
+ this.$vux.toast.text(res.msg,"middle");
+ if ( res.code == 667 ){
+ setTimeout(function(){
+ location.href = '/mall/web/user/login'
+ })
}
+ }
+ })
+ },
+ createPoster2 (){
+ if ( !this.isAuthorize ){
+ location.href = this.authorizeSrc
+ return;
+ }
+ var no = this.no
+ posterApi.createPoster2({"couponNo":no}).then(res => {
+ if ( res.code == 0 ){
this.imgSrc = res.response
} else {
this.$vux.toast.text(res.msg,"middle");
@@ -144,12 +189,39 @@
//返回上一页
goBack() {
history.go(-1);
+ },
+ getParam(name) {
+ var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
+ var url = window.location.href;
+ url = window.location.href.substring(url.indexOf("?") + 1, url.length);
+ var r = url.match(reg);
+ if (r != null) return unescape(r[2]);
+ return null;
+ },
+ //判断是否有no
+ getNo (){
+ this.getCityName()
+ this.getAddress()
+ this.no = this.getParam("no")
+ this.sourceType = this.getParam("sourceType")
+
+ if ( this.sourceType == 2 ){
+ this.getPoster2()
+ } else {
+ this.getPoster()
+ }
+ },
+ //点击生成海报按钮
+ create (){
+ if ( this.sourceType == 2 ){
+ this.createPoster2()
+ } else {
+ this.createPoster()
+ }
}
},
mounted() {
- this.getCityName()
- this.getPoster();
- this.getAddress()
+ this.getNo()
}
};