diff --git a/src/api/poster.js b/src/api/poster.js new file mode 100644 index 0000000..f76ad61 --- /dev/null +++ b/src/api/poster.js @@ -0,0 +1,13 @@ + +export default { + //获取海报信息 + getPoster: { + method: 'GET', + url: '/mall/web/consumer_add/:merchantNo', + }, + //生成海报 + createPoster:{ + method: 'GET', + url: '/mall/web/recommend/poster' + } +} \ No newline at end of file diff --git a/src/models/evaluation-model.js b/src/models/evaluation-model.js index 7bf3279..d551fdc 100644 --- a/src/models/evaluation-model.js +++ b/src/models/evaluation-model.js @@ -4,7 +4,9 @@ import evaluation from "../api/evaluation.js"; export default { // 提交评价 add: (data, token) => - utilsModel.config(evaluation.add).request({ + utilsModel + .config(evaluation.add) + .request({ data: data, headers: { "encodeToken": token diff --git a/src/models/poster-model.js b/src/models/poster-model.js new file mode 100644 index 0000000..85e983e --- /dev/null +++ b/src/models/poster-model.js @@ -0,0 +1,21 @@ + +import utilsModel from './utils-model' +import posterApi from '../api/poster.js' + +export default { + getPoster : (merchantNo, token) => + utilsModel + .config(posterApi.getPoster, {merchantNo: merchantNo}) + .request({ + + }), + + createPoster : (params) => + utilsModel + .config(posterApi.createPoster) + .request({ + params:params + }), +} + + diff --git a/src/view/home.vue b/src/view/home.vue index e186932..fd6257d 100644 --- a/src/view/home.vue +++ b/src/view/home.vue @@ -75,7 +75,6 @@ promotionImgList: {}, //优惠券, goodsList:[], imghost: "http://medou.oss-cn-shenzhen.aliyuncs.com/", - }; }, components: { @@ -93,6 +92,7 @@ this.getGoodsList() this.defaultCity = arr[1] this.show = false + localStorage.setItem('cityName',this.addressValue) }, change (name) { this.addressValue = name @@ -160,6 +160,10 @@ this.show = true } else { this.defaultCity = res.data.districtName + this.addressValue = [] + this.addressValue.push(res.data.provinceId) + this.addressValue.push(res.data.cityId) + this.addressValue.push(res.data.districtId) } } else { this.$vux.toast.text(res.msg,"middle"); diff --git a/src/view/month-card.vue b/src/view/month-card.vue index 2c0aa19..972a3dc 100644 --- a/src/view/month-card.vue +++ b/src/view/month-card.vue @@ -13,7 +13,6 @@

-
diff --git a/src/view/poster.vue b/src/view/poster.vue index b2d1d8c..14cc49c 100644 --- a/src/view/poster.vue +++ b/src/view/poster.vue @@ -5,18 +5,18 @@
分销海报 - 天河区 + {{defaultCity}}
- - + +
@@ -33,8 +33,11 @@ data() { return { show: false, + imgSrc: "", + defaultCity: '天河区', addressData: [], addressValue: [], + imghost: "http://medou.oss-cn-shenzhen.aliyuncs.com/", }; }, components: { @@ -46,20 +49,61 @@ }, methods: { + getCityName (){ + let name = localStorage.getItem("cityName") + let arr = name.split(',') + this.addressValue = arr + let cityNameArr = arr[2].split('&') + let cityName = cityNameArr[1] + this.defaultCity = cityName + }, getPoster (){ var merchantNo = $("#merchantNo").val() console.log(merchantNo) posterApi.getPoster(merchantNo).then(res => { console.log("海报",res) if ( res.code == 0 ){ - + if ( res.data.hasOAuth == 0 ){ + location.href = res.data.oauthUrl + return + } + if ( res.data.imageUrl ){ + this.imgSrc = res.data.imageUrl + } else { + createPoster() + } } else { this.$vux.toast.text(res.msg,"middle"); + if ( res.code == 667 ){ + location.href = '/mall/web/user/login' + } } }) }, + createPoster (status){ + var merchantNo = $("#merchantNo").val() + posterApi.createPoster({"merchantNo":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 ){ + location.href = '/mall/web/user/login' + } + } + }) + }, + getName (){ + let arr = this.addressValue[2].split('&') + this.defaultCity = arr[1] + this.show = false + }, change (name) { - console.log('new Value', name) + this.addressValue = name + }, getAddress (){ homeApi.getAddress().then(res => { @@ -76,8 +120,8 @@ } }, mounted() { - this.getAddress() - this.getPoster() + this.getAddress() + this.getCityName() } };