From 51e0f1516bfb644a742302e765bb477a38b76db9 Mon Sep 17 00:00:00 2001 From: fengchengzhi Date: Wed, 19 Sep 2018 19:18:49 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=88=86=E4=BA=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/wxShare.js | 49 ++++++++++++++++++++++++++++++------------- src/view/home.vue | 18 ++++++++++------ 2 files changed, 46 insertions(+), 21 deletions(-) diff --git a/src/models/wxShare.js b/src/models/wxShare.js index 9d4c00e..3c5c08d 100644 --- a/src/models/wxShare.js +++ b/src/models/wxShare.js @@ -2,13 +2,41 @@ import Vue from 'vue' import wx from 'weixin-js-sdk' import axios from 'axios' - +import utilsModel from './utils-model' //微信分享功能 -Vue.prototype.wxShareL = function(link) { - var wxconfigApi = 'http://1hjz.3ncto.com.cn/mall/web/share/config'; - axios.get(wxconfigApi).then(function(response) { - +//Vue.prototype.wxShareL = function(link,params) { +//// homeApi.getGoods(params).then(res => {}) +//// getGoods : (params) => +//// utilsModel +//// .config(homeApi.getGoods) +//// .request({ +//// params : params, +//// }), +// var getNews = function(params) => +// utilsModel +// .config({ +// method: 'GET', +// url: '/mall/web/share/config', +// }) +// .request({ +// params : params, +// }) +// getNews(params).then(res => { +// console.log(res) +// }) +//} + + +Vue.prototype.wxShare = function(params) { + //var params = params || {} + var wxconfigApi = 'http://192.168.40.82:8808/mall/web/share/config'; + console.log(params) + // /mall/web/share/config?merchantNo=2&source=0 //首页 + // /mall/web/share/config?merchantNo=2&source=1 + // /mall/web/share/config?couponNO=2&source=1 + + axios.get(wxconfigApi,{params:params}).then(function(response) { var response = response var jsApiSignConfig = response.data.data.jsApiSignConfig var shareConfig = response.data.data.shareConfig @@ -24,6 +52,7 @@ Vue.prototype.wxShareL = function(link) { console.log('jsApiSignConfig',jsApiSignConfig) console.log('shareConfig',shareConfig) + wx.ready(() => { //获取“分享给朋友”按钮点击状态及自定义分享内容接口 wx.onMenuShareAppMessage({ // 分享给朋友 @@ -40,14 +69,4 @@ Vue.prototype.wxShareL = function(link) { console.log(error); }); - // wx.ready(() => { - // var imgUrl = 'http://www.yihaojiazheng.cn/mall/web/share/config' - // wx.onMenuShareAppMessage({ // 分享给朋友 - // title: title, // 分享标题 - // desc: desc, // 分享描述 - // link: link, // 分享链接 默认以当前链接 - // imgUrl: imgUrl, // 分享图标 - // }) - // }) - } \ No newline at end of file diff --git a/src/view/home.vue b/src/view/home.vue index 311e6a8..78cb8cd 100644 --- a/src/view/home.vue +++ b/src/view/home.vue @@ -107,28 +107,31 @@ watch: { $route(to,from){ this.getdefaultAddress() + }, + defaultCity (val,old){ + // console.log(this.merchantNo) + this.wxShare({"merchantNo":this.merchantNo,"source":0,"url":encodeURIComponent(location.href)}) } }, computed: { }, created() { - // this.wxShare() - this.wxShareL() + }, methods: { + //获取城市名称 getName (){ let arr = this.addressValue[2].split('&') || '' this.districtId = arr[0] this.merchantNo = arr[2] - this.getGoodsList() + this.getGoodsList() //加载商品列表 this.defaultCity = arr[1] this.show = false localStorage.setItem('cityName',this.addressValue) }, getCityName (){ let name = localStorage.getItem("cityName")||'' - // console.log(name) if(!name){ this.merchantNo = 2 return @@ -200,11 +203,14 @@ }, //获取默认地址信息 getdefaultAddress (){ + let StorageData = localStorage.getItem("cityName")||'' homeApi.getdefaultAddress().then(res => { // console.log('默认地址信息',res) if ( res.code == 0 ){ if ( !res.data ){ - this.show = true + if ( !StorageData ){ + this.show = true + } this.merchantNo = 2 } else { this.defaultCity = res.data.districtName || '' @@ -227,7 +233,7 @@ //异步加载 this.getdefaultAddress() this.getAddress() - + this.wxShare({"merchantNo":this.merchantNo,"source":0,"url":encodeURIComponent(location.href)}) }, destroyed () {