master
linyongLynn 1 day ago
parent 2acfb9e405
commit 00e99d2701

8
node_modules/.package-lock.json generated vendored

@ -1,8 +1,14 @@
{ {
"name": "wx-dangyuanjiaoyujidi", "name": "wx-dangyuanjiaoyujidi",
"lockfileVersion": 2, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"node_modules/jweixin-module": {
"version": "1.6.0",
"resolved": "https://registry.npmmirror.com/jweixin-module/-/jweixin-module-1.6.0.tgz",
"integrity": "sha512-dGk9cf+ipipHmtzYmKZs5B2toX+p4hLyllGLF6xuC8t+B05oYxd8fYoaRz0T30U2n3RUv8a4iwvjhA+OcYz52w==",
"license": "ISC"
},
"node_modules/moment": { "node_modules/moment": {
"version": "2.29.3", "version": "2.29.3",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.3.tgz", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.3.tgz",

@ -0,0 +1,30 @@
# jweixin-module
微信JS-SDK
## 安装
### NPM
```shell
npm install jweixin-module --save
```
### UMD
```http
https://unpkg.com/jweixin-module/out/index.js
```
## 使用
```js
var jweixin = require('jweixin-module')
jweixin.ready(function(){
// TODO
});
```
## 完整API
>[微信JS-SDK说明文档](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115)

File diff suppressed because one or more lines are too long

@ -0,0 +1,26 @@
{
"name": "jweixin-module",
"version": "1.6.0",
"description": "微信JS-SDK",
"main": "lib/index.js",
"scripts": {},
"repository": {
"type": "git",
"url": "git+https://github.com/zhetengbiji/jweixin-module.git"
},
"keywords": [
"wxjssdk",
"weixin",
"jweixin",
"wechat",
"jssdk",
"wx"
],
"author": "Shengqiang Guo",
"license": "ISC",
"bugs": {
"url": "https://github.com/zhetengbiji/jweixin-module/issues"
},
"homepage": "https://github.com/zhetengbiji/jweixin-module#readme",
"devDependencies": {}
}

12
package-lock.json generated

@ -5,10 +5,17 @@
"packages": { "packages": {
"": { "": {
"dependencies": { "dependencies": {
"jweixin-module": "^1.6.0",
"moment": "^2.29.3", "moment": "^2.29.3",
"uview-ui": "^2.0.31" "uview-ui": "^2.0.31"
} }
}, },
"node_modules/jweixin-module": {
"version": "1.6.0",
"resolved": "https://registry.npmmirror.com/jweixin-module/-/jweixin-module-1.6.0.tgz",
"integrity": "sha512-dGk9cf+ipipHmtzYmKZs5B2toX+p4hLyllGLF6xuC8t+B05oYxd8fYoaRz0T30U2n3RUv8a4iwvjhA+OcYz52w==",
"license": "ISC"
},
"node_modules/moment": { "node_modules/moment": {
"version": "2.29.3", "version": "2.29.3",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.3.tgz", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.3.tgz",
@ -27,6 +34,11 @@
} }
}, },
"dependencies": { "dependencies": {
"jweixin-module": {
"version": "1.6.0",
"resolved": "https://registry.npmmirror.com/jweixin-module/-/jweixin-module-1.6.0.tgz",
"integrity": "sha512-dGk9cf+ipipHmtzYmKZs5B2toX+p4hLyllGLF6xuC8t+B05oYxd8fYoaRz0T30U2n3RUv8a4iwvjhA+OcYz52w=="
},
"moment": { "moment": {
"version": "2.29.3", "version": "2.29.3",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.3.tgz", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.3.tgz",

@ -1,5 +1,6 @@
{ {
"dependencies": { "dependencies": {
"jweixin-module": "^1.6.0",
"moment": "^2.29.3", "moment": "^2.29.3",
"uview-ui": "^2.0.31" "uview-ui": "^2.0.31"
} }

@ -1,16 +1,25 @@
<template> <template>
<view> <view>
<!-- H5环境嵌入iframe地图 --> <!-- H5环境嵌入iframe地图 -->
<view v-if="isH5" class="page-body"> <view v-if="isH5" class="h5-map-container">
<view class="page-section page-section-gap"> <iframe
<view class="h5-map-container"> :src="getMapUrl()"
<iframe width="100%"
:src="getMapUrl()" height="100vh"
width="100%" frameborder="0"
height="100vh" class="h5-map-iframe">
frameborder="0" </iframe>
class="h5-map-iframe">
</iframe> <!-- H5环境底部工具栏 -->
<view class="h5-map-toolbar">
<view class="toolbar-content">
<view class="location-info">
<view class="location-name">{{info.name || '中共苏州独立支部旧址'}}</view>
<view class="location-address">{{info.address || '苏州市姑苏区'}}</view>
</view>
<view class="navigation-btn" @click="openlocation">
<text class="nav-text">导航</text>
</view>
</view> </view>
</view> </view>
</view> </view>
@ -22,59 +31,67 @@
</template> </template>
<script> <script>
const jweixin = require('jweixin-module');
export default { export default {
data() { data() {
return { return {
info: { info: {},
latitude: 31.299893, covers: [{
longitude: 120.626022, latitude: 31.302377,
name: '苏州革命博物馆', longitude: 120.625826,
address: '苏州市姑苏区' width: 30,
}, height: 30,
covers: [], iconPath: '/static/img/location.png',
isH5: false // H5 id: 1
}],
isH5: false
} }
}, },
onLoad() { onLoad() {
// //
this.isH5 = typeof window !== 'undefined' && window.location this.isH5 = typeof window !== 'undefined' && window.location
// H5
if (this.isH5) {
// H5CSS
document.body.style.paddingTop = '0';
//
const navBar = document.querySelector('.uni-page-head');
if (navBar) {
navBar.style.display = 'none';
}
}
this.loadInfo(); this.loadInfo();
}, },
onShareAppMessage() { onShareAppMessage() {
return this.util.shareInfo return this.util.shareInfo
}, },
onShareTimeline(){
return this.util.shareInfo
},
methods: { methods: {
// H5URL // H5URL
getMapUrl() { getMapUrl() {
if (this.info.latitude && this.info.longitude) { if (this.info.latitude && this.info.longitude) {
// 使 // 使
const url = `https://apis.map.qq.com/uri/v1/marker?marker=coord:${this.info.latitude},${this.info.longitude};title:${encodeURIComponent(this.info.name || '展馆')};addr:${encodeURIComponent(this.info.address || '')}&referer=myapp`; const url = `https://apis.map.qq.com/uri/v1/marker?marker=coord:${this.info.latitude},${this.info.longitude};title:${encodeURIComponent(this.info.name || '中共苏州独立支部旧址')};addr:${encodeURIComponent(this.info.address || '')}&referer=myapp`;
return url; return url;
} }
// 使 // 使
return 'https://apis.map.qq.com/uri/v1/marker?marker=coord:31.299893,120.626022;title:苏州革命博物馆;addr:苏州市姑苏区&referer=myapp'; return 'https://apis.map.qq.com/uri/v1/marker?marker=coord:31.302377,120.625826;title:中共苏州独立支部旧址;addr:苏州市姑苏区体育场路4号&referer=myapp';
}, },
markertap() { markertap() {
this.openlocation(); this.openlocation();
}, },
openlocation() { openlocation() {
if (this.isH5) { if (this.isH5) {
// H5使JS-SDK // H5使JS-SDK
if (typeof wx !== 'undefined' && wx.openLocation) { this.initWxJSSDK();
// JS-SDK
wx.openLocation({
latitude: this.info.latitude,
longitude: this.info.longitude,
name: this.info.name,
address: this.info.address,
scale: 14
});
} else {
// 使
const mapUrl = `https://apis.map.qq.com/uri/v1/marker?marker=coord:${this.info.latitude},${this.info.longitude};title:${encodeURIComponent(this.info.name)};addr:${encodeURIComponent(this.info.address)}&referer=myapp`;
window.open(mapUrl, '_blank');
}
} else { } else {
// 使uni.openLocation // 使uni.openLocation
uni.openLocation({ uni.openLocation({
@ -85,7 +102,83 @@
}); });
} }
}, },
loadInfo(cb) {
// JS-SDK
initWxJSSDK() {
// jweixin
if (typeof jweixin === 'undefined') {
console.error('jweixin模块未加载');
uni.showToast({ title: '请在微信中打开', icon: 'none' });
return;
}
const currentUrl = window.location.href.split('#')[0];
console.log('当前页面URL:', currentUrl);
//
this.util.request({
api: `/api/mobile/user/wx-jssdk?url=${encodeURIComponent(currentUrl)}`,
method: 'GET',
utilSuccess: (res) => {
console.log('JS-SDK鉴权成功:', res);
this.configWxJSSDK(res);
},
utilFail: (err) => {
console.error('JS-SDK鉴权失败:', err);
// 使
this.fallbackToTencentMap();
}
});
},
// JS-SDK
configWxJSSDK(config) {
if (typeof jweixin === 'undefined') {
console.error('jweixin模块未加载');
this.fallbackToTencentMap();
return;
}
jweixin.config({
debug: config.debug || false,
beta: config.beta || false,
appId: config.appId,
timestamp: config.timestamp,
nonceStr: config.nonceStr,
signature: config.signature,
jsApiList: config.jsApiList || ['openLocation'],
openTagList: config.openTagList || []
});
jweixin.ready(() => {
console.log('微信JS-SDK配置成功');
this.openWxLocation();
});
jweixin.error((res) => {
console.error('微信JS-SDK配置失败:', res);
this.fallbackToTencentMap();
});
},
// openLocation
openWxLocation() {
jweixin.openLocation({
latitude: this.info.latitude,
longitude: this.info.longitude,
name: this.info.name || '中共苏州独立支部旧址',
address: this.info.address || '苏州市姑苏区体育场路4号',
scale: 14,
infoUrl: ''
});
},
// 使
fallbackToTencentMap() {
// const mapUrl = `https://apis.map.qq.com/uri/v1/marker?marker=coord:${this.info.latitude},${this.info.longitude};title:${encodeURIComponent(this.info.name || '')};addr:${encodeURIComponent(this.info.address || '')}&referer=myapp`;
// window.open(mapUrl, '_blank');
},
loadInfo() {
var that = this; var that = this;
this.util.request({ this.util.request({
api: '/api/mobile/visit/introduce', api: '/api/mobile/visit/introduce',
@ -93,22 +186,14 @@
res.latitude = parseFloat(res.latitude); res.latitude = parseFloat(res.latitude);
res.longitude = parseFloat(res.longitude); res.longitude = parseFloat(res.longitude);
that.info = res; that.info = res;
that.covers = []
// that.covers.push({
if (!that.isH5) { latitude: res.latitude,
that.covers.push({ longitude: res.longitude,
latitude: res.latitude, width: 30,
longitude: res.longitude, height: 30,
width: 70, iconPath: '/static/img/location.png'
height: 70, });
iconPath: '/static/img/location.png'
});
}
//
if (cb) {
cb(res);
}
}, },
utilFail: function(res) { utilFail: function(res) {
@ -130,23 +215,75 @@
.h5-map-iframe { .h5-map-iframe {
width: 100%; width: 100%;
height: 100%; height: 100vh;
border: none; border: none;
display: block; display: block;
} }
.page-body { /* H5底部工具栏样式 */
.h5-map-toolbar {
position: absolute;
bottom: 0;
left: 0;
width: 100%; width: 100%;
height: 100vh; height: 230rpx;
position: relative; background: #fff;
box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);
z-index: 999;
} }
.page-section { .toolbar-content {
width: 100%; display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 30rpx;
height: 100%; height: 100%;
box-sizing: border-box;
}
.location-info {
flex: 1;
margin-right: 20rpx;
}
.location-name {
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 8rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.location-address {
font-size: 26rpx;
color: #666;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.navigation-btn {
display: flex;
align-items: center;
justify-content: center;
width: 100rpx;
height: 80rpx;
background: #007AFF;
border-radius: 12rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 122, 255, 0.3);
transition: all 0.3s ease;
}
.navigation-btn:active {
transform: scale(0.95);
box-shadow: 0 2rpx 8rpx rgba(0, 122, 255, 0.4);
} }
.page-section-gap { .nav-text {
padding: 0; font-size: 28rpx;
color: #fff;
font-weight: bold;
} }
</style> </style>

@ -60,7 +60,7 @@
<view class="list-item" @click="toPage(4)"> <view class="list-item" @click="toPage(4)">
<view class="list-item-left"> <view class="list-item-left">
<text class="iconfont icon-fenxiang"></text> <text class="iconfont icon-fenxiang"></text>
<text class="list-item-lefttxt">系统</text> <text class="list-item-lefttxt">推荐预约管理系统</text>
</view> </view>
<view class="list-item-right"> <view class="list-item-right">
<u-icon name="arrow-right" color="#ccc"></u-icon> <u-icon name="arrow-right" color="#ccc"></u-icon>

@ -259,6 +259,7 @@ const request = options => {
options.utilFail('TODO: 特殊处理非200错误(' + res.statusCode + ')'); options.utilFail('TODO: 特殊处理非200错误(' + res.statusCode + ')');
} }
} }
uni.clearStorageSync();
} else { } else {
if (res.data.hasOwnProperty("errcode")) { if (res.data.hasOwnProperty("errcode")) {
@ -267,6 +268,7 @@ const request = options => {
} else { } else {
options.utilFail(res.data.errmsg); options.utilFail(res.data.errmsg);
} }
uni.clearStorageSync();
} else { } else {
if (options.utilSuccess != undefined) { if (options.utilSuccess != undefined) {
options.utilSuccess(res.data); options.utilSuccess(res.data);

Loading…
Cancel
Save