Browse Source

Merge branch 'feature-v2.0' into develop

feature/feature-compatible
huangww 7 years ago
parent
commit
5b006fdc22
7 changed files with 161 additions and 31 deletions
  1. 6
      package.json
  2. BIN
      src/assets/images/icon/wx-icon.png
  3. 70
      src/main.js
  4. 72
      src/models/wxShare.js
  5. 6
      src/router/index.js
  6. 26
      src/view/home.vue
  7. 12
      src/view/poster.vue

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

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

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

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

72
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);
});
}

6
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',

26
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,6 @@
<script>
import homeApi from "../models/home-model.js";
import Swiper from '@/common/swiper';
import { Alert, Toast,Popup,Picker,Loading } from "vux";
import routerFooter from "../components/nav-bottom";
export default {
@ -108,25 +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() {
},
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)
localStorage.setItem('cityName',this.addressValue)
},
getCityName (){
let name = localStorage.getItem("cityName")||''
console.log(name)
if(!name){
this.merchantNo = 2
return
@ -198,11 +203,14 @@
},
//
getdefaultAddress (){
let StorageData = localStorage.getItem("cityName")||''
homeApi.getdefaultAddress().then(res => {
console.log('默认地址信息',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 || ''
@ -225,7 +233,7 @@
//
this.getdefaultAddress()
this.getAddress()
this.wxShare({"merchantNo":this.merchantNo,"source":0,"url":encodeURIComponent(location.href)})
},
destroyed () {

12
src/view/poster.vue

@ -1,7 +1,7 @@
<template>
<div class="poster">
<img class="weixin" src="../assets/images/poster/weixin.png" v-show="ImgFix" @click="ImgFix = false" />
<img class="weixin" src="../assets/images/poster/weixin.png" v-show="ImgFix" @click="ImgFix = false" />
<div style="height: 0.9rem;"></div>
<div class="page-top">
<a @click="goBack()" class="goBack"><img src="../assets/images/my-money/left.png" /></a>
@ -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");
@ -187,6 +190,7 @@
},
change (name) {
this.addressValue = name
this.getName()
},
getAddress (){
homeApi.getAddress().then(res => {
@ -224,7 +228,7 @@
}
},
//
create (){
createImg (){
if ( this.sourceType == 2 ){
this.createPoster2()
} else {

Loading…
Cancel
Save