Browse Source

home

feature/feature-compatible
fengchengzhi 7 years ago
parent
commit
73853ad515
6 changed files with 120 additions and 45 deletions
  1. 2
      package.json
  2. BIN
      src/assets/images/icon/wx-icon.png
  3. 86
      src/main.js
  4. 53
      src/models/wxShare.js
  5. 15
      src/view/home.vue
  6. 9
      src/view/poster.vue

2
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",

BIN
src/assets/images/icon/wx-icon.png

Before After
Width: 256  |  Height: 256  |  Size: 4.6 KiB

86
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: '<App/>',
components: {App}
var vue = new Vue({
el: '#app',
router,
template: '<App/>',
components: {
App
}
})
//v.wxShare();
//vue.wxShare();

53
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, // 分享图标
// })
// })
}

15
src/view/home.vue

@ -35,7 +35,7 @@
<div class="right">
<h3>{{item1.name}}</h3>
<div class="text">{{item1.shortDesc}}</div>
<div class="card-name"><i>{{toJSON(item1.smallLabel)}}</i></div>
<div class="card-name"><i v-if="!item1.smallLabel">{{toJSON(item1.smallLabel)}}</i></div>
<div class="btn-box">
<span> <em>{{item1.originalPrice > 0 ? item1.originalPrice/100 : item1.price/100}}</em></span>
<a :href="'/mall/web/vgoods/detail/' + item1.goodsNo">立即购买</a>
@ -69,7 +69,7 @@
<script>
import homeApi from "../models/home-model.js";
import Swiper from '@/common/swiper';
// import Swiper from '@/common/swiper';
import { Alert, Toast,Popup,Picker,Loading } from "vux";
import routerFooter from "../components/nav-bottom";
export default {
@ -112,6 +112,10 @@
},
computed: {
},
created() {
// this.wxShare()
this.wxShareL()
},
methods: {
getName (){
@ -121,12 +125,11 @@
this.getGoodsList()
this.defaultCity = arr[1]
this.show = false
localStorage.setItem('cityName',this.addressValue)
localStorage.setItem('cityName',this.addressValue)
},
getCityName (){
let name = localStorage.getItem("cityName")||''
console.log(name)
// console.log(name)
if(!name){
this.merchantNo = 2
return
@ -199,7 +202,7 @@
//
getdefaultAddress (){
homeApi.getdefaultAddress().then(res => {
console.log('默认地址信息',res)
// console.log('',res)
if ( res.code == 0 ){
if ( !res.data ){
this.show = true

9
src/view/poster.vue

@ -10,8 +10,9 @@
</div>
<div class="page-content">
<img class="poster-img" v-if="imgSrc != ''" :src="imgSrc">
<!--<img src="../assets/images/girl.jpg">-->
<button class="create-poster" @click="create">重新生成海报</button>
<!--<img src="" v-if="imgSrc != ''" :src="imgSrc">
<img src="../assets/images/hill.png">-->
<button class="create-poster" @click="createImg()">重新生成海报</button>
</div>
<popup v-model="show">
@ -116,6 +117,7 @@
this.showLoading = false
},500)
if ( res.code == 0 ){
this.imgSrc = ''
this.imgSrc = res.response
} else {
this.$vux.toast.text(res.msg,"middle");
@ -168,6 +170,7 @@
this.showLoading = false
},500)
if ( res.code == 0 ){
this.imgSrc = ''
this.imgSrc = res.response
} else {
this.$vux.toast.text(res.msg,"middle");
@ -225,7 +228,7 @@
}
},
//
create (){
createImg (){
if ( this.sourceType == 2 ){
this.createPoster2()
} else {

Loading…
Cancel
Save