diff --git a/package.json b/package.json index b611516..2e19c4c 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "element-ui": "^2.4.6", "lodash": "^4.17.4", "vue": "^2.5.9", - "vue-awesome-swiper": "3.4.2", + "vue-awesome-swiper": "^3.1.3", "vue-router": "^2.8.1", "vue-template-compiler": "^2.5.9", "vue-weui": "^0.3.2", diff --git a/src/assets/images/icon/wx-icon.png b/src/assets/images/icon/wx-icon.png new file mode 100644 index 0000000..d1d70ab Binary files /dev/null and b/src/assets/images/icon/wx-icon.png differ diff --git a/src/main.js b/src/main.js index cd678c0..a98f44d 100644 --- a/src/main.js +++ b/src/main.js @@ -2,7 +2,7 @@ // (runtime-only or standalone) has been set in webpack.base.conf with an alias. import Vue from 'vue' -import {WechatPlugin, AjaxPlugin, LoadingPlugin, ToastPlugin, AlertPlugin} from 'vux' +import { WechatPlugin, AjaxPlugin, LoadingPlugin, ToastPlugin, AlertPlugin } from 'vux' import App from './App' import router from './router' import '@/assets/iconfont.css' @@ -12,12 +12,12 @@ import '@/common/rem.js' import ElementUI from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' import $ from 'jquery' -//import Swiper from 'swiper/dist/js/swiper.js'; import VueAwesomeSwiper from 'vue-awesome-swiper' -//import 'swiper/dist/css/swiper.css'//这里注意具体看使用的版本是否需要引入样式,以及具体位置。 -//import '@/assets/styles/swiper.css +import '@/assets/styles/swiper.css' //import wx from 'weixin-js-sdk' //import axios from 'axios' +import '@/models/wxShare.js' + Vue.config.productionTip = false Vue.use(WechatPlugin) Vue.use(AjaxPlugin) @@ -25,41 +25,57 @@ Vue.use(LoadingPlugin) Vue.use(ToastPlugin) Vue.use(AlertPlugin) -Vue.use(VueAwesomeSwiper, /* { default global options } */) -//Vue.use(VueAwesomeSwiper) -/* eslint-disable no-new */ +Vue.use(VueAwesomeSwiper) -//Vue.prototype.wxShare = function(title="",dec="",links=""){ +//Vue.prototype.wxShare = function(link) { // var wxconfigApi = 'http://1hjz.3ncto.com.cn/mall/web/share/config'; -// axios.get(wxconfigApi).then((res)=>{ -// console.log(res) -// //配置微信参数 -//// wx.config({ -//// debug: false, // 开启调试模式,开发时可以开启 -//// appId: Data.appid, // 必填,公众号的唯一标识 由接口返回 -//// timestamp: Data.timestamp, // 必填,生成签名的时间戳 由接口返回 -//// nonceStr: Data.nonceStr, // 必填,生成签名的随机串 由接口返回 -//// signature: Data.signature, // 必填,签名 由接口返回 -//// jsApiList: ['onMenuShareAppMessage', 'onMenuShareTimeline'] -//// }) -////// 验证参数通过后 -//// wx.ready(()=>{ -//// -//// }) -// -// }).error((error)=>{ -// +// axios.get(wxconfigApi).then(function(response) { +// var response = response +// console.log('123',response) +// var jsApiSignConfig = response.data.data.jsApiSignConfig +// console.log(response) +// wx.config({ +// debug: true, // 开启调试模式,开发时可以开启 +// appId: jsApiSignConfig.appId, // 必填,公众号的唯一标识 由接口返回 +// timestamp: jsApiSignConfig.timestamp, // 必填,生成签名的时间戳 由接口返回 +// nonceStr: jsApiSignConfig.nonceStr, // 必填,生成签名的随机串 由接口返回 +// signature: jsApiSignConfig.signature, // 必填,签名 由接口返回 +// jsApiList: response.data.data.jsApiList +// }) +// +// wx.ready(() => { +// wx.onMenuShareAppMessage({ // 分享给朋友 +// title: response.data.data.shareConfig.title, // 分享标题 +// desc: response.data.data.shareConfig.desc, // 分享描述 +// link: response.data.data.shareConfig.url, // 分享链接 默认以当前链接 +// imgUrl: response.data.data.shareConfig.img, // 分享图标 +// }) +// }) +// +// // }) +// .catch(function(error) { +// 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, // 分享图标 +// // }) +// // }) +// //} - - -var v = new Vue({ - el: '#app', - router, - template: '', - components: {App} +var vue = new Vue({ + el: '#app', + router, + template: '', + components: { + App + } }) - -//v.wxShare(); \ No newline at end of file +//vue.wxShare(); \ No newline at end of file diff --git a/src/models/wxShare.js b/src/models/wxShare.js new file mode 100644 index 0000000..9d4c00e --- /dev/null +++ b/src/models/wxShare.js @@ -0,0 +1,53 @@ + +import Vue from 'vue' +import wx from 'weixin-js-sdk' +import axios from 'axios' + +//微信分享功能 + +Vue.prototype.wxShareL = function(link) { + var wxconfigApi = 'http://1hjz.3ncto.com.cn/mall/web/share/config'; + axios.get(wxconfigApi).then(function(response) { + + var response = response + var jsApiSignConfig = response.data.data.jsApiSignConfig + var shareConfig = response.data.data.shareConfig + + wx.config({ + debug: false, // 开启调试模式,开发时可以开启 + appId: jsApiSignConfig.appId, // 必填,公众号的唯一标识 由接口返回 + timestamp: jsApiSignConfig.timestamp, // 必填,生成签名的时间戳 由接口返回 + nonceStr: jsApiSignConfig.nonceStr, // 必填,生成签名的随机串 由接口返回 + signature: jsApiSignConfig.signature, // 必填,签名 由接口返回 + jsApiList: response.data.data.jsApiList + }) + console.log('jsApiSignConfig',jsApiSignConfig) + console.log('shareConfig',shareConfig) + + wx.ready(() => { + //获取“分享给朋友”按钮点击状态及自定义分享内容接口 + wx.onMenuShareAppMessage({ // 分享给朋友 + title: shareConfig.title, // 分享标题 + desc: shareConfig.desc, // 分享描述 + link: shareConfig.url, // 分享链接 默认以当前链接 + imgUrl: shareConfig.img, // 分享图标 + }) + }) + + + }) + .catch(function(error) { + 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 8f197e0..f0f8fce 100644 --- a/src/view/home.vue +++ b/src/view/home.vue @@ -35,7 +35,7 @@

{{item1.name}}

{{item1.shortDesc}}
-
{{toJSON(item1.smallLabel)}}
+
{{toJSON(item1.smallLabel)}}
{{item1.originalPrice > 0 ? item1.originalPrice/100 : item1.price/100}} 立即购买 @@ -69,7 +69,7 @@