Browse Source

测试

feature/feature-compatible
fengchengzhi 7 years ago
parent
commit
c695823e59
4 changed files with 116 additions and 19 deletions
  1. 10
      src/api/poster.js
  2. 14
      src/models/poster-model.js
  3. 7
      src/router/index.js
  4. 104
      src/view/poster.vue

10
src/api/poster.js

@ -9,5 +9,15 @@ export default {
createPoster:{ createPoster:{
method: 'GET', method: 'GET',
url: '/mall/web/recommend/:merchantNo/poster' 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'
} }
} }

14
src/models/poster-model.js

@ -16,6 +16,20 @@ export default {
.request({ .request({
}), }),
getPoster2: (no) =>
utilsModel
.config(posterApi.getPoster2,{no: no})
.request({
}),
createPoster2: (params) =>
utilsModel
.config(posterApi.createPoster2,)
.request({
params:params
}),
} }

7
src/router/index.js

@ -55,10 +55,11 @@ let router = new Router({
path: '/demo', path: '/demo',
name: 'demo', name: 'demo',
component: demo component: demo
},{
path:"/",
redirect:"/home"
} }
// {
// path:"/",
// redirect:"/home"
// }
] ]
}) })

104
src/view/poster.vue

@ -9,8 +9,8 @@
<i class="text" @click="show = true">{{defaultCity}}</i> <i class="text" @click="show = true">{{defaultCity}}</i>
</div> </div>
<div class="page-content"> <div class="page-content">
<img class="poster-img" v-if="imgSrc != ''" :src="imghost + imgSrc">
<button class="create-poster" @click="createPoster(1)">重新生成海报</button>
<img class="poster-img" v-if="imgSrc != ''" :src="imgSrc">
<button class="create-poster" @click="create">重新生成海报</button>
</div> </div>
<popup v-model="show"> <popup v-model="show">
@ -37,12 +37,13 @@
imgSrc: "", imgSrc: "",
merchantNo: "", // merchantNo: "", //
isAuthorize: false, isAuthorize: false,
authorizeSrc : '',
authorizeSrc : "",
ImgFix: true, ImgFix: true,
defaultCity: '天河区', defaultCity: '天河区',
addressData: [], addressData: [],
addressValue: [], addressValue: [],
imghost: "http://medou.oss-cn-shenzhen.aliyuncs.com/",
no: "",
sourceType : ""
}; };
}, },
components: { components: {
@ -69,10 +70,8 @@
}, },
getPoster (){ getPoster (){
var merchantNo = this.merchantNo
//console.log(merchantNo)
let merchantNo = this.merchantNo
posterApi.getPoster(merchantNo).then(res => { posterApi.getPoster(merchantNo).then(res => {
console.log("res",res)
if ( res.code == 0 ){ if ( res.code == 0 ){
this.authorizeSrc = res.data.oauthUrl || '' this.authorizeSrc = res.data.oauthUrl || ''
if ( res.data.hasOAuth == 1 ){ if ( res.data.hasOAuth == 1 ){
@ -86,7 +85,7 @@
location.href = res.data.oauthUrl location.href = res.data.oauthUrl
return return
} else { } else {
createPoster()
this.createPoster()
} }
} }
@ -95,13 +94,13 @@
if ( res.code == 667 ){ if ( res.code == 667 ){
setTimeout(function(){ setTimeout(function(){
location.href = '/mall/web/user/login' location.href = '/mall/web/user/login'
})
},3000)
} }
} }
}) })
}, },
createPoster (status){
console.log(111,this.authorizeSrc)
createPoster (){
//console.log(111,this.authorizeSrc)
if ( !this.isAuthorize ){ if ( !this.isAuthorize ){
location.href = this.authorizeSrc location.href = this.authorizeSrc
return; return;
@ -109,9 +108,55 @@
var merchantNo = this.merchantNo var merchantNo = this.merchantNo
posterApi.createPoster(merchantNo).then(res => { posterApi.createPoster(merchantNo).then(res => {
if ( res.code == 0 ){ 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 this.imgSrc = res.response
} else { } else {
this.$vux.toast.text(res.msg,"middle"); this.$vux.toast.text(res.msg,"middle");
@ -144,12 +189,39 @@
// //
goBack() { goBack() {
history.go(-1); 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() { mounted() {
this.getCityName()
this.getPoster();
this.getAddress()
this.getNo()
} }
}; };
</script> </script>

Loading…
Cancel
Save