# vue-mall
> 微信公众号测试项目
## 测试功能
#### 1、微信网页授权
授权方案采用
![image](https://segmentfault.com/img/remote/1460000010753253)
图片引用地址[SegmentFault](https://segmentfault.com/a/1190000010753247)
这种授权在第4步请求服务器返回token后,vue客服端直接重定向到最开始进入的页面
```code
let params = { ...to.query }
// api接口登录
wxmp.login(params).then(res => {
setToken(res.data.token)
window.location.href = window.location.origin + getToUrl()
})
```
#### 2、微信自定义分享
微信分享使用的是history模式实现自定义分享
经过测试实现步骤如下:
- 授权后进入router.beforeEach时判断系统类型,是IOS系统就记录当前URL到vuex中
注意:如果进入路由有重定向,需要加入重定向后的路由名称,比如'/'重定向到'/home'
```code
if (!Vue.device.isAndroid) {
if (!store.state.app.iosJsUrl) {
let landingPage = document.URL
// 如果进入路由有跳转需要加入跳转后的路由名称,比如/跳转到/home
if (to.name === HOME && landingPage.indexOf(HOME) === -1) {
landingPage = landingPage + HOME
}
store.commit(types.SET_WX_JS_URL, {iosJsUrl: landingPage})
}
}
```
- 进入router.afterEach时判断系统类型,获取不同的jssdk签名地址
```code
router.afterEach(to => {
// store.commit(types.UPDATE_LOADING_STATUS, {isLoading: false})
let _url = window.location.origin + to.fullPath
if (!Vue.device.isAndroid) {
_url = store.state.app.iosJsUrl.split('#')[0]
}
wechat.getJSSDK(_url)
})
```
- vue全局公用函数实现分享
```code
Vue.prototype.wxShare = wechat.setWxShare
setWxShare (title, desc, link, imgUrl) {
Vue.wechat.ready(() => {
// 分享给朋友
Vue.wechat.onMenuShareAppMessage({
title: title, // 分享标题
desc: desc, // 分享描述
link: link, // 分享链接 默认以当前链接
imgUrl: imgUrl, // 分享图标
success () {
},
cancel () {
}
})
// 分享到朋友圈
Vue.wechat.onMenuShareTimeline({
title: title, // 分享标题
desc: desc, // 分享描述
link: link, // 分享链接 默认以当前链接
imgUrl: imgUrl, // 分享图标
success () {
},
cancel () {
}
})
})
}
```
- 页面中调用wxShare实现自定义分享
```code
activated () {
this.share()
},
methods: {
share () {
let link = window.location.href.split('#')[0]
this.wxShare('首页', '首页内容', link, 'https://o3e85j0cv.qnssl.com/tulips-1083572__340.jpg')
}
}
```
#### 最后最重要的一点是:
## 调试分享的时候使用域名地址,不要使用ip+端口
## 调试分享的时候使用域名地址,不要使用ip+端口
## 调试分享的时候使用域名地址,不要使用ip+端口
## 重要的事情得说三遍,被这个坑惨了
## Build Setup
``` bash
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# build for production and view the bundle analyzer report
npm run build --report
# run unit tests
npm run unit
# run e2e tests
npm run e2e
# run all tests
npm test
```
For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
没有合适的资源?快使用搜索试试~ 我知道了~
vue-mall:微信公众号测试项目
共71个文件
js:36个
vue:11个
png:11个
需积分: 18 10 下载量 38 浏览量
2021-05-16
18:08:27
上传
评论
收藏 187KB ZIP 举报
温馨提示
vue-mall 微信公众号测试项目 测试功能 1、微信网页授权 授权方案采用 图片引用地址 这种授权在第4步请求服务器返回token后,vue客服端直接重定向到最开始进入的页面 let params = { ...to.query } // api接口登录 wxmp.login(params).then(res => { setToken(res.data.token) [removed].href = [removed].origin + getToUrl() }) 2、微信自定义分享 微信分享使用的是history模式实现自定义分享 经过测试实现步骤如下: 授权后进入router.beforeEach时判断系统类型,是IOS系统就记录当前URL到vuex中 注意:如果进入路由有重定向,需要加入重定向后的路
资源详情
资源评论
资源推荐
收起资源包目录
vue-mall-master.zip (71个子文件)
vue-mall-master
.babelrc 269B
config
index.js 3KB
prod.env.js 61B
dev.env.js 156B
test.env.js 149B
package.json 3KB
test
unit
.eslintrc 58B
specs
HelloWorld.spec.js 352B
setup.js 56B
jest.conf.js 725B
e2e
specs
test.js 561B
runner.js 2KB
nightwatch.conf.js 1KB
custom-assertions
elementCount.js 779B
index.html 521B
package-lock.json 535KB
static
vconsole.min.js 76KB
favicon.ico 31KB
.gitkeep 0B
src
App.vue 730B
assets
icon-shopcar.png 2KB
icon-home.png 2KB
icon-home-active.png 2KB
icon-my.png 2KB
icon-my-active.png 2KB
icon-shopcar-active.png 2KB
logo.png 7KB
icon-type.png 2KB
vux_logo.png 14KB
icon-type-active.png 2KB
api
wxmp.js 320B
order.js 236B
fetch.js 2KB
views
classify
classify.vue 478B
oauth2.vue 207B
shopcar
shopcar.vue 696B
home
home.vue 824B
tpl.vue 586B
my
my.vue 2KB
myCollection.vue 1KB
order
list.vue 1KB
detail.vue 784B
main.js 898B
components
tab.vue 2KB
styles
theme.less 436B
router
routers.js 2KB
index.js 2KB
libs
util.js 578B
wechat.js 2KB
tools.js 931B
store
mutation-types.js 347B
index.js 276B
modules
order.js 1016B
app.js 605B
.eslintrc.js 627B
.gitignore 194B
README.md 3KB
.eslintignore 51B
.editorconfig 147B
favicon.ico 31KB
build
utils.js 3KB
build.js 1KB
webpack.prod.conf.js 5KB
check-versions.js 1KB
webpack.dev.conf.js 2KB
dev-server.js 2KB
webpack.test.conf.js 867B
logo.png 7KB
webpack.base.conf.js 2KB
vue-loader.conf.js 543B
.postcssrc.js 223B
共 71 条
- 1
SouravGoswami
- 粉丝: 22
- 资源: 4531
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0