Commit be7cf529 by 李伟康

提交

1 parent f2df3f89
Showing 78 changed files with 1862 additions and 301 deletions
...@@ -6,7 +6,6 @@ sentryInit() ...@@ -6,7 +6,6 @@ sentryInit()
import api from './api/index' import api from './api/index'
import util from './utils/util' import util from './utils/util'
import wxApi from './utils/utils_wx' import wxApi from './utils/utils_wx'
import '~/router/routerBefore'
import router from './router/index' import router from './router/index'
import { setSystem_info } from '~/utils/cache/storageApi' import { setSystem_info } from '~/utils/cache/storageApi'
...@@ -19,12 +18,10 @@ import getUpdateManager from './utils/lib/wxUpdateManager' ...@@ -19,12 +18,10 @@ import getUpdateManager from './utils/lib/wxUpdateManager'
import eventbus from './utils/evenbus' import eventbus from './utils/evenbus'
// 微信小程序异步使用 使用方法wx.pro+对应api即可 promisify 这个是配置单独某个api
import { promisifyAll } from './utils/lib/wx-promise-pro'
promisifyAll()
// 实例化对象存储 // 实例化对象存储
import { Storage } from './utils/cache/storage' import { Storage } from './utils/cache/storage'
import './router/routerBefore'
App({ App({
onLaunch(options) { onLaunch(options) {
getUpdateManager() getUpdateManager()
...@@ -35,7 +32,8 @@ App({ ...@@ -35,7 +32,8 @@ App({
api, api,
router, router,
storage:new Storage(), storage:new Storage(),
eventbus eventbus,
wxApi
} }
// 存储设备信息 // 存储设备信息
setSystem_info() setSystem_info()
...@@ -45,5 +43,7 @@ App({ ...@@ -45,5 +43,7 @@ App({
wx.p.router.goHome() wx.p.router.goHome()
}, },
onHide() {}, onHide() {},
globalData: {} globalData: {
ROUTE_QUERY:{}
}
}) })
{ {
"pages": [ "pages": [
"pages/index/index", "pages/loading/loading",
"pages/tab/index/index", "pages/tab/index/index",
"pages/tab/output/output", "pages/tab/equity/index",
"pages/tab/mine/mine", "pages/tab/mall/index",
"pages/tab/mine/index",
"pages/webView/webView" "pages/webView/webView"
], ],
"requiredPrivateInfos": ["getLocation"], "requiredPrivateInfos": ["getLocation"],
...@@ -21,25 +22,53 @@ ...@@ -21,25 +22,53 @@
"list": [ "list": [
{ {
"pagePath": "pages/tab/index/index", "pagePath": "pages/tab/index/index",
"text": "拓客户", "text": "首页",
"iconPath": "assets/images/home.png", "iconPath": "assets/images/home.png",
"selectedIconPath": "assets/images/home_active.png" "selectedIconPath": "assets/images/home_active.png"
}, },
{ {
"pagePath": "pages/tab/output/output", "pagePath": "pages/tab/equity/index",
"text": "看产值", "text": "权益",
"iconPath": "assets/images/mall.png", "iconPath": "assets/images/mall.png",
"selectedIconPath": "assets/images/mall_active.png" "selectedIconPath": "assets/images/mall_active.png"
}, },
{ {
"pagePath": "pages/tab/mine/mine", "pagePath": "pages/tab/mall/index",
"text": "个人中心", "text": "商城",
"iconPath": "assets/images/mall.png",
"selectedIconPath": "assets/images/mall_active.png"
},
{
"pagePath": "pages/tab/mine/index",
"text": "我的",
"iconPath": "assets/images/mine.png", "iconPath": "assets/images/mine.png",
"selectedIconPath": "assets/images/mine_active.png" "selectedIconPath": "assets/images/mine_active.png"
} }
] ]
}, },
"subpackages": [], "subpackages": [
{
"root": "packageIndex",
"pages": [
"pages/index/index"
]
},
{
"root": "packageEquity",
"pages": [
]
},
{
"root": "packageMall",
"pages": [
]
},
{
"root": "packageMine",
"pages": [
]
}
],
"usingComponents": { "usingComponents": {
"calendar": "/components/Calendar/Calendar", "calendar": "/components/Calendar/Calendar",
"NavigationBar": "/components/NavigationBar/NavigationBar" "NavigationBar": "/components/NavigationBar/NavigationBar"
......
module.exports = {
root: true,
env: {
node: true,
},
parserOptions: {
ecmaVersion: 7,
sourceType: "module",
},
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
},
};
{
"printWidth": 800,
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "none",
"semi": false,
"wrap_line_length": 820,
"wrap_attributes": "auto",
"proseWrap": "always",
"arrowParens": "avoid",
"bracketSpacing": true,
"htmlWhitespaceSensitivity": "ignore",
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"jsxBracketSameLine": true,
"files.insertFinalNewline": true,
"prettier.ignorePath": ".prettierignore",
"useTabs": false,
"eslintIntegration": false,
"overrides": [
{
"files": ".prettierrc",
"options": {
"parser": "json"
}
}
],
"endOfLine": "auto"
}
No preview for this file type
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Home</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Home</h1>
<h3> </h3>
</div>
<nav>
<h2><a href="index.html">Home</a></h2>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Jul 06 2023 14:31:29 GMT+0800 (中国标准时间)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>
\ No newline at end of file \ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: index.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: index.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/*
* @Descripttion: api封装类
* @version: 1.0.0
* @Author: liweikang
* @Date: 2023-07-04 17:22:43
* @LastEditors: limin
* @LastEditTime: 2023-07-05 15:04:01
* @FilePath: \glsx-map-sdk\src\index.js
*/
import Request from './request'
class GlMapApi {
constructor(params = {}) {
const { key, secret } = params
this.request = new Request(key, secret)
}
/**
* 定义一个异步方法,用于计算两个坐标之间的距离
* @param {*} from 起始位置 [lat,lng]
* @param {*} to 结束位置 [lat,lng]
* @param {*} type 0:直线距离 , 1:驾车导航距离(仅支持国内坐标) , 3:步行规划距离(仅支持5km之间的距离)
* @param {*} $attrs 自定义入参 参考https://lbs.amap.com/api/webservice/gettingstarted
* @returns {Promise&lt;{elements: Array}>}
*/
async calculateDistance(from, to, type = 1, $attrs = {}) {
try {
const destination = JSON.parse(JSON.stringify(from)).reverse().join(','),
origins = JSON.parse(JSON.stringify(to)).reverse().join(','),
{ results } = await this.request.get('/v3/distance', {
destination,
origins,
type,
...$attrs
})
return {
elements: results
}
} catch (error) {
throw error
}
}
/**
* 批量距离计算(矩阵)
* @param {*} from 起始位置 [lat,lng]
* @param {*} toList 终点位置 [[lat,lng],[lat,lng]]
* @param {*} type 直线距离 , 1:驾车导航距离(仅支持国内坐标) , 3:步行规划距离(仅支持5km之间的距离)
* @param {*} $attrs 自定义入参 参考https://lbs.amap.com/api/webservice/gettingstarted
* @returns {Promise&lt;{rows: Array}>}
*/
async calculateDistanceMatrix(from, toList, type = 1, $attrs = {}) {
try {
const destination = JSON.parse(JSON.stringify(from)).reverse().join(','),
origins = JSON.parse(JSON.stringify(toList))
.map(e => (e = e.reverse()))
.join('|'),
{ results } = await this.request.get('/v3/distance', {
destination,
origins,
type,
...$attrs
}),
res = {
rows: [
{
elements: results
}
]
}
return Promise.resolve(res)
} catch (error) {
return Promise.reject(error)
}
}
/**
* 地址解析(地址转坐标)
* @param {*} address (String)
* @param {*} $attrs 自定义入参 参考https://lbs.amap.com/api/webservice/gettingstarted
* @returns
*/
geocoder(address, $attrs = {}) {
return this.request.get('/v3/geocode/geo', {
address,
...$attrs
})
}
/**
* 逆地址解析(坐标位置描述)
* @param {*} location [lat&lt;纬度>,lng&lt;经度>]
* @param {*} $attrs 自定义入参 参考https://lbs.amap.com/api/webservice/gettingstarted
* @returns
*/
async detailedAdrress(location, $attrs = {}) {
try {
const [lat, lng] = location
const { regeocode } = await this.request.get('/v3/geocode/regeo', {
location: JSON.parse(JSON.stringify(location)).reverse().join(','),
...$attrs
}),
{ addressComponent, formatted_address } = regeocode,
address = `${addressComponent.province || ''}${addressComponent.city || ''}${addressComponent.district || ''}${addressComponent.township || ''}`,
data = {
...regeocode,
address,
formatted_addresses: {
recommend: formatted_address,
rough: formatted_address,
standard_address: formatted_address
},
address_component: {
city: addressComponent.city,
district: addressComponent.district,
nation: addressComponent.country,
province: addressComponent.province,
street: addressComponent.township
},
ad_info: {
adcode: addressComponent.adcode,
city: addressComponent.city,
city_code: addressComponent.citycode,
district: addressComponent.district,
location: {
lat,
lng
},
name: `${addressComponent.country + ',' || ''}${addressComponent.province + ',' || ''}${addressComponent.city + ',' || ''}${addressComponent.district || ''}`,
nation: addressComponent.country,
nation_code: '',
phone_area_code: addressComponent.citycode,
province: addressComponent.province
},
location: {
lat,
lng
}
}
return Promise.resolve(data)
} catch (error) {
return Promise.reject(error)
}
}
/**
* IP定位
* @param {*} $attrs 自定义入参 参考https://lbs.amap.com/api/webservice/gettingstarted
* @returns
*/
getLocationByIp($attrs = {}) {
return this.request.get('/v3/ip', $attrs)
}
/**
* 坐标转换用于将一组坐标转换为不同的坐标系
* @param {*} locationsList [[lat,lng],[lat,lng]] 纬度前,经度后 (最多支持40对坐标)
* @param {*} coordsys 原坐标系(可选值:
gps;
mapbar;
baidu;
autonavi(不进行转换))
* @param {*} $attrs 自定义入参 参考https://lbs.amap.com/api/webservice/gettingstarted
* @returns
*/
translate(locationsList, coordsys = 'autonavi', $attrs = {}) {
// 使用数组解构和map方法,将locationsList参数转换为字符串,并反转数组顺序,然后用竖线连接,得到locations字符串
const locations = JSON.parse(JSON.stringify(locationsList))
.map(e => (e = e.reverse()))
.join('|')
// 调用request对象的get方法,传入请求路径为/v3/assistant/coordinate/convert,请求数据为locations字符串和coordsys参数(默认为autonavi),并返回结果
return this.request.get('/v3/assistant/coordinate/convert', {
locations,
coordsys,
...$attrs
})
}
/**
* 路线规划
* @param {*} from 起始位置 [lat,lng] 纬度前,经度后
* @param {*} to 终点位置 [lat,lng] 纬度前,经度后
* @param {*} type 出行类型 1步行 2骑车 3驾车
* @param {*} $attrs 自定义入参 参考https://lbs.amap.com/api/webservice/gettingstarted
*/
async routePlanning(from, to, type = 3, $attrs = {}) {
const funName = {
1: '/v3/direction/walking',
2: '/v4/direction/bicycling',
3: '/v3/direction/driving'
}[type],
origin = JSON.parse(JSON.stringify(from)).reverse().join(','),
destination = JSON.parse(JSON.stringify(to)).reverse().join(',')
try {
const { route } = await this.request.get(funName, {
origin,
destination,
...$attrs
})
return Promise.resolve(route)
} catch (error) {
return Promise.reject(error)
}
}
/**
* 输入提示
* @param {*} keywords 查询关键词
* @param {*} location 定位坐标 [lat,lng] 纬度前,经度后
* @param {*} $attrs 自定义入参 参考https://lbs.amap.com/api/webservice/gettingstarted
*/
async keywordSearch(keywords, location, $attrs = {}) {
try {
const { tips } = await this.request.get('/v3/assistant/inputtips', {
keywords,
location: JSON.parse(JSON.stringify(location)).reverse().join(','),
...$attrs
})
return Promise.resolve(tips)
} catch (error) {
return Promise.reject(error)
}
}
}
export default GlMapApi
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Jul 06 2023 14:31:29 GMT+0800 (中国标准时间)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>
/*global document */
(() => {
const source = document.getElementsByClassName('prettyprint source linenums');
let i = 0;
let lineNumber = 0;
let lineId;
let lines;
let totalLines;
let anchorHash;
if (source && source[0]) {
anchorHash = document.location.hash.substring(1);
lines = source[0].getElementsByTagName('li');
totalLines = lines.length;
for (; i < totalLines; i++) {
lineNumber++;
lineId = `line${lineNumber}`;
lines[i].id = lineId;
if (lineId === anchorHash) {
lines[i].className += ' selected';
}
}
}
})();
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com",
/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]);
@font-face {
font-family: 'Open Sans';
font-weight: normal;
font-style: normal;
src: url('../fonts/OpenSans-Regular-webfont.eot');
src:
local('Open Sans'),
local('OpenSans'),
url('../fonts/OpenSans-Regular-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/OpenSans-Regular-webfont.woff') format('woff'),
url('../fonts/OpenSans-Regular-webfont.svg#open_sansregular') format('svg');
}
@font-face {
font-family: 'Open Sans Light';
font-weight: normal;
font-style: normal;
src: url('../fonts/OpenSans-Light-webfont.eot');
src:
local('Open Sans Light'),
local('OpenSans Light'),
url('../fonts/OpenSans-Light-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/OpenSans-Light-webfont.woff') format('woff'),
url('../fonts/OpenSans-Light-webfont.svg#open_sanslight') format('svg');
}
html
{
overflow: auto;
background-color: #fff;
font-size: 14px;
}
body
{
font-family: 'Open Sans', sans-serif;
line-height: 1.5;
color: #4d4e53;
background-color: white;
}
a, a:visited, a:active {
color: #0095dd;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
header
{
display: block;
padding: 0px 4px;
}
tt, code, kbd, samp {
font-family: Consolas, Monaco, 'Andale Mono', monospace;
}
.class-description {
font-size: 130%;
line-height: 140%;
margin-bottom: 1em;
margin-top: 1em;
}
.class-description:empty {
margin: 0;
}
#main {
float: left;
width: 70%;
}
article dl {
margin-bottom: 40px;
}
article img {
max-width: 100%;
}
section
{
display: block;
background-color: #fff;
padding: 12px 24px;
border-bottom: 1px solid #ccc;
margin-right: 30px;
}
.variation {
display: none;
}
.signature-attributes {
font-size: 60%;
color: #aaa;
font-style: italic;
font-weight: lighter;
}
nav
{
display: block;
float: right;
margin-top: 28px;
width: 30%;
box-sizing: border-box;
border-left: 1px solid #ccc;
padding-left: 16px;
}
nav ul {
font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif;
font-size: 100%;
line-height: 17px;
padding: 0;
margin: 0;
list-style-type: none;
}
nav ul a, nav ul a:visited, nav ul a:active {
font-family: Consolas, Monaco, 'Andale Mono', monospace;
line-height: 18px;
color: #4D4E53;
}
nav h3 {
margin-top: 12px;
}
nav li {
margin-top: 6px;
}
footer {
display: block;
padding: 6px;
margin-top: 12px;
font-style: italic;
font-size: 90%;
}
h1, h2, h3, h4 {
font-weight: 200;
margin: 0;
}
h1
{
font-family: 'Open Sans Light', sans-serif;
font-size: 48px;
letter-spacing: -2px;
margin: 12px 24px 20px;
}
h2, h3.subsection-title
{
font-size: 30px;
font-weight: 700;
letter-spacing: -1px;
margin-bottom: 12px;
}
h3
{
font-size: 24px;
letter-spacing: -0.5px;
margin-bottom: 12px;
}
h4
{
font-size: 18px;
letter-spacing: -0.33px;
margin-bottom: 12px;
color: #4d4e53;
}
h5, .container-overview .subsection-title
{
font-size: 120%;
font-weight: bold;
letter-spacing: -0.01em;
margin: 8px 0 3px 0;
}
h6
{
font-size: 100%;
letter-spacing: -0.01em;
margin: 6px 0 3px 0;
font-style: italic;
}
table
{
border-spacing: 0;
border: 0;
border-collapse: collapse;
}
td, th
{
border: 1px solid #ddd;
margin: 0px;
text-align: left;
vertical-align: top;
padding: 4px 6px;
display: table-cell;
}
thead tr
{
background-color: #ddd;
font-weight: bold;
}
th { border-right: 1px solid #aaa; }
tr > th:last-child { border-right: 1px solid #ddd; }
.ancestors, .attribs { color: #999; }
.ancestors a, .attribs a
{
color: #999 !important;
text-decoration: none;
}
.clear
{
clear: both;
}
.important
{
font-weight: bold;
color: #950B02;
}
.yes-def {
text-indent: -1000px;
}
.type-signature {
color: #aaa;
}
.name, .signature {
font-family: Consolas, Monaco, 'Andale Mono', monospace;
}
.details { margin-top: 14px; border-left: 2px solid #DDD; }
.details dt { width: 120px; float: left; padding-left: 10px; padding-top: 6px; }
.details dd { margin-left: 70px; }
.details ul { margin: 0; }
.details ul { list-style-type: none; }
.details li { margin-left: 30px; padding-top: 6px; }
.details pre.prettyprint { margin: 0 }
.details .object-value { padding-top: 0; }
.description {
margin-bottom: 1em;
margin-top: 1em;
}
.code-caption
{
font-style: italic;
font-size: 107%;
margin: 0;
}
.source
{
border: 1px solid #ddd;
width: 80%;
overflow: auto;
}
.prettyprint.source {
width: inherit;
}
.source code
{
font-size: 100%;
line-height: 18px;
display: block;
padding: 4px 12px;
margin: 0;
background-color: #fff;
color: #4D4E53;
}
.prettyprint code span.line
{
display: inline-block;
}
.prettyprint.linenums
{
padding-left: 70px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.prettyprint.linenums ol
{
padding-left: 0;
}
.prettyprint.linenums li
{
border-left: 3px #ddd solid;
}
.prettyprint.linenums li.selected,
.prettyprint.linenums li.selected *
{
background-color: lightyellow;
}
.prettyprint.linenums li *
{
-webkit-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
}
.params .name, .props .name, .name code {
color: #4D4E53;
font-family: Consolas, Monaco, 'Andale Mono', monospace;
font-size: 100%;
}
.params td.description > p:first-child,
.props td.description > p:first-child
{
margin-top: 0;
padding-top: 0;
}
.params td.description > p:last-child,
.props td.description > p:last-child
{
margin-bottom: 0;
padding-bottom: 0;
}
.disabled {
color: #454545;
}
/* JSDoc prettify.js theme */
/* plain text */
.pln {
color: #000000;
font-weight: normal;
font-style: normal;
}
/* string content */
.str {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* a keyword */
.kwd {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* a comment */
.com {
font-weight: normal;
font-style: italic;
}
/* a type name */
.typ {
color: #000000;
font-weight: normal;
font-style: normal;
}
/* a literal value */
.lit {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* punctuation */
.pun {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* lisp open bracket */
.opn {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* lisp close bracket */
.clo {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* a markup tag name */
.tag {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* a markup attribute name */
.atn {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* a markup attribute value */
.atv {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* a declaration */
.dec {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* a variable name */
.var {
color: #000000;
font-weight: normal;
font-style: normal;
}
/* a function name */
.fun {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* Specify class=linenums on a pre to get line numbering */
ol.linenums {
margin-top: 0;
margin-bottom: 0;
}
/* Tomorrow Theme */
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
/* Pretty printing styles. Used with prettify.js. */
/* SPAN elements with the classes below are added by prettyprint. */
/* plain text */
.pln {
color: #4d4d4c; }
@media screen {
/* string content */
.str {
color: #718c00; }
/* a keyword */
.kwd {
color: #8959a8; }
/* a comment */
.com {
color: #8e908c; }
/* a type name */
.typ {
color: #4271ae; }
/* a literal value */
.lit {
color: #f5871f; }
/* punctuation */
.pun {
color: #4d4d4c; }
/* lisp open bracket */
.opn {
color: #4d4d4c; }
/* lisp close bracket */
.clo {
color: #4d4d4c; }
/* a markup tag name */
.tag {
color: #c82829; }
/* a markup attribute name */
.atn {
color: #f5871f; }
/* a markup attribute value */
.atv {
color: #3e999f; }
/* a declaration */
.dec {
color: #f5871f; }
/* a variable name */
.var {
color: #c82829; }
/* a function name */
.fun {
color: #4271ae; } }
/* Use higher contrast and text-weight for printable form. */
@media print, projection {
.str {
color: #060; }
.kwd {
color: #006;
font-weight: bold; }
.com {
color: #600;
font-style: italic; }
.typ {
color: #404;
font-weight: bold; }
.lit {
color: #044; }
.pun, .opn, .clo {
color: #440; }
.tag {
color: #006;
font-weight: bold; }
.atn {
color: #404; }
.atv {
color: #060; } }
/* Style */
/*
pre.prettyprint {
background: white;
font-family: Consolas, Monaco, 'Andale Mono', monospace;
font-size: 12px;
line-height: 1.5;
border: 1px solid #ccc;
padding: 10px; }
*/
/* Specify class=linenums on a pre to get line numbering */
ol.linenums {
margin-top: 0;
margin-bottom: 0; }
/* IE indents via margin-left */
li.L0,
li.L1,
li.L2,
li.L3,
li.L4,
li.L5,
li.L6,
li.L7,
li.L8,
li.L9 {
/* */ }
/* Alternate shading for lines */
li.L1,
li.L3,
li.L5,
li.L7,
li.L9 {
/* */ }
{
"_from": "glsx-map-sdk",
"_id": "glsx-map-sdk@0.2.0",
"_inBundle": false,
"_integrity": "sha512-uEFlXvJEDofYjasR4mwkmF5yNTRs5QA2ZAynGPHiKpKdpjQkVFPJH0zGupmQEkxmh4f5B0wPbDobHvLgld7mVw==",
"_location": "/glsx-map-sdk",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "glsx-map-sdk",
"name": "glsx-map-sdk",
"escapedName": "glsx-map-sdk",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/glsx-map-sdk/-/glsx-map-sdk-0.2.0.tgz",
"_shasum": "93740dedd7b8a6569a0626a2e47523e263050929",
"_spec": "glsx-map-sdk",
"_where": "D:\\2023\\07\\海马刀",
"author": {
"name": "liwk"
},
"bundleDependencies": false,
"deprecated": false,
"description": "glsx-map-sdk",
"devDependencies": {
"rollup": "^1.32.1",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-eslint": "^7.0.0",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-uglify": "^6.0.4"
},
"license": "ISC",
"main": "src/index.js",
"name": "glsx-map-sdk",
"scripts": {
"build": "rollup -c",
"doc": "jsdoc src/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "0.2.0"
}
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
// import { eslint } from 'rollup-plugin-eslint'
import babel from 'rollup-plugin-babel'
import replace from 'rollup-plugin-replace'
import { uglify } from 'rollup-plugin-uglify'
const packages = require('./package.json')
export default {
input: `src/index.js`,
output: {
file: `dist/${packages.name}.js`,
format: 'umd',
name: packages.name
},
plugins: [
resolve(),
commonjs(),
// eslint({
// include: ['src/**'],
// exclude: ['node_modules/**']
// }),
babel({
exclude: 'node_modules/**',
runtimeHelpers: true
}),
replace({
exclude: 'node_modules/**',
ENV: JSON.stringify(process.env.NODE_ENV)
}),
uglify()
]
}
/*
* @Descripttion: 常量类
* @version: 1.0.0
* @Author: limin
* @Date: 2023-07-04 17:40:51
* @LastEditors: limin
* @LastEditTime: 2023-07-05 08:48:32
* @FilePath: \glsx-map-sdk\src\constants.js
*/
export const MAP_OPTIONS = { domain: 'https://restapi.amap.com', KEY: '373bd88fa36ebc0247d60281386b6cec', SECRET: 'a2a93fa04721a36819d86b71cb31fe41' }
/*
* @Descripttion:帮助类
* @version: 1.0.0
* @Author: limin
* @Date: 2023-07-04 17:37:45
* @LastEditors: limin
* @LastEditTime: 2023-07-05 08:46:52
* @FilePath: \glsx-map-sdk\src\helper.js
*/
export const isMiniprogram = !window
/*
* @Descripttion: api封装类
* @version: 1.0.0
* @Author: liweikang
* @Date: 2023-07-04 17:22:43
* @LastEditors: limin
* @LastEditTime: 2023-07-05 15:04:01
* @FilePath: \glsx-map-sdk\src\index.js
*/
import Request from './request'
class GlMapApi {
constructor(params = {}) {
const { key, secret } = params
this.request = new Request(key, secret)
}
/**
* 定义一个异步方法,用于计算两个坐标之间的距离
* @param {*} from 起始位置 [lat,lng]
* @param {*} to 结束位置 [lat,lng]
* @param {*} type 0:直线距离 , 1:驾车导航距离(仅支持国内坐标) , 3:步行规划距离(仅支持5km之间的距离)
* @param {*} $attrs 自定义入参 参考https://lbs.amap.com/api/webservice/gettingstarted
* @returns {Promise<{elements: Array}>}
*/
async calculateDistance(from, to, type = 1, $attrs = {}) {
try {
const destination = JSON.parse(JSON.stringify(from)).reverse().join(','),
origins = JSON.parse(JSON.stringify(to)).reverse().join(','),
{ results } = await this.request.get('/v3/distance', {
destination,
origins,
type,
...$attrs
})
return {
elements: results
}
} catch (error) {
throw error
}
}
/**
* 批量距离计算(矩阵)
* @param {*} from 起始位置 [lat,lng]
* @param {*} toList 终点位置 [[lat,lng],[lat,lng]]
* @param {*} type 直线距离 , 1:驾车导航距离(仅支持国内坐标) , 3:步行规划距离(仅支持5km之间的距离)
* @param {*} $attrs 自定义入参 参考https://lbs.amap.com/api/webservice/gettingstarted
* @returns {Promise<{rows: Array}>}
*/
async calculateDistanceMatrix(from, toList, type = 1, $attrs = {}) {
try {
const destination = JSON.parse(JSON.stringify(from)).reverse().join(','),
origins = JSON.parse(JSON.stringify(toList))
.map(e => (e = e.reverse()))
.join('|'),
{ results } = await this.request.get('/v3/distance', {
destination,
origins,
type,
...$attrs
}),
res = {
rows: [
{
elements: results
}
]
}
return Promise.resolve(res)
} catch (error) {
return Promise.reject(error)
}
}
/**
* 地址解析(地址转坐标)
* @param {*} address (String)
* @param {*} $attrs 自定义入参 参考https://lbs.amap.com/api/webservice/gettingstarted
* @returns
*/
geocoder(address, $attrs = {}) {
return this.request.get('/v3/geocode/geo', {
address,
...$attrs
})
}
/**
* 逆地址解析(坐标位置描述)
* @param {*} location [lat<纬度>,lng<经度>]
* @param {*} $attrs 自定义入参 参考https://lbs.amap.com/api/webservice/gettingstarted
* @returns
*/
async detailedAdrress(location, $attrs = {}) {
try {
const [lat, lng] = location
const { regeocode } = await this.request.get('/v3/geocode/regeo', {
location: JSON.parse(JSON.stringify(location)).reverse().join(','),
...$attrs
}),
{ addressComponent, formatted_address } = regeocode,
address = `${addressComponent.province || ''}${addressComponent.city || ''}${addressComponent.district || ''}${addressComponent.township || ''}`,
data = {
...regeocode,
address,
formatted_addresses: {
recommend: formatted_address,
rough: formatted_address,
standard_address: formatted_address
},
address_component: {
city: addressComponent.city,
district: addressComponent.district,
nation: addressComponent.country,
province: addressComponent.province,
street: addressComponent.township
},
ad_info: {
adcode: addressComponent.adcode,
city: addressComponent.city,
city_code: addressComponent.citycode,
district: addressComponent.district,
location: {
lat,
lng
},
name: `${addressComponent.country + ',' || ''}${addressComponent.province + ',' || ''}${addressComponent.city + ',' || ''}${addressComponent.district || ''}`,
nation: addressComponent.country,
nation_code: '',
phone_area_code: addressComponent.citycode,
province: addressComponent.province
},
location: {
lat,
lng
}
}
return Promise.resolve(data)
} catch (error) {
return Promise.reject(error)
}
}
/**
* IP定位
* @param {*} $attrs 自定义入参 参考https://lbs.amap.com/api/webservice/gettingstarted
* @returns
*/
getLocationByIp($attrs = {}) {
return this.request.get('/v3/ip', $attrs)
}
/**
* 坐标转换用于将一组坐标转换为不同的坐标系
* @param {*} locationsList [[lat,lng],[lat,lng]] 纬度前,经度后 (最多支持40对坐标)
* @param {*} coordsys 原坐标系(可选值:
gps;
mapbar;
baidu;
autonavi(不进行转换))
* @param {*} $attrs 自定义入参 参考https://lbs.amap.com/api/webservice/gettingstarted
* @returns
*/
translate(locationsList, coordsys = 'autonavi', $attrs = {}) {
// 使用数组解构和map方法,将locationsList参数转换为字符串,并反转数组顺序,然后用竖线连接,得到locations字符串
const locations = JSON.parse(JSON.stringify(locationsList))
.map(e => (e = e.reverse()))
.join('|')
// 调用request对象的get方法,传入请求路径为/v3/assistant/coordinate/convert,请求数据为locations字符串和coordsys参数(默认为autonavi),并返回结果
return this.request.get('/v3/assistant/coordinate/convert', {
locations,
coordsys,
...$attrs
})
}
/**
* 路线规划
* @param {*} from 起始位置 [lat,lng] 纬度前,经度后
* @param {*} to 终点位置 [lat,lng] 纬度前,经度后
* @param {*} type 出行类型 1步行 2骑车 3驾车
* @param {*} $attrs 自定义入参 参考https://lbs.amap.com/api/webservice/gettingstarted
*/
async routePlanning(from, to, type = 3, $attrs = {}) {
const funName = {
1: '/v3/direction/walking',
2: '/v4/direction/bicycling',
3: '/v3/direction/driving'
}[type],
origin = JSON.parse(JSON.stringify(from)).reverse().join(','),
destination = JSON.parse(JSON.stringify(to)).reverse().join(',')
try {
const { route } = await this.request.get(funName, {
origin,
destination,
...$attrs
})
return Promise.resolve(route)
} catch (error) {
return Promise.reject(error)
}
}
/**
* 输入提示
* @param {*} keywords 查询关键词
* @param {*} location 定位坐标 [lat,lng] 纬度前,经度后
* @param {*} $attrs 自定义入参 参考https://lbs.amap.com/api/webservice/gettingstarted
*/
async keywordSearch(keywords, location, $attrs = {}) {
try {
const { tips } = await this.request.get('/v3/assistant/inputtips', {
keywords,
location: JSON.parse(JSON.stringify(location)).reverse().join(','),
...$attrs
})
return Promise.resolve(tips)
} catch (error) {
return Promise.reject(error)
}
}
}
export default GlMapApi
/*
* @Descripttion: 定义一个Request类,用于封装请求高德地图API的方法
* @version: 1.0.0
* @Author: limin
* @Date: 2023-07-04 17:25:31
* @LastEditors: limin
* @LastEditTime: 2023-07-05 14:50:37
* @FilePath: \glsx-map-sdk\src\request.js
*/
import md5 from './lib/md5'
import qs from './lib/qs'
import { MAP_OPTIONS } from './constants'
import { isMiniprogram } from './helper'
class Request {
// 构造函数,接收key和secret作为参数,如果没有传入,则使用默认值
constructor(key = MAP_OPTIONS.KEY, secret = MAP_OPTIONS.SECRET) {
// 将key和secret赋值给实例属性
this.key = key
this.secret = secret
}
/**对参数进行排序:按参数名升序 */
setLocaleCompare(params) {
// 将key添加到参数对象中
params.key = this.key
return Object.fromEntries(Object.entries(params).sort(([a], [b]) => a.localeCompare(b)))
}
/**签名计算(sig) */
getSign(params) {
return md5(`${decodeURIComponent(qs.stringify(this.setLocaleCompare(params)))}${this.secret}`)
}
/**封装的GET方法 */
get(method, data) {
// 调用request方法,传入请求方式为GET,请求路径为method,请求数据为data
return this.request('GET', method, data)
}
/**封装的请求方法 */
async request(RequestMethods, method, data = {}) {
// 调用getSign方法,传入请求数据和请求路径,得到签名
const sig = this.getSign(data, method),
obj = {
...this.setLocaleCompare(data),
sig
}
if (isMiniprogram) {
wx.showNavigationBarLoading()
try {
const res = await new Promise((resolve, reject) => {
wx.request({
url: `${MAP_OPTIONS.domain}${method}`,
data: obj,
method: RequestMethods,
header:
RequestMethods === 'POST'
? {
'content-type': 'application/json'
}
: {},
dataType: 'json',
responseType: 'text',
success: resolve,
fail: reject
})
})
const { statusCode, data, errMsg } = res
if (statusCode == '200') {
if (data.status == '1') {
return data
} else {
wx.showToast({
title: data.info,
icon: 'none'
})
}
} else {
wx.showToast({
title: errMsg,
icon: 'error'
})
}
} catch (error) {
wx.hideLoading()
console.error(`接口异常:`, error)
wx.showToast({
title: '系统异常',
icon: 'error'
})
throw error
} finally {
wx.hideNavigationBarLoading()
}
} else {
// 如果不是小程序环境,则使用window.fetch方法发送请求,并传入完整的请求地址和请求方式
const params = []
Object.keys(obj).map(key => {
params.push(`${key}=${encodeURIComponent(obj[key])}`)
})
try {
const res = await window.fetch(`${MAP_OPTIONS.domain}${method}?${params.join('&')}`, {
method: RequestMethods
})
const data = await res.json()
if (data.status == '1') return data
else throw data.info
} catch (error) {
console.error(`接口异常:`, error)
throw error
}
}
}
}
export default Request
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"glsx-map-sdk": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/glsx-map-sdk/-/glsx-map-sdk-0.2.0.tgz",
"integrity": "sha512-uEFlXvJEDofYjasR4mwkmF5yNTRs5QA2ZAynGPHiKpKdpjQkVFPJH0zGupmQEkxmh4f5B0wPbDobHvLgld7mVw=="
}
}
}
{
"name": "hmd",
"version": "1.0.0",
"main": "app.js",
"dependencies": {
"glsx-map-sdk": "^0.2.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "http://192.168.3.233:8090/saas/mini-program/hmd"
},
"author": "",
"license": "ISC",
"description": ""
}
// packageIndex/pages/index/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log(options)
this.setData(options)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
{}
\ No newline at end of file \ No newline at end of file
<view>
{{a}}
<view>{{b}}</view>
<view>{{c}}</view>
<view>{{d}}</view>
</view>
\ No newline at end of file \ No newline at end of file
// pages/tab/output/output.js // pages/loading/loading.js
Page({ Page({
/** /**
......
/* pages/loading/loading.wxss */
\ No newline at end of file \ No newline at end of file
<!--pages/loading/loading.wxml-->
<text>pages/loading/loading.wxml</text>
// pages/tab/equity/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* pages/tab/equity/index.wxss */
\ No newline at end of file \ No newline at end of file
<!--pages/tab/equity/index.wxml-->
<text>pages/tab/equity/index.wxml</text>
...@@ -15,7 +15,16 @@ Page({ ...@@ -15,7 +15,16 @@ Page({
onLoad: function (options) { onLoad: function (options) {
}, },
jump(){
wx.p.router.go('/packageIndex/pages/index/index',{
a:123,
b:['555','苟利国家生死岂因祸福避趋之'],
c:{
AA:321,
BB:'xxx'
}
})
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
......
<view style="padding-top:200px">
<button bindtap="jump">点击跳转携带参数</button>
</view>
\ No newline at end of file \ No newline at end of file
// pages/tab/mall/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* pages/tab/mall/index.wxss */
\ No newline at end of file \ No newline at end of file
<!--pages/tab/mall/index.wxml-->
<text>pages/tab/mall/index.wxml</text>
// pages/tab/mine/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* pages/tab/mine/index.wxss */
\ No newline at end of file \ No newline at end of file
<!--pages/tab/mine/index.wxml-->
<text>pages/tab/mine/index.wxml</text>
/* pages/tab/output/output.wxss */
\ No newline at end of file \ No newline at end of file
<!--pages/tab/output/output.wxml-->
<text>pages/tab/output/output.wxml</text>
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
"nodeModules": false, "nodeModules": false,
"enhance": true, "enhance": true,
"useMultiFrameRuntime": true, "useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": true,
"showShadowRootInWxmlPanel": true, "showShadowRootInWxmlPanel": true,
"packNpmManually": false, "packNpmManually": false,
"packNpmRelationList": [], "packNpmRelationList": [],
...@@ -48,7 +46,7 @@ ...@@ -48,7 +46,7 @@
"tabIndent": "insertSpaces", "tabIndent": "insertSpaces",
"tabSize": 2 "tabSize": 2
}, },
"libVersion": "2.23.4", "condition": {},
"packOptions": { "packOptions": {
"ignore": [ "ignore": [
{ {
...@@ -58,7 +56,5 @@ ...@@ -58,7 +56,5 @@
], ],
"include": [] "include": []
}, },
"appid": "wxfe82b8d65d07808f", "appid": "wxfe82b8d65d07808f"
"projectname": "miniprogram-scrm-shopmall",
"condition": {}
} }
\ No newline at end of file \ No newline at end of file
{ {
"setting": { "setting": {
"compileHotReLoad": true, "compileHotReLoad": false,
"urlCheck": false, "urlCheck": false,
"lazyloadPlaceholderEnable": true "lazyloadPlaceholderEnable": true
}, },
...@@ -27,39 +27,11 @@ ...@@ -27,39 +27,11 @@
"query": "merchantId=44205858", "query": "merchantId=44205858",
"launchMode": "default", "launchMode": "default",
"scene": null "scene": null
},
{
"name": "",
"pathName": "packageMine/pages/coupon/recommend/recommend",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/serviceCode/serviceCode",
"query": "id=100&sendDate=1656496796863139&merchantId=123",
"launchMode": "default",
"scene": 1194
},
{
"name": "",
"pathName": "pages/serviceCode/serviceCode",
"query": "id=100&sendDate=1656496796863139",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/index/index",
"query": "",
"launchMode": "default",
"scene": null
} }
] ]
} }
}, },
"projectname": "hmd", "projectname": "hmd",
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"libVersion": "2.24.4" "libVersion": "3.0.0"
} }
\ No newline at end of file \ No newline at end of file
import Router from "./router.js"; import Router from "./router.js";
import routes from "./routers.js";
export default new Router(routes); export default new Router();
/** class RouterBefore {
* 执行路由前的准备工作 constructor(options) {
*/ console.log('---------------- 路由初始化 ----------------')
this.initPageProxy()
/**处理前置钩子逻辑 */ }
const routerBefore = (next) => { /**监听页面 */
// console.log("处理前置钩子逻辑"); pageLeaveProxy(thisPage) {
let onLoad = thisPage.onLoad
next(); thisPage.onLoad = function () {
}; let options = {
/**处理后置钩子逻辑 */ ...getApp().globalData.ROUTE_QUERY,
const routerAfter = (next) => { ...arguments[0]
// console.log("处理后置钩子逻辑"); }
onLoad && onLoad.apply(this, [options]),(getApp().globalData.ROUTE_QUERY = {})
next(); }
}; }
/**全局注册事件 */
// 重写Page方法 initPageProxy() {
const OldPage = Page; let thisPage = Page
Page = function (options) { let _this = this
const oldShow = options.onShow; Page = function (el) {
const oldHide = options.onHide; try {
options.onShow = function () { el || (el = {}), _this.pageLeaveProxy(el), thisPage.apply(this, arguments)
routerBefore(() => { } catch (el) {
oldShow.apply(this, arguments); thisPage.apply(this, arguments)
}); }
}; }
options.onHide = function () { }
routerAfter(() => { }
oldHide.apply(this, arguments); export default new RouterBefore()
});
};
OldPage(options);
};
export default routerBefore;
\ No newline at end of file \ No newline at end of file
export default __wxConfig.pages.map(item => ({
url: `/${item}`,
name: item.split('/').pop(),
parent: item.split('/')[0]
}))
\ No newline at end of file \ No newline at end of file
// import util from '../utils/util.js'
// import {
// getUserInfo
// } from '~/utils/cache/userInfo'
/**
* wx.onAppRoute钩子方法,
* 所有的参数都是路由类上的参数
* @param {*} obj.query
* @param {*} obj.routeHooks
* @param {*} obj.routerList
* @param {*} obj.getPageInstance
* @param {*} obj.getRootName
* @param {*} obj.setNavigationBarTitleText
* @param {*} obj.getRouterList
*/
/**
* 生成特定格式路由
*
* @param {*} routerList 路由参数
* @returns
*/
export const generateRoutList = routerList => {
let _routerList = routerList
try {
__wxConfig &&
__wxConfig.tabBar &&
__wxConfig.tabBar.list &&
(_routerList = routerList.map(item => {
let obj = {}
if (item.parent != '__plugin__') {
obj = {
...item,
isTab: __wxConfig.tabBar.list.some(({ pagePath }) => item.url.includes(pagePath.replace('.html', '')))
}
if (item.parent !== 'pages') {
let parentList = item.url.split(`/`)
if (parentList.length > 5) {
item.url = item.url.replace(/\/__plugin__\/[a-z0-9A-Z]+/, '')
obj.subPages = item.url.split(`/${item.parent}/pages/`)[1].split('/')[0]
}
}
}
return obj
}))
} catch (err) {}
return _routerList
}
import md5 from '../lib/md5' import GlMap from 'glsx-map-sdk'
import qs from '../lib/qs' export default new GlMap()
const key = 'F2HBZ-KH73F-7A2J2-JC4UR-WOHCO-UVFGZ'
const secret = 'YBmrM98E5pM4gYeknWiBPaWpFR4AISUl'
const domain = 'https://apis.map.qq.com'
class QQMap {
setLocaleCompare(params) {
params.key = key
let keys = []
let obj = {}
Object.keys(params).map(e => keys.push(e))
keys.sort((a, b) => a.localeCompare(b)).map(e => (obj[e] = params[e]))
return obj
}
getSign(params, methods) {
let obj = this.setLocaleCompare(params)
let sign = `${methods}?${decodeURIComponent(qs.stringify(obj))}${secret}`
return md5(sign)
}
get(method, data) {
return this.request('GET', method, data)
}
request(RequestMethods, method, data) {
return new Promise((resolve, reject) => {
wx.showNavigationBarLoading()
if (!data) data = {}
let header =
RequestMethods === 'POST'
? {
'content-type': 'application/json'
}
: {}
const sig = this.getSign(data, method)
let params = {
...this.setLocaleCompare(data),
sig
}
wx.request({
url: `${domain}${method}`,
data: params,
method: RequestMethods,
header,
dataType: 'json',
responseType: 'text',
success({ statusCode, data }) {
if (statusCode == '200') {
if (data.status == '0') {
resolve(data.result || data)
}
} else {
reject(data.result || data)
}
},
fail(error) {
wx.hideLoading()
console.error(`接口异常:`, error)
wx.showToast({
title: '系统异常',
icon: 'error'
})
reject(error)
},
complete() {
wx.stopPullDownRefresh()
wx.hideNavigationBarLoading()
}
})
})
}
/**计算距离 */
calculateDistance(from, to) {
from = from.join(',')
to = to.join(',')
return this.get('/ws/distance/v1/', {
from,
to,
mode: 'driving'
})
}
/** 批量距离计算(矩阵) */
calculateDistanceMatrix(from, toList) {
from = from.join(',')
let to = toList.join(';')
return this.get('/ws/distance/v1/matrix/', {
from,
to,
mode: 'driving'
})
}
/**地址解析(地址转坐标) */
geocoder(address) {
return this.get('/ws/geocoder/v1/', {
address
})
}
/**逆地址解析(坐标位置描述) location=lat<纬度>,lng<经度> */
detailedAdrress(location) {
location = location.join(',')
return this.get('/ws/geocoder/v1/', {
location
})
}
/**IP定位 */
getLocationByIp() {
return this.get('/ws/location/v1/ip')
}
/**坐标转换 */
translate(locations, type = 5) {
locations = locations.join(';') //格式:纬度前,经度后
return this.get('/ws/coord/v1/translate', {
locations,
type
})
}
}
export default new QQMap()
\ No newline at end of file \ No newline at end of file
import wxqrcode from '~/utils/lib/wxqrcode.js' import wxqrcode from '~/utils/lib/wxqrcode.js'
/**
* 微信校验通知类工具封装
*/
const tipsObj = {
phone: {
icon: 'error',
title: '请输入手机号'
},
username: {
icon: 'error',
title: '请输入用户名'
},
password: {
icon: 'error',
title: '请输入密码'
}
}
/** /**
* 禁止滑动 * 禁止滑动
...@@ -72,24 +55,6 @@ const showToast = val => { ...@@ -72,24 +55,6 @@ const showToast = val => {
return wx.showToast(obj) return wx.showToast(obj)
} }
/**
*
* @param {* string | object} name 信息名称
* @param {* object | null} [params] 信息名称参数
*/
const wxShowToast = (name, params) => {
if (arguments.length == 2) {
wx.showToast({
title: tipsObj[name]['title'],
icon: tipsObj[name]['icon'],
...params
})
} else {
wx.showToast({
...params
})
}
}
/**获取设备信息 */ /**获取设备信息 */
const getSystemInfo = callBack => { const getSystemInfo = callBack => {
...@@ -155,10 +120,10 @@ export function handleCopy(url) { ...@@ -155,10 +120,10 @@ export function handleCopy(url) {
/**获取节点信息 /**获取节点信息
* name(id获取class) * name(id获取class)
* callBack 回调函数 * callBack 回调函数
* isComponents是否在组件 * componentThis是否在组件 (传组件this)
*/ */
const getViewInfo = (name, callBack, isComponents) => { const getViewInfo = (name, callBack, componentThis) => {
const query = !isComponents ? wx.createSelectorQuery() : wx.createSelectorQuery().in(isComponents) const query = !componentThis ? wx.createSelectorQuery() : wx.createSelectorQuery().in(componentThis)
query query
.selectAll(name) .selectAll(name)
.boundingClientRect(res => { .boundingClientRect(res => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!