├── .gitignore ├── App.vue ├── README.md ├── config └── index.js ├── lib └── qqmap-wx-jssdk.min.js ├── main.js ├── manifest.json ├── package-lock.json ├── package.json ├── pages.json ├── pages ├── index │ └── index.vue ├── search │ └── search.vue └── select │ └── select.vue ├── static └── images │ └── location.png ├── store ├── actions.js ├── getters.js ├── index.js ├── mutation-types.js ├── mutations.js └── state.js ├── styles ├── index.scss └── vant-theme.scss ├── uni.scss ├── utils └── index.js └── wxcomponents └── vant ├── button ├── index.d.ts ├── index.js ├── index.json ├── index.wxml └── index.wxss ├── cell-group ├── index.d.ts ├── index.js ├── index.json ├── index.wxml └── index.wxss ├── cell ├── index.d.ts ├── index.js ├── index.json ├── index.wxml └── index.wxss ├── common ├── color.d.ts ├── color.js ├── component.d.ts ├── component.js ├── index.wxss ├── style │ ├── clearfix.wxss │ ├── ellipsis.wxss │ ├── hairline.wxss │ ├── mixins │ │ ├── clearfix.wxss │ │ ├── ellipsis.wxss │ │ └── hairline.wxss │ ├── theme.wxss │ └── var.wxss ├── utils.d.ts └── utils.js ├── field ├── index.d.ts ├── index.js ├── index.json ├── index.wxml └── index.wxss ├── icon ├── index.d.ts ├── index.js ├── index.json ├── index.wxml └── index.wxss ├── info ├── index.d.ts ├── index.js ├── index.json ├── index.wxml └── index.wxss ├── loading ├── index.d.ts ├── index.js ├── index.json ├── index.wxml └── index.wxss ├── mixins ├── basic.d.ts ├── basic.js ├── button.d.ts ├── button.js ├── link.d.ts ├── link.js ├── open-type.d.ts ├── open-type.js ├── touch.d.ts ├── touch.js ├── transition.d.ts └── transition.js ├── search ├── index.d.ts ├── index.js ├── index.json ├── index.wxml └── index.wxss └── wxs ├── add-unit.wxs ├── array.wxs ├── bem.wxs ├── memoize.wxs ├── object.wxs └── utils.wxs /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | unpackage 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw* -------------------------------------------------------------------------------- /App.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 从已有微信小程序项目中扣离出来的签到打卡及地图定位,不涉及其他业务。 2 | 因为微信小程序的`wx.chooseLocation`无法满足业务需要,所以自己撸了一个,个性化更强一些。 3 | 4 | ## 使用方法 5 | 6 | 因为只是在微信小程序中使用,所以一些相关的 SDK 都是腾讯地图的,如果需要在其他端使用,请自行修改。 7 | 8 | 1、先去腾讯地图申请一个 KEY:[去申请](https://lbs.qq.com) 9 | 2、将申请的 KEY 填入项目`config\index.js`中的`MAP_KEY` 10 | 3、`manifest.json`中配置上自己的小程序的 appid,不然无法定位 11 | 4、执行`npm install`安装一些依赖(必须) 12 | 13 | ## 项目内容 14 | 15 | 1、引用了部分[Vant](https://youzan.github.io/vant-weapp)组件,具体见`wxcomponents\vant` 16 | 2、引用了[dayjs](https://github.com/iamkun/dayjs)处理日期格式 17 | 3、引用了部分[lodash](https://lodash.com)的方法 18 | 4、获取位置信息及搜索使用的`微信小程序JavaScript SDK`,详情见文档:[https://lbs.qq.com/qqmap_wx_jssdk/index.html](https://lbs.qq.com/qqmap_wx_jssdk/index.html) 19 | 20 | ## 截图预览 21 | 22 | ![image](https://image.liubing.me/2020/03/14/cd7ee4cd27b50.gif) 23 | 24 | ![image](https://image.liubing.me/2020/03/14/c6598849d265b.png) 25 | 26 | ![image](https://image.liubing.me/2020/03/14/5f814796dc35a.png) 27 | 28 | ![image](https://image.liubing.me/2020/03/14/ac6cbfb9247a3.png) 29 | 30 | ![image](https://image.liubing.me/2020/03/14/d88b49c34579e.png) 31 | 32 | ## 其他 33 | 34 | uniapp微信小程序中具体使用vant可参考:[https://liubing.me/uniapp-use-vant-weapp.html](https://liubing.me/uniapp-use-vant-weapp.html) 35 | -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | // 腾讯地图KEY,自行申请:https://lbs.qq.com 2 | export const MAP_KEY = 'GEWBZ-3GZCP-34CDS-LAIP7-IATVO-LWFLQ' // 最好自己去申请一个,随时可能会被删除 3 | -------------------------------------------------------------------------------- /lib/qqmap-wx-jssdk.min.js: -------------------------------------------------------------------------------- 1 | var ERROR_CONF = { KEY_ERR: 311, KEY_ERR_MSG: 'key格式错误', PARAM_ERR: 310, PARAM_ERR_MSG: '请求参数信息有误', SYSTEM_ERR: 600, SYSTEM_ERR_MSG: '系统错误', WX_ERR_CODE: 1000, WX_OK_CODE: 200 }; var BASE_URL = 'https://apis.map.qq.com/ws/'; var URL_SEARCH = BASE_URL + 'place/v1/search'; var URL_SUGGESTION = BASE_URL + 'place/v1/suggestion'; var URL_GET_GEOCODER = BASE_URL + 'geocoder/v1/'; var URL_CITY_LIST = BASE_URL + 'district/v1/list'; var URL_AREA_LIST = BASE_URL + 'district/v1/getchildren'; var URL_DISTANCE = BASE_URL + 'distance/v1/'; var URL_DIRECTION = BASE_URL + 'direction/v1/'; var MODE = { driving: 'driving', transit: 'transit' }; var EARTH_RADIUS = 6378136.49; var Utils = { safeAdd(x, y) { var lsw = (x & 0xffff) + (y & 0xffff); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xffff) }, bitRotateLeft(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)) }, md5cmn(q, a, b, x, s, t) { return this.safeAdd(this.bitRotateLeft(this.safeAdd(this.safeAdd(a, q), this.safeAdd(x, t)), s), b) }, md5ff(a, b, c, d, x, s, t) { return this.md5cmn((b & c) | (~b & d), a, b, x, s, t) }, md5gg(a, b, c, d, x, s, t) { return this.md5cmn((b & d) | (c & ~d), a, b, x, s, t) }, md5hh(a, b, c, d, x, s, t) { return this.md5cmn(b ^ c ^ d, a, b, x, s, t) }, md5ii(a, b, c, d, x, s, t) { return this.md5cmn(c ^ (b | ~d), a, b, x, s, t) }, binlMD5(x, len) { x[len >> 5] |= 0x80 << (len % 32); x[((len + 64) >>> 9 << 4) + 14] = len; var i; var olda; var oldb; var oldc; var oldd; var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; for (i = 0; i < x.length; i += 16) { olda = a; oldb = b; oldc = c; oldd = d; a = this.md5ff(a, b, c, d, x[i], 7, -680876936); d = this.md5ff(d, a, b, c, x[i + 1], 12, -389564586); c = this.md5ff(c, d, a, b, x[i + 2], 17, 606105819); b = this.md5ff(b, c, d, a, x[i + 3], 22, -1044525330); a = this.md5ff(a, b, c, d, x[i + 4], 7, -176418897); d = this.md5ff(d, a, b, c, x[i + 5], 12, 1200080426); c = this.md5ff(c, d, a, b, x[i + 6], 17, -1473231341); b = this.md5ff(b, c, d, a, x[i + 7], 22, -45705983); a = this.md5ff(a, b, c, d, x[i + 8], 7, 1770035416); d = this.md5ff(d, a, b, c, x[i + 9], 12, -1958414417); c = this.md5ff(c, d, a, b, x[i + 10], 17, -42063); b = this.md5ff(b, c, d, a, x[i + 11], 22, -1990404162); a = this.md5ff(a, b, c, d, x[i + 12], 7, 1804603682); d = this.md5ff(d, a, b, c, x[i + 13], 12, -40341101); c = this.md5ff(c, d, a, b, x[i + 14], 17, -1502002290); b = this.md5ff(b, c, d, a, x[i + 15], 22, 1236535329); a = this.md5gg(a, b, c, d, x[i + 1], 5, -165796510); d = this.md5gg(d, a, b, c, x[i + 6], 9, -1069501632); c = this.md5gg(c, d, a, b, x[i + 11], 14, 643717713); b = this.md5gg(b, c, d, a, x[i], 20, -373897302); a = this.md5gg(a, b, c, d, x[i + 5], 5, -701558691); d = this.md5gg(d, a, b, c, x[i + 10], 9, 38016083); c = this.md5gg(c, d, a, b, x[i + 15], 14, -660478335); b = this.md5gg(b, c, d, a, x[i + 4], 20, -405537848); a = this.md5gg(a, b, c, d, x[i + 9], 5, 568446438); d = this.md5gg(d, a, b, c, x[i + 14], 9, -1019803690); c = this.md5gg(c, d, a, b, x[i + 3], 14, -187363961); b = this.md5gg(b, c, d, a, x[i + 8], 20, 1163531501); a = this.md5gg(a, b, c, d, x[i + 13], 5, -1444681467); d = this.md5gg(d, a, b, c, x[i + 2], 9, -51403784); c = this.md5gg(c, d, a, b, x[i + 7], 14, 1735328473); b = this.md5gg(b, c, d, a, x[i + 12], 20, -1926607734); a = this.md5hh(a, b, c, d, x[i + 5], 4, -378558); d = this.md5hh(d, a, b, c, x[i + 8], 11, -2022574463); c = this.md5hh(c, d, a, b, x[i + 11], 16, 1839030562); b = this.md5hh(b, c, d, a, x[i + 14], 23, -35309556); a = this.md5hh(a, b, c, d, x[i + 1], 4, -1530992060); d = this.md5hh(d, a, b, c, x[i + 4], 11, 1272893353); c = this.md5hh(c, d, a, b, x[i + 7], 16, -155497632); b = this.md5hh(b, c, d, a, x[i + 10], 23, -1094730640); a = this.md5hh(a, b, c, d, x[i + 13], 4, 681279174); d = this.md5hh(d, a, b, c, x[i], 11, -358537222); c = this.md5hh(c, d, a, b, x[i + 3], 16, -722521979); b = this.md5hh(b, c, d, a, x[i + 6], 23, 76029189); a = this.md5hh(a, b, c, d, x[i + 9], 4, -640364487); d = this.md5hh(d, a, b, c, x[i + 12], 11, -421815835); c = this.md5hh(c, d, a, b, x[i + 15], 16, 530742520); b = this.md5hh(b, c, d, a, x[i + 2], 23, -995338651); a = this.md5ii(a, b, c, d, x[i], 6, -198630844); d = this.md5ii(d, a, b, c, x[i + 7], 10, 1126891415); c = this.md5ii(c, d, a, b, x[i + 14], 15, -1416354905); b = this.md5ii(b, c, d, a, x[i + 5], 21, -57434055); a = this.md5ii(a, b, c, d, x[i + 12], 6, 1700485571); d = this.md5ii(d, a, b, c, x[i + 3], 10, -1894986606); c = this.md5ii(c, d, a, b, x[i + 10], 15, -1051523); b = this.md5ii(b, c, d, a, x[i + 1], 21, -2054922799); a = this.md5ii(a, b, c, d, x[i + 8], 6, 1873313359); d = this.md5ii(d, a, b, c, x[i + 15], 10, -30611744); c = this.md5ii(c, d, a, b, x[i + 6], 15, -1560198380); b = this.md5ii(b, c, d, a, x[i + 13], 21, 1309151649); a = this.md5ii(a, b, c, d, x[i + 4], 6, -145523070); d = this.md5ii(d, a, b, c, x[i + 11], 10, -1120210379); c = this.md5ii(c, d, a, b, x[i + 2], 15, 718787259); b = this.md5ii(b, c, d, a, x[i + 9], 21, -343485551); a = this.safeAdd(a, olda); b = this.safeAdd(b, oldb); c = this.safeAdd(c, oldc); d = this.safeAdd(d, oldd) } return [a, b, c, d] }, binl2rstr(input) { var i; var output = ''; var length32 = input.length * 32; for (i = 0; i < length32; i += 8) { output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xff) } return output }, rstr2binl(input) { var i; var output = []; output[(input.length >> 2) - 1] = undefined; for (i = 0; i < output.length; i += 1) { output[i] = 0 } var length8 = input.length * 8; for (i = 0; i < length8; i += 8) { output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << (i % 32) } return output }, rstrMD5(s) { return this.binl2rstr(this.binlMD5(this.rstr2binl(s), s.length * 8)) }, rstrHMACMD5(key, data) { var i; var bkey = this.rstr2binl(key); var ipad = []; var opad = []; var hash; ipad[15] = opad[15] = undefined; if (bkey.length > 16) { bkey = this.binlMD5(bkey, key.length * 8) } for (i = 0; i < 16; i += 1) { ipad[i] = bkey[i] ^ 0x36363636; opad[i] = bkey[i] ^ 0x5c5c5c5c } hash = this.binlMD5(ipad.concat(this.rstr2binl(data)), 512 + data.length * 8); return this.binl2rstr(this.binlMD5(opad.concat(hash), 512 + 128)) }, rstr2hex(input) { var hexTab = '0123456789abcdef'; var output = ''; var x; var i; for (i = 0; i < input.length; i += 1) { x = input.charCodeAt(i); output += hexTab.charAt((x >>> 4) & 0x0f) + hexTab.charAt(x & 0x0f) } return output }, str2rstrUTF8(input) { return unescape(encodeURIComponent(input)) }, rawMD5(s) { return this.rstrMD5(this.str2rstrUTF8(s)) }, hexMD5(s) { return this.rstr2hex(this.rawMD5(s)) }, rawHMACMD5(k, d) { return this.rstrHMACMD5(this.str2rstrUTF8(k), str2rstrUTF8(d)) }, hexHMACMD5(k, d) { return this.rstr2hex(this.rawHMACMD5(k, d)) }, md5(string, key, raw) { if (!key) { if (!raw) { return this.hexMD5(string) } return this.rawMD5(string) } if (!raw) { return this.hexHMACMD5(key, string) } return this.rawHMACMD5(key, string) }, getSig(requestParam, sk, feature, mode) { var sig = null; var requestArr = []; Object.keys(requestParam).sort().forEach(function (key) { requestArr.push(key + '=' + requestParam[key]) }); if (feature == 'search') { sig = '/ws/place/v1/search?' + requestArr.join('&') + sk } if (feature == 'suggest') { sig = '/ws/place/v1/suggestion?' + requestArr.join('&') + sk } if (feature == 'reverseGeocoder') { sig = '/ws/geocoder/v1/?' + requestArr.join('&') + sk } if (feature == 'geocoder') { sig = '/ws/geocoder/v1/?' + requestArr.join('&') + sk } if (feature == 'getCityList') { sig = '/ws/district/v1/list?' + requestArr.join('&') + sk } if (feature == 'getDistrictByCityId') { sig = '/ws/district/v1/getchildren?' + requestArr.join('&') + sk } if (feature == 'calculateDistance') { sig = '/ws/distance/v1/?' + requestArr.join('&') + sk } if (feature == 'direction') { sig = '/ws/direction/v1/' + mode + '?' + requestArr.join('&') + sk } sig = this.md5(sig); return sig }, location2query(data) { if (typeof data == 'string') { return data } var query = ''; for (var i = 0; i < data.length; i++) { var d = data[i]; if (!!query) { query += ';' } if (d.location) { query = query + d.location.lat + ',' + d.location.lng } if (d.latitude && d.longitude) { query = query + d.latitude + ',' + d.longitude } } return query }, rad(d) { return d * Math.PI / 180.0 }, getEndLocation(location) { var to = location.split(';'); var endLocation = []; for (var i = 0; i < to.length; i++) { endLocation.push({ lat: parseFloat(to[i].split(',')[0]), lng: parseFloat(to[i].split(',')[1]) }) } return endLocation }, getDistance(latFrom, lngFrom, latTo, lngTo) { var radLatFrom = this.rad(latFrom); var radLatTo = this.rad(latTo); var a = radLatFrom - radLatTo; var b = this.rad(lngFrom) - this.rad(lngTo); var distance = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLatFrom) * Math.cos(radLatTo) * Math.pow(Math.sin(b / 2), 2))); distance = distance * EARTH_RADIUS; distance = Math.round(distance * 10000) / 10000; return parseFloat(distance.toFixed(0)) }, getWXLocation(success, fail, complete) { wx.getLocation({ type: 'gcj02', success: success, fail: fail, complete: complete }) }, getLocationParam(location) { if (typeof location == 'string') { var locationArr = location.split(','); if (locationArr.length === 2) { location = { latitude: location.split(',')[0], longitude: location.split(',')[1] } } else { location = {} } } return location }, polyfillParam(param) { param.success = param.success || function () { }; param.fail = param.fail || function () { }; param.complete = param.complete || function () { } }, checkParamKeyEmpty(param, key) { if (!param[key]) { var errconf = this.buildErrorConfig(ERROR_CONF.PARAM_ERR, ERROR_CONF.PARAM_ERR_MSG + key + '参数格式有误'); param.fail(errconf); param.complete(errconf); return true } return false }, checkKeyword(param) { return !this.checkParamKeyEmpty(param, 'keyword') }, checkLocation(param) { var location = this.getLocationParam(param.location); if (!location || !location.latitude || !location.longitude) { var errconf = this.buildErrorConfig(ERROR_CONF.PARAM_ERR, ERROR_CONF.PARAM_ERR_MSG + ' location参数格式有误'); param.fail(errconf); param.complete(errconf); return false } return true }, buildErrorConfig(errCode, errMsg) { return { status: errCode, message: errMsg } }, handleData(param, data, feature) { if (feature == 'search') { var searchResult = data.data; var searchSimplify = []; for (var i = 0; i < searchResult.length; i++) { searchSimplify.push({ id: searchResult[i].id || null, title: searchResult[i].title || null, latitude: searchResult[i].location && searchResult[i].location.lat || null, longitude: searchResult[i].location && searchResult[i].location.lng || null, address: searchResult[i].address || null, category: searchResult[i].category || null, tel: searchResult[i].tel || null, adcode: searchResult[i].ad_info && searchResult[i].ad_info.adcode || null, city: searchResult[i].ad_info && searchResult[i].ad_info.city || null, district: searchResult[i].ad_info && searchResult[i].ad_info.district || null, province: searchResult[i].ad_info && searchResult[i].ad_info.province || null }) } param.success(data, { searchResult: searchResult, searchSimplify: searchSimplify }) } else if (feature == 'suggest') { var suggestResult = data.data; var suggestSimplify = []; for (var i = 0; i < suggestResult.length; i++) { suggestSimplify.push({ adcode: suggestResult[i].adcode || null, address: suggestResult[i].address || null, category: suggestResult[i].category || null, city: suggestResult[i].city || null, district: suggestResult[i].district || null, id: suggestResult[i].id || null, latitude: suggestResult[i].location && suggestResult[i].location.lat || null, longitude: suggestResult[i].location && suggestResult[i].location.lng || null, province: suggestResult[i].province || null, title: suggestResult[i].title || null, type: suggestResult[i].type || null }) } param.success(data, { suggestResult: suggestResult, suggestSimplify: suggestSimplify }) } else if (feature == 'reverseGeocoder') { var reverseGeocoderResult = data.result; var reverseGeocoderSimplify = { address: reverseGeocoderResult.address || null, latitude: reverseGeocoderResult.location && reverseGeocoderResult.location.lat || null, longitude: reverseGeocoderResult.location && reverseGeocoderResult.location.lng || null, adcode: reverseGeocoderResult.ad_info && reverseGeocoderResult.ad_info.adcode || null, city: reverseGeocoderResult.address_component && reverseGeocoderResult.address_component.city || null, district: reverseGeocoderResult.address_component && reverseGeocoderResult.address_component.district || null, nation: reverseGeocoderResult.address_component && reverseGeocoderResult.address_component.nation || null, province: reverseGeocoderResult.address_component && reverseGeocoderResult.address_component.province || null, street: reverseGeocoderResult.address_component && reverseGeocoderResult.address_component.street || null, street_number: reverseGeocoderResult.address_component && reverseGeocoderResult.address_component.street_number || null, recommend: reverseGeocoderResult.formatted_addresses && reverseGeocoderResult.formatted_addresses.recommend || null, rough: reverseGeocoderResult.formatted_addresses && reverseGeocoderResult.formatted_addresses.rough || null }; if (reverseGeocoderResult.pois) { var pois = reverseGeocoderResult.pois; var poisSimplify = []; for (var i = 0; i < pois.length; i++) { poisSimplify.push({ id: pois[i].id || null, title: pois[i].title || null, latitude: pois[i].location && pois[i].location.lat || null, longitude: pois[i].location && pois[i].location.lng || null, address: pois[i].address || null, category: pois[i].category || null, adcode: pois[i].ad_info && pois[i].ad_info.adcode || null, city: pois[i].ad_info && pois[i].ad_info.city || null, district: pois[i].ad_info && pois[i].ad_info.district || null, province: pois[i].ad_info && pois[i].ad_info.province || null }) } param.success(data, { reverseGeocoderResult: reverseGeocoderResult, reverseGeocoderSimplify: reverseGeocoderSimplify, pois: pois, poisSimplify: poisSimplify }) } else { param.success(data, { reverseGeocoderResult: reverseGeocoderResult, reverseGeocoderSimplify: reverseGeocoderSimplify }) } } else if (feature == 'geocoder') { var geocoderResult = data.result; var geocoderSimplify = { title: geocoderResult.title || null, latitude: geocoderResult.location && geocoderResult.location.lat || null, longitude: geocoderResult.location && geocoderResult.location.lng || null, adcode: geocoderResult.ad_info && geocoderResult.ad_info.adcode || null, province: geocoderResult.address_components && geocoderResult.address_components.province || null, city: geocoderResult.address_components && geocoderResult.address_components.city || null, district: geocoderResult.address_components && geocoderResult.address_components.district || null, street: geocoderResult.address_components && geocoderResult.address_components.street || null, street_number: geocoderResult.address_components && geocoderResult.address_components.street_number || null, level: geocoderResult.level || null }; param.success(data, { geocoderResult: geocoderResult, geocoderSimplify: geocoderSimplify }) } else if (feature == 'getCityList') { var provinceResult = data.result[0]; var cityResult = data.result[1]; var districtResult = data.result[2]; param.success(data, { provinceResult: provinceResult, cityResult: cityResult, districtResult: districtResult }) } else if (feature == 'getDistrictByCityId') { var districtByCity = data.result[0]; param.success(data, districtByCity) } else if (feature == 'calculateDistance') { var calculateDistanceResult = data.result.elements; var distance = []; for (var i = 0; i < calculateDistanceResult.length; i++) { distance.push(calculateDistanceResult[i].distance) } param.success(data, { calculateDistanceResult: calculateDistanceResult, distance: distance }) } else if (feature == 'direction') { var direction = data.result.routes; param.success(data, direction) } else { param.success(data) } }, buildWxRequestConfig(param, options, feature) { var that = this; options.header = { "content-type": "application/json" }; options.method = 'GET'; options.success = function (res) { var data = res.data; if (data.status === 0) { that.handleData(param, data, feature) } else { param.fail(data) } }; options.fail = function (res) { res.statusCode = ERROR_CONF.WX_ERR_CODE; param.fail(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)) }; options.complete = function (res) { var statusCode = +res.statusCode; switch (statusCode) { case ERROR_CONF.WX_ERR_CODE: { param.complete(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)); break } case ERROR_CONF.WX_OK_CODE: { var data = res.data; if (data.status === 0) { param.complete(data) } else { param.complete(that.buildErrorConfig(data.status, data.message)) } break } default: { param.complete(that.buildErrorConfig(ERROR_CONF.SYSTEM_ERR, ERROR_CONF.SYSTEM_ERR_MSG)) } } }; return options }, locationProcess(param, locationsuccess, locationfail, locationcomplete) { var that = this; locationfail = locationfail || function (res) { res.statusCode = ERROR_CONF.WX_ERR_CODE; param.fail(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)) }; locationcomplete = locationcomplete || function (res) { if (res.statusCode == ERROR_CONF.WX_ERR_CODE) { param.complete(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)) } }; if (!param.location) { that.getWXLocation(locationsuccess, locationfail, locationcomplete) } else if (that.checkLocation(param)) { var location = Utils.getLocationParam(param.location); locationsuccess(location) } } }; class QQMapWX { constructor(options) { if (!options.key) { throw Error('key值不能为空') } this.key = options.key }; search(options) { var that = this; options = options || {}; Utils.polyfillParam(options); if (!Utils.checkKeyword(options)) { return } var requestParam = { keyword: options.keyword, orderby: options.orderby || '_distance', page_size: options.page_size || 10, page_index: options.page_index || 1, output: 'json', key: that.key }; if (options.address_format) { requestParam.address_format = options.address_format } if (options.filter) { requestParam.filter = options.filter } var distance = options.distance || "1000"; var auto_extend = options.auto_extend || 1; var region = null; var rectangle = null; if (options.region) { region = options.region } if (options.rectangle) { rectangle = options.rectangle } var locationsuccess = function (result) { if (region && !rectangle) { requestParam.boundary = "region(" + region + "," + auto_extend + "," + result.latitude + "," + result.longitude + ")"; if (options.sig) { requestParam.sig = Utils.getSig(requestParam, options.sig, 'search') } } else if (rectangle && !region) { requestParam.boundary = "rectangle(" + rectangle + ")"; if (options.sig) { requestParam.sig = Utils.getSig(requestParam, options.sig, 'search') } } else { requestParam.boundary = "nearby(" + result.latitude + "," + result.longitude + "," + distance + "," + auto_extend + ")"; if (options.sig) { requestParam.sig = Utils.getSig(requestParam, options.sig, 'search') } } wx.request(Utils.buildWxRequestConfig(options, { url: URL_SEARCH, data: requestParam }, 'search')) }; Utils.locationProcess(options, locationsuccess) }; getSuggestion(options) { var that = this; options = options || {}; Utils.polyfillParam(options); if (!Utils.checkKeyword(options)) { return } var requestParam = { keyword: options.keyword, region: options.region || '全国', region_fix: options.region_fix || 0, policy: options.policy || 0, page_size: options.page_size || 10, page_index: options.page_index || 1, get_subpois: options.get_subpois || 0, output: 'json', key: that.key }; if (options.address_format) { requestParam.address_format = options.address_format } if (options.filter) { requestParam.filter = options.filter } if (options.location) { var locationsuccess = function (result) { requestParam.location = result.latitude + ',' + result.longitude; if (options.sig) { requestParam.sig = Utils.getSig(requestParam, options.sig, 'suggest') } wx.request(Utils.buildWxRequestConfig(options, { url: URL_SUGGESTION, data: requestParam }, "suggest")) }; Utils.locationProcess(options, locationsuccess) } else { if (options.sig) { requestParam.sig = Utils.getSig(requestParam, options.sig, 'suggest') } wx.request(Utils.buildWxRequestConfig(options, { url: URL_SUGGESTION, data: requestParam }, "suggest")) } }; reverseGeocoder(options) { var that = this; options = options || {}; Utils.polyfillParam(options); var requestParam = { coord_type: options.coord_type || 5, get_poi: options.get_poi || 0, output: 'json', key: that.key }; if (options.poi_options) { requestParam.poi_options = options.poi_options } var locationsuccess = function (result) { requestParam.location = result.latitude + ',' + result.longitude; if (options.sig) { requestParam.sig = Utils.getSig(requestParam, options.sig, 'reverseGeocoder') } wx.request(Utils.buildWxRequestConfig(options, { url: URL_GET_GEOCODER, data: requestParam }, 'reverseGeocoder')) }; Utils.locationProcess(options, locationsuccess) }; geocoder(options) { var that = this; options = options || {}; Utils.polyfillParam(options); if (Utils.checkParamKeyEmpty(options, 'address')) { return } var requestParam = { address: options.address, output: 'json', key: that.key }; if (options.region) { requestParam.region = options.region } if (options.sig) { requestParam.sig = Utils.getSig(requestParam, options.sig, 'geocoder') } wx.request(Utils.buildWxRequestConfig(options, { url: URL_GET_GEOCODER, data: requestParam }, 'geocoder')) }; getCityList(options) { var that = this; options = options || {}; Utils.polyfillParam(options); var requestParam = { output: 'json', key: that.key }; if (options.sig) { requestParam.sig = Utils.getSig(requestParam, options.sig, 'getCityList') } wx.request(Utils.buildWxRequestConfig(options, { url: URL_CITY_LIST, data: requestParam }, 'getCityList')) }; getDistrictByCityId(options) { var that = this; options = options || {}; Utils.polyfillParam(options); if (Utils.checkParamKeyEmpty(options, 'id')) { return } var requestParam = { id: options.id || '', output: 'json', key: that.key }; if (options.sig) { requestParam.sig = Utils.getSig(requestParam, options.sig, 'getDistrictByCityId') } wx.request(Utils.buildWxRequestConfig(options, { url: URL_AREA_LIST, data: requestParam }, 'getDistrictByCityId')) }; calculateDistance(options) { var that = this; options = options || {}; Utils.polyfillParam(options); if (Utils.checkParamKeyEmpty(options, 'to')) { return } var requestParam = { mode: options.mode || 'walking', to: Utils.location2query(options.to), output: 'json', key: that.key }; if (options.from) { options.location = options.from } if (requestParam.mode == 'straight') { var locationsuccess = function (result) { var locationTo = Utils.getEndLocation(requestParam.to); var data = { message: "query ok", result: { elements: [] }, status: 0 }; for (var i = 0; i < locationTo.length; i++) { data.result.elements.push({ distance: Utils.getDistance(result.latitude, result.longitude, locationTo[i].lat, locationTo[i].lng), duration: 0, from: { lat: result.latitude, lng: result.longitude }, to: { lat: locationTo[i].lat, lng: locationTo[i].lng } }) } var calculateResult = data.result.elements; var distanceResult = []; for (var i = 0; i < calculateResult.length; i++) { distanceResult.push(calculateResult[i].distance) } return options.success(data, { calculateResult: calculateResult, distanceResult: distanceResult }) }; Utils.locationProcess(options, locationsuccess) } else { var locationsuccess = function (result) { requestParam.from = result.latitude + ',' + result.longitude; if (options.sig) { requestParam.sig = Utils.getSig(requestParam, options.sig, 'calculateDistance') } wx.request(Utils.buildWxRequestConfig(options, { url: URL_DISTANCE, data: requestParam }, 'calculateDistance')) }; Utils.locationProcess(options, locationsuccess) } }; direction(options) { var that = this; options = options || {}; Utils.polyfillParam(options); if (Utils.checkParamKeyEmpty(options, 'to')) { return } var requestParam = { output: 'json', key: that.key }; if (typeof options.to == 'string') { requestParam.to = options.to } else { requestParam.to = options.to.latitude + ',' + options.to.longitude } var SET_URL_DIRECTION = null; options.mode = options.mode || MODE.driving; SET_URL_DIRECTION = URL_DIRECTION + options.mode; if (options.from) { options.location = options.from } if (options.mode == MODE.driving) { if (options.from_poi) { requestParam.from_poi = options.from_poi } if (options.heading) { requestParam.heading = options.heading } if (options.speed) { requestParam.speed = options.speed } if (options.accuracy) { requestParam.accuracy = options.accuracy } if (options.road_type) { requestParam.road_type = options.road_type } if (options.to_poi) { requestParam.to_poi = options.to_poi } if (options.from_track) { requestParam.from_track = options.from_track } if (options.waypoints) { requestParam.waypoints = options.waypoints } if (options.policy) { requestParam.policy = options.policy } if (options.plate_number) { requestParam.plate_number = options.plate_number } } if (options.mode == MODE.transit) { if (options.departure_time) { requestParam.departure_time = options.departure_time } if (options.policy) { requestParam.policy = options.policy } } var locationsuccess = function (result) { requestParam.from = result.latitude + ',' + result.longitude; if (options.sig) { requestParam.sig = Utils.getSig(requestParam, options.sig, 'direction', options.mode) } wx.request(Utils.buildWxRequestConfig(options, { url: SET_URL_DIRECTION, data: requestParam }, 'direction')) }; Utils.locationProcess(options, locationsuccess) } }; module.exports = QQMapWX; -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App' 3 | import store from './store/index' 4 | import './styles/index.scss' 5 | Vue.config.productionTip = false 6 | 7 | App.mpType = 'app' 8 | 9 | const app = new Vue({ 10 | ...App, 11 | store 12 | }) 13 | app.$mount() 14 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "uni-map-choose-location", 3 | "appid": "", 4 | "description": "", 5 | "versionName": "1.0.0", 6 | "versionCode": "100", 7 | "transformPx": false, 8 | /* 5+App特有相关 */ 9 | "app-plus": { 10 | "usingComponents": true, 11 | "nvueCompiler": "uni-app", 12 | "compilerVersion": 3, 13 | "splashscreen": { 14 | "alwaysShowBeforeRender": true, 15 | "waiting": true, 16 | "autoclose": true, 17 | "delay": 0 18 | }, 19 | /* 模块配置 */ 20 | "modules": {}, 21 | /* 应用发布信息 */ 22 | "distribute": { 23 | /* android打包配置 */ 24 | "android": { 25 | "permissions": [ 26 | "", 27 | "", 28 | "", 29 | "", 30 | "", 31 | "", 32 | "", 33 | "", 34 | "", 35 | "", 36 | "", 37 | "", 38 | "", 39 | "", 40 | "", 41 | "", 42 | "", 43 | "", 44 | "", 45 | "", 46 | "", 47 | "" 48 | ] 49 | }, 50 | /* ios打包配置 */ 51 | "ios": {}, 52 | /* SDK配置 */ 53 | "sdkConfigs": {} 54 | } 55 | }, 56 | /* 快应用特有相关 */ 57 | "quickapp": {}, 58 | /* 小程序特有相关 */ 59 | "mp-weixin": { 60 | "appid": "", 61 | "setting": { 62 | "urlCheck": false, 63 | "es6": false 64 | }, 65 | "usingComponents": true, 66 | "permission": { 67 | "scope.userLocation": { 68 | "desc": "需要您授权使用位置信息" 69 | } 70 | } 71 | }, 72 | "mp-alipay": { 73 | "usingComponents": true 74 | }, 75 | "mp-baidu": { 76 | "usingComponents": true 77 | }, 78 | "mp-toutiao": { 79 | "usingComponents": true 80 | } 81 | } -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "uni-map-choose-location", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@vant/weapp": { 8 | "version": "1.0.7", 9 | "resolved": "https://registry.npmjs.org/@vant/weapp/-/weapp-1.0.7.tgz", 10 | "integrity": "sha512-F7gkcVKLTh4Pt17ukZnpZmn78CbtfmUtxSZif02ysyXZmqtAf1aAUffL3i1y+qzGWCXF4y/OVkOBVQVrKHI4MA==" 11 | }, 12 | "dayjs": { 13 | "version": "1.8.22", 14 | "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.8.22.tgz", 15 | "integrity": "sha512-N8IXfxBD62Y9cKTuuuSoOlCXRnnzaTj1vu91r855iq6FbY5cZqOZnW/95nUn6kJiR+W9PHHrLykEoQOe6fUKxQ==" 16 | }, 17 | "lodash": { 18 | "version": "4.17.15", 19 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", 20 | "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "uni-map-choose-location", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "main.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "@vant/weapp": "^1.0.7", 13 | "dayjs": "^1.8.22", 14 | "lodash": "^4.17.15" 15 | }, 16 | "standard": { 17 | "globals": { 18 | "wx": false, 19 | "uni": false 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /pages.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | { 4 | "path": "pages/index/index", 5 | "style": { 6 | "navigationBarTitleText": "签到" 7 | } 8 | }, 9 | { 10 | "path": "pages/select/select", 11 | "style": { 12 | "navigationBarTitleText": "位置微调" 13 | } 14 | }, 15 | { 16 | "path": "pages/search/search", 17 | "style": { 18 | "navigationBarTitleText": "搜索" 19 | } 20 | } 21 | ], 22 | "globalStyle": { 23 | "navigationBarTextStyle": "black", 24 | "navigationBarTitleText": "", 25 | "navigationBarBackgroundColor": "#FFFFFF", 26 | "backgroundColor": "#FFFFFF", 27 | "usingComponents": { 28 | "van-button": "/wxcomponents/vant/button/index", 29 | "van-cell": "/wxcomponents/vant/cell/index", 30 | "van-cell-group": "/wxcomponents/vant/cell-group/index", 31 | "van-search": "/wxcomponents/vant/search/index", 32 | "van-icon": "/wxcomponents/vant/icon/index", 33 | "van-field": "/wxcomponents/vant/field/index", 34 | "van-loading": "/wxcomponents/vant/loading/index", 35 | "van-info": "/wxcomponents/vant/info/index" 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /pages/index/index.vue: -------------------------------------------------------------------------------- 1 | 57 | 58 | 175 | 176 | 227 | -------------------------------------------------------------------------------- /pages/search/search.vue: -------------------------------------------------------------------------------- 1 | 36 | 37 | 97 | 98 | 146 | -------------------------------------------------------------------------------- /pages/select/select.vue: -------------------------------------------------------------------------------- 1 | 53 | 54 | 150 | 151 | 244 | -------------------------------------------------------------------------------- /static/images/location.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liub1934/uni-map-choose-location/278866470a7669ce99a47dbe64e9d2412a33f81b/static/images/location.png -------------------------------------------------------------------------------- /store/actions.js: -------------------------------------------------------------------------------- 1 | export default {} 2 | -------------------------------------------------------------------------------- /store/getters.js: -------------------------------------------------------------------------------- 1 | export default { 2 | selectedLocation: state => state.selectedLocation, 3 | selectedSearch: state => state.selectedSearch 4 | } 5 | -------------------------------------------------------------------------------- /store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | 4 | import getters from './getters' 5 | import actions from './actions' 6 | import mutations from './mutations' 7 | import state from './state' 8 | 9 | import Logger from 'vuex/dist/logger' 10 | const debug = process.env.NODE_ENV !== 'production' 11 | 12 | Vue.use(Vuex) 13 | 14 | export default new Vuex.Store({ 15 | getters, 16 | actions, 17 | mutations, 18 | state, 19 | strict: debug, 20 | plugins: debug ? [Logger()] : [] 21 | }) 22 | -------------------------------------------------------------------------------- /store/mutation-types.js: -------------------------------------------------------------------------------- 1 | export const SET_SELECTED_LOCATION = 'SET_SELECTED_LOCATION' 2 | export const SET_SELECTED_SEARCH = 'SET_SELECTED_SEARCH' 3 | -------------------------------------------------------------------------------- /store/mutations.js: -------------------------------------------------------------------------------- 1 | import * as types from './mutation-types' 2 | export default { 3 | [types.SET_SELECTED_LOCATION] (state, data) { 4 | state.selectedLocation = data 5 | }, 6 | [types.SET_SELECTED_SEARCH] (state, data) { 7 | state.selectedSearch = data 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /store/state.js: -------------------------------------------------------------------------------- 1 | export default { 2 | selectedLocation: null, // 已选择的位置信息 3 | selectedSearch: null // 已选择的搜索数据 4 | } 5 | -------------------------------------------------------------------------------- /styles/index.scss: -------------------------------------------------------------------------------- 1 | @import "./vant-theme.scss"; 2 | 3 | page { 4 | height: 100%; 5 | box-sizing: border-box; 6 | padding-bottom: constant(safe-area-inset-bottom); 7 | padding-bottom: env(safe-area-inset-bottom); 8 | } -------------------------------------------------------------------------------- /styles/vant-theme.scss: -------------------------------------------------------------------------------- 1 | page { 2 | --button-primary-background-color: $uni-color-primary; 3 | --button-primary-border-color: $uni-color-primary; 4 | } -------------------------------------------------------------------------------- /uni.scss: -------------------------------------------------------------------------------- 1 | /** 2 | * 这里是uni-app内置的常用样式变量 3 | * 4 | * uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量 5 | * 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App 6 | * 7 | */ 8 | 9 | /** 10 | * 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能 11 | * 12 | * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件 13 | */ 14 | 15 | /* 颜色变量 */ 16 | 17 | /* 行为相关颜色 */ 18 | $uni-color-primary: #007aff; 19 | $uni-color-success: #4cd964; 20 | $uni-color-warning: #f0ad4e; 21 | $uni-color-error: #dd524d; 22 | 23 | /* 文字基本颜色 */ 24 | $uni-text-color:#333;//基本色 25 | $uni-text-color-inverse:#fff;//反色 26 | $uni-text-color-grey:#999;//辅助灰色,如加载更多的提示信息 27 | $uni-text-color-placeholder: #808080; 28 | $uni-text-color-disable:#c0c0c0; 29 | 30 | /* 背景颜色 */ 31 | $uni-bg-color:#ffffff; 32 | $uni-bg-color-grey:#f8f8f8; 33 | $uni-bg-color-hover:#f1f1f1;//点击状态颜色 34 | $uni-bg-color-mask:rgba(0, 0, 0, 0.4);//遮罩颜色 35 | 36 | /* 边框颜色 */ 37 | $uni-border-color:#c8c7cc; 38 | 39 | /* 尺寸变量 */ 40 | 41 | /* 文字尺寸 */ 42 | $uni-font-size-sm:24upx; 43 | $uni-font-size-base:28upx; 44 | $uni-font-size-lg:32upx; 45 | 46 | /* 图片尺寸 */ 47 | $uni-img-size-sm:40upx; 48 | $uni-img-size-base:52upx; 49 | $uni-img-size-lg:80upx; 50 | 51 | /* Border Radius */ 52 | $uni-border-radius-sm: 4upx; 53 | $uni-border-radius-base: 6upx; 54 | $uni-border-radius-lg: 12upx; 55 | $uni-border-radius-circle: 50%; 56 | 57 | /* 水平间距 */ 58 | $uni-spacing-row-sm: 10px; 59 | $uni-spacing-row-base: 20upx; 60 | $uni-spacing-row-lg: 30upx; 61 | 62 | /* 垂直间距 */ 63 | $uni-spacing-col-sm: 8upx; 64 | $uni-spacing-col-base: 16upx; 65 | $uni-spacing-col-lg: 24upx; 66 | 67 | /* 透明度 */ 68 | $uni-opacity-disabled: 0.3; // 组件禁用态的透明度 69 | 70 | /* 文章场景相关 */ 71 | $uni-color-title: #2C405A; // 文章标题颜色 72 | $uni-font-size-title:40upx; 73 | $uni-color-subtitle: #555555; // 二级标题颜色 74 | $uni-font-size-subtitle:36upx; 75 | $uni-color-paragraph: #3F536E; // 文章段落颜色 76 | $uni-font-size-paragraph:30upx; -------------------------------------------------------------------------------- /utils/index.js: -------------------------------------------------------------------------------- 1 | import dayjs from 'dayjs' 2 | import { MAP_KEY } from '@/config' 3 | 4 | const QQMapWX = require('@/lib/qqmap-wx-jssdk.min.js') 5 | const qqmapsdk = new QQMapWX({ 6 | key: MAP_KEY 7 | }) 8 | 9 | /** 10 | * dayjs格式化日期 11 | * 12 | * @export 13 | * @param {*} date 日期 14 | * @param {string} [fmt='YYYY-MM-DD'] 日期格式,详细参考:https://github.com/iamkun/dayjs/blob/dev/docs/zh-cn/API-reference.md#%E6%A0%BC%E5%BC%8F%E5%8C%96 15 | * @returns 16 | */ 17 | export function formatDate (date, fmt = 'YYYY-MM-DD') { 18 | return dayjs(date).format(fmt) 19 | } 20 | 21 | /** 22 | * 逆地址解析(坐标转具体位置信息) 23 | * @doc 文档参考:https://lbs.qq.com/qqmap_wx_jssdk/method-reverseGeocoder.html 24 | * @export 25 | * @param {*} location 坐标:{ latitude: 39.984060, longitude: 116.307520 } 26 | * @returns 27 | */ 28 | export function reverseGeocoder (location) { 29 | return new Promise((resolve, reject) => { 30 | qqmapsdk.reverseGeocoder({ 31 | location: location, 32 | get_poi: 1, 33 | poi_options: 'policy=1;page_size=20;page_index=1', 34 | success: res => { 35 | resolve(res) 36 | }, 37 | fail: err => { 38 | reject(err) 39 | uni.showToast({ 40 | title: err.message, 41 | icon: 'none', 42 | duration: 3000 43 | }) 44 | } 45 | }) 46 | }) 47 | } 48 | 49 | /** 50 | * 地图关键词搜索 51 | * @doc 文档参考:https://lbs.qq.com/qqmap_wx_jssdk/method-search.html 52 | * @export 53 | * @param {*} keyword 搜索关键词 54 | * @param {*} location 坐标:{ latitude: 39.984060, longitude: 116.307520 } 55 | * @returns 56 | */ 57 | export function mapSearch (keyword, location) { 58 | return new Promise((resolve, reject) => { 59 | qqmapsdk.search({ 60 | keyword: keyword, 61 | location: location, 62 | page_size: 20, 63 | auto_extend: 0, 64 | success: res => { 65 | resolve(res) 66 | }, 67 | fail: err => { 68 | reject(err) 69 | uni.showToast({ 70 | title: err.message, 71 | icon: 'none', 72 | duration: 3000 73 | }) 74 | } 75 | }) 76 | }) 77 | } 78 | 79 | /** 80 | * 授权请求 81 | * 82 | * @export 83 | * @param {*} authorizeScope 更多scope参考:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html 84 | * @param {*} modal modal弹窗参数信息 85 | * @returns 86 | */ 87 | export function setAuthorize (authorizeScope, modal) { 88 | return new Promise((resolve, reject) => { 89 | if (!modal) { 90 | modal = { 91 | title: '授权', 92 | content: '需要您设置授权已使用相应功能', 93 | confirmText: '设置' 94 | } 95 | } 96 | uni.getSetting({ 97 | success (res) { 98 | // hasAuthor === undefined 表示 初始化进入,从未授权 99 | // hasAuthor === true 表示 已授权 100 | // hasAuthor === false 表示 授权拒绝 101 | const hasAuthor = res.authSetting[authorizeScope] 102 | switch (hasAuthor) { 103 | case undefined: 104 | uni.authorize({ 105 | scope: authorizeScope, 106 | success: res => { 107 | resolve(res) 108 | }, 109 | fail: err => { 110 | uni.showToast({ 111 | title: '授权失败', 112 | icon: 'none', 113 | duration: 3000 114 | }) 115 | reject(err) 116 | } 117 | }) 118 | break 119 | case true: 120 | resolve() 121 | break 122 | case false: 123 | uni.showModal({ 124 | ...modal, 125 | success: res => { 126 | if (res.confirm) { 127 | uni.openSetting({ 128 | success: res => { 129 | if (res.authSetting[authorizeScope]) { 130 | resolve(res) 131 | } else { 132 | reject(res) 133 | uni.showToast({ 134 | title: '授权失败', 135 | icon: 'none', 136 | duration: 3000 137 | }) 138 | } 139 | }, 140 | fail: err => { 141 | reject(err) 142 | uni.showToast({ 143 | title: '打开设置异常', 144 | icon: 'none', 145 | duration: 3000 146 | }) 147 | } 148 | }) 149 | } else { 150 | reject(res) 151 | uni.showToast({ 152 | title: '授权失败', 153 | icon: 'none', 154 | duration: 3000 155 | }) 156 | } 157 | }, 158 | fail: err => { 159 | reject(err) 160 | uni.showToast({ 161 | title: '弹窗异常', 162 | icon: 'none', 163 | duration: 3000 164 | }) 165 | } 166 | }) 167 | break 168 | } 169 | }, 170 | fail: err => { 171 | reject(err) 172 | uni.showToast({ 173 | title: '获取当前设置异常', 174 | icon: 'none', 175 | duration: 3000 176 | }) 177 | } 178 | }) 179 | }) 180 | } 181 | 182 | /** 183 | * 获取用户当前位置信息 184 | * 185 | * @export 186 | */ 187 | export function getLocation () { 188 | return new Promise((resolve, reject) => { 189 | const scope = 'scope.userLocation' 190 | const modal = { 191 | title: '授权', 192 | content: '需要您授权使用位置信息', 193 | confirmText: '设置' 194 | } 195 | setAuthorize(scope, modal) 196 | .then(() => { 197 | uni.getLocation({ 198 | altitude: true, 199 | success: res => { 200 | resolve(res) 201 | }, 202 | fail: err => { 203 | reject(err) 204 | uni.showToast({ 205 | title: '获取位置信息失败', 206 | icon: 'none', 207 | duration: 3000 208 | }) 209 | } 210 | }) 211 | }) 212 | .catch(err => { 213 | reject(err) 214 | }) 215 | }) 216 | } 217 | -------------------------------------------------------------------------------- /wxcomponents/vant/button/index.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /wxcomponents/vant/button/index.js: -------------------------------------------------------------------------------- 1 | import { VantComponent } from '../common/component'; 2 | import { button } from '../mixins/button'; 3 | import { openType } from '../mixins/open-type'; 4 | VantComponent({ 5 | mixins: [button, openType], 6 | classes: ['hover-class', 'loading-class'], 7 | data: { 8 | baseStyle: '' 9 | }, 10 | props: { 11 | icon: String, 12 | plain: Boolean, 13 | block: Boolean, 14 | round: Boolean, 15 | square: Boolean, 16 | loading: Boolean, 17 | hairline: Boolean, 18 | disabled: Boolean, 19 | loadingText: String, 20 | customStyle: String, 21 | loadingType: { 22 | type: String, 23 | value: 'circular' 24 | }, 25 | type: { 26 | type: String, 27 | value: 'default' 28 | }, 29 | size: { 30 | type: String, 31 | value: 'normal' 32 | }, 33 | loadingSize: { 34 | type: String, 35 | value: '20px' 36 | }, 37 | color: { 38 | type: String, 39 | observer(color) { 40 | let style = ''; 41 | if (color) { 42 | style += `color: ${this.data.plain ? color : 'white'};`; 43 | if (!this.data.plain) { 44 | // Use background instead of backgroundColor to make linear-gradient work 45 | style += `background: ${color};`; 46 | } 47 | // hide border when color is linear-gradient 48 | if (color.indexOf('gradient') !== -1) { 49 | style += 'border: 0;'; 50 | } 51 | else { 52 | style += `border-color: ${color};`; 53 | } 54 | } 55 | if (style !== this.data.baseStyle) { 56 | this.setData({ baseStyle: style }); 57 | } 58 | } 59 | } 60 | }, 61 | methods: { 62 | onClick() { 63 | if (!this.data.disabled && !this.data.loading) { 64 | this.$emit('click'); 65 | } 66 | } 67 | } 68 | }); 69 | -------------------------------------------------------------------------------- /wxcomponents/vant/button/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": { 4 | "van-icon": "../icon/index", 5 | "van-loading": "../loading/index" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /wxcomponents/vant/button/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 53 | 54 | 55 | 56 | function get(type, color,plain) { 57 | if(plain) { 58 | return color ? color: '#c9c9c9'; 59 | } 60 | 61 | if(type === 'default') { 62 | return '#c9c9c9'; 63 | } 64 | return 'white'; 65 | } 66 | 67 | module.exports = get; 68 | 69 | -------------------------------------------------------------------------------- /wxcomponents/vant/button/index.wxss: -------------------------------------------------------------------------------- 1 | @import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0} -------------------------------------------------------------------------------- /wxcomponents/vant/cell-group/index.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /wxcomponents/vant/cell-group/index.js: -------------------------------------------------------------------------------- 1 | import { VantComponent } from '../common/component'; 2 | VantComponent({ 3 | props: { 4 | title: String, 5 | border: { 6 | type: Boolean, 7 | value: true 8 | } 9 | } 10 | }); 11 | -------------------------------------------------------------------------------- /wxcomponents/vant/cell-group/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } -------------------------------------------------------------------------------- /wxcomponents/vant/cell-group/index.wxml: -------------------------------------------------------------------------------- 1 | 5 | {{ title }} 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /wxcomponents/vant/cell-group/index.wxss: -------------------------------------------------------------------------------- 1 | @import '../common/index.wxss';.van-cell-group__title{padding:16px 16px 8px;padding:var(--cell-group-title-padding,16px 16px 8px);font-size:14px;font-size:var(--cell-group-title-font-size,14px);line-height:16px;line-height:var(--cell-group-title-line-height,16px);color:#969799;color:var(--cell-group-title-color,#969799)} -------------------------------------------------------------------------------- /wxcomponents/vant/cell/index.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /wxcomponents/vant/cell/index.js: -------------------------------------------------------------------------------- 1 | import { link } from '../mixins/link'; 2 | import { VantComponent } from '../common/component'; 3 | VantComponent({ 4 | classes: [ 5 | 'title-class', 6 | 'label-class', 7 | 'value-class', 8 | 'right-icon-class', 9 | 'hover-class' 10 | ], 11 | mixins: [link], 12 | props: { 13 | title: null, 14 | value: null, 15 | icon: String, 16 | size: String, 17 | label: String, 18 | center: Boolean, 19 | isLink: Boolean, 20 | required: Boolean, 21 | clickable: Boolean, 22 | titleWidth: String, 23 | customStyle: String, 24 | arrowDirection: String, 25 | useLabelSlot: Boolean, 26 | border: { 27 | type: Boolean, 28 | value: true 29 | } 30 | }, 31 | methods: { 32 | onClick(event) { 33 | this.$emit('click', event.detail); 34 | this.jumpLink(); 35 | } 36 | } 37 | }); 38 | -------------------------------------------------------------------------------- /wxcomponents/vant/cell/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": { 4 | "van-icon": "../icon/index" 5 | } 6 | } -------------------------------------------------------------------------------- /wxcomponents/vant/cell/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 16 | 17 | 18 | 22 | {{ title }} 23 | 24 | 25 | 26 | 27 | {{ label }} 28 | 29 | 30 | 31 | 32 | {{ value }} 33 | 34 | 35 | 36 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /wxcomponents/vant/cell/index.wxss: -------------------------------------------------------------------------------- 1 | @import '../common/index.wxss';.van-cell{position:relative;display:-webkit-flex;display:flex;box-sizing:border-box;width:100%;padding:10px 16px;padding:var(--cell-vertical-padding,10px) var(--cell-horizontal-padding,16px);font-size:14px;font-size:var(--cell-font-size,14px);line-height:24px;line-height:var(--cell-line-height,24px);color:#323233;color:var(--cell-text-color,#323233);background-color:#fff;background-color:var(--cell-background-color,#fff)}.van-cell:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:auto;right:0;bottom:0;left:16px;border-bottom:1px solid #ebedf0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-cell--borderless:after{display:none}.van-cell-group{background-color:#fff;background-color:var(--cell-background-color,#fff)}.van-cell__label{margin-top:3px;margin-top:var(--cell-label-margin-top,3px);font-size:12px;font-size:var(--cell-label-font-size,12px);line-height:18px;line-height:var(--cell-label-line-height,18px);color:#969799;color:var(--cell-label-color,#969799)}.van-cell__value{overflow:hidden;text-align:right;vertical-align:middle;color:#969799;color:var(--cell-value-color,#969799)}.van-cell__title,.van-cell__value{-webkit-flex:1;flex:1}.van-cell__title:empty,.van-cell__value:empty{display:none}.van-cell__left-icon-wrap,.van-cell__right-icon-wrap{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;height:24px;height:var(--cell-line-height,24px);font-size:16px;font-size:var(--cell-icon-size,16px)}.van-cell__left-icon-wrap{margin-right:5px}.van-cell__right-icon-wrap{margin-left:5px;color:#969799;color:var(--cell-right-icon-color,#969799)}.van-cell__left-icon{vertical-align:middle}.van-cell__left-icon,.van-cell__right-icon{line-height:24px;line-height:var(--cell-line-height,24px)}.van-cell--clickable.van-cell--hover{background-color:#f2f3f5;background-color:var(--cell-active-color,#f2f3f5)}.van-cell--required{overflow:visible}.van-cell--required:before{position:absolute;content:"*";left:8px;left:var(--padding-xs,8px);font-size:14px;font-size:var(--cell-font-size,14px);color:#ee0a24;color:var(--cell-required-color,#ee0a24)}.van-cell--center{-webkit-align-items:center;align-items:center}.van-cell--large{padding-top:12px;padding-top:var(--cell-large-vertical-padding,12px);padding-bottom:12px;padding-bottom:var(--cell-large-vertical-padding,12px)}.van-cell--large .van-cell__title{font-size:16px;font-size:var(--cell-large-title-font-size,16px)}.van-cell--large .van-cell__label{font-size:14px;font-size:var(--cell-large-label-font-size,14px)} -------------------------------------------------------------------------------- /wxcomponents/vant/common/color.d.ts: -------------------------------------------------------------------------------- 1 | export declare const RED = "#ee0a24"; 2 | export declare const BLUE = "#1989fa"; 3 | export declare const WHITE = "#fff"; 4 | export declare const GREEN = "#07c160"; 5 | export declare const ORANGE = "#ff976a"; 6 | export declare const GRAY = "#323233"; 7 | export declare const GRAY_DARK = "#969799"; 8 | -------------------------------------------------------------------------------- /wxcomponents/vant/common/color.js: -------------------------------------------------------------------------------- 1 | export const RED = '#ee0a24'; 2 | export const BLUE = '#1989fa'; 3 | export const WHITE = '#fff'; 4 | export const GREEN = '#07c160'; 5 | export const ORANGE = '#ff976a'; 6 | export const GRAY = '#323233'; 7 | export const GRAY_DARK = '#969799'; 8 | -------------------------------------------------------------------------------- /wxcomponents/vant/common/component.d.ts: -------------------------------------------------------------------------------- 1 | import { VantComponentOptions, CombinedComponentInstance } from '../definitions/index'; 2 | declare function VantComponent(vantOptions?: VantComponentOptions>): void; 3 | export { VantComponent }; 4 | -------------------------------------------------------------------------------- /wxcomponents/vant/common/component.js: -------------------------------------------------------------------------------- 1 | import { basic } from '../mixins/basic'; 2 | function mapKeys(source, target, map) { 3 | Object.keys(map).forEach(key => { 4 | if (source[key]) { 5 | target[map[key]] = source[key]; 6 | } 7 | }); 8 | } 9 | function VantComponent(vantOptions = {}) { 10 | const options = {}; 11 | mapKeys(vantOptions, options, { 12 | data: 'data', 13 | props: 'properties', 14 | mixins: 'behaviors', 15 | methods: 'methods', 16 | beforeCreate: 'created', 17 | created: 'attached', 18 | mounted: 'ready', 19 | relations: 'relations', 20 | destroyed: 'detached', 21 | classes: 'externalClasses' 22 | }); 23 | const { relation } = vantOptions; 24 | if (relation) { 25 | options.relations = Object.assign(options.relations || {}, { 26 | [`../${relation.name}/index`]: relation 27 | }); 28 | } 29 | // add default externalClasses 30 | options.externalClasses = options.externalClasses || []; 31 | options.externalClasses.push('custom-class'); 32 | // add default behaviors 33 | options.behaviors = options.behaviors || []; 34 | options.behaviors.push(basic); 35 | // map field to form-field behavior 36 | if (vantOptions.field) { 37 | options.behaviors.push('wx://form-field'); 38 | } 39 | // add default options 40 | options.options = { 41 | multipleSlots: true, 42 | addGlobalClass: true 43 | }; 44 | Component(options); 45 | } 46 | export { VantComponent }; 47 | -------------------------------------------------------------------------------- /wxcomponents/vant/common/index.wxss: -------------------------------------------------------------------------------- 1 | .van-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{display:-webkit-box;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3}.van-clearfix:after{display:table;clear:both;content:""}.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:-50%;right:-50%;bottom:-50%;left:-50%;border:0 solid #eee;-webkit-transform:scale(.5);transform:scale(.5)}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px} -------------------------------------------------------------------------------- /wxcomponents/vant/common/style/clearfix.wxss: -------------------------------------------------------------------------------- 1 | .van-clearfix:after{display:table;clear:both;content:""} -------------------------------------------------------------------------------- /wxcomponents/vant/common/style/ellipsis.wxss: -------------------------------------------------------------------------------- 1 | .van-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{display:-webkit-box;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3} -------------------------------------------------------------------------------- /wxcomponents/vant/common/style/hairline.wxss: -------------------------------------------------------------------------------- 1 | .van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:-50%;right:-50%;bottom:-50%;left:-50%;border:0 solid #eee;-webkit-transform:scale(.5);transform:scale(.5)}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px} -------------------------------------------------------------------------------- /wxcomponents/vant/common/style/mixins/clearfix.wxss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liub1934/uni-map-choose-location/278866470a7669ce99a47dbe64e9d2412a33f81b/wxcomponents/vant/common/style/mixins/clearfix.wxss -------------------------------------------------------------------------------- /wxcomponents/vant/common/style/mixins/ellipsis.wxss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liub1934/uni-map-choose-location/278866470a7669ce99a47dbe64e9d2412a33f81b/wxcomponents/vant/common/style/mixins/ellipsis.wxss -------------------------------------------------------------------------------- /wxcomponents/vant/common/style/mixins/hairline.wxss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liub1934/uni-map-choose-location/278866470a7669ce99a47dbe64e9d2412a33f81b/wxcomponents/vant/common/style/mixins/hairline.wxss -------------------------------------------------------------------------------- /wxcomponents/vant/common/style/theme.wxss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liub1934/uni-map-choose-location/278866470a7669ce99a47dbe64e9d2412a33f81b/wxcomponents/vant/common/style/theme.wxss -------------------------------------------------------------------------------- /wxcomponents/vant/common/style/var.wxss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liub1934/uni-map-choose-location/278866470a7669ce99a47dbe64e9d2412a33f81b/wxcomponents/vant/common/style/var.wxss -------------------------------------------------------------------------------- /wxcomponents/vant/common/utils.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | export declare function isDef(value: any): boolean; 3 | export declare function isObj(x: any): boolean; 4 | export declare function isNumber(value: any): boolean; 5 | export declare function range(num: number, min: number, max: number): number; 6 | export declare function nextTick(fn: Function): void; 7 | export declare function getSystemInfoSync(): WechatMiniprogram.GetSystemInfoSuccessCallbackResult; 8 | export declare function addUnit(value?: string | number): string | undefined; 9 | -------------------------------------------------------------------------------- /wxcomponents/vant/common/utils.js: -------------------------------------------------------------------------------- 1 | export function isDef(value) { 2 | return value !== undefined && value !== null; 3 | } 4 | export function isObj(x) { 5 | const type = typeof x; 6 | return x !== null && (type === 'object' || type === 'function'); 7 | } 8 | export function isNumber(value) { 9 | return /^\d+(\.\d+)?$/.test(value); 10 | } 11 | export function range(num, min, max) { 12 | return Math.min(Math.max(num, min), max); 13 | } 14 | export function nextTick(fn) { 15 | setTimeout(() => { 16 | fn(); 17 | }, 1000 / 30); 18 | } 19 | let systemInfo = null; 20 | export function getSystemInfoSync() { 21 | if (systemInfo == null) { 22 | systemInfo = wx.getSystemInfoSync(); 23 | } 24 | return systemInfo; 25 | } 26 | export function addUnit(value) { 27 | if (!isDef(value)) { 28 | return undefined; 29 | } 30 | value = String(value); 31 | return isNumber(value) ? `${value}px` : value; 32 | } 33 | -------------------------------------------------------------------------------- /wxcomponents/vant/field/index.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /wxcomponents/vant/field/index.js: -------------------------------------------------------------------------------- 1 | import { VantComponent } from '../common/component'; 2 | import { getSystemInfoSync } from '../common/utils'; 3 | VantComponent({ 4 | field: true, 5 | classes: ['input-class', 'right-icon-class'], 6 | props: { 7 | size: String, 8 | icon: String, 9 | label: String, 10 | error: Boolean, 11 | fixed: Boolean, 12 | focus: Boolean, 13 | center: Boolean, 14 | isLink: Boolean, 15 | leftIcon: String, 16 | rightIcon: String, 17 | disabled: Boolean, 18 | autosize: Boolean, 19 | readonly: Boolean, 20 | required: Boolean, 21 | password: Boolean, 22 | iconClass: String, 23 | clearable: Boolean, 24 | clickable: Boolean, 25 | inputAlign: String, 26 | placeholder: String, 27 | customStyle: String, 28 | confirmType: String, 29 | confirmHold: Boolean, 30 | holdKeyboard: Boolean, 31 | errorMessage: String, 32 | arrowDirection: String, 33 | placeholderStyle: String, 34 | errorMessageAlign: String, 35 | selectionEnd: { 36 | type: Number, 37 | value: -1 38 | }, 39 | selectionStart: { 40 | type: Number, 41 | value: -1 42 | }, 43 | showConfirmBar: { 44 | type: Boolean, 45 | value: true 46 | }, 47 | adjustPosition: { 48 | type: Boolean, 49 | value: true 50 | }, 51 | cursorSpacing: { 52 | type: Number, 53 | value: 50 54 | }, 55 | maxlength: { 56 | type: Number, 57 | value: -1 58 | }, 59 | type: { 60 | type: String, 61 | value: 'text' 62 | }, 63 | border: { 64 | type: Boolean, 65 | value: true 66 | }, 67 | titleWidth: { 68 | type: String, 69 | value: '90px' 70 | } 71 | }, 72 | data: { 73 | focused: false, 74 | system: getSystemInfoSync().system.split(' ').shift().toLowerCase() 75 | }, 76 | methods: { 77 | onInput(event) { 78 | const { value = '' } = event.detail || {}; 79 | this.setData({ value }); 80 | wx.nextTick(() => { 81 | this.emitChange(value); 82 | }); 83 | }, 84 | onFocus(event) { 85 | this.setData({ focused: true }); 86 | this.$emit('focus', event.detail); 87 | }, 88 | onBlur(event) { 89 | this.setData({ focused: false }); 90 | this.$emit('blur', event.detail); 91 | }, 92 | onClickIcon() { 93 | this.$emit('click-icon'); 94 | }, 95 | onClear() { 96 | this.setData({ value: '' }); 97 | wx.nextTick(() => { 98 | this.emitChange(''); 99 | this.$emit('clear', ''); 100 | }); 101 | }, 102 | onConfirm() { 103 | this.$emit('confirm', this.data.value); 104 | }, 105 | emitChange(value) { 106 | this.$emit('input', value); 107 | this.$emit('change', value); 108 | }, 109 | noop() { } 110 | } 111 | }); 112 | -------------------------------------------------------------------------------- /wxcomponents/vant/field/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": { 4 | "van-cell": "../cell/index", 5 | "van-icon": "../icon/index" 6 | } 7 | } -------------------------------------------------------------------------------- /wxcomponents/vant/field/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 19 | 20 | 44 | 68 | 75 | 76 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | {{ errorMessage }} 92 | 93 | 94 | -------------------------------------------------------------------------------- /wxcomponents/vant/field/index.wxss: -------------------------------------------------------------------------------- 1 | @import '../common/index.wxss';.van-field__body{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center}.van-field__body--textarea{line-height:1.2em;min-height:24px;min-height:var(--cell-line-height,24px)}.van-field__body--textarea.van-field__body--ios{margin-top:-4.5px}.van-field__input{position:relative;display:block;box-sizing:border-box;width:100%;margin:0;padding:0;line-height:inherit;text-align:left;background-color:initial;border:0;resize:none;color:#323233;color:var(--field-input-text-color,#323233);height:24px;height:var(--cell-line-height,24px);min-height:24px;min-height:var(--cell-line-height,24px)}.van-field__input--textarea{height:18px;height:var(--field-text-area-min-height,18px);min-height:18px;min-height:var(--field-text-area-min-height,18px)}.van-field__input--error{color:#ee0a24;color:var(--field-input-error-text-color,#ee0a24)}.van-field__input--disabled{background-color:initial;opacity:1;color:#969799;color:var(--field-input-disabled-text-color,#969799)}.van-field__input--center{text-align:center}.van-field__input--right{text-align:right}.van-field__placeholder{position:absolute;top:0;right:0;left:0;pointer-events:none;color:#969799;color:var(--field-placeholder-text-color,#969799)}.van-field__placeholder--error{color:#ee0a24;color:var(--field-error-message-color,#ee0a24)}.van-field__icon-root{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;min-height:24px;min-height:var(--cell-line-height,24px)}.van-field__clear-root,.van-field__icon-container{line-height:inherit;vertical-align:middle;padding:0 8px;padding:0 var(--padding-xs,8px);margin-right:-8px;margin-right:-var(--padding-xs,8px)}.van-field__button,.van-field__clear-root,.van-field__icon-container{-webkit-flex-shrink:0;flex-shrink:0}.van-field__clear-root{color:#c8c9cc;color:var(--field-clear-icon-color,#c8c9cc)}.van-field__icon-container{color:#969799;color:var(--field-icon-container-color,#969799)}.van-field__icon-container:empty{display:none}.van-field__button{padding-left:8px;padding-left:var(--padding-xs,8px)}.van-field__button:empty{display:none}.van-field__error-message{text-align:left;font-size:12px;font-size:var(--field-error-message-text-font-size,12px);color:#ee0a24;color:var(--field-error-message-color,#ee0a24)}.van-field__error-message--center{text-align:center}.van-field__error-message--right{text-align:right} -------------------------------------------------------------------------------- /wxcomponents/vant/icon/index.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /wxcomponents/vant/icon/index.js: -------------------------------------------------------------------------------- 1 | import { VantComponent } from '../common/component'; 2 | VantComponent({ 3 | props: { 4 | dot: Boolean, 5 | info: null, 6 | size: null, 7 | color: String, 8 | customStyle: String, 9 | classPrefix: { 10 | type: String, 11 | value: 'van-icon' 12 | }, 13 | name: { 14 | type: String, 15 | observer(val) { 16 | this.setData({ 17 | isImageName: val.indexOf('/') !== -1 18 | }); 19 | } 20 | } 21 | }, 22 | methods: { 23 | onClick() { 24 | this.$emit('click'); 25 | } 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /wxcomponents/vant/icon/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": { 4 | "van-info": "../info/index" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /wxcomponents/vant/icon/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 14 | 20 | 21 | -------------------------------------------------------------------------------- /wxcomponents/vant/icon/index.wxss: -------------------------------------------------------------------------------- 1 | @import '../common/index.wxss';@font-face{font-weight:400;font-family:vant-icon;font-style:normal;font-display:auto;src:url(https://img.yzcdn.cn/vant/vant-icon-d3825a.woff2) format("woff2"),url(https://img.yzcdn.cn/vant/vant-icon-d3825a.woff) format("woff"),url(https://img.yzcdn.cn/vant/vant-icon-d3825a.ttf) format("truetype")}.van-icon{position:relative;font:normal normal normal 14px/1 vant-icon;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased}.van-icon,.van-icon:before{display:inline-block}.van-icon-add-o:before{content:"\F000"}.van-icon-add-square:before{content:"\F001"}.van-icon-add:before{content:"\F002"}.van-icon-after-sale:before{content:"\F003"}.van-icon-aim:before{content:"\F004"}.van-icon-alipay:before{content:"\F005"}.van-icon-apps-o:before{content:"\F006"}.van-icon-arrow-down:before{content:"\F007"}.van-icon-arrow-left:before{content:"\F008"}.van-icon-arrow-up:before{content:"\F009"}.van-icon-arrow:before{content:"\F00A"}.van-icon-ascending:before{content:"\F00B"}.van-icon-audio:before{content:"\F00C"}.van-icon-award-o:before{content:"\F00D"}.van-icon-award:before{content:"\F00E"}.van-icon-bag-o:before{content:"\F00F"}.van-icon-bag:before{content:"\F010"}.van-icon-balance-list-o:before{content:"\F011"}.van-icon-balance-list:before{content:"\F012"}.van-icon-balance-o:before{content:"\F013"}.van-icon-balance-pay:before{content:"\F014"}.van-icon-bar-chart-o:before{content:"\F015"}.van-icon-bars:before{content:"\F016"}.van-icon-bell:before{content:"\F017"}.van-icon-bill-o:before{content:"\F018"}.van-icon-bill:before{content:"\F019"}.van-icon-birthday-cake-o:before{content:"\F01A"}.van-icon-bookmark-o:before{content:"\F01B"}.van-icon-bookmark:before{content:"\F01C"}.van-icon-browsing-history-o:before{content:"\F01D"}.van-icon-browsing-history:before{content:"\F01E"}.van-icon-brush-o:before{content:"\F01F"}.van-icon-bulb-o:before{content:"\F020"}.van-icon-bullhorn-o:before{content:"\F021"}.van-icon-calender-o:before{content:"\F022"}.van-icon-card:before{content:"\F023"}.van-icon-cart-circle-o:before{content:"\F024"}.van-icon-cart-circle:before{content:"\F025"}.van-icon-cart-o:before{content:"\F026"}.van-icon-cart:before{content:"\F027"}.van-icon-cash-back-record:before{content:"\F028"}.van-icon-cash-on-deliver:before{content:"\F029"}.van-icon-cashier-o:before{content:"\F02A"}.van-icon-certificate:before{content:"\F02B"}.van-icon-chart-trending-o:before{content:"\F02C"}.van-icon-chat-o:before{content:"\F02D"}.van-icon-chat:before{content:"\F02E"}.van-icon-checked:before{content:"\F02F"}.van-icon-circle:before{content:"\F030"}.van-icon-clear:before{content:"\F031"}.van-icon-clock-o:before{content:"\F032"}.van-icon-clock:before{content:"\F033"}.van-icon-close:before{content:"\F034"}.van-icon-closed-eye:before{content:"\F035"}.van-icon-cluster-o:before{content:"\F036"}.van-icon-cluster:before{content:"\F037"}.van-icon-column:before{content:"\F038"}.van-icon-comment-circle-o:before{content:"\F039"}.van-icon-comment-circle:before{content:"\F03A"}.van-icon-comment-o:before{content:"\F03B"}.van-icon-comment:before{content:"\F03C"}.van-icon-completed:before{content:"\F03D"}.van-icon-contact:before{content:"\F03E"}.van-icon-coupon-o:before{content:"\F03F"}.van-icon-coupon:before{content:"\F040"}.van-icon-credit-pay:before{content:"\F041"}.van-icon-cross:before{content:"\F042"}.van-icon-debit-pay:before{content:"\F043"}.van-icon-delete:before{content:"\F044"}.van-icon-descending:before{content:"\F045"}.van-icon-description:before{content:"\F046"}.van-icon-desktop-o:before{content:"\F047"}.van-icon-diamond-o:before{content:"\F048"}.van-icon-diamond:before{content:"\F049"}.van-icon-discount:before{content:"\F04A"}.van-icon-down:before{content:"\F04B"}.van-icon-ecard-pay:before{content:"\F04C"}.van-icon-edit:before{content:"\F04D"}.van-icon-ellipsis:before{content:"\F04E"}.van-icon-empty:before{content:"\F04F"}.van-icon-envelop-o:before{content:"\F050"}.van-icon-exchange:before{content:"\F051"}.van-icon-expand-o:before{content:"\F052"}.van-icon-expand:before{content:"\F053"}.van-icon-eye-o:before{content:"\F054"}.van-icon-eye:before{content:"\F055"}.van-icon-fail:before{content:"\F056"}.van-icon-failure:before{content:"\F057"}.van-icon-filter-o:before{content:"\F058"}.van-icon-fire-o:before{content:"\F059"}.van-icon-fire:before{content:"\F05A"}.van-icon-flag-o:before{content:"\F05B"}.van-icon-flower-o:before{content:"\F05C"}.van-icon-free-postage:before{content:"\F05D"}.van-icon-friends-o:before{content:"\F05E"}.van-icon-friends:before{content:"\F05F"}.van-icon-gem-o:before{content:"\F060"}.van-icon-gem:before{content:"\F061"}.van-icon-gift-card-o:before{content:"\F062"}.van-icon-gift-card:before{content:"\F063"}.van-icon-gift-o:before{content:"\F064"}.van-icon-gift:before{content:"\F065"}.van-icon-gold-coin-o:before{content:"\F066"}.van-icon-gold-coin:before{content:"\F067"}.van-icon-good-job-o:before{content:"\F068"}.van-icon-good-job:before{content:"\F069"}.van-icon-goods-collect-o:before{content:"\F06A"}.van-icon-goods-collect:before{content:"\F06B"}.van-icon-graphic:before{content:"\F06C"}.van-icon-home-o:before{content:"\F06D"}.van-icon-hot-o:before{content:"\F06E"}.van-icon-hot-sale-o:before{content:"\F06F"}.van-icon-hot-sale:before{content:"\F070"}.van-icon-hot:before{content:"\F071"}.van-icon-hotel-o:before{content:"\F072"}.van-icon-idcard:before{content:"\F073"}.van-icon-info-o:before{content:"\F074"}.van-icon-info:before{content:"\F075"}.van-icon-invition:before{content:"\F076"}.van-icon-label-o:before{content:"\F077"}.van-icon-label:before{content:"\F078"}.van-icon-like-o:before{content:"\F079"}.van-icon-like:before{content:"\F07A"}.van-icon-live:before{content:"\F07B"}.van-icon-location-o:before{content:"\F07C"}.van-icon-location:before{content:"\F07D"}.van-icon-lock:before{content:"\F07E"}.van-icon-logistics:before{content:"\F07F"}.van-icon-manager-o:before{content:"\F080"}.van-icon-manager:before{content:"\F081"}.van-icon-map-marked:before{content:"\F082"}.van-icon-medal-o:before{content:"\F083"}.van-icon-medal:before{content:"\F084"}.van-icon-more-o:before{content:"\F085"}.van-icon-more:before{content:"\F086"}.van-icon-music-o:before{content:"\F087"}.van-icon-music:before{content:"\F088"}.van-icon-new-arrival-o:before{content:"\F089"}.van-icon-new-arrival:before{content:"\F08A"}.van-icon-new-o:before{content:"\F08B"}.van-icon-new:before{content:"\F08C"}.van-icon-newspaper-o:before{content:"\F08D"}.van-icon-notes-o:before{content:"\F08E"}.van-icon-orders-o:before{content:"\F08F"}.van-icon-other-pay:before{content:"\F090"}.van-icon-paid:before{content:"\F091"}.van-icon-passed:before{content:"\F092"}.van-icon-pause-circle-o:before{content:"\F093"}.van-icon-pause-circle:before{content:"\F094"}.van-icon-pause:before{content:"\F095"}.van-icon-peer-pay:before{content:"\F096"}.van-icon-pending-payment:before{content:"\F097"}.van-icon-phone-circle-o:before{content:"\F098"}.van-icon-phone-circle:before{content:"\F099"}.van-icon-phone-o:before{content:"\F09A"}.van-icon-phone:before{content:"\F09B"}.van-icon-photo-o:before{content:"\F09C"}.van-icon-photo:before{content:"\F09D"}.van-icon-photograph:before{content:"\F09E"}.van-icon-play-circle-o:before{content:"\F09F"}.van-icon-play-circle:before{content:"\F0A0"}.van-icon-play:before{content:"\F0A1"}.van-icon-plus:before{content:"\F0A2"}.van-icon-point-gift-o:before{content:"\F0A3"}.van-icon-point-gift:before{content:"\F0A4"}.van-icon-points:before{content:"\F0A5"}.van-icon-printer:before{content:"\F0A6"}.van-icon-qr-invalid:before{content:"\F0A7"}.van-icon-qr:before{content:"\F0A8"}.van-icon-question-o:before{content:"\F0A9"}.van-icon-question:before{content:"\F0AA"}.van-icon-records:before{content:"\F0AB"}.van-icon-refund-o:before{content:"\F0AC"}.van-icon-replay:before{content:"\F0AD"}.van-icon-scan:before{content:"\F0AE"}.van-icon-search:before{content:"\F0AF"}.van-icon-send-gift-o:before{content:"\F0B0"}.van-icon-send-gift:before{content:"\F0B1"}.van-icon-service-o:before{content:"\F0B2"}.van-icon-service:before{content:"\F0B3"}.van-icon-setting-o:before{content:"\F0B4"}.van-icon-setting:before{content:"\F0B5"}.van-icon-share:before{content:"\F0B6"}.van-icon-shop-collect-o:before{content:"\F0B7"}.van-icon-shop-collect:before{content:"\F0B8"}.van-icon-shop-o:before{content:"\F0B9"}.van-icon-shop:before{content:"\F0BA"}.van-icon-shopping-cart-o:before{content:"\F0BB"}.van-icon-shopping-cart:before{content:"\F0BC"}.van-icon-shrink:before{content:"\F0BD"}.van-icon-sign:before{content:"\F0BE"}.van-icon-smile-comment-o:before{content:"\F0BF"}.van-icon-smile-comment:before{content:"\F0C0"}.van-icon-smile-o:before{content:"\F0C1"}.van-icon-smile:before{content:"\F0C2"}.van-icon-star-o:before{content:"\F0C3"}.van-icon-star:before{content:"\F0C4"}.van-icon-stop-circle-o:before{content:"\F0C5"}.van-icon-stop-circle:before{content:"\F0C6"}.van-icon-stop:before{content:"\F0C7"}.van-icon-success:before{content:"\F0C8"}.van-icon-thumb-circle-o:before{content:"\F0C9"}.van-icon-thumb-circle:before{content:"\F0CA"}.van-icon-todo-list-o:before{content:"\F0CB"}.van-icon-todo-list:before{content:"\F0CC"}.van-icon-tosend:before{content:"\F0CD"}.van-icon-tv-o:before{content:"\F0CE"}.van-icon-umbrella-circle:before{content:"\F0CF"}.van-icon-underway-o:before{content:"\F0D0"}.van-icon-underway:before{content:"\F0D1"}.van-icon-upgrade:before{content:"\F0D2"}.van-icon-user-circle-o:before{content:"\F0D3"}.van-icon-user-o:before{content:"\F0D4"}.van-icon-video-o:before{content:"\F0D5"}.van-icon-video:before{content:"\F0D6"}.van-icon-vip-card-o:before{content:"\F0D7"}.van-icon-vip-card:before{content:"\F0D8"}.van-icon-volume-o:before{content:"\F0D9"}.van-icon-volume:before{content:"\F0DA"}.van-icon-wap-home-o:before{content:"\F0DB"}.van-icon-wap-home:before{content:"\F0DC"}.van-icon-wap-nav:before{content:"\F0DD"}.van-icon-warn-o:before{content:"\F0DE"}.van-icon-warning-o:before{content:"\F0DF"}.van-icon-warning:before{content:"\F0E0"}.van-icon-weapp-nav:before{content:"\F0E1"}.van-icon-wechat:before{content:"\F0E2"}.van-icon-youzan-shield:before{content:"\F0E3"}:host{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-icon--image{width:1em;height:1em}.van-icon__image{width:100%;height:100%}.van-icon__info{z-index:1} -------------------------------------------------------------------------------- /wxcomponents/vant/info/index.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /wxcomponents/vant/info/index.js: -------------------------------------------------------------------------------- 1 | import { VantComponent } from '../common/component'; 2 | VantComponent({ 3 | props: { 4 | dot: Boolean, 5 | info: null, 6 | customStyle: String 7 | } 8 | }); 9 | -------------------------------------------------------------------------------- /wxcomponents/vant/info/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } 4 | -------------------------------------------------------------------------------- /wxcomponents/vant/info/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ dot ? '' : info }} 8 | -------------------------------------------------------------------------------- /wxcomponents/vant/info/index.wxss: -------------------------------------------------------------------------------- 1 | @import '../common/index.wxss';.van-info{position:absolute;top:0;right:0;box-sizing:border-box;white-space:nowrap;text-align:center;-webkit-transform:translate(50%,-50%);transform:translate(50%,-50%);-webkit-transform-origin:100%;transform-origin:100%;min-width:16px;min-width:var(--info-size,16px);padding:0 3px;padding:var(--info-padding,0 3px);color:#fff;color:var(--info-color,#fff);font-weight:500;font-weight:var(--info-font-weight,500);font-size:12px;font-size:var(--info-font-size,12px);font-family:PingFang SC,Helvetica Neue,Arial,sans-serif;font-family:var(--info-font-family,PingFang SC,Helvetica Neue,Arial,sans-serif);line-height:14px;line-height:calc(var(--info-size, 16px) - var(--info-border-width, 1px)*2);background-color:#ee0a24;background-color:var(--info-background-color,#ee0a24);border:1px solid #fff;border:var(--info-border-width,1px) solid var(--white,#fff);border-radius:16px;border-radius:var(--info-size,16px)}.van-info--dot{min-width:0;border-radius:100%;width:8px;width:var(--info-dot-size,8px);height:8px;height:var(--info-dot-size,8px);background-color:#ee0a24;background-color:var(--info-dot-color,#ee0a24)} -------------------------------------------------------------------------------- /wxcomponents/vant/loading/index.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /wxcomponents/vant/loading/index.js: -------------------------------------------------------------------------------- 1 | import { VantComponent } from '../common/component'; 2 | VantComponent({ 3 | props: { 4 | color: String, 5 | vertical: Boolean, 6 | type: { 7 | type: String, 8 | value: 'circular' 9 | }, 10 | size: String, 11 | textSize: String 12 | } 13 | }); 14 | -------------------------------------------------------------------------------- /wxcomponents/vant/loading/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } -------------------------------------------------------------------------------- /wxcomponents/vant/loading/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /wxcomponents/vant/loading/index.wxss: -------------------------------------------------------------------------------- 1 | @import '../common/index.wxss';:host{font-size:0;line-height:1}.van-loading{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;color:#c8c9cc;color:var(--loading-spinner-color,#c8c9cc)}.van-loading__spinner{position:relative;box-sizing:border-box;width:30px;width:var(--loading-spinner-size,30px);max-width:100%;max-height:100%;height:30px;height:var(--loading-spinner-size,30px);-webkit-animation:van-rotate .8s linear infinite;animation:van-rotate .8s linear infinite;-webkit-animation:van-rotate var(--loading-spinner-animation-duration,.8s) linear infinite;animation:van-rotate var(--loading-spinner-animation-duration,.8s) linear infinite}.van-loading__spinner--spinner{-webkit-animation-timing-function:steps(12);animation-timing-function:steps(12)}.van-loading__spinner--circular{border:1px solid transparent;border-top-color:initial;border-radius:100%}.van-loading__text{margin-left:8px;margin-left:var(--padding-xs,8px);color:#969799;color:var(--loading-text-color,#969799);font-size:14px;font-size:var(--loading-text-font-size,14px);line-height:20px;line-height:var(--loading-text-line-height,20px)}.van-loading__text:empty{display:none}.van-loading--vertical{-webkit-flex-direction:column;flex-direction:column}.van-loading--vertical .van-loading__text{margin:8px 0 0;margin:var(--padding-xs,8px) 0 0}.van-loading__dot{position:absolute;top:0;left:0;width:100%;height:100%}.van-loading__dot:before{display:block;width:2px;height:25%;margin:0 auto;background-color:currentColor;border-radius:40%;content:" "}.van-loading__dot:first-of-type{-webkit-transform:rotate(30deg);transform:rotate(30deg);opacity:1}.van-loading__dot:nth-of-type(2){-webkit-transform:rotate(60deg);transform:rotate(60deg);opacity:.9375}.van-loading__dot:nth-of-type(3){-webkit-transform:rotate(90deg);transform:rotate(90deg);opacity:.875}.van-loading__dot:nth-of-type(4){-webkit-transform:rotate(120deg);transform:rotate(120deg);opacity:.8125}.van-loading__dot:nth-of-type(5){-webkit-transform:rotate(150deg);transform:rotate(150deg);opacity:.75}.van-loading__dot:nth-of-type(6){-webkit-transform:rotate(180deg);transform:rotate(180deg);opacity:.6875}.van-loading__dot:nth-of-type(7){-webkit-transform:rotate(210deg);transform:rotate(210deg);opacity:.625}.van-loading__dot:nth-of-type(8){-webkit-transform:rotate(240deg);transform:rotate(240deg);opacity:.5625}.van-loading__dot:nth-of-type(9){-webkit-transform:rotate(270deg);transform:rotate(270deg);opacity:.5}.van-loading__dot:nth-of-type(10){-webkit-transform:rotate(300deg);transform:rotate(300deg);opacity:.4375}.van-loading__dot:nth-of-type(11){-webkit-transform:rotate(330deg);transform:rotate(330deg);opacity:.375}.van-loading__dot:nth-of-type(12){-webkit-transform:rotate(1turn);transform:rotate(1turn);opacity:.3125}@-webkit-keyframes van-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes van-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}} -------------------------------------------------------------------------------- /wxcomponents/vant/mixins/basic.d.ts: -------------------------------------------------------------------------------- 1 | export declare const basic: string; 2 | -------------------------------------------------------------------------------- /wxcomponents/vant/mixins/basic.js: -------------------------------------------------------------------------------- 1 | export const basic = Behavior({ 2 | methods: { 3 | $emit(...args) { 4 | this.triggerEvent(...args); 5 | }, 6 | set(data, callback) { 7 | this.setData(data, callback); 8 | return new Promise(resolve => wx.nextTick(resolve)); 9 | }, 10 | getRect(selector, all) { 11 | return new Promise(resolve => { 12 | wx.createSelectorQuery() 13 | .in(this)[all ? 'selectAll' : 'select'](selector) 14 | .boundingClientRect(rect => { 15 | if (all && Array.isArray(rect) && rect.length) { 16 | resolve(rect); 17 | } 18 | if (!all && rect) { 19 | resolve(rect); 20 | } 21 | }) 22 | .exec(); 23 | }); 24 | } 25 | } 26 | }); 27 | -------------------------------------------------------------------------------- /wxcomponents/vant/mixins/button.d.ts: -------------------------------------------------------------------------------- 1 | export declare const button: string; 2 | -------------------------------------------------------------------------------- /wxcomponents/vant/mixins/button.js: -------------------------------------------------------------------------------- 1 | export const button = Behavior({ 2 | externalClasses: ['hover-class'], 3 | properties: { 4 | id: String, 5 | lang: { 6 | type: String, 7 | value: 'en' 8 | }, 9 | businessId: Number, 10 | sessionFrom: String, 11 | sendMessageTitle: String, 12 | sendMessagePath: String, 13 | sendMessageImg: String, 14 | showMessageCard: Boolean, 15 | appParameter: String, 16 | ariaLabel: String 17 | } 18 | }); 19 | -------------------------------------------------------------------------------- /wxcomponents/vant/mixins/link.d.ts: -------------------------------------------------------------------------------- 1 | export declare const link: string; 2 | -------------------------------------------------------------------------------- /wxcomponents/vant/mixins/link.js: -------------------------------------------------------------------------------- 1 | export const link = Behavior({ 2 | properties: { 3 | url: String, 4 | linkType: { 5 | type: String, 6 | value: 'navigateTo' 7 | } 8 | }, 9 | methods: { 10 | jumpLink(urlKey = 'url') { 11 | const url = this.data[urlKey]; 12 | if (url) { 13 | wx[this.data.linkType]({ url }); 14 | } 15 | } 16 | } 17 | }); 18 | -------------------------------------------------------------------------------- /wxcomponents/vant/mixins/open-type.d.ts: -------------------------------------------------------------------------------- 1 | export declare const openType: string; 2 | -------------------------------------------------------------------------------- /wxcomponents/vant/mixins/open-type.js: -------------------------------------------------------------------------------- 1 | export const openType = Behavior({ 2 | properties: { 3 | openType: String 4 | }, 5 | methods: { 6 | bindGetUserInfo(event) { 7 | this.$emit('getuserinfo', event.detail); 8 | }, 9 | bindContact(event) { 10 | this.$emit('contact', event.detail); 11 | }, 12 | bindGetPhoneNumber(event) { 13 | this.$emit('getphonenumber', event.detail); 14 | }, 15 | bindError(event) { 16 | this.$emit('error', event.detail); 17 | }, 18 | bindLaunchApp(event) { 19 | this.$emit('launchapp', event.detail); 20 | }, 21 | bindOpenSetting(event) { 22 | this.$emit('opensetting', event.detail); 23 | }, 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /wxcomponents/vant/mixins/touch.d.ts: -------------------------------------------------------------------------------- 1 | export declare const touch: string; 2 | -------------------------------------------------------------------------------- /wxcomponents/vant/mixins/touch.js: -------------------------------------------------------------------------------- 1 | const MIN_DISTANCE = 10; 2 | function getDirection(x, y) { 3 | if (x > y && x > MIN_DISTANCE) { 4 | return 'horizontal'; 5 | } 6 | if (y > x && y > MIN_DISTANCE) { 7 | return 'vertical'; 8 | } 9 | return ''; 10 | } 11 | export const touch = Behavior({ 12 | methods: { 13 | resetTouchStatus() { 14 | this.direction = ''; 15 | this.deltaX = 0; 16 | this.deltaY = 0; 17 | this.offsetX = 0; 18 | this.offsetY = 0; 19 | }, 20 | touchStart(event) { 21 | this.resetTouchStatus(); 22 | const touch = event.touches[0]; 23 | this.startX = touch.clientX; 24 | this.startY = touch.clientY; 25 | }, 26 | touchMove(event) { 27 | const touch = event.touches[0]; 28 | this.deltaX = touch.clientX - this.startX; 29 | this.deltaY = touch.clientY - this.startY; 30 | this.offsetX = Math.abs(this.deltaX); 31 | this.offsetY = Math.abs(this.deltaY); 32 | this.direction = this.direction || getDirection(this.offsetX, this.offsetY); 33 | } 34 | } 35 | }); 36 | -------------------------------------------------------------------------------- /wxcomponents/vant/mixins/transition.d.ts: -------------------------------------------------------------------------------- 1 | export declare const transition: (showDefaultValue: boolean) => any; 2 | -------------------------------------------------------------------------------- /wxcomponents/vant/mixins/transition.js: -------------------------------------------------------------------------------- 1 | import { isObj } from '../common/utils'; 2 | const getClassNames = (name) => ({ 3 | enter: `van-${name}-enter van-${name}-enter-active enter-class enter-active-class`, 4 | 'enter-to': `van-${name}-enter-to van-${name}-enter-active enter-to-class enter-active-class`, 5 | leave: `van-${name}-leave van-${name}-leave-active leave-class leave-active-class`, 6 | 'leave-to': `van-${name}-leave-to van-${name}-leave-active leave-to-class leave-active-class` 7 | }); 8 | const nextTick = () => new Promise(resolve => setTimeout(resolve, 1000 / 30)); 9 | export const transition = function (showDefaultValue) { 10 | return Behavior({ 11 | properties: { 12 | customStyle: String, 13 | // @ts-ignore 14 | show: { 15 | type: Boolean, 16 | value: showDefaultValue, 17 | observer: 'observeShow' 18 | }, 19 | // @ts-ignore 20 | duration: { 21 | type: null, 22 | value: 300, 23 | observer: 'observeDuration' 24 | }, 25 | name: { 26 | type: String, 27 | value: 'fade' 28 | } 29 | }, 30 | data: { 31 | type: '', 32 | inited: false, 33 | display: false 34 | }, 35 | methods: { 36 | observeShow(value, old) { 37 | if (value === old) { 38 | return; 39 | } 40 | value ? this.enter() : this.leave(); 41 | }, 42 | enter() { 43 | const { duration, name } = this.data; 44 | const classNames = getClassNames(name); 45 | const currentDuration = isObj(duration) ? duration.enter : duration; 46 | this.status = 'enter'; 47 | this.$emit('before-enter'); 48 | Promise.resolve() 49 | .then(nextTick) 50 | .then(() => { 51 | this.checkStatus('enter'); 52 | this.$emit('enter'); 53 | this.setData({ 54 | inited: true, 55 | display: true, 56 | classes: classNames.enter, 57 | currentDuration 58 | }); 59 | }) 60 | .then(nextTick) 61 | .then(() => { 62 | this.checkStatus('enter'); 63 | this.transitionEnded = false; 64 | this.setData({ 65 | classes: classNames['enter-to'] 66 | }); 67 | }) 68 | .catch(() => { }); 69 | }, 70 | leave() { 71 | if (!this.data.display) { 72 | return; 73 | } 74 | const { duration, name } = this.data; 75 | const classNames = getClassNames(name); 76 | const currentDuration = isObj(duration) ? duration.leave : duration; 77 | this.status = 'leave'; 78 | this.$emit('before-leave'); 79 | Promise.resolve() 80 | .then(nextTick) 81 | .then(() => { 82 | this.checkStatus('leave'); 83 | this.$emit('leave'); 84 | this.setData({ 85 | classes: classNames.leave, 86 | currentDuration 87 | }); 88 | }) 89 | .then(nextTick) 90 | .then(() => { 91 | this.checkStatus('leave'); 92 | this.transitionEnded = false; 93 | setTimeout(() => this.onTransitionEnd(), currentDuration); 94 | this.setData({ 95 | classes: classNames['leave-to'] 96 | }); 97 | }) 98 | .catch(() => { }); 99 | }, 100 | checkStatus(status) { 101 | if (status !== this.status) { 102 | throw new Error(`incongruent status: ${status}`); 103 | } 104 | }, 105 | onTransitionEnd() { 106 | if (this.transitionEnded) { 107 | return; 108 | } 109 | this.transitionEnded = true; 110 | this.$emit(`after-${this.status}`); 111 | const { show, display } = this.data; 112 | if (!show && display) { 113 | this.setData({ display: false }); 114 | } 115 | } 116 | } 117 | }); 118 | }; 119 | -------------------------------------------------------------------------------- /wxcomponents/vant/search/index.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /wxcomponents/vant/search/index.js: -------------------------------------------------------------------------------- 1 | import { VantComponent } from '../common/component'; 2 | VantComponent({ 3 | field: true, 4 | classes: ['field-class', 'input-class', 'cancel-class'], 5 | props: { 6 | label: String, 7 | focus: Boolean, 8 | error: Boolean, 9 | disabled: Boolean, 10 | readonly: Boolean, 11 | inputAlign: String, 12 | showAction: Boolean, 13 | useActionSlot: Boolean, 14 | useLeftIconSlot: Boolean, 15 | useRightIconSlot: Boolean, 16 | leftIcon: { 17 | type: String, 18 | value: 'search' 19 | }, 20 | rightIcon: String, 21 | placeholder: String, 22 | placeholderStyle: String, 23 | actionText: { 24 | type: String, 25 | value: '取消' 26 | }, 27 | background: { 28 | type: String, 29 | value: '#ffffff' 30 | }, 31 | maxlength: { 32 | type: Number, 33 | value: -1 34 | }, 35 | shape: { 36 | type: String, 37 | value: 'square' 38 | }, 39 | clearable: { 40 | type: Boolean, 41 | value: true 42 | } 43 | }, 44 | methods: { 45 | onChange(event) { 46 | this.setData({ value: event.detail }); 47 | this.$emit('change', event.detail); 48 | }, 49 | onCancel() { 50 | /** 51 | * 修复修改输入框值时,输入框失焦和赋值同时触发,赋值失效 52 | * https://github.com/youzan/@vant/weapp/issues/1768 53 | */ 54 | setTimeout(() => { 55 | this.setData({ value: '' }); 56 | this.$emit('cancel'); 57 | this.$emit('change', ''); 58 | }, 200); 59 | }, 60 | onSearch() { 61 | this.$emit('search', this.data.value); 62 | }, 63 | onFocus() { 64 | this.$emit('focus'); 65 | }, 66 | onBlur() { 67 | this.$emit('blur'); 68 | }, 69 | onClear() { 70 | this.$emit('clear'); 71 | }, 72 | } 73 | }); 74 | -------------------------------------------------------------------------------- /wxcomponents/vant/search/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": { 4 | "van-field": "../field/index" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /wxcomponents/vant/search/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | {{ label }} 9 | 10 | 11 | 36 | 37 | 38 | 39 | 40 | 41 | 47 | 48 | {{ actionText }} 49 | 50 | 51 | -------------------------------------------------------------------------------- /wxcomponents/vant/search/index.wxss: -------------------------------------------------------------------------------- 1 | @import '../common/index.wxss';.van-search{-webkit-align-items:center;align-items:center;box-sizing:border-box;padding:10px 12px;padding:var(--search-padding,10px 12px)}.van-search,.van-search__content{display:-webkit-flex;display:flex}.van-search__content{-webkit-flex:1;flex:1;padding-left:8px;padding-left:var(--padding-xs,8px);border-radius:2px;border-radius:var(--border-radius-sm,2px);background-color:#f7f8fa;background-color:var(--search-background-color,#f7f8fa)}.van-search__content--round{border-radius:17px;border-radius:calc(var(--search-input-height, 34px)/2)}.van-search__label{padding:0 5px;padding:var(--search-label-padding,0 5px);font-size:14px;font-size:var(--search-label-font-size,14px);line-height:34px;line-height:var(--search-input-height,34px);color:#323233;color:var(--search-label-color,#323233)}.van-search__field{-webkit-flex:1;flex:1}.van-search__field__left-icon{color:#969799;color:var(--search-left-icon-color,#969799)}.van-search--withaction{padding-right:0}.van-search__action{padding:0 8px;padding:var(--search-action-padding,0 8px);font-size:14px;font-size:var(--search-action-font-size,14px);line-height:34px;line-height:var(--search-input-height,34px);color:#323233;color:var(--search-action-text-color,#323233)}.van-search__action--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)} -------------------------------------------------------------------------------- /wxcomponents/vant/wxs/add-unit.wxs: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | var REGEXP = getRegExp('^\d+(\.\d+)?$'); 3 | 4 | function addUnit(value) { 5 | if (value == null) { 6 | return undefined; 7 | } 8 | 9 | return REGEXP.test('' + value) ? value + 'px' : value; 10 | } 11 | 12 | module.exports = { 13 | addUnit: addUnit 14 | }; 15 | -------------------------------------------------------------------------------- /wxcomponents/vant/wxs/array.wxs: -------------------------------------------------------------------------------- 1 | function isArray(array) { 2 | return array && array.constructor === 'Array'; 3 | } 4 | 5 | module.exports.isArray = isArray; 6 | -------------------------------------------------------------------------------- /wxcomponents/vant/wxs/bem.wxs: -------------------------------------------------------------------------------- 1 | var array = require('./array.wxs'); 2 | var object = require('./object.wxs'); 3 | var PREFIX = 'van-'; 4 | 5 | function join(name, mods) { 6 | name = PREFIX + name; 7 | mods = mods.map(function(mod) { 8 | return name + '--' + mod; 9 | }); 10 | mods.unshift(name); 11 | return mods.join(' '); 12 | } 13 | 14 | function traversing(mods, conf) { 15 | if (!conf) { 16 | return; 17 | } 18 | 19 | if (typeof conf === 'string' || typeof conf === 'number') { 20 | mods.push(conf); 21 | } else if (array.isArray(conf)) { 22 | conf.forEach(function(item) { 23 | traversing(mods, item); 24 | }); 25 | } else if (typeof conf === 'object') { 26 | object.keys(conf).forEach(function(key) { 27 | conf[key] && mods.push(key); 28 | }); 29 | } 30 | } 31 | 32 | function bem(name, conf) { 33 | var mods = []; 34 | traversing(mods, conf); 35 | return join(name, mods); 36 | } 37 | 38 | module.exports.bem = bem; 39 | -------------------------------------------------------------------------------- /wxcomponents/vant/wxs/memoize.wxs: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple memoize 3 | * wxs doesn't support fn.apply, so this memoize only support up to 2 args 4 | */ 5 | 6 | function isPrimitive(value) { 7 | var type = typeof value; 8 | return ( 9 | type === 'boolean' || 10 | type === 'number' || 11 | type === 'string' || 12 | type === 'undefined' || 13 | value === null 14 | ); 15 | } 16 | 17 | // mock simple fn.call in wxs 18 | function call(fn, args) { 19 | if (args.length === 2) { 20 | return fn(args[0], args[1]); 21 | } 22 | 23 | if (args.length === 1) { 24 | return fn(args[0]); 25 | } 26 | 27 | return fn(); 28 | } 29 | 30 | function serializer(args) { 31 | if (args.length === 1 && isPrimitive(args[0])) { 32 | return args[0]; 33 | } 34 | var obj = {}; 35 | for (var i = 0; i < args.length; i++) { 36 | obj['key' + i] = args[i]; 37 | } 38 | return JSON.stringify(obj); 39 | } 40 | 41 | function memoize(fn) { 42 | var cache = {}; 43 | 44 | return function() { 45 | var key = serializer(arguments); 46 | if (cache[key] === undefined) { 47 | cache[key] = call(fn, arguments); 48 | } 49 | 50 | return cache[key]; 51 | }; 52 | } 53 | 54 | module.exports.memoize = memoize; 55 | -------------------------------------------------------------------------------- /wxcomponents/vant/wxs/object.wxs: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | var REGEXP = getRegExp('{|}|"', 'g'); 3 | 4 | function keys(obj) { 5 | return JSON.stringify(obj) 6 | .replace(REGEXP, '') 7 | .split(',') 8 | .map(function(item) { 9 | return item.split(':')[0]; 10 | }); 11 | } 12 | 13 | module.exports.keys = keys; 14 | -------------------------------------------------------------------------------- /wxcomponents/vant/wxs/utils.wxs: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | var bem = require('./bem.wxs').bem; 3 | var memoize = require('./memoize.wxs').memoize; 4 | var addUnit = require('./add-unit.wxs').addUnit; 5 | 6 | module.exports = { 7 | bem: memoize(bem), 8 | memoize: memoize, 9 | addUnit: addUnit 10 | }; 11 | --------------------------------------------------------------------------------