diff --git a/package.json b/package.json index 961e218..349dad2 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", @@ -54,13 +54,15 @@ "semver": "^5.4.1", "style-loader": "^0.16.1", "url-loader": "^0.5.9", + "vue-awesome-swiper": "^3.1.3", "vue-loader": "^11.1.4", "vue-style-loader": "^2.0.0", "webpack": "^2.7.0", "webpack-bundle-analyzer": "^2.9.0", "webpack-dev-middleware": "^1.12.0", "webpack-hot-middleware": "^2.19.1", - "webpack-merge": "^2.6.1" + "webpack-merge": "^2.6.1", + "weixin-js-sdk": "^1.3.3" }, "engines": { "node": ">= 4.0.0", 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 06b3c2e..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,10 +12,11 @@ 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 wx from 'weixin-js-sdk' +//import axios from 'axios' +import '@/models/wxShare.js' Vue.config.productionTip = false Vue.use(WechatPlugin) @@ -24,14 +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(link) { +// var wxconfigApi = 'http://1hjz.3ncto.com.cn/mall/web/share/config'; +// 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, // 分享图标 +// // }) +// // }) +// +//} -new Vue({ - el: '#app', - router, - template: '', - components: {App} -}) \ No newline at end of file +var vue = new Vue({ + el: '#app', + router, + template: '', + components: { + App + } +}) +//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..3c5c08d --- /dev/null +++ b/src/models/wxShare.js @@ -0,0 +1,72 @@ + +import Vue from 'vue' +import wx from 'weixin-js-sdk' +import axios from 'axios' +import utilsModel from './utils-model' +//微信分享功能 + +//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 + + 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); + }); + +} \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index 8362d8d..c1fdf25 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -19,9 +19,9 @@ let router = new Router({ base: '/v2', routes: [ { - path: '/month-card', - name: '领取优惠券', - component: monthCard + path: '/month-card', + name: '领取优惠券', + component: monthCard }, { path: '/put-money', diff --git a/src/view/home.vue b/src/view/home.vue index 8f197e0..78cb8cd 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,6 @@