├── .gitignore ├── README.md ├── app.js ├── app.json ├── app.wxss ├── colorui ├── animation.wxss ├── components │ ├── cu-custom.js │ ├── cu-custom.json │ ├── cu-custom.wxml │ └── cu-custom.wxss ├── icon.wxss └── main.wxss ├── images ├── groups_drak.png ├── groups_light.png ├── home_drak.png ├── home_light.png ├── personal_drak.png └── personal_light.png ├── lib ├── qqmap-wx-jssdk.js ├── qqmap-wx-jssdk.min.js └── weui.wxss ├── pages ├── groups │ ├── all │ │ ├── all.js │ │ ├── all.json │ │ ├── all.wxml │ │ └── all.wxss │ └── single │ │ ├── single.js │ │ ├── single.json │ │ ├── single.wxml │ │ └── single.wxss ├── home │ └── search │ │ ├── search.js │ │ ├── search.json │ │ ├── search.wxml │ │ └── search.wxss ├── index │ ├── index.js │ ├── index.json │ ├── index.wxml │ └── index.wxss ├── personal │ ├── home │ │ ├── home.js │ │ ├── home.json │ │ ├── home.wxml │ │ ├── home.wxss │ │ └── weather.jpg │ ├── modification │ │ ├── modification.js │ │ ├── modification.json │ │ ├── modification.wxml │ │ └── modification.wxss │ └── workresume │ │ ├── workresume.js │ │ ├── workresume.json │ │ ├── workresume.wxml │ │ └── workresume.wxss └── public │ ├── usergroups │ ├── usergroups.js │ ├── usergroups.json │ ├── usergroups.wxml │ └── usergroups.wxss │ ├── userpage │ ├── userpage.js │ ├── userpage.json │ ├── userpage.wxml │ └── userpage.wxss │ └── userprofile │ ├── userprofile.js │ ├── userprofile.json │ ├── userprofile.wxml │ └── userprofile.wxss ├── project.config.json └── sitemap.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows 2 | [Dd]esktop.ini 3 | Thumbs.db 4 | $RECYCLE.BIN/ 5 | 6 | # macOS 7 | .DS_Store 8 | .fseventsd 9 | .Spotlight-V100 10 | .TemporaryItems 11 | .Trashes 12 | 13 | # Node.js 14 | node_modules/ 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 『红线』校友录项目 2 | 3 | ## RedBrick框架 4 | 5 | **RedBrick框架** 在 [ColorUI](https://github.com/weilanwl/ColorUI) 组件框架的基础上,结合基础操作栏布局,总结出来的应用基础架构 6 | 7 | ## 开发日志 8 | 9 | ### 2020.07.04 10 | 11 | - 对于应用的整体设计有个初步概念 12 | - 了解小程序的基础组件类型和扩展能力类型 13 | 14 | ### 2020.07.05 15 | 16 | - 应用设计模式的完善与讨论 17 | 18 | ### 2020.07.06 19 | 20 | - 基础组件知识和扩展能力的学习 21 | - 应用开发版型的确定与技术难点 22 | 23 | ### 2020.07.07 24 | 25 | - 1.0框架 26 | 27 | ### 2020.07.08 28 | 29 | - 消息栏目主体内容与对象跳转的传参消息页 30 | 31 | ### 2020.07.09 32 | 33 | - **/首页/动态** 瀑布屏懒加载的技术实现 34 | - [瀑布流组件实现翻页与图片懒加载](https://www.jb51.net/article/186884.htm) 35 | 36 | ### 2020.07.10 37 | 38 | - RedBrick框架构建 39 | - 消息页首页搭建 40 | 41 | ### 2020.07.11 42 | 43 | - 消息页个人消息搭建 44 | - 消息页系统消息搭建 45 | 46 | ### 2020.07.12 47 | 48 | - [扩展组件学习](https://developers.weixin.qq.com/miniprogram/dev/extended/) 49 | 50 | ### 2020.07.13 51 | 52 | - 扩展组件引入与技术实现 53 | 54 | ### 2020.07.14 55 | 56 | - 页面传值 57 | 58 | ### 2020.07.15 59 | 60 | - 完成初步的组件开发 61 | - 开始 **1.0** 版本的正式开发 62 | - **colorui** 部分 wxss 修改与重构 63 | - **home** 页面搭建 64 | - **card-graphic、card-resume、crad-text** 组件开发 65 | 66 | ### 2020.07.17 67 | 68 | - 动态页搭建 69 | - 个人页搭建 70 | 71 | ### 2020.07.18 72 | 73 | - 资料页搭建 74 | - -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | //app.js 2 | App({ 3 | onLaunch: function () { 4 | // 展示本地存储能力 5 | var logs = wx.getStorageSync('logs') || [] 6 | logs.unshift(Date.now()) 7 | wx.setStorageSync('logs', logs) 8 | 9 | // 登录 10 | wx.login({ 11 | success: res => { 12 | // 发送 res.code 到后台换取 openId, sessionKey, unionId 13 | } 14 | }) 15 | // 获取用户信息 16 | wx.getSetting({ 17 | success: res => { 18 | if (res.authSetting['scope.userInfo']) { 19 | // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 20 | wx.getUserInfo({ 21 | success: res => { 22 | // 可以将 res 发送给后台解码出 unionId 23 | this.globalData.userInfo = res.userInfo 24 | 25 | // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 26 | // 所以此处加入 callback 以防止这种情况 27 | if (this.userInfoReadyCallback) { 28 | this.userInfoReadyCallback(res) 29 | } 30 | } 31 | }) 32 | } 33 | } 34 | }) 35 | // 获取系统状态栏信息 36 | wx.getSystemInfo({ 37 | success: e => { 38 | this.globalData.StatusBar = e.statusBarHeight; 39 | let capsule = wx.getMenuButtonBoundingClientRect(); 40 | if (capsule) { 41 | this.globalData.Custom = capsule; 42 | this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight; 43 | } else { 44 | this.globalData.CustomBar = e.statusBarHeight + 50; 45 | } 46 | } 47 | }) 48 | }, 49 | globalData: { 50 | userInfo: null 51 | } 52 | }) -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | "pages/index/index", 4 | "pages/home/search/search", 5 | "pages/groups/single/single", 6 | "pages/groups/all/all", 7 | "pages/personal/home/home", 8 | "pages/personal/modification/modification", 9 | "pages/public/userpage/userpage", 10 | "pages/public/usergroups/usergroups", 11 | "pages/public/userprofile/userprofile", 12 | "pages/personal/workresume/workresume" 13 | ], 14 | "permission": { 15 | "scope.userLocation": { 16 | "desc": "你的位置信息将用于寻找附近校友" 17 | } 18 | }, 19 | "tabBar": { 20 | "color": "#a9a9a9", 21 | "selectedColor": "#666666", 22 | "list": [{ 23 | "pagePath": "pages/index/index", 24 | "text": "首页", 25 | "iconPath": "./images/home_light.png", 26 | "selectedIconPath": "./images/home_drak.png" 27 | }, 28 | { 29 | "pagePath": "pages/groups/all/all", 30 | "text": "圈子", 31 | "iconPath": "./images/groups_light.png", 32 | "selectedIconPath": "./images/groups_drak.png" 33 | }, 34 | { 35 | "pagePath": "pages/personal/home/home", 36 | "text": "我的", 37 | "iconPath": "./images/personal_light.png", 38 | "selectedIconPath": "./images/personal_drak.png" 39 | } 40 | ] 41 | }, 42 | "window": { 43 | "backgroundTextStyle": "light", 44 | "navigationBarBackgroundColor": "#fff", 45 | "navigationBarTitleText": "ColorUI", 46 | "navigationStyle": "custom", 47 | "navigationBarTextStyle": "black" 48 | }, 49 | "usingComponents": { 50 | "cu-custom": "/colorui/components/cu-custom" 51 | }, 52 | "sitemapLocation": "sitemap.json" 53 | } -------------------------------------------------------------------------------- /app.wxss: -------------------------------------------------------------------------------- 1 | @import "colorui/main.wxss"; 2 | @import "colorui/icon.wxss"; 3 | @import "colorui/animation.wxss"; 4 | 5 | .container { 6 | width: 100%; 7 | height: 500rpx; 8 | box-sizing: border-box; 9 | } 10 | -------------------------------------------------------------------------------- /colorui/animation.wxss: -------------------------------------------------------------------------------- 1 | /* 2 | Animation 微动画 3 | 基于ColorUI组建库的动画模块 by 文晓港 2019年3月26日19:52:28 4 | */ 5 | 6 | /* css 滤镜 控制黑白底色gif的 */ 7 | .gif-black{ 8 | mix-blend-mode: screen; 9 | } 10 | .gif-white{ 11 | mix-blend-mode: multiply; 12 | } 13 | 14 | 15 | /* Animation css */ 16 | [class*=animation-] { 17 | animation-duration: .5s; 18 | animation-timing-function: ease-out; 19 | animation-fill-mode: both 20 | } 21 | 22 | .animation-fade { 23 | animation-name: fade; 24 | animation-duration: .8s; 25 | animation-timing-function: linear 26 | } 27 | 28 | .animation-scale-up { 29 | animation-name: scale-up 30 | } 31 | 32 | .animation-scale-down { 33 | animation-name: scale-down 34 | } 35 | 36 | .animation-slide-top { 37 | animation-name: slide-top 38 | } 39 | 40 | .animation-slide-bottom { 41 | animation-name: slide-bottom 42 | } 43 | 44 | .animation-slide-left { 45 | animation-name: slide-left 46 | } 47 | 48 | .animation-slide-right { 49 | animation-name: slide-right 50 | } 51 | 52 | .animation-shake { 53 | animation-name: shake 54 | } 55 | 56 | .animation-reverse { 57 | animation-direction: reverse 58 | } 59 | 60 | @keyframes fade { 61 | 0% { 62 | opacity: 0 63 | } 64 | 65 | 100% { 66 | opacity: 1 67 | } 68 | } 69 | 70 | @keyframes scale-up { 71 | 0% { 72 | opacity: 0; 73 | transform: scale(.2) 74 | } 75 | 76 | 100% { 77 | opacity: 1; 78 | transform: scale(1) 79 | } 80 | } 81 | 82 | @keyframes scale-down { 83 | 0% { 84 | opacity: 0; 85 | transform: scale(1.8) 86 | } 87 | 88 | 100% { 89 | opacity: 1; 90 | transform: scale(1) 91 | } 92 | } 93 | 94 | @keyframes slide-top { 95 | 0% { 96 | opacity: 0; 97 | transform: translateY(-100%) 98 | } 99 | 100 | 100% { 101 | opacity: 1; 102 | transform: translateY(0) 103 | } 104 | } 105 | 106 | @keyframes slide-bottom { 107 | 0% { 108 | opacity: 0; 109 | transform: translateY(100%) 110 | } 111 | 112 | 100% { 113 | opacity: 1; 114 | transform: translateY(0) 115 | } 116 | } 117 | 118 | @keyframes shake { 119 | 120 | 0%, 121 | 100% { 122 | transform: translateX(0) 123 | } 124 | 125 | 10% { 126 | transform: translateX(-9px) 127 | } 128 | 129 | 20% { 130 | transform: translateX(8px) 131 | } 132 | 133 | 30% { 134 | transform: translateX(-7px) 135 | } 136 | 137 | 40% { 138 | transform: translateX(6px) 139 | } 140 | 141 | 50% { 142 | transform: translateX(-5px) 143 | } 144 | 145 | 60% { 146 | transform: translateX(4px) 147 | } 148 | 149 | 70% { 150 | transform: translateX(-3px) 151 | } 152 | 153 | 80% { 154 | transform: translateX(2px) 155 | } 156 | 157 | 90% { 158 | transform: translateX(-1px) 159 | } 160 | } 161 | 162 | @keyframes slide-left { 163 | 0% { 164 | opacity: 0; 165 | transform: translateX(-100%) 166 | } 167 | 168 | 100% { 169 | opacity: 1; 170 | transform: translateX(0) 171 | } 172 | } 173 | 174 | @keyframes slide-right { 175 | 0% { 176 | opacity: 0; 177 | transform: translateX(100%) 178 | } 179 | 180 | 100% { 181 | opacity: 1; 182 | transform: translateX(0) 183 | } 184 | } -------------------------------------------------------------------------------- /colorui/components/cu-custom.js: -------------------------------------------------------------------------------- 1 | const app = getApp(); 2 | Component({ 3 | /** 4 | * 组件的一些选项 5 | */ 6 | options: { 7 | addGlobalClass: true, 8 | multipleSlots: true 9 | }, 10 | /** 11 | * 组件的对外属性 12 | */ 13 | properties: { 14 | bgColor: { 15 | type: String, 16 | default: '' 17 | }, 18 | isCustom: { 19 | type: [Boolean, String], 20 | default: false 21 | }, 22 | isBack: { 23 | type: [Boolean, String], 24 | default: false 25 | }, 26 | bgImage: { 27 | type: String, 28 | default: '' 29 | }, 30 | }, 31 | /** 32 | * 组件的初始数据 33 | */ 34 | data: { 35 | StatusBar: app.globalData.StatusBar, 36 | CustomBar: app.globalData.CustomBar, 37 | Custom: app.globalData.Custom 38 | }, 39 | /** 40 | * 组件的方法列表 41 | */ 42 | methods: { 43 | BackPage() { 44 | wx.navigateBack({ 45 | delta: 1 46 | }); 47 | }, 48 | toHome(){ 49 | wx.reLaunch({ 50 | url: '/pages/index/index', 51 | }) 52 | } 53 | } 54 | }) -------------------------------------------------------------------------------- /colorui/components/cu-custom.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true, 3 | "usingComponents": {} 4 | } -------------------------------------------------------------------------------- /colorui/components/cu-custom.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /colorui/components/cu-custom.wxss: -------------------------------------------------------------------------------- 1 | /* colorui/components/cu-custom.wxss */ -------------------------------------------------------------------------------- /images/groups_drak.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jing-Wenxing/RedLine/0537ea2a612684d58d70db19a7c7ccc2d39b9a2e/images/groups_drak.png -------------------------------------------------------------------------------- /images/groups_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jing-Wenxing/RedLine/0537ea2a612684d58d70db19a7c7ccc2d39b9a2e/images/groups_light.png -------------------------------------------------------------------------------- /images/home_drak.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jing-Wenxing/RedLine/0537ea2a612684d58d70db19a7c7ccc2d39b9a2e/images/home_drak.png -------------------------------------------------------------------------------- /images/home_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jing-Wenxing/RedLine/0537ea2a612684d58d70db19a7c7ccc2d39b9a2e/images/home_light.png -------------------------------------------------------------------------------- /images/personal_drak.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jing-Wenxing/RedLine/0537ea2a612684d58d70db19a7c7ccc2d39b9a2e/images/personal_drak.png -------------------------------------------------------------------------------- /images/personal_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jing-Wenxing/RedLine/0537ea2a612684d58d70db19a7c7ccc2d39b9a2e/images/personal_light.png -------------------------------------------------------------------------------- /lib/qqmap-wx-jssdk.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 微信小程序JavaScriptSDK 3 | * 4 | * @version 1.2 5 | * @date 2019-03-06 6 | * @author v_ylyue@tencent.com 7 | */ 8 | 9 | var ERROR_CONF = { 10 | KEY_ERR: 311, 11 | KEY_ERR_MSG: 'key格式错误', 12 | PARAM_ERR: 310, 13 | PARAM_ERR_MSG: '请求参数信息有误', 14 | SYSTEM_ERR: 600, 15 | SYSTEM_ERR_MSG: '系统错误', 16 | WX_ERR_CODE: 1000, 17 | WX_OK_CODE: 200 18 | }; 19 | var BASE_URL = 'https://apis.map.qq.com/ws/'; 20 | var URL_SEARCH = BASE_URL + 'place/v1/search'; 21 | var URL_SUGGESTION = BASE_URL + 'place/v1/suggestion'; 22 | var URL_GET_GEOCODER = BASE_URL + 'geocoder/v1/'; 23 | var URL_CITY_LIST = BASE_URL + 'district/v1/list'; 24 | var URL_AREA_LIST = BASE_URL + 'district/v1/getchildren'; 25 | var URL_DISTANCE = BASE_URL + 'distance/v1/'; 26 | var URL_DIRECTION = BASE_URL + 'direction/v1/'; 27 | var MODE = { 28 | driving: 'driving', 29 | transit: 'transit' 30 | }; 31 | var EARTH_RADIUS = 6378136.49; 32 | var Utils = { 33 | /** 34 | * md5加密方法 35 | * 版权所有©2011 Sebastian Tschan,https://blueimp.net 36 | */ 37 | safeAdd(x, y) { 38 | var lsw = (x & 0xffff) + (y & 0xffff); 39 | var msw = (x >> 16) + (y >> 16) + (lsw >> 16); 40 | return (msw << 16) | (lsw & 0xffff); 41 | }, 42 | bitRotateLeft(num, cnt) { 43 | return (num << cnt) | (num >>> (32 - cnt)); 44 | }, 45 | md5cmn(q, a, b, x, s, t) { 46 | return this.safeAdd(this.bitRotateLeft(this.safeAdd(this.safeAdd(a, q), this.safeAdd(x, t)), s), b); 47 | }, 48 | md5ff(a, b, c, d, x, s, t) { 49 | return this.md5cmn((b & c) | (~b & d), a, b, x, s, t); 50 | }, 51 | md5gg(a, b, c, d, x, s, t) { 52 | return this.md5cmn((b & d) | (c & ~d), a, b, x, s, t); 53 | }, 54 | md5hh(a, b, c, d, x, s, t) { 55 | return this.md5cmn(b ^ c ^ d, a, b, x, s, t); 56 | }, 57 | md5ii(a, b, c, d, x, s, t) { 58 | return this.md5cmn(c ^ (b | ~d), a, b, x, s, t); 59 | }, 60 | binlMD5(x, len) { 61 | /* append padding */ 62 | x[len >> 5] |= 0x80 << (len % 32); 63 | x[((len + 64) >>> 9 << 4) + 14] = len; 64 | 65 | var i; 66 | var olda; 67 | var oldb; 68 | var oldc; 69 | var oldd; 70 | var a = 1732584193; 71 | var b = -271733879; 72 | var c = -1732584194; 73 | var d = 271733878; 74 | 75 | for (i = 0; i < x.length; i += 16) { 76 | olda = a; 77 | oldb = b; 78 | oldc = c; 79 | oldd = d; 80 | 81 | a = this.md5ff(a, b, c, d, x[i], 7, -680876936); 82 | d = this.md5ff(d, a, b, c, x[i + 1], 12, -389564586); 83 | c = this.md5ff(c, d, a, b, x[i + 2], 17, 606105819); 84 | b = this.md5ff(b, c, d, a, x[i + 3], 22, -1044525330); 85 | a = this.md5ff(a, b, c, d, x[i + 4], 7, -176418897); 86 | d = this.md5ff(d, a, b, c, x[i + 5], 12, 1200080426); 87 | c = this.md5ff(c, d, a, b, x[i + 6], 17, -1473231341); 88 | b = this.md5ff(b, c, d, a, x[i + 7], 22, -45705983); 89 | a = this.md5ff(a, b, c, d, x[i + 8], 7, 1770035416); 90 | d = this.md5ff(d, a, b, c, x[i + 9], 12, -1958414417); 91 | c = this.md5ff(c, d, a, b, x[i + 10], 17, -42063); 92 | b = this.md5ff(b, c, d, a, x[i + 11], 22, -1990404162); 93 | a = this.md5ff(a, b, c, d, x[i + 12], 7, 1804603682); 94 | d = this.md5ff(d, a, b, c, x[i + 13], 12, -40341101); 95 | c = this.md5ff(c, d, a, b, x[i + 14], 17, -1502002290); 96 | b = this.md5ff(b, c, d, a, x[i + 15], 22, 1236535329); 97 | 98 | a = this.md5gg(a, b, c, d, x[i + 1], 5, -165796510); 99 | d = this.md5gg(d, a, b, c, x[i + 6], 9, -1069501632); 100 | c = this.md5gg(c, d, a, b, x[i + 11], 14, 643717713); 101 | b = this.md5gg(b, c, d, a, x[i], 20, -373897302); 102 | a = this.md5gg(a, b, c, d, x[i + 5], 5, -701558691); 103 | d = this.md5gg(d, a, b, c, x[i + 10], 9, 38016083); 104 | c = this.md5gg(c, d, a, b, x[i + 15], 14, -660478335); 105 | b = this.md5gg(b, c, d, a, x[i + 4], 20, -405537848); 106 | a = this.md5gg(a, b, c, d, x[i + 9], 5, 568446438); 107 | d = this.md5gg(d, a, b, c, x[i + 14], 9, -1019803690); 108 | c = this.md5gg(c, d, a, b, x[i + 3], 14, -187363961); 109 | b = this.md5gg(b, c, d, a, x[i + 8], 20, 1163531501); 110 | a = this.md5gg(a, b, c, d, x[i + 13], 5, -1444681467); 111 | d = this.md5gg(d, a, b, c, x[i + 2], 9, -51403784); 112 | c = this.md5gg(c, d, a, b, x[i + 7], 14, 1735328473); 113 | b = this.md5gg(b, c, d, a, x[i + 12], 20, -1926607734); 114 | 115 | a = this.md5hh(a, b, c, d, x[i + 5], 4, -378558); 116 | d = this.md5hh(d, a, b, c, x[i + 8], 11, -2022574463); 117 | c = this.md5hh(c, d, a, b, x[i + 11], 16, 1839030562); 118 | b = this.md5hh(b, c, d, a, x[i + 14], 23, -35309556); 119 | a = this.md5hh(a, b, c, d, x[i + 1], 4, -1530992060); 120 | d = this.md5hh(d, a, b, c, x[i + 4], 11, 1272893353); 121 | c = this.md5hh(c, d, a, b, x[i + 7], 16, -155497632); 122 | b = this.md5hh(b, c, d, a, x[i + 10], 23, -1094730640); 123 | a = this.md5hh(a, b, c, d, x[i + 13], 4, 681279174); 124 | d = this.md5hh(d, a, b, c, x[i], 11, -358537222); 125 | c = this.md5hh(c, d, a, b, x[i + 3], 16, -722521979); 126 | b = this.md5hh(b, c, d, a, x[i + 6], 23, 76029189); 127 | a = this.md5hh(a, b, c, d, x[i + 9], 4, -640364487); 128 | d = this.md5hh(d, a, b, c, x[i + 12], 11, -421815835); 129 | c = this.md5hh(c, d, a, b, x[i + 15], 16, 530742520); 130 | b = this.md5hh(b, c, d, a, x[i + 2], 23, -995338651); 131 | 132 | a = this.md5ii(a, b, c, d, x[i], 6, -198630844); 133 | d = this.md5ii(d, a, b, c, x[i + 7], 10, 1126891415); 134 | c = this.md5ii(c, d, a, b, x[i + 14], 15, -1416354905); 135 | b = this.md5ii(b, c, d, a, x[i + 5], 21, -57434055); 136 | a = this.md5ii(a, b, c, d, x[i + 12], 6, 1700485571); 137 | d = this.md5ii(d, a, b, c, x[i + 3], 10, -1894986606); 138 | c = this.md5ii(c, d, a, b, x[i + 10], 15, -1051523); 139 | b = this.md5ii(b, c, d, a, x[i + 1], 21, -2054922799); 140 | a = this.md5ii(a, b, c, d, x[i + 8], 6, 1873313359); 141 | d = this.md5ii(d, a, b, c, x[i + 15], 10, -30611744); 142 | c = this.md5ii(c, d, a, b, x[i + 6], 15, -1560198380); 143 | b = this.md5ii(b, c, d, a, x[i + 13], 21, 1309151649); 144 | a = this.md5ii(a, b, c, d, x[i + 4], 6, -145523070); 145 | d = this.md5ii(d, a, b, c, x[i + 11], 10, -1120210379); 146 | c = this.md5ii(c, d, a, b, x[i + 2], 15, 718787259); 147 | b = this.md5ii(b, c, d, a, x[i + 9], 21, -343485551); 148 | 149 | a = this.safeAdd(a, olda); 150 | b = this.safeAdd(b, oldb); 151 | c = this.safeAdd(c, oldc); 152 | d = this.safeAdd(d, oldd); 153 | } 154 | return [a, b, c, d]; 155 | }, 156 | binl2rstr(input) { 157 | var i; 158 | var output = ''; 159 | var length32 = input.length * 32; 160 | for (i = 0; i < length32; i += 8) { 161 | output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xff); 162 | } 163 | return output; 164 | }, 165 | rstr2binl(input) { 166 | var i; 167 | var output = []; 168 | output[(input.length >> 2) - 1] = undefined; 169 | for (i = 0; i < output.length; i += 1) { 170 | output[i] = 0; 171 | } 172 | var length8 = input.length * 8; 173 | for (i = 0; i < length8; i += 8) { 174 | output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << (i % 32); 175 | } 176 | return output; 177 | }, 178 | rstrMD5(s) { 179 | return this.binl2rstr(this.binlMD5(this.rstr2binl(s), s.length * 8)); 180 | }, 181 | rstrHMACMD5(key, data) { 182 | var i; 183 | var bkey = this.rstr2binl(key); 184 | var ipad = []; 185 | var opad = []; 186 | var hash; 187 | ipad[15] = opad[15] = undefined; 188 | if (bkey.length > 16) { 189 | bkey = this.binlMD5(bkey, key.length * 8); 190 | } 191 | for (i = 0; i < 16; i += 1) { 192 | ipad[i] = bkey[i] ^ 0x36363636; 193 | opad[i] = bkey[i] ^ 0x5c5c5c5c; 194 | } 195 | hash = this.binlMD5(ipad.concat(this.rstr2binl(data)), 512 + data.length * 8); 196 | return this.binl2rstr(this.binlMD5(opad.concat(hash), 512 + 128)); 197 | }, 198 | rstr2hex(input) { 199 | var hexTab = '0123456789abcdef'; 200 | var output = ''; 201 | var x; 202 | var i; 203 | for (i = 0; i < input.length; i += 1) { 204 | x = input.charCodeAt(i); 205 | output += hexTab.charAt((x >>> 4) & 0x0f) + hexTab.charAt(x & 0x0f); 206 | } 207 | return output; 208 | }, 209 | str2rstrUTF8(input) { 210 | return unescape(encodeURIComponent(input)); 211 | }, 212 | rawMD5(s) { 213 | return this.rstrMD5(this.str2rstrUTF8(s)); 214 | }, 215 | hexMD5(s) { 216 | return this.rstr2hex(this.rawMD5(s)); 217 | }, 218 | rawHMACMD5(k, d) { 219 | return this.rstrHMACMD5(this.str2rstrUTF8(k), str2rstrUTF8(d)); 220 | }, 221 | hexHMACMD5(k, d) { 222 | return this.rstr2hex(this.rawHMACMD5(k, d)); 223 | }, 224 | 225 | md5(string, key, raw) { 226 | if (!key) { 227 | if (!raw) { 228 | return this.hexMD5(string); 229 | } 230 | return this.rawMD5(string); 231 | } 232 | if (!raw) { 233 | return this.hexHMACMD5(key, string); 234 | } 235 | return this.rawHMACMD5(key, string); 236 | }, 237 | /** 238 | * 得到md5加密后的sig参数 239 | * @param {Object} requestParam 接口参数 240 | * @param {String} sk签名字符串 241 | * @param {String} featrue 方法名 242 | * @return 返回加密后的sig参数 243 | */ 244 | getSig(requestParam, sk, feature, mode) { 245 | var sig = null; 246 | var requestArr = []; 247 | Object.keys(requestParam).sort().forEach(function(key){ 248 | requestArr.push(key + '=' + requestParam[key]); 249 | }); 250 | if (feature == 'search') { 251 | sig = '/ws/place/v1/search?' + requestArr.join('&') + sk; 252 | } 253 | if (feature == 'suggest') { 254 | sig = '/ws/place/v1/suggestion?' + requestArr.join('&') + sk; 255 | } 256 | if (feature == 'reverseGeocoder') { 257 | sig = '/ws/geocoder/v1/?' + requestArr.join('&') + sk; 258 | } 259 | if (feature == 'geocoder') { 260 | sig = '/ws/geocoder/v1/?' + requestArr.join('&') + sk; 261 | } 262 | if (feature == 'getCityList') { 263 | sig = '/ws/district/v1/list?' + requestArr.join('&') + sk; 264 | } 265 | if (feature == 'getDistrictByCityId') { 266 | sig = '/ws/district/v1/getchildren?' + requestArr.join('&') + sk; 267 | } 268 | if (feature == 'calculateDistance') { 269 | sig = '/ws/distance/v1/?' + requestArr.join('&') + sk; 270 | } 271 | if (feature == 'direction') { 272 | sig = '/ws/direction/v1/' + mode + '?' + requestArr.join('&') + sk; 273 | } 274 | sig = this.md5(sig); 275 | return sig; 276 | }, 277 | /** 278 | * 得到终点query字符串 279 | * @param {Array|String} 检索数据 280 | */ 281 | location2query(data) { 282 | if (typeof data == 'string') { 283 | return data; 284 | } 285 | var query = ''; 286 | for (var i = 0; i < data.length; i++) { 287 | var d = data[i]; 288 | if (!!query) { 289 | query += ';'; 290 | } 291 | if (d.location) { 292 | query = query + d.location.lat + ',' + d.location.lng; 293 | } 294 | if (d.latitude && d.longitude) { 295 | query = query + d.latitude + ',' + d.longitude; 296 | } 297 | } 298 | return query; 299 | }, 300 | 301 | /** 302 | * 计算角度 303 | */ 304 | rad(d) { 305 | return d * Math.PI / 180.0; 306 | }, 307 | /** 308 | * 处理终点location数组 309 | * @return 返回终点数组 310 | */ 311 | getEndLocation(location){ 312 | var to = location.split(';'); 313 | var endLocation = []; 314 | for (var i = 0; i < to.length; i++) { 315 | endLocation.push({ 316 | lat: parseFloat(to[i].split(',')[0]), 317 | lng: parseFloat(to[i].split(',')[1]) 318 | }) 319 | } 320 | return endLocation; 321 | }, 322 | 323 | /** 324 | * 计算两点间直线距离 325 | * @param a 表示纬度差 326 | * @param b 表示经度差 327 | * @return 返回的是距离,单位m 328 | */ 329 | getDistance(latFrom, lngFrom, latTo, lngTo) { 330 | var radLatFrom = this.rad(latFrom); 331 | var radLatTo = this.rad(latTo); 332 | var a = radLatFrom - radLatTo; 333 | var b = this.rad(lngFrom) - this.rad(lngTo); 334 | 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))); 335 | distance = distance * EARTH_RADIUS; 336 | distance = Math.round(distance * 10000) / 10000; 337 | return parseFloat(distance.toFixed(0)); 338 | }, 339 | /** 340 | * 使用微信接口进行定位 341 | */ 342 | getWXLocation(success, fail, complete) { 343 | wx.getLocation({ 344 | type: 'gcj02', 345 | success: success, 346 | fail: fail, 347 | complete: complete 348 | }); 349 | }, 350 | 351 | /** 352 | * 获取location参数 353 | */ 354 | getLocationParam(location) { 355 | if (typeof location == 'string') { 356 | var locationArr = location.split(','); 357 | if (locationArr.length === 2) { 358 | location = { 359 | latitude: location.split(',')[0], 360 | longitude: location.split(',')[1] 361 | }; 362 | } else { 363 | location = {}; 364 | } 365 | } 366 | return location; 367 | }, 368 | 369 | /** 370 | * 回调函数默认处理 371 | */ 372 | polyfillParam(param) { 373 | param.success = param.success || function () { }; 374 | param.fail = param.fail || function () { }; 375 | param.complete = param.complete || function () { }; 376 | }, 377 | 378 | /** 379 | * 验证param对应的key值是否为空 380 | * 381 | * @param {Object} param 接口参数 382 | * @param {String} key 对应参数的key 383 | */ 384 | checkParamKeyEmpty(param, key) { 385 | if (!param[key]) { 386 | var errconf = this.buildErrorConfig(ERROR_CONF.PARAM_ERR, ERROR_CONF.PARAM_ERR_MSG + key +'参数格式有误'); 387 | param.fail(errconf); 388 | param.complete(errconf); 389 | return true; 390 | } 391 | return false; 392 | }, 393 | 394 | /** 395 | * 验证参数中是否存在检索词keyword 396 | * 397 | * @param {Object} param 接口参数 398 | */ 399 | checkKeyword(param){ 400 | return !this.checkParamKeyEmpty(param, 'keyword'); 401 | }, 402 | 403 | /** 404 | * 验证location值 405 | * 406 | * @param {Object} param 接口参数 407 | */ 408 | checkLocation(param) { 409 | var location = this.getLocationParam(param.location); 410 | if (!location || !location.latitude || !location.longitude) { 411 | var errconf = this.buildErrorConfig(ERROR_CONF.PARAM_ERR, ERROR_CONF.PARAM_ERR_MSG + ' location参数格式有误'); 412 | param.fail(errconf); 413 | param.complete(errconf); 414 | return false; 415 | } 416 | return true; 417 | }, 418 | 419 | /** 420 | * 构造错误数据结构 421 | * @param {Number} errCode 错误码 422 | * @param {Number} errMsg 错误描述 423 | */ 424 | buildErrorConfig(errCode, errMsg) { 425 | return { 426 | status: errCode, 427 | message: errMsg 428 | }; 429 | }, 430 | 431 | /** 432 | * 433 | * 数据处理函数 434 | * 根据传入参数不同处理不同数据 435 | * @param {String} feature 功能名称 436 | * search 地点搜索 437 | * suggest关键词提示 438 | * reverseGeocoder逆地址解析 439 | * geocoder地址解析 440 | * getCityList获取城市列表:父集 441 | * getDistrictByCityId获取区县列表:子集 442 | * calculateDistance距离计算 443 | * @param {Object} param 接口参数 444 | * @param {Object} data 数据 445 | */ 446 | handleData(param,data,feature){ 447 | if (feature == 'search') { 448 | var searchResult = data.data; 449 | var searchSimplify = []; 450 | for (var i = 0; i < searchResult.length; i++) { 451 | searchSimplify.push({ 452 | id: searchResult[i].id || null, 453 | title: searchResult[i].title || null, 454 | latitude: searchResult[i].location && searchResult[i].location.lat || null, 455 | longitude: searchResult[i].location && searchResult[i].location.lng || null, 456 | address: searchResult[i].address || null, 457 | category: searchResult[i].category || null, 458 | tel: searchResult[i].tel || null, 459 | adcode: searchResult[i].ad_info && searchResult[i].ad_info.adcode || null, 460 | city: searchResult[i].ad_info && searchResult[i].ad_info.city || null, 461 | district: searchResult[i].ad_info && searchResult[i].ad_info.district || null, 462 | province: searchResult[i].ad_info && searchResult[i].ad_info.province || null 463 | }) 464 | } 465 | param.success(data, { 466 | searchResult: searchResult, 467 | searchSimplify: searchSimplify 468 | }) 469 | } else if (feature == 'suggest') { 470 | var suggestResult = data.data; 471 | var suggestSimplify = []; 472 | for (var i = 0; i < suggestResult.length; i++) { 473 | suggestSimplify.push({ 474 | adcode: suggestResult[i].adcode || null, 475 | address: suggestResult[i].address || null, 476 | category: suggestResult[i].category || null, 477 | city: suggestResult[i].city || null, 478 | district: suggestResult[i].district || null, 479 | id: suggestResult[i].id || null, 480 | latitude: suggestResult[i].location && suggestResult[i].location.lat || null, 481 | longitude: suggestResult[i].location && suggestResult[i].location.lng || null, 482 | province: suggestResult[i].province || null, 483 | title: suggestResult[i].title || null, 484 | type: suggestResult[i].type || null 485 | }) 486 | } 487 | param.success(data, { 488 | suggestResult: suggestResult, 489 | suggestSimplify: suggestSimplify 490 | }) 491 | } else if (feature == 'reverseGeocoder') { 492 | var reverseGeocoderResult = data.result; 493 | var reverseGeocoderSimplify = { 494 | address: reverseGeocoderResult.address || null, 495 | latitude: reverseGeocoderResult.location && reverseGeocoderResult.location.lat || null, 496 | longitude: reverseGeocoderResult.location && reverseGeocoderResult.location.lng || null, 497 | adcode: reverseGeocoderResult.ad_info && reverseGeocoderResult.ad_info.adcode || null, 498 | city: reverseGeocoderResult.address_component && reverseGeocoderResult.address_component.city || null, 499 | district: reverseGeocoderResult.address_component && reverseGeocoderResult.address_component.district || null, 500 | nation: reverseGeocoderResult.address_component && reverseGeocoderResult.address_component.nation || null, 501 | province: reverseGeocoderResult.address_component && reverseGeocoderResult.address_component.province || null, 502 | street: reverseGeocoderResult.address_component && reverseGeocoderResult.address_component.street || null, 503 | street_number: reverseGeocoderResult.address_component && reverseGeocoderResult.address_component.street_number || null, 504 | recommend: reverseGeocoderResult.formatted_addresses && reverseGeocoderResult.formatted_addresses.recommend || null, 505 | rough: reverseGeocoderResult.formatted_addresses && reverseGeocoderResult.formatted_addresses.rough || null 506 | }; 507 | if (reverseGeocoderResult.pois) {//判断是否返回周边poi 508 | var pois = reverseGeocoderResult.pois; 509 | var poisSimplify = []; 510 | for (var i = 0;i < pois.length;i++) { 511 | poisSimplify.push({ 512 | id: pois[i].id || null, 513 | title: pois[i].title || null, 514 | latitude: pois[i].location && pois[i].location.lat || null, 515 | longitude: pois[i].location && pois[i].location.lng || null, 516 | address: pois[i].address || null, 517 | category: pois[i].category || null, 518 | adcode: pois[i].ad_info && pois[i].ad_info.adcode || null, 519 | city: pois[i].ad_info && pois[i].ad_info.city || null, 520 | district: pois[i].ad_info && pois[i].ad_info.district || null, 521 | province: pois[i].ad_info && pois[i].ad_info.province || null 522 | }) 523 | } 524 | param.success(data,{ 525 | reverseGeocoderResult: reverseGeocoderResult, 526 | reverseGeocoderSimplify: reverseGeocoderSimplify, 527 | pois: pois, 528 | poisSimplify: poisSimplify 529 | }) 530 | } else { 531 | param.success(data, { 532 | reverseGeocoderResult: reverseGeocoderResult, 533 | reverseGeocoderSimplify: reverseGeocoderSimplify 534 | }) 535 | } 536 | } else if (feature == 'geocoder') { 537 | var geocoderResult = data.result; 538 | var geocoderSimplify = { 539 | title: geocoderResult.title || null, 540 | latitude: geocoderResult.location && geocoderResult.location.lat || null, 541 | longitude: geocoderResult.location && geocoderResult.location.lng || null, 542 | adcode: geocoderResult.ad_info && geocoderResult.ad_info.adcode || null, 543 | province: geocoderResult.address_components && geocoderResult.address_components.province || null, 544 | city: geocoderResult.address_components && geocoderResult.address_components.city || null, 545 | district: geocoderResult.address_components && geocoderResult.address_components.district || null, 546 | street: geocoderResult.address_components && geocoderResult.address_components.street || null, 547 | street_number: geocoderResult.address_components && geocoderResult.address_components.street_number || null, 548 | level: geocoderResult.level || null 549 | }; 550 | param.success(data,{ 551 | geocoderResult: geocoderResult, 552 | geocoderSimplify: geocoderSimplify 553 | }); 554 | } else if (feature == 'getCityList') { 555 | var provinceResult = data.result[0]; 556 | var cityResult = data.result[1]; 557 | var districtResult = data.result[2]; 558 | param.success(data,{ 559 | provinceResult: provinceResult, 560 | cityResult: cityResult, 561 | districtResult: districtResult 562 | }); 563 | } else if (feature == 'getDistrictByCityId') { 564 | var districtByCity = data.result[0]; 565 | param.success(data, districtByCity); 566 | } else if (feature == 'calculateDistance') { 567 | var calculateDistanceResult = data.result.elements; 568 | var distance = []; 569 | for (var i = 0; i < calculateDistanceResult.length; i++){ 570 | distance.push(calculateDistanceResult[i].distance); 571 | } 572 | param.success(data, { 573 | calculateDistanceResult: calculateDistanceResult, 574 | distance: distance 575 | }); 576 | } else if (feature == 'direction') { 577 | var direction = data.result.routes; 578 | param.success(data,direction); 579 | } else { 580 | param.success(data); 581 | } 582 | }, 583 | 584 | /** 585 | * 构造微信请求参数,公共属性处理 586 | * 587 | * @param {Object} param 接口参数 588 | * @param {Object} param 配置项 589 | * @param {String} feature 方法名 590 | */ 591 | buildWxRequestConfig(param, options, feature) { 592 | var that = this; 593 | options.header = { "content-type": "application/json" }; 594 | options.method = 'GET'; 595 | options.success = function (res) { 596 | var data = res.data; 597 | if (data.status === 0) { 598 | that.handleData(param, data, feature); 599 | } else { 600 | param.fail(data); 601 | } 602 | }; 603 | options.fail = function (res) { 604 | res.statusCode = ERROR_CONF.WX_ERR_CODE; 605 | param.fail(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)); 606 | }; 607 | options.complete = function (res) { 608 | var statusCode = +res.statusCode; 609 | switch(statusCode) { 610 | case ERROR_CONF.WX_ERR_CODE: { 611 | param.complete(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)); 612 | break; 613 | } 614 | case ERROR_CONF.WX_OK_CODE: { 615 | var data = res.data; 616 | if (data.status === 0) { 617 | param.complete(data); 618 | } else { 619 | param.complete(that.buildErrorConfig(data.status, data.message)); 620 | } 621 | break; 622 | } 623 | default:{ 624 | param.complete(that.buildErrorConfig(ERROR_CONF.SYSTEM_ERR, ERROR_CONF.SYSTEM_ERR_MSG)); 625 | } 626 | 627 | } 628 | }; 629 | return options; 630 | }, 631 | 632 | /** 633 | * 处理用户参数是否传入坐标进行不同的处理 634 | */ 635 | locationProcess(param, locationsuccess, locationfail, locationcomplete) { 636 | var that = this; 637 | locationfail = locationfail || function (res) { 638 | res.statusCode = ERROR_CONF.WX_ERR_CODE; 639 | param.fail(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)); 640 | }; 641 | locationcomplete = locationcomplete || function (res) { 642 | if (res.statusCode == ERROR_CONF.WX_ERR_CODE) { 643 | param.complete(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)); 644 | } 645 | }; 646 | if (!param.location) { 647 | that.getWXLocation(locationsuccess, locationfail, locationcomplete); 648 | } else if (that.checkLocation(param)) { 649 | var location = Utils.getLocationParam(param.location); 650 | locationsuccess(location); 651 | } 652 | } 653 | }; 654 | 655 | 656 | class QQMapWX { 657 | 658 | /** 659 | * 构造函数 660 | * 661 | * @param {Object} options 接口参数,key 为必选参数 662 | */ 663 | constructor(options) { 664 | if (!options.key) { 665 | throw Error('key值不能为空'); 666 | } 667 | this.key = options.key; 668 | }; 669 | 670 | /** 671 | * POI周边检索 672 | * 673 | * @param {Object} options 接口参数对象 674 | * 675 | * 参数对象结构可以参考 676 | * @see http://lbs.qq.com/webservice_v1/guide-search.html 677 | */ 678 | search(options) { 679 | var that = this; 680 | options = options || {}; 681 | 682 | Utils.polyfillParam(options); 683 | 684 | if (!Utils.checkKeyword(options)) { 685 | return; 686 | } 687 | 688 | var requestParam = { 689 | keyword: options.keyword, 690 | orderby: options.orderby || '_distance', 691 | page_size: options.page_size || 10, 692 | page_index: options.page_index || 1, 693 | output: 'json', 694 | key: that.key 695 | }; 696 | 697 | if (options.address_format) { 698 | requestParam.address_format = options.address_format; 699 | } 700 | 701 | if (options.filter) { 702 | requestParam.filter = options.filter; 703 | } 704 | 705 | var distance = options.distance || "1000"; 706 | var auto_extend = options.auto_extend || 1; 707 | var region = null; 708 | var rectangle = null; 709 | 710 | //判断城市限定参数 711 | if (options.region) { 712 | region = options.region; 713 | } 714 | 715 | //矩形限定坐标(暂时只支持字符串格式) 716 | if (options.rectangle) { 717 | rectangle = options.rectangle; 718 | } 719 | 720 | var locationsuccess = function (result) { 721 | if (region && !rectangle) { 722 | //城市限定参数拼接 723 | requestParam.boundary = "region(" + region + "," + auto_extend + "," + result.latitude + "," + result.longitude + ")"; 724 | if (options.sig) { 725 | requestParam.sig = Utils.getSig(requestParam, options.sig, 'search'); 726 | } 727 | } else if (rectangle && !region) { 728 | //矩形搜索 729 | requestParam.boundary = "rectangle(" + rectangle + ")"; 730 | if (options.sig) { 731 | requestParam.sig = Utils.getSig(requestParam, options.sig, 'search'); 732 | } 733 | } else { 734 | requestParam.boundary = "nearby(" + result.latitude + "," + result.longitude + "," + distance + "," + auto_extend + ")"; 735 | if (options.sig) { 736 | requestParam.sig = Utils.getSig(requestParam, options.sig, 'search'); 737 | } 738 | } 739 | wx.request(Utils.buildWxRequestConfig(options, { 740 | url: URL_SEARCH, 741 | data: requestParam 742 | }, 'search')); 743 | }; 744 | Utils.locationProcess(options, locationsuccess); 745 | }; 746 | 747 | /** 748 | * sug模糊检索 749 | * 750 | * @param {Object} options 接口参数对象 751 | * 752 | * 参数对象结构可以参考 753 | * http://lbs.qq.com/webservice_v1/guide-suggestion.html 754 | */ 755 | getSuggestion(options) { 756 | var that = this; 757 | options = options || {}; 758 | Utils.polyfillParam(options); 759 | 760 | if (!Utils.checkKeyword(options)) { 761 | return; 762 | } 763 | 764 | var requestParam = { 765 | keyword: options.keyword, 766 | region: options.region || '全国', 767 | region_fix: options.region_fix || 0, 768 | policy: options.policy || 0, 769 | page_size: options.page_size || 10,//控制显示条数 770 | page_index: options.page_index || 1,//控制页数 771 | get_subpois : options.get_subpois || 0,//返回子地点 772 | output: 'json', 773 | key: that.key 774 | }; 775 | //长地址 776 | if (options.address_format) { 777 | requestParam.address_format = options.address_format; 778 | } 779 | //过滤 780 | if (options.filter) { 781 | requestParam.filter = options.filter; 782 | } 783 | //排序 784 | if (options.location) { 785 | var locationsuccess = function (result) { 786 | requestParam.location = result.latitude + ',' + result.longitude; 787 | if (options.sig) { 788 | requestParam.sig = Utils.getSig(requestParam, options.sig, 'suggest'); 789 | } 790 | wx.request(Utils.buildWxRequestConfig(options, { 791 | url: URL_SUGGESTION, 792 | data: requestParam 793 | }, "suggest")); 794 | }; 795 | Utils.locationProcess(options, locationsuccess); 796 | } else { 797 | if (options.sig) { 798 | requestParam.sig = Utils.getSig(requestParam, options.sig, 'suggest'); 799 | } 800 | wx.request(Utils.buildWxRequestConfig(options, { 801 | url: URL_SUGGESTION, 802 | data: requestParam 803 | }, "suggest")); 804 | } 805 | }; 806 | 807 | /** 808 | * 逆地址解析 809 | * 810 | * @param {Object} options 接口参数对象 811 | * 812 | * 请求参数结构可以参考 813 | * http://lbs.qq.com/webservice_v1/guide-gcoder.html 814 | */ 815 | reverseGeocoder(options) { 816 | var that = this; 817 | options = options || {}; 818 | Utils.polyfillParam(options); 819 | var requestParam = { 820 | coord_type: options.coord_type || 5, 821 | get_poi: options.get_poi || 0, 822 | output: 'json', 823 | key: that.key 824 | }; 825 | if (options.poi_options) { 826 | requestParam.poi_options = options.poi_options 827 | } 828 | 829 | var locationsuccess = function (result) { 830 | requestParam.location = result.latitude + ',' + result.longitude; 831 | if (options.sig) { 832 | requestParam.sig = Utils.getSig(requestParam, options.sig, 'reverseGeocoder'); 833 | } 834 | wx.request(Utils.buildWxRequestConfig(options, { 835 | url: URL_GET_GEOCODER, 836 | data: requestParam 837 | }, 'reverseGeocoder')); 838 | }; 839 | Utils.locationProcess(options, locationsuccess); 840 | }; 841 | 842 | /** 843 | * 地址解析 844 | * 845 | * @param {Object} options 接口参数对象 846 | * 847 | * 请求参数结构可以参考 848 | * http://lbs.qq.com/webservice_v1/guide-geocoder.html 849 | */ 850 | geocoder(options) { 851 | var that = this; 852 | options = options || {}; 853 | Utils.polyfillParam(options); 854 | 855 | if (Utils.checkParamKeyEmpty(options, 'address')) { 856 | return; 857 | } 858 | 859 | var requestParam = { 860 | address: options.address, 861 | output: 'json', 862 | key: that.key 863 | }; 864 | 865 | //城市限定 866 | if (options.region) { 867 | requestParam.region = options.region; 868 | } 869 | 870 | if (options.sig) { 871 | requestParam.sig = Utils.getSig(requestParam, options.sig, 'geocoder'); 872 | } 873 | 874 | wx.request(Utils.buildWxRequestConfig(options, { 875 | url: URL_GET_GEOCODER, 876 | data: requestParam 877 | },'geocoder')); 878 | }; 879 | 880 | 881 | /** 882 | * 获取城市列表 883 | * 884 | * @param {Object} options 接口参数对象 885 | * 886 | * 请求参数结构可以参考 887 | * http://lbs.qq.com/webservice_v1/guide-region.html 888 | */ 889 | getCityList(options) { 890 | var that = this; 891 | options = options || {}; 892 | Utils.polyfillParam(options); 893 | var requestParam = { 894 | output: 'json', 895 | key: that.key 896 | }; 897 | 898 | if (options.sig) { 899 | requestParam.sig = Utils.getSig(requestParam, options.sig, 'getCityList'); 900 | } 901 | 902 | wx.request(Utils.buildWxRequestConfig(options, { 903 | url: URL_CITY_LIST, 904 | data: requestParam 905 | },'getCityList')); 906 | }; 907 | 908 | /** 909 | * 获取对应城市ID的区县列表 910 | * 911 | * @param {Object} options 接口参数对象 912 | * 913 | * 请求参数结构可以参考 914 | * http://lbs.qq.com/webservice_v1/guide-region.html 915 | */ 916 | getDistrictByCityId(options) { 917 | var that = this; 918 | options = options || {}; 919 | Utils.polyfillParam(options); 920 | 921 | if (Utils.checkParamKeyEmpty(options, 'id')) { 922 | return; 923 | } 924 | 925 | var requestParam = { 926 | id: options.id || '', 927 | output: 'json', 928 | key: that.key 929 | }; 930 | 931 | if (options.sig) { 932 | requestParam.sig = Utils.getSig(requestParam, options.sig, 'getDistrictByCityId'); 933 | } 934 | 935 | wx.request(Utils.buildWxRequestConfig(options, { 936 | url: URL_AREA_LIST, 937 | data: requestParam 938 | },'getDistrictByCityId')); 939 | }; 940 | 941 | /** 942 | * 用于单起点到多终点的路线距离(非直线距离)计算: 943 | * 支持两种距离计算方式:步行和驾车。 944 | * 起点到终点最大限制直线距离10公里。 945 | * 946 | * 新增直线距离计算。 947 | * 948 | * @param {Object} options 接口参数对象 949 | * 950 | * 请求参数结构可以参考 951 | * http://lbs.qq.com/webservice_v1/guide-distance.html 952 | */ 953 | calculateDistance(options) { 954 | var that = this; 955 | options = options || {}; 956 | Utils.polyfillParam(options); 957 | 958 | if (Utils.checkParamKeyEmpty(options, 'to')) { 959 | return; 960 | } 961 | 962 | var requestParam = { 963 | mode: options.mode || 'walking', 964 | to: Utils.location2query(options.to), 965 | output: 'json', 966 | key: that.key 967 | }; 968 | 969 | if (options.from) { 970 | options.location = options.from; 971 | } 972 | 973 | //计算直线距离 974 | if(requestParam.mode == 'straight'){ 975 | var locationsuccess = function (result) { 976 | var locationTo = Utils.getEndLocation(requestParam.to);//处理终点坐标 977 | var data = { 978 | message:"query ok", 979 | result:{ 980 | elements:[] 981 | }, 982 | status:0 983 | }; 984 | for (var i = 0; i < locationTo.length; i++) { 985 | data.result.elements.push({//将坐标存入 986 | distance: Utils.getDistance(result.latitude, result.longitude, locationTo[i].lat, locationTo[i].lng), 987 | duration:0, 988 | from:{ 989 | lat: result.latitude, 990 | lng:result.longitude 991 | }, 992 | to:{ 993 | lat: locationTo[i].lat, 994 | lng: locationTo[i].lng 995 | } 996 | }); 997 | } 998 | var calculateResult = data.result.elements; 999 | var distanceResult = []; 1000 | for (var i = 0; i < calculateResult.length; i++) { 1001 | distanceResult.push(calculateResult[i].distance); 1002 | } 1003 | return options.success(data,{ 1004 | calculateResult: calculateResult, 1005 | distanceResult: distanceResult 1006 | }); 1007 | }; 1008 | 1009 | Utils.locationProcess(options, locationsuccess); 1010 | } else { 1011 | var locationsuccess = function (result) { 1012 | requestParam.from = result.latitude + ',' + result.longitude; 1013 | if (options.sig) { 1014 | requestParam.sig = Utils.getSig(requestParam, options.sig, 'calculateDistance'); 1015 | } 1016 | wx.request(Utils.buildWxRequestConfig(options, { 1017 | url: URL_DISTANCE, 1018 | data: requestParam 1019 | },'calculateDistance')); 1020 | }; 1021 | 1022 | Utils.locationProcess(options, locationsuccess); 1023 | } 1024 | }; 1025 | 1026 | /** 1027 | * 路线规划: 1028 | * 1029 | * @param {Object} options 接口参数对象 1030 | * 1031 | * 请求参数结构可以参考 1032 | * https://lbs.qq.com/webservice_v1/guide-road.html 1033 | */ 1034 | direction(options) { 1035 | var that = this; 1036 | options = options || {}; 1037 | Utils.polyfillParam(options); 1038 | 1039 | if (Utils.checkParamKeyEmpty(options, 'to')) { 1040 | return; 1041 | } 1042 | 1043 | var requestParam = { 1044 | output: 'json', 1045 | key: that.key 1046 | }; 1047 | 1048 | //to格式处理 1049 | if (typeof options.to == 'string') { 1050 | requestParam.to = options.to; 1051 | } else { 1052 | requestParam.to = options.to.latitude + ',' + options.to.longitude; 1053 | } 1054 | //初始化局部请求域名 1055 | var SET_URL_DIRECTION = null; 1056 | //设置默认mode属性 1057 | options.mode = options.mode || MODE.driving; 1058 | 1059 | //设置请求域名 1060 | SET_URL_DIRECTION = URL_DIRECTION + options.mode; 1061 | 1062 | if (options.from) { 1063 | options.location = options.from; 1064 | } 1065 | 1066 | if (options.mode == MODE.driving) { 1067 | if (options.from_poi) { 1068 | requestParam.from_poi = options.from_poi; 1069 | } 1070 | if (options.heading) { 1071 | requestParam.heading = options.heading; 1072 | } 1073 | if (options.speed) { 1074 | requestParam.speed = options.speed; 1075 | } 1076 | if (options.accuracy) { 1077 | requestParam.accuracy = options.accuracy; 1078 | } 1079 | if (options.road_type) { 1080 | requestParam.road_type = options.road_type; 1081 | } 1082 | if (options.to_poi) { 1083 | requestParam.to_poi = options.to_poi; 1084 | } 1085 | if (options.from_track) { 1086 | requestParam.from_track = options.from_track; 1087 | } 1088 | if (options.waypoints) { 1089 | requestParam.waypoints = options.waypoints; 1090 | } 1091 | if (options.policy) { 1092 | requestParam.policy = options.policy; 1093 | } 1094 | if (options.plate_number) { 1095 | requestParam.plate_number = options.plate_number; 1096 | } 1097 | } 1098 | 1099 | if (options.mode == MODE.transit) { 1100 | if (options.departure_time) { 1101 | requestParam.departure_time = options.departure_time; 1102 | } 1103 | if (options.policy) { 1104 | requestParam.policy = options.policy; 1105 | } 1106 | } 1107 | 1108 | var locationsuccess = function (result) { 1109 | requestParam.from = result.latitude + ',' + result.longitude; 1110 | if (options.sig) { 1111 | requestParam.sig = Utils.getSig(requestParam, options.sig, 'direction',options.mode); 1112 | } 1113 | wx.request(Utils.buildWxRequestConfig(options, { 1114 | url: SET_URL_DIRECTION, 1115 | data: requestParam 1116 | }, 'direction')); 1117 | }; 1118 | 1119 | Utils.locationProcess(options, locationsuccess); 1120 | } 1121 | }; 1122 | 1123 | module.exports = QQMapWX; -------------------------------------------------------------------------------- /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; -------------------------------------------------------------------------------- /lib/weui.wxss: -------------------------------------------------------------------------------- 1 | /*! 2 | * weui.js v1.1.0 (https://github.com/weui/weui-wxss) 3 | * Copyright 2016, wechat ui team 4 | * MIT license 5 | */ 6 | page { 7 | line-height: 1.6; 8 | font-family: -apple-system-font, "Helvetica Neue", sans-serif; 9 | } 10 | icon { 11 | vertical-align: middle; 12 | } 13 | .weui-cells { 14 | position: relative; 15 | margin-top: 1.17647059em; 16 | background-color: #FFFFFF; 17 | line-height: 1.41176471; 18 | font-size: 17px; 19 | } 20 | .weui-cells:before { 21 | content: " "; 22 | position: absolute; 23 | left: 0; 24 | top: 0; 25 | right: 0; 26 | height: 1px; 27 | border-top: 1rpx solid #D9D9D9; 28 | color: #D9D9D9; 29 | } 30 | .weui-cells:after { 31 | content: " "; 32 | position: absolute; 33 | left: 0; 34 | bottom: 0; 35 | right: 0; 36 | height: 1px; 37 | border-bottom: 1rpx solid #D9D9D9; 38 | color: #D9D9D9; 39 | } 40 | .weui-cells__title { 41 | margin-top: .77em; 42 | margin-bottom: .3em; 43 | padding-left: 15px; 44 | padding-right: 15px; 45 | color: #999999; 46 | font-size: 14px; 47 | } 48 | .weui-cells_after-title { 49 | margin-top: 0; 50 | } 51 | .weui-cells__tips { 52 | margin-top: .3em; 53 | color: #999999; 54 | padding-left: 15px; 55 | padding-right: 15px; 56 | font-size: 14px; 57 | } 58 | .weui-cell { 59 | padding: 10px 15px; 60 | position: relative; 61 | display: -webkit-box; 62 | display: -webkit-flex; 63 | display: flex; 64 | -webkit-box-align: center; 65 | -webkit-align-items: center; 66 | align-items: center; 67 | } 68 | .weui-cell:before { 69 | content: " "; 70 | position: absolute; 71 | left: 0; 72 | top: 0; 73 | right: 0; 74 | height: 1px; 75 | border-top: 1rpx solid #D9D9D9; 76 | color: #D9D9D9; 77 | left: 15px; 78 | } 79 | .weui-cell:first-child:before { 80 | display: none; 81 | } 82 | .weui-cell_active { 83 | background-color: #ECECEC; 84 | } 85 | .weui-cell_primary { 86 | -webkit-box-align: start; 87 | -webkit-align-items: flex-start; 88 | align-items: flex-start; 89 | } 90 | .weui-cell__bd { 91 | -webkit-box-flex: 1; 92 | -webkit-flex: 1; 93 | flex: 1; 94 | } 95 | .weui-cell__ft { 96 | text-align: right; 97 | color: #999999; 98 | } 99 | .weui-cell_access { 100 | color: inherit; 101 | } 102 | .weui-cell__ft_in-access { 103 | padding-right: 13px; 104 | position: relative; 105 | } 106 | .weui-cell__ft_in-access:after { 107 | content: " "; 108 | display: inline-block; 109 | height: 6px; 110 | width: 6px; 111 | border-width: 2px 2px 0 0; 112 | border-color: #C8C8CD; 113 | border-style: solid; 114 | -webkit-transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0); 115 | transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0); 116 | position: relative; 117 | top: -2px; 118 | position: absolute; 119 | top: 50%; 120 | margin-top: -4px; 121 | right: 2px; 122 | } 123 | .weui-cell_link { 124 | color: #586C94; 125 | font-size: 14px; 126 | } 127 | .weui-cell_link:active { 128 | background-color: #ECECEC; 129 | } 130 | .weui-cell_link:first-child:before { 131 | display: block; 132 | } 133 | .weui-icon-radio { 134 | margin-left: 3.2px; 135 | margin-right: 3.2px; 136 | } 137 | .weui-icon-checkbox_circle, 138 | .weui-icon-checkbox_success { 139 | margin-left: 4.6px; 140 | margin-right: 4.6px; 141 | } 142 | .weui-check__label:active { 143 | background-color: #ECECEC; 144 | } 145 | .weui-check { 146 | position: absolute; 147 | left: -9999px; 148 | } 149 | .weui-check__hd_in-checkbox { 150 | padding-right: 0.35em; 151 | } 152 | .weui-cell__ft_in-radio { 153 | padding-left: 0.35em; 154 | } 155 | .weui-cell_input { 156 | padding-top: 0; 157 | padding-bottom: 0; 158 | } 159 | .weui-label { 160 | width: 105px; 161 | word-wrap: break-word; 162 | word-break: break-all; 163 | } 164 | .weui-input { 165 | height: 2.58823529em; 166 | min-height: 2.58823529em; 167 | line-height: 2.58823529em; 168 | } 169 | .weui-toptips { 170 | position: fixed; 171 | -webkit-transform: translateZ(0); 172 | transform: translateZ(0); 173 | top: 0; 174 | left: 0; 175 | right: 0; 176 | padding: 5px; 177 | font-size: 14px; 178 | text-align: center; 179 | color: #FFFFFF; 180 | z-index: 5000; 181 | word-wrap: break-word; 182 | word-break: break-all; 183 | } 184 | .weui-toptips_warn { 185 | background-color: #E64340; 186 | } 187 | .weui-textarea { 188 | display: block; 189 | width: 100%; 190 | } 191 | .weui-textarea-counter { 192 | color: #B2B2B2; 193 | text-align: right; 194 | } 195 | .weui-textarea-counter_warn { 196 | color: #E64340; 197 | } 198 | .weui-cell_warn { 199 | color: #E64340; 200 | } 201 | .weui-form-preview { 202 | position: relative; 203 | background-color: #FFFFFF; 204 | } 205 | .weui-form-preview:before { 206 | content: " "; 207 | position: absolute; 208 | left: 0; 209 | top: 0; 210 | right: 0; 211 | height: 1px; 212 | border-top: 1rpx solid #D9D9D9; 213 | color: #D9D9D9; 214 | } 215 | .weui-form-preview:after { 216 | content: " "; 217 | position: absolute; 218 | left: 0; 219 | bottom: 0; 220 | right: 0; 221 | height: 1px; 222 | border-bottom: 1rpx solid #D9D9D9; 223 | color: #D9D9D9; 224 | } 225 | .weui-form-preview__value { 226 | font-size: 14px; 227 | } 228 | .weui-form-preview__value_in-hd { 229 | font-size: 26px; 230 | } 231 | .weui-form-preview__hd { 232 | position: relative; 233 | padding: 10px 15px; 234 | text-align: right; 235 | line-height: 2.5em; 236 | } 237 | .weui-form-preview__hd:after { 238 | content: " "; 239 | position: absolute; 240 | left: 0; 241 | bottom: 0; 242 | right: 0; 243 | height: 1px; 244 | border-bottom: 1rpx solid #D9D9D9; 245 | color: #D9D9D9; 246 | left: 15px; 247 | } 248 | .weui-form-preview__bd { 249 | padding: 10px 15px; 250 | font-size: .9em; 251 | text-align: right; 252 | color: #999999; 253 | line-height: 2; 254 | } 255 | .weui-form-preview__ft { 256 | position: relative; 257 | line-height: 50px; 258 | display: -webkit-box; 259 | display: -webkit-flex; 260 | display: flex; 261 | } 262 | .weui-form-preview__ft:after { 263 | content: " "; 264 | position: absolute; 265 | left: 0; 266 | top: 0; 267 | right: 0; 268 | height: 1px; 269 | border-top: 1rpx solid #D5D5D6; 270 | color: #D5D5D6; 271 | } 272 | .weui-form-preview__item { 273 | overflow: hidden; 274 | } 275 | .weui-form-preview__label { 276 | float: left; 277 | margin-right: 1em; 278 | min-width: 4em; 279 | color: #999999; 280 | text-align: justify; 281 | text-align-last: justify; 282 | } 283 | .weui-form-preview__value { 284 | display: block; 285 | overflow: hidden; 286 | word-break: normal; 287 | word-wrap: break-word; 288 | } 289 | .weui-form-preview__btn { 290 | position: relative; 291 | display: block; 292 | -webkit-box-flex: 1; 293 | -webkit-flex: 1; 294 | flex: 1; 295 | color: #3CC51F; 296 | text-align: center; 297 | } 298 | .weui-form-preview__btn:after { 299 | content: " "; 300 | position: absolute; 301 | left: 0; 302 | top: 0; 303 | width: 1px; 304 | bottom: 0; 305 | border-left: 1rpx solid #D5D5D6; 306 | color: #D5D5D6; 307 | } 308 | .weui-form-preview__btn:first-child:after { 309 | display: none; 310 | } 311 | .weui-form-preview__btn_active { 312 | background-color: #EEEEEE; 313 | } 314 | .weui-form-preview__btn_default { 315 | color: #999999; 316 | } 317 | .weui-form-preview__btn_primary { 318 | color: #0BB20C; 319 | } 320 | .weui-cell_select { 321 | padding: 0; 322 | } 323 | .weui-select { 324 | position: relative; 325 | padding-left: 15px; 326 | padding-right: 30px; 327 | height: 2.58823529em; 328 | min-height: 2.58823529em; 329 | line-height: 2.58823529em; 330 | border-right: 1rpx solid #D9D9D9; 331 | } 332 | .weui-select:before { 333 | content: " "; 334 | display: inline-block; 335 | height: 6px; 336 | width: 6px; 337 | border-width: 2px 2px 0 0; 338 | border-color: #C8C8CD; 339 | border-style: solid; 340 | -webkit-transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0); 341 | transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0); 342 | position: relative; 343 | top: -2px; 344 | position: absolute; 345 | top: 50%; 346 | right: 15px; 347 | margin-top: -4px; 348 | } 349 | .weui-select_in-select-after { 350 | padding-left: 0; 351 | } 352 | .weui-cell__hd_in-select-after, 353 | .weui-cell__bd_in-select-before { 354 | padding-left: 15px; 355 | } 356 | .weui-cell_vcode { 357 | padding-right: 0; 358 | } 359 | .weui-vcode-img { 360 | margin-left: 5px; 361 | height: 2.58823529em; 362 | vertical-align: middle; 363 | } 364 | .weui-vcode-btn { 365 | display: inline-block; 366 | height: 2.58823529em; 367 | margin-left: 5px; 368 | padding: 0 0.6em 0 0.7em; 369 | border-left: 1px solid #E5E5E5; 370 | line-height: 2.58823529em; 371 | vertical-align: middle; 372 | font-size: 17px; 373 | color: #3CC51F; 374 | white-space: nowrap; 375 | } 376 | .weui-vcode-btn:active { 377 | color: #52a341; 378 | } 379 | .weui-cell_switch { 380 | padding-top: 6px; 381 | padding-bottom: 6px; 382 | } 383 | .weui-uploader__hd { 384 | display: -webkit-box; 385 | display: -webkit-flex; 386 | display: flex; 387 | padding-bottom: 10px; 388 | -webkit-box-align: center; 389 | -webkit-align-items: center; 390 | align-items: center; 391 | } 392 | .weui-uploader__title { 393 | -webkit-box-flex: 1; 394 | -webkit-flex: 1; 395 | flex: 1; 396 | } 397 | .weui-uploader__info { 398 | color: #B2B2B2; 399 | } 400 | .weui-uploader__bd { 401 | margin-bottom: -4px; 402 | margin-right: -9px; 403 | overflow: hidden; 404 | } 405 | .weui-uploader__file { 406 | float: left; 407 | margin-right: 9px; 408 | margin-bottom: 9px; 409 | } 410 | .weui-uploader__img { 411 | display: block; 412 | width: 79px; 413 | height: 79px; 414 | } 415 | .weui-uploader__file_status { 416 | position: relative; 417 | } 418 | .weui-uploader__file_status:before { 419 | content: " "; 420 | position: absolute; 421 | top: 0; 422 | right: 0; 423 | bottom: 0; 424 | left: 0; 425 | background-color: rgba(0, 0, 0, 0.5); 426 | } 427 | .weui-uploader__file-content { 428 | position: absolute; 429 | top: 50%; 430 | left: 50%; 431 | -webkit-transform: translate(-50%, -50%); 432 | transform: translate(-50%, -50%); 433 | color: #FFFFFF; 434 | } 435 | .weui-uploader__input-box { 436 | float: left; 437 | position: relative; 438 | margin-right: 9px; 439 | margin-bottom: 9px; 440 | width: 77px; 441 | height: 77px; 442 | border: 1px solid #D9D9D9; 443 | } 444 | .weui-uploader__input-box:before, 445 | .weui-uploader__input-box:after { 446 | content: " "; 447 | position: absolute; 448 | top: 50%; 449 | left: 50%; 450 | -webkit-transform: translate(-50%, -50%); 451 | transform: translate(-50%, -50%); 452 | background-color: #D9D9D9; 453 | } 454 | .weui-uploader__input-box:before { 455 | width: 2px; 456 | height: 39.5px; 457 | } 458 | .weui-uploader__input-box:after { 459 | width: 39.5px; 460 | height: 2px; 461 | } 462 | .weui-uploader__input-box:active { 463 | border-color: #999999; 464 | } 465 | .weui-uploader__input-box:active:before, 466 | .weui-uploader__input-box:active:after { 467 | background-color: #999999; 468 | } 469 | .weui-uploader__input { 470 | position: absolute; 471 | z-index: 1; 472 | top: 0; 473 | left: 0; 474 | width: 100%; 475 | height: 100%; 476 | opacity: 0; 477 | } 478 | .weui-article { 479 | padding: 20px 15px; 480 | font-size: 15px; 481 | } 482 | .weui-article__section { 483 | margin-bottom: 1.5em; 484 | } 485 | .weui-article__h1 { 486 | font-size: 18px; 487 | font-weight: 400; 488 | margin-bottom: .9em; 489 | } 490 | .weui-article__h2 { 491 | font-size: 16px; 492 | font-weight: 400; 493 | margin-bottom: .34em; 494 | } 495 | .weui-article__h3 { 496 | font-weight: 400; 497 | font-size: 15px; 498 | margin-bottom: .34em; 499 | } 500 | .weui-article__p { 501 | margin: 0 0 .8em; 502 | } 503 | .weui-msg { 504 | padding-top: 36px; 505 | text-align: center; 506 | } 507 | .weui-msg__link { 508 | display: inline; 509 | color: #586C94; 510 | } 511 | .weui-msg__icon-area { 512 | margin-bottom: 30px; 513 | } 514 | .weui-msg__text-area { 515 | margin-bottom: 25px; 516 | padding: 0 20px; 517 | } 518 | .weui-msg__title { 519 | margin-bottom: 5px; 520 | font-weight: 400; 521 | font-size: 20px; 522 | } 523 | .weui-msg__desc { 524 | font-size: 14px; 525 | color: #999999; 526 | } 527 | .weui-msg__opr-area { 528 | margin-bottom: 25px; 529 | } 530 | .weui-msg__extra-area { 531 | margin-bottom: 15px; 532 | font-size: 14px; 533 | color: #999999; 534 | } 535 | @media screen and (min-height: 438px) { 536 | .weui-msg__extra-area { 537 | position: fixed; 538 | left: 0; 539 | bottom: 0; 540 | width: 100%; 541 | text-align: center; 542 | } 543 | } 544 | .weui-flex { 545 | display: -webkit-box; 546 | display: -webkit-flex; 547 | display: flex; 548 | } 549 | .weui-flex__item { 550 | -webkit-box-flex: 1; 551 | -webkit-flex: 1; 552 | flex: 1; 553 | } 554 | .weui-btn { 555 | margin-top: 15px; 556 | } 557 | .weui-btn:first-child { 558 | margin-top: 0; 559 | } 560 | .weui-btn-area { 561 | margin: 1.17647059em 15px 0.3em; 562 | } 563 | .weui-agree { 564 | display: block; 565 | padding: .5em 15px; 566 | font-size: 13px; 567 | } 568 | .weui-agree__text { 569 | color: #999999; 570 | } 571 | .weui-agree__link { 572 | display: inline; 573 | color: #586C94; 574 | } 575 | .weui-agree__checkbox { 576 | position: absolute; 577 | left: -9999px; 578 | } 579 | .weui-agree__checkbox-icon { 580 | position: relative; 581 | top: 2px; 582 | display: inline-block; 583 | border: 1px solid #D1D1D1; 584 | background-color: #FFFFFF; 585 | border-radius: 3px; 586 | width: 11px; 587 | height: 11px; 588 | } 589 | .weui-agree__checkbox-icon-check { 590 | position: absolute; 591 | top: 1px; 592 | left: 1px; 593 | } 594 | .weui-footer { 595 | color: #999999; 596 | font-size: 14px; 597 | text-align: center; 598 | } 599 | .weui-footer_fixed-bottom { 600 | position: fixed; 601 | bottom: .52em; 602 | left: 0; 603 | right: 0; 604 | } 605 | .weui-footer__links { 606 | font-size: 0; 607 | } 608 | .weui-footer__link { 609 | display: inline-block; 610 | vertical-align: top; 611 | margin: 0 .62em; 612 | position: relative; 613 | font-size: 14px; 614 | color: #586C94; 615 | } 616 | .weui-footer__link:before { 617 | content: " "; 618 | position: absolute; 619 | left: 0; 620 | top: 0; 621 | width: 1px; 622 | bottom: 0; 623 | border-left: 1rpx solid #C7C7C7; 624 | color: #C7C7C7; 625 | left: -0.65em; 626 | top: .36em; 627 | bottom: .36em; 628 | } 629 | .weui-footer__link:first-child:before { 630 | display: none; 631 | } 632 | .weui-footer__text { 633 | padding: 0 .34em; 634 | font-size: 12px; 635 | } 636 | .weui-grids { 637 | border-top: 1rpx solid #D9D9D9; 638 | border-left: 1rpx solid #D9D9D9; 639 | overflow: hidden; 640 | } 641 | .weui-grid { 642 | position: relative; 643 | float: left; 644 | padding: 20px 10px; 645 | width: 33.33333333%; 646 | box-sizing: border-box; 647 | border-right: 1rpx solid #D9D9D9; 648 | border-bottom: 1rpx solid #D9D9D9; 649 | } 650 | .weui-grid_active { 651 | background-color: #ECECEC; 652 | } 653 | .weui-grid__icon { 654 | display: block; 655 | width: 28px; 656 | height: 28px; 657 | margin: 0 auto; 658 | } 659 | .weui-grid__label { 660 | margin-top: 5px; 661 | display: block; 662 | text-align: center; 663 | color: #000000; 664 | font-size: 14px; 665 | white-space: nowrap; 666 | text-overflow: ellipsis; 667 | overflow: hidden; 668 | } 669 | .weui-loading { 670 | margin: 0 5px; 671 | width: 20px; 672 | height: 20px; 673 | display: inline-block; 674 | vertical-align: middle; 675 | -webkit-animation: weuiLoading 1s steps(12, end) infinite; 676 | animation: weuiLoading 1s steps(12, end) infinite; 677 | background: transparent url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0EzQTFBMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSg5MCA2NSA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNBQkE5QUEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoMTIwIDU4LjY2IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0IyQjJCMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=) no-repeat; 678 | background-size: 100%; 679 | } 680 | @-webkit-keyframes weuiLoading { 681 | 0% { 682 | -webkit-transform: rotate3d(0, 0, 1, 0deg); 683 | transform: rotate3d(0, 0, 1, 0deg); 684 | } 685 | 100% { 686 | -webkit-transform: rotate3d(0, 0, 1, 360deg); 687 | transform: rotate3d(0, 0, 1, 360deg); 688 | } 689 | } 690 | @keyframes weuiLoading { 691 | 0% { 692 | -webkit-transform: rotate3d(0, 0, 1, 0deg); 693 | transform: rotate3d(0, 0, 1, 0deg); 694 | } 695 | 100% { 696 | -webkit-transform: rotate3d(0, 0, 1, 360deg); 697 | transform: rotate3d(0, 0, 1, 360deg); 698 | } 699 | } 700 | .weui-badge { 701 | display: inline-block; 702 | padding: .15em .4em; 703 | min-width: 8px; 704 | border-radius: 18px; 705 | background-color: #F43530; 706 | color: #FFFFFF; 707 | line-height: 1.2; 708 | text-align: center; 709 | font-size: 12px; 710 | vertical-align: middle; 711 | } 712 | .weui-badge_dot { 713 | padding: .4em; 714 | min-width: 0; 715 | } 716 | .weui-loadmore { 717 | width: 65%; 718 | margin: 1.5em auto; 719 | line-height: 1.6em; 720 | font-size: 14px; 721 | text-align: center; 722 | } 723 | .weui-loadmore__tips { 724 | display: inline-block; 725 | vertical-align: middle; 726 | } 727 | .weui-loadmore_line { 728 | border-top: 1px solid #E5E5E5; 729 | margin-top: 2.4em; 730 | } 731 | .weui-loadmore__tips_in-line { 732 | position: relative; 733 | top: -0.9em; 734 | padding: 0 .55em; 735 | background-color: #FFFFFF; 736 | color: #999999; 737 | } 738 | .weui-loadmore__tips_in-dot { 739 | position: relative; 740 | padding: 0 .16em; 741 | width: 4px; 742 | height: 1.6em; 743 | } 744 | .weui-loadmore__tips_in-dot:before { 745 | content: " "; 746 | position: absolute; 747 | top: 50%; 748 | left: 50%; 749 | margin-top: -1px; 750 | margin-left: -2px; 751 | width: 4px; 752 | height: 4px; 753 | border-radius: 50%; 754 | background-color: #E5E5E5; 755 | } 756 | .weui-panel { 757 | background-color: #FFFFFF; 758 | margin-top: 10px; 759 | position: relative; 760 | overflow: hidden; 761 | } 762 | .weui-panel:first-child { 763 | margin-top: 0; 764 | } 765 | .weui-panel:before { 766 | content: " "; 767 | position: absolute; 768 | left: 0; 769 | top: 0; 770 | right: 0; 771 | height: 1px; 772 | border-top: 1rpx solid #E5E5E5; 773 | color: #E5E5E5; 774 | } 775 | .weui-panel:after { 776 | content: " "; 777 | position: absolute; 778 | left: 0; 779 | bottom: 0; 780 | right: 0; 781 | height: 1px; 782 | border-bottom: 1rpx solid #E5E5E5; 783 | color: #E5E5E5; 784 | } 785 | .weui-panel__hd { 786 | padding: 14px 15px 10px; 787 | color: #999999; 788 | font-size: 13px; 789 | position: relative; 790 | } 791 | .weui-panel__hd:after { 792 | content: " "; 793 | position: absolute; 794 | left: 0; 795 | bottom: 0; 796 | right: 0; 797 | height: 1px; 798 | border-bottom: 1rpx solid #E5E5E5; 799 | color: #E5E5E5; 800 | left: 15px; 801 | } 802 | .weui-media-box { 803 | padding: 15px; 804 | position: relative; 805 | } 806 | .weui-media-box:before { 807 | content: " "; 808 | position: absolute; 809 | left: 0; 810 | top: 0; 811 | right: 0; 812 | height: 1px; 813 | border-top: 1rpx solid #E5E5E5; 814 | color: #E5E5E5; 815 | left: 15px; 816 | } 817 | .weui-media-box:first-child:before { 818 | display: none; 819 | } 820 | .weui-media-box__title { 821 | font-weight: 400; 822 | font-size: 17px; 823 | width: auto; 824 | overflow: hidden; 825 | text-overflow: ellipsis; 826 | white-space: nowrap; 827 | word-wrap: normal; 828 | word-wrap: break-word; 829 | word-break: break-all; 830 | } 831 | .weui-media-box__desc { 832 | color: #999999; 833 | font-size: 13px; 834 | line-height: 1.2; 835 | overflow: hidden; 836 | text-overflow: ellipsis; 837 | display: -webkit-box; 838 | -webkit-box-orient: vertical; 839 | -webkit-line-clamp: 2; 840 | } 841 | .weui-media-box__info { 842 | margin-top: 15px; 843 | padding-bottom: 5px; 844 | font-size: 13px; 845 | color: #CECECE; 846 | line-height: 1em; 847 | list-style: none; 848 | overflow: hidden; 849 | } 850 | .weui-media-box__info__meta { 851 | float: left; 852 | padding-right: 1em; 853 | } 854 | .weui-media-box__info__meta_extra { 855 | padding-left: 1em; 856 | border-left: 1px solid #CECECE; 857 | } 858 | .weui-media-box__title_in-text { 859 | margin-bottom: 8px; 860 | } 861 | .weui-media-box_appmsg { 862 | display: -webkit-box; 863 | display: -webkit-flex; 864 | display: flex; 865 | -webkit-box-align: center; 866 | -webkit-align-items: center; 867 | align-items: center; 868 | } 869 | .weui-media-box__thumb { 870 | width: 100%; 871 | height: 100%; 872 | vertical-align: top; 873 | } 874 | .weui-media-box__hd_in-appmsg { 875 | margin-right: .8em; 876 | width: 60px; 877 | height: 60px; 878 | line-height: 60px; 879 | text-align: center; 880 | } 881 | .weui-media-box__bd_in-appmsg { 882 | -webkit-box-flex: 1; 883 | -webkit-flex: 1; 884 | flex: 1; 885 | min-width: 0; 886 | } 887 | .weui-media-box_small-appmsg { 888 | padding: 0; 889 | } 890 | .weui-cells_in-small-appmsg { 891 | margin-top: 0; 892 | } 893 | .weui-cells_in-small-appmsg:before { 894 | display: none; 895 | } 896 | .weui-progress { 897 | display: -webkit-box; 898 | display: -webkit-flex; 899 | display: flex; 900 | -webkit-box-align: center; 901 | -webkit-align-items: center; 902 | align-items: center; 903 | } 904 | .weui-progress__bar { 905 | -webkit-box-flex: 1; 906 | -webkit-flex: 1; 907 | flex: 1; 908 | } 909 | .weui-progress__opr { 910 | margin-left: 15px; 911 | font-size: 0; 912 | } 913 | .weui-navbar { 914 | display: -webkit-box; 915 | display: -webkit-flex; 916 | display: flex; 917 | position: absolute; 918 | z-index: 500; 919 | top: 0; 920 | width: 100%; 921 | border-bottom: 1rpx solid #CCCCCC; 922 | } 923 | .weui-navbar__item { 924 | position: relative; 925 | display: block; 926 | -webkit-box-flex: 1; 927 | -webkit-flex: 1; 928 | flex: 1; 929 | padding: 13px 0; 930 | text-align: center; 931 | font-size: 0; 932 | } 933 | .weui-navbar__item.weui-bar__item_on { 934 | color: #1AAD19; 935 | } 936 | .weui-navbar__slider { 937 | position: absolute; 938 | content: " "; 939 | left: 0; 940 | bottom: 0; 941 | width: 6em; 942 | height: 3px; 943 | background-color: #1AAD19; 944 | -webkit-transition: -webkit-transform .3s; 945 | transition: -webkit-transform .3s; 946 | transition: transform .3s; 947 | transition: transform .3s, -webkit-transform .3s; 948 | } 949 | .weui-navbar__title { 950 | display: inline-block; 951 | font-size: 15px; 952 | max-width: 8em; 953 | width: auto; 954 | overflow: hidden; 955 | text-overflow: ellipsis; 956 | white-space: nowrap; 957 | word-wrap: normal; 958 | } 959 | .weui-tab { 960 | position: relative; 961 | height: 100%; 962 | } 963 | .weui-tab__panel { 964 | box-sizing: border-box; 965 | height: 100%; 966 | padding-top: 50px; 967 | overflow: auto; 968 | -webkit-overflow-scrolling: touch; 969 | } 970 | .weui-search-bar { 971 | position: relative; 972 | padding: 8px 10px; 973 | display: -webkit-box; 974 | display: -webkit-flex; 975 | display: flex; 976 | box-sizing: border-box; 977 | background-color: #EFEFF4; 978 | border-top: 1rpx solid #D7D6DC; 979 | border-bottom: 1rpx solid #D7D6DC; 980 | } 981 | .weui-icon-search { 982 | margin-right: 8px; 983 | font-size: inherit; 984 | } 985 | .weui-icon-search_in-box { 986 | position: absolute; 987 | left: 10px; 988 | top: 7px; 989 | } 990 | .weui-search-bar__text { 991 | display: inline-block; 992 | font-size: 14px; 993 | vertical-align: middle; 994 | } 995 | .weui-search-bar__form { 996 | position: relative; 997 | -webkit-box-flex: 1; 998 | -webkit-flex: auto; 999 | flex: auto; 1000 | border-radius: 5px; 1001 | background: #FFFFFF; 1002 | border: 1rpx solid #E6E6EA; 1003 | } 1004 | .weui-search-bar__box { 1005 | position: relative; 1006 | padding-left: 30px; 1007 | padding-right: 30px; 1008 | width: 100%; 1009 | box-sizing: border-box; 1010 | z-index: 1; 1011 | } 1012 | .weui-search-bar__input { 1013 | height: 28px; 1014 | line-height: 28px; 1015 | font-size: 14px; 1016 | } 1017 | .weui-icon-clear { 1018 | position: absolute; 1019 | top: 0; 1020 | right: 0; 1021 | padding: 7px 8px; 1022 | font-size: 0; 1023 | } 1024 | .weui-search-bar__label { 1025 | position: absolute; 1026 | top: 0; 1027 | right: 0; 1028 | bottom: 0; 1029 | left: 0; 1030 | z-index: 2; 1031 | border-radius: 3px; 1032 | text-align: center; 1033 | color: #9B9B9B; 1034 | background: #FFFFFF; 1035 | line-height: 28px; 1036 | } 1037 | .weui-search-bar__cancel-btn { 1038 | margin-left: 10px; 1039 | line-height: 28px; 1040 | color: #09BB07; 1041 | white-space: nowrap; 1042 | } 1043 | -------------------------------------------------------------------------------- /pages/groups/all/all.js: -------------------------------------------------------------------------------- 1 | const app = getApp(); 2 | 3 | wx.cloud.init({ 4 | env: 'minipro-4x4pl', 5 | traceUser: true, 6 | }) 7 | 8 | Page({ 9 | 10 | /** 11 | * 页面的初始数据 12 | */ 13 | data: { 14 | CustomBar: app.globalData.CustomBar, 15 | groupList: [], 16 | }, 17 | searchIcon(e) { 18 | let key = e.detail.value.toLowerCase(); 19 | let list = this.data.groupList; 20 | for (let i = 0; i < list.length; i++) { 21 | let a = key; 22 | let b = list[i].groupname.toLowerCase(); 23 | if (b.search(a) != -1) { 24 | list[i].isShow = true 25 | } else { 26 | list[i].isShow = false 27 | } 28 | } 29 | this.setData({ 30 | groupList: list 31 | }) 32 | }, 33 | /* ===== 自定义函数 ===== */ 34 | // 关注状态改变 35 | /* 36 | lovechange(event) { 37 | console.log(this.data.groupList[event.target.dataset.index].love) 38 | console.log(event) 39 | var dates = 'groupList[' + event.target.dataset.index + '].love' 40 | 41 | this.setData({ 42 | [dates]: !event.target.dataset.love, 43 | }) 44 | 45 | console.log(this.data.groupList[event.target.dataset.index].love) 46 | 47 | // 后端逻辑 48 | // 两个函数 49 | // 删除用户表中,圈子数组的本圈子cid 50 | // 删除圈子表中,用户数组的用户标识uid 51 | }, 52 | */ 53 | /** 54 | * 生命周期函数--监听页面加载 55 | */ 56 | onLoad: function (options) { 57 | wx.showLoading({ 58 | title: '加载中', 59 | mask: true 60 | }); 61 | var that = this; 62 | wx.cloud.callFunction({ 63 | name: 'circleService', 64 | data: { 65 | action:'getAllGroup', 66 | }, 67 | success: function(res) { 68 | that.setData({ 69 | groupList : res.result.data 70 | }) 71 | wx.hideLoading() 72 | }, 73 | fail: function(res){ 74 | wx.hideLoading() 75 | wx.showToast({ 76 | title: '获取失败,请重试', 77 | icon: 'none', 78 | duration: 1000 79 | }) 80 | } 81 | }) 82 | 83 | }, 84 | 85 | /** 86 | * 生命周期函数--监听页面初次渲染完成 87 | */ 88 | onReady: function () { 89 | 90 | }, 91 | 92 | /** 93 | * 生命周期函数--监听页面显示 94 | */ 95 | onShow: function () { 96 | 97 | }, 98 | 99 | /** 100 | * 生命周期函数--监听页面隐藏 101 | */ 102 | onHide: function () { 103 | 104 | }, 105 | 106 | /** 107 | * 生命周期函数--监听页面卸载 108 | */ 109 | onUnload: function () { 110 | 111 | }, 112 | 113 | /** 114 | * 页面相关事件处理函数--监听用户下拉动作 115 | */ 116 | onPullDownRefresh: function () { 117 | 118 | }, 119 | 120 | /** 121 | * 页面上拉触底事件的处理函数 122 | */ 123 | onReachBottom: function () { 124 | 125 | }, 126 | 127 | /** 128 | * 用户点击右上角分享 129 | */ 130 | onShareAppMessage: function () { 131 | 132 | } 133 | }) -------------------------------------------------------------------------------- /pages/groups/all/all.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /pages/groups/all/all.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 全部圈子 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | {{item.iconname}} 18 | 19 | 20 | 21 | {{item.groupname}} 22 | 23 | 24 | 25 | {{item}} 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /pages/groups/all/all.wxss: -------------------------------------------------------------------------------- 1 | .we { 2 | padding-top: 100rpx; 3 | } 4 | 5 | item.none { 6 | display: none; 7 | } 8 | 9 | .groups { 10 | margin-top: 20rpx; 11 | } -------------------------------------------------------------------------------- /pages/groups/single/single.js: -------------------------------------------------------------------------------- 1 | const app = getApp(); 2 | Page({ 3 | 4 | /** 5 | * 页面的初始数据 6 | */ 7 | data: { 8 | StatusBar: app.globalData.StatusBar, 9 | CustomBar: app.globalData.CustomBar, 10 | Custom: app.globalData.Custom, 11 | name: '', 12 | options:null, 13 | mygroup:[], 14 | love : false, 15 | groupcontent: { 16 | avatarurl: '', 17 | groupname: '', 18 | grouptag: [], 19 | description: ' ', 20 | member: [] 21 | } 22 | }, 23 | searchIcon(e) { 24 | let key = e.detail.value.toLowerCase(); 25 | let list = this.data.groupcontent.people; 26 | for (let i = 0; i < list.length; i++) { 27 | let a = key; 28 | let b = list[i].name.toLowerCase(); 29 | if (b.search(a) != -1) { 30 | list[i].isShow = true 31 | } else { 32 | list[i].isShow = false 33 | } 34 | } 35 | var url = 'groupcontent.people' 36 | this.setData({ 37 | [url]: list 38 | }) 39 | }, 40 | /* ===== 自定义函数 ===== */ 41 | // 关注状态改变 42 | lovechange(event) { 43 | wx.showLoading({ 44 | title: '加载中', 45 | mask: true 46 | }); 47 | var that = this 48 | var pageName = this.data['name'] 49 | var dates = 'groupcontent.love' 50 | this.setData({ 51 | [dates]: !event.target.dataset.love, 52 | }) 53 | 54 | //console.log(this.data.love) 55 | 56 | // 后端逻辑 57 | // 两个函数 58 | // 删除用户表中,圈子数组的本圈子cid 59 | // 删除圈子表中,用户数组的用户标识uid 60 | 61 | var groupName = this.data.name 62 | //判断是否已关注,已关注add为0,将执行取消关注操作 63 | var add = this.data.love?0:1 64 | 65 | wx.cloud.callFunction({ 66 | name: 'profileService', 67 | data: { 68 | action:'getProfile' 69 | }, 70 | success: function(res) { 71 | var users = res['result']['data'][0] 72 | var groupData = users['group'] 73 | var userId = users['_id'] 74 | var userOpenId = users['_openid'] 75 | var userName = users['firstname'] + users['lastname'] 76 | 77 | wx.cloud.callFunction({ 78 | name: 'circleService', 79 | data: { 80 | action :'currentGroup', 81 | name : groupName 82 | }, 83 | success: function(res) { 84 | //console.log(res['result']['data'][0]['member']) 85 | var groups = res['result']['data'][0] 86 | var groupMember = res['result']['data'][0]['member'] 87 | var groupId = res['result']['data'][0]['_id'] 88 | //console.log(groupId) 89 | if(add==0){ 90 | //用户关注列表删除 91 | for(var i=0;i 2 | 3 | 4 | 5 | 6 | {{name}} 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | {{groupcontent.description}} 16 | 17 | 18 | 19 | {{item}} 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | {{item.name}} 40 | 41 | 42 | 43 | 44 | 45 | 没有更多用户了 46 | -------------------------------------------------------------------------------- /pages/groups/single/single.wxss: -------------------------------------------------------------------------------- 1 | .we { 2 | padding-top: 100rpx; 3 | } 4 | 5 | item.none { 6 | display: none; 7 | } 8 | 9 | .topstyle { 10 | position: relative; 11 | } 12 | 13 | .cu-card.case .image .cu-bar { 14 | position: absolute; 15 | bottom: 0; 16 | width: 100%; 17 | background-color: transparent; 18 | padding: 0rpx 30rpx; 19 | } -------------------------------------------------------------------------------- /pages/home/search/search.js: -------------------------------------------------------------------------------- 1 | // pages/home/search/search.js 2 | Page({ 3 | 4 | /** 5 | * 页面的初始数据 6 | */ 7 | data: { 8 | city: '', 9 | searchkey: '', 10 | userList: [], 11 | groupList: [], 12 | localUserList:[] 13 | /* 14 | userList: [{ 15 | avatarurl: '', 16 | firstname: '何', 17 | area: ['湖南省', '长沙市', '芙蓉区'], 18 | profession: '计算机科学与技术', 19 | grade: '15', 20 | }], 21 | groupList: [{ 22 | avatarurl: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big99008.jpg', 23 | groupname: '计算机科学与技术', 24 | grouptag: ['信工院'], 25 | description: '' 26 | }], 27 | */ 28 | }, 29 | 30 | /** 31 | * 生命周期函数--监听页面加载 32 | */ 33 | onLoad: function (options) { 34 | wx.showLoading({ 35 | title: '加载中', 36 | mask: true 37 | }); 38 | var that = this 39 | var key = options.searchvalue 40 | var city = options.city 41 | this.setData({ 42 | city: options.city, 43 | searchkey: options.searchvalue 44 | }) 45 | 46 | wx.cloud.callFunction({ 47 | name: 'profileService', 48 | data: { 49 | action: 'searchUserByCity', 50 | key : city 51 | }, 52 | success: function(res) { 53 | 54 | var localUserLi = res['result']['data'] 55 | console.log(localUserLi) 56 | that.setData({ 57 | localUserList:localUserLi 58 | }) 59 | }, 60 | fail: function(res){ 61 | wx.hideLoading() 62 | wx.showToast({ 63 | title: '获取失败,请重试', 64 | icon: 'none', 65 | duration: 1000 66 | }) 67 | } 68 | }) 69 | 70 | //获取用户搜索结果 71 | wx.cloud.callFunction({ 72 | name: 'profileService', 73 | data: { 74 | action: 'searchUser', 75 | key : key 76 | }, 77 | success: function(res) { 78 | var userLi = res['result']['data'] 79 | that.setData({ 80 | userList : userLi 81 | }) 82 | }, 83 | fail: function(res){ 84 | wx.hideLoading() 85 | wx.showToast({ 86 | title: '获取失败,请重试', 87 | icon: 'none', 88 | duration: 1000 89 | }) 90 | } 91 | }) 92 | 93 | //获取圈子搜索结果 94 | wx.cloud.callFunction({ 95 | name: 'circleService', 96 | data: { 97 | action: 'searchGroup', 98 | key : key 99 | }, 100 | success: function(res) { 101 | var groupLi = res['result']['data'] 102 | that.setData({ 103 | groupList: groupLi, 104 | }) 105 | wx.hideLoading() 106 | }, 107 | fail: function(res){ 108 | wx.hideLoading() 109 | wx.showToast({ 110 | title: '获取失败,请重试', 111 | icon: 'none', 112 | duration: 1000 113 | }) 114 | } 115 | }) 116 | 117 | }, 118 | 119 | /** 120 | * 生命周期函数--监听页面初次渲染完成 121 | */ 122 | onReady: function () { 123 | 124 | }, 125 | 126 | /** 127 | * 生命周期函数--监听页面显示 128 | */ 129 | onShow: function () { 130 | 131 | }, 132 | 133 | /** 134 | * 生命周期函数--监听页面隐藏 135 | */ 136 | onHide: function () { 137 | 138 | }, 139 | 140 | /** 141 | * 生命周期函数--监听页面卸载 142 | */ 143 | onUnload: function () { 144 | 145 | }, 146 | 147 | /** 148 | * 页面相关事件处理函数--监听用户下拉动作 149 | */ 150 | onPullDownRefresh: function () { 151 | 152 | }, 153 | 154 | /** 155 | * 页面上拉触底事件的处理函数 156 | */ 157 | onReachBottom: function () { 158 | 159 | }, 160 | 161 | /** 162 | * 用户点击右上角分享 163 | */ 164 | onShareAppMessage: function () { 165 | 166 | } 167 | }) -------------------------------------------------------------------------------- /pages/home/search/search.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": { 3 | } 4 | } -------------------------------------------------------------------------------- /pages/home/search/search.wxml: -------------------------------------------------------------------------------- 1 | 2 | 搜索 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 校友 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | {{item.firstname}} 同学 22 | 23 | 24 | {{item.profession}} 25 | {{item.grade}}级 26 | {{item.area[1]}} 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 圈子 38 | 39 | 40 | 41 | 42 | 43 | 44 | {{item.iconname}} 45 | 46 | 47 | 48 | {{item.groupname}} 49 | 50 | 51 | 52 | {{item}} 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 同城 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | {{item.firstname}} 同学 77 | 78 | 79 | {{item.profession}} 80 | {{item.grade}}级 81 | {{item.area[1]}} 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 没有更多结果了 93 | -------------------------------------------------------------------------------- /pages/home/search/search.wxss: -------------------------------------------------------------------------------- 1 | @import "/colorui/main.wxss"; 2 | @import "/colorui/icon.wxss"; 3 | @import "/colorui/animation.wxss"; 4 | 5 | .contentes { 6 | padding-top: 100rpx; 7 | } 8 | 9 | .groups { 10 | margin-top: 20rpx; 11 | } -------------------------------------------------------------------------------- /pages/index/index.js: -------------------------------------------------------------------------------- 1 | //index.js 2 | //获取应用实例 3 | const app = getApp() 4 | var myDate = new Date() 5 | 6 | //定位服务 7 | var QQMapWX = require('../../lib/qqmap-wx-jssdk.js'); 8 | 9 | var qqmapsdk = new QQMapWX({ 10 | key:'FDEBZ-N6B66-LGYSC-M23JB-7N3AT-4NFSP' 11 | }); 12 | 13 | wx.cloud.init({ 14 | env: 'minipro-4x4pl', 15 | traceUser: true, 16 | }) 17 | 18 | Page({ 19 | data: { 20 | //判断小程序的API,回调,参数,组件等是否在当前版本可用。 21 | canIUse: wx.canIUse('button.open-type.getUserInfo'), 22 | isHide: false, 23 | isform: true, 24 | PageCur: 'home', 25 | StatusBar: app.globalData.StatusBar, 26 | CustomBar: app.globalData.CustomBar, 27 | save: false, 28 | gradearray: [], 29 | classarray: ['1', '2', '3', '4', '5', '6', '7', '8'], 30 | professionarray: ['国际经济与贸易', '金融学', '市场营销', '会计学', '法学', '人力资源管理', '旅游管理', '财务管理', '英语', '日语', '汉语言文学', '播音与主持艺术', '广播电视编导', '摄影', '视觉传达设计', '艺术设计', '环境设计', '工业设计', '产品设计', '园林', '风景园林', '电子信息工程', '计算机科学与技术', '软件工程', '土木工程', '物流工程', '食品科学与工程', '工程管理', ], 31 | personal: { 32 | username: '', 33 | firstname: '', 34 | lastname: '', 35 | fullname:'', 36 | grade: '', 37 | profession: '', 38 | class: '', 39 | area: [], 40 | city: '', 41 | group: [] 42 | }, 43 | searchvalue: '', 44 | customItem: '', 45 | // 地址值 46 | area: ['', '选择城市', ''], 47 | cardCur: 0, 48 | swiperList: [], 49 | }, 50 | bindGradeChange: function (e) { 51 | var url = 'personal.grade' 52 | this.setData({ 53 | [url]: this.data.gradearray[e.detail.value] 54 | }) 55 | }, 56 | bindClassChange: function (e) { 57 | var url = 'personal.class' 58 | this.setData({ 59 | [url]: this.data.classarray[e.detail.value] 60 | }) 61 | }, 62 | bindProfessionChange: function (e) { 63 | var url = 'personal.profession' 64 | this.setData({ 65 | [url]: this.data.professionarray[e.detail.value] 66 | }) 67 | }, 68 | bindAreaChange0: function (e) { 69 | var url = 'personal.area' 70 | this.setData({ 71 | [url]: e.detail.value 72 | }) 73 | }, 74 | saveupdate() { 75 | let that = this; 76 | var isComplete = true; 77 | var form = this.data.personal; 78 | 79 | //检测表单是否完整填写 80 | for(var i in form){ 81 | if(i=="fullname"){ 82 | continue 83 | } 84 | if(i=="city"){ 85 | continue 86 | } 87 | if((typeof form[i]) == 'object' && JSON.stringify(form[i]) == "{}"){ 88 | isComplete = false 89 | } 90 | if((typeof form[i]) == 'string' && form[i] == ""){ 91 | isComplete = false 92 | } 93 | } 94 | if(!isComplete){ 95 | wx.showToast({ 96 | title: '请完整填写资料', 97 | icon: 'none', 98 | duration: 1500 99 | }) 100 | } 101 | if(isComplete){ 102 | // 保存 103 | wx.showLoading({ 104 | title: '保存中', 105 | mask: true 106 | }); 107 | 108 | form['fullname'] = form['firstname'] + form['lastname'] 109 | form['city'] = form['area'][1] 110 | wx.cloud.callFunction({ 111 | name: 'profileService', 112 | data: { 113 | action:'addProfile', 114 | addData: form 115 | }, 116 | success: function(res) { 117 | wx.hideLoading() 118 | wx.showToast({ 119 | title: '提交成功', 120 | icon: 'success', 121 | duration: 1000 122 | }) 123 | that.setData({ 124 | isform: false 125 | }) 126 | }, 127 | fail: function(res){ 128 | wx.hideLoading() 129 | wx.showToast({ 130 | title: '提交失败,请重试', 131 | icon: 'none', 132 | duration: 1000 133 | }) 134 | } 135 | }) 136 | 137 | } 138 | 139 | }, 140 | inputs(e) { 141 | let value = e.detail.value; 142 | var str = e.currentTarget.dataset.name; 143 | this.setData({ 144 | [str]: value, 145 | save: true 146 | }); 147 | }, 148 | onLoad: function () { 149 | var that = this; 150 | wx.showLoading({ 151 | title: '加载中', 152 | mask: true 153 | }); 154 | // 获取年份列表 155 | var year = myDate.getFullYear(); 156 | var gradearray = [] 157 | for (let i = year; i >= 2002; i--) { 158 | gradearray.push(i.toString()) 159 | } 160 | 161 | var swiperLists = [] 162 | 163 | // 查看是否授权 164 | wx.getSetting({ 165 | success: function (res) { 166 | if (res.authSetting['scope.userInfo']) { 167 | wx.getUserInfo({ 168 | success: function (res) { 169 | // 用户已经授权过,不需要显示授权页面,所以不需要改变 isHide 的值 170 | // 根据自己的需求有其他操作再补充 171 | // 我这里实现的是在用户授权成功后,调用微信的 wx.login 接口,从而获取code 172 | wx.login({ 173 | success: res => { 174 | // 获取到用户的 code 之后:res.code 175 | //console.log("用户的code:" + res.code); 176 | // 后端锅 177 | } 178 | }); 179 | } 180 | }); 181 | } else { 182 | // 用户没有授权 183 | // 改变 isHide 的值,显示授权页面 184 | this.setData({ 185 | isHide: true 186 | }); 187 | } 188 | } 189 | }); 190 | //是否填写过资料 191 | wx.cloud.callFunction({ 192 | name: 'profileService', 193 | data: { 194 | action:'getProfile', 195 | }, 196 | success: function(res) { 197 | that.setData({ 198 | isform : (res.result.data[0] == null) 199 | }) 200 | if(res.result.data[0] != null){ 201 | wx.cloud.callFunction({ 202 | name: 'profileService', 203 | data: { 204 | action:'getProfile', 205 | }, 206 | success: function(res) { 207 | that.setData({ 208 | swiperList : res.result.data[0].group 209 | }) 210 | wx.hideLoading() 211 | }, 212 | fail: function(res){ 213 | wx.hideLoading() 214 | wx.showToast({ 215 | title: '获取失败,请重试', 216 | icon: 'none', 217 | duration: 1000 218 | }) 219 | } 220 | }) 221 | 222 | } 223 | 224 | wx.hideLoading() 225 | }, 226 | fail: function(res){ 227 | wx.hideLoading() 228 | wx.showToast({ 229 | title: '获取失败,请重试', 230 | icon: 'none', 231 | duration: 1000 232 | }) 233 | } 234 | }) 235 | 236 | 237 | this.setData({ 238 | gradearray: gradearray, 239 | swiperList: swiperLists, 240 | }); 241 | 242 | //定位信息 243 | var _this = this; 244 | qqmapsdk.reverseGeocoder({ 245 | success: function(res) {//成功后的回调 246 | _this.setData({ 247 | city :res.result.address_component.city 248 | }) 249 | console.log(res); 250 | }, 251 | fail: function(error) { 252 | _this.setData({ 253 | city:'位置获取失败' 254 | }) 255 | console.error(error); 256 | }, 257 | complete: function(res) { 258 | //console.log(res); 259 | } 260 | }) 261 | }, 262 | 263 | bindGetUserInfo: function (e) { 264 | if (e.detail.userInfo) { 265 | //用户按了允许授权按钮 266 | 267 | // 获取到用户的信息了,打印到控制台上看下 268 | console.log("用户的信息如下:"); 269 | console.log(e.detail.userInfo); 270 | //授权成功后,通过改变 isHide 的值,让实现页面显示出来,把授权页面隐藏起来 271 | this.setData({ 272 | isHide: false 273 | }); 274 | } else { 275 | //用户按了拒绝按钮 276 | wx.showModal({ 277 | title: '警告', 278 | content: '您点击了拒绝授权,将无法进入小程序,请授权之后再进入!!!', 279 | showCancel: false, 280 | confirmText: '返回授权', 281 | success: function (res) { 282 | // 用户没有授权成功,不需要改变 isHide 的值 283 | if (res.confirm) { 284 | console.log('用户点击了“返回授权”'); 285 | } 286 | } 287 | }); 288 | } 289 | }, 290 | // 导航切换函数 291 | NavChange(e) { 292 | this.setData({ 293 | PageCur: e.currentTarget.dataset.cur 294 | }) 295 | }, 296 | 297 | // 搜索页切换函数 298 | pagechangesearch() { 299 | let searchvalue = this.data.searchvalue; 300 | if (searchvalue != '') { 301 | wx.navigateTo({ 302 | url: '/pages/home/search/search?searchvalue=' + searchvalue + '&city=' + this.data.city, 303 | }) 304 | } 305 | else{ 306 | wx.showToast({ 307 | title: '请填写要搜索的内容', 308 | icon: 'none', 309 | duration: 1000 310 | }) 311 | } 312 | 313 | }, 314 | // 搜索值确定 315 | updatesearchvalue(e) { 316 | 317 | this.setData({ 318 | searchvalue: e.detail.value, 319 | }) 320 | }, 321 | // 地址切换函数 322 | bindAreaChange: function (e) { 323 | this.setData({ 324 | area: e.detail.value, 325 | city: e.detail.value[1] 326 | }) 327 | 328 | // 后端代码 329 | // 上传改变地域的值 330 | }, 331 | // cardSwiper 332 | cardSwiper(e) { 333 | this.setData({ 334 | cardCur: e.detail.current 335 | }) 336 | }, 337 | /** 338 | * 生命周期函数--监听页面显示 339 | */ 340 | onShow: function () { 341 | this.onLoad() 342 | } 343 | /* ===== 自定义函数 ===== */ 344 | // 关注状态改变 345 | /* 346 | lovechange(event) { 347 | console.log(this.data.swiperList[event.target.dataset.index].love) 348 | console.log(event) 349 | var dates = 'swiperList[' + event.target.dataset.index + '].love' 350 | 351 | this.setData({ 352 | [dates]: !event.target.dataset.love, 353 | }) 354 | 355 | console.log(this.data.swiperList[event.target.dataset.index].love) 356 | }, 357 | */ 358 | }) -------------------------------------------------------------------------------- /pages/index/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": { 3 | } 4 | } -------------------------------------------------------------------------------- /pages/index/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 申请获取以下权限 6 | 获得你的公开信息(昵称,头像等) 7 | 8 | 9 | 10 | 11 | 12 | 请升级微信版本 13 | 14 | 15 | 16 | 17 | 18 | 资料填写 19 | 20 | 21 | 22 | 23 | 24 | 昵称 25 | 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 | 51 | 52 | 53 | {{personal.grade}} 级 54 | 55 | 56 | 57 | 58 | 59 | 60 | 专业 61 | 62 | 63 | 64 | 65 | {{personal.profession}} 专业 66 | 67 | 68 | 69 | 70 | 71 | 72 | 班级 73 | 74 | 75 | 76 | 77 | {{personal.class}} 班 78 | 79 | 80 | 81 | 82 | 83 | 84 | 地点 85 | 86 | 87 | 88 | 89 | {{personal.area[0]}} {{personal.area[1]}} {{personal.area[2]}} 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 首页 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | {{city}} 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 暂无数据 148 | 请在下方选择你想加入圈子 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | {{item.groupname}} 171 | 172 | 173 | 174 | 标 签 175 | 176 | 177 | 178 | {{item}} 179 | 180 | 181 | 182 | 183 | 184 | 185 | 描 述 186 | 187 | 188 | 189 | {{item.description}} 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | -------------------------------------------------------------------------------- /pages/index/index.wxss: -------------------------------------------------------------------------------- 1 | @import "/colorui/main.wxss"; 2 | @import "/colorui/icon.wxss"; 3 | @import "/colorui/animation.wxss"; 4 | @import "/lib/weui.wxss"; 5 | 6 | .picker{ 7 | padding: 13px; 8 | background-color: #FFFFFF; 9 | } 10 | 11 | .topswiper { 12 | margin-top: 100rpx; 13 | } 14 | 15 | .single { 16 | height: 75vh; 17 | } 18 | 19 | .authority { 20 | background-image: url(https://pic.gksec.com/2020/08/03/05f18caa48fb7/bg-2020.gif); 21 | background-size: 100% 100%; 22 | height: 100vh; 23 | } 24 | 25 | .top { 26 | height: 70vh; 27 | } 28 | 29 | .text { 30 | height: 7.5vh; 31 | } 32 | 33 | .bottom { 34 | height: 22.5vh; 35 | } -------------------------------------------------------------------------------- /pages/personal/home/home.js: -------------------------------------------------------------------------------- 1 | // pages/personal/home/home.js 2 | Page({ 3 | 4 | /** 5 | * 页面的初始数据 6 | */ 7 | data: { 8 | 9 | }, 10 | 11 | /** 12 | * 生命周期函数--监听页面加载 13 | */ 14 | onLoad: function (options) { 15 | 16 | }, 17 | 18 | /** 19 | * 生命周期函数--监听页面初次渲染完成 20 | */ 21 | onReady: function () { 22 | 23 | }, 24 | 25 | /** 26 | * 生命周期函数--监听页面显示 27 | */ 28 | onShow: function () { 29 | 30 | }, 31 | 32 | /** 33 | * 生命周期函数--监听页面隐藏 34 | */ 35 | onHide: function () { 36 | 37 | }, 38 | 39 | /** 40 | * 生命周期函数--监听页面卸载 41 | */ 42 | onUnload: function () { 43 | 44 | }, 45 | 46 | /** 47 | * 页面相关事件处理函数--监听用户下拉动作 48 | */ 49 | onPullDownRefresh: function () { 50 | 51 | }, 52 | 53 | /** 54 | * 页面上拉触底事件的处理函数 55 | */ 56 | onReachBottom: function () { 57 | 58 | }, 59 | 60 | /** 61 | * 用户点击右上角分享 62 | */ 63 | onShareAppMessage: function () { 64 | 65 | } 66 | }) -------------------------------------------------------------------------------- /pages/personal/home/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /pages/personal/home/home.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 我的 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 我的资料 25 | 26 | 27 | 28 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /pages/personal/home/home.wxss: -------------------------------------------------------------------------------- 1 | .UCenter-bg { 2 | background-image: url(https://pic.gksec.com/2020/07/31/7daa2b117debc/weather.jpg); 3 | background-size: cover; 4 | height: 500rpx; 5 | display: flex; 6 | justify-content: center; 7 | padding-top: 40rpx; 8 | overflow: hidden; 9 | position: relative; 10 | flex-direction: column; 11 | align-items: center; 12 | color: #fff; 13 | font-weight: 300; 14 | text-shadow: 0 0 3px rgba(0, 0, 0, 0.3); 15 | } 16 | 17 | .UCenter-bg text { 18 | opacity: 0.8; 19 | } 20 | 21 | .UCenter-bg image { 22 | width: 200rpx; 23 | height: 200rpx; 24 | } 25 | 26 | .UCenter-bg .gif-wave{ 27 | position: absolute; 28 | width: 100%; 29 | bottom: 0; 30 | left: 0; 31 | z-index: 99; 32 | mix-blend-mode: screen; 33 | height: 100rpx; 34 | } 35 | 36 | map,.mapBox{ 37 | left: 0; 38 | z-index: 99; 39 | mix-blend-mode: screen; 40 | height: 100rpx; 41 | } 42 | 43 | map,.mapBox{ 44 | width: 750rpx; 45 | height: 300rpx; 46 | } 47 | 48 | .userinfo-avatar { 49 | overflow: hidden; 50 | display: block; 51 | width: 200rpx; 52 | height: 200rpx; 53 | margin: 20rpx; 54 | margin-top: 50rpx; 55 | border-radius: 50%; 56 | border: 2px solid #fff; 57 | box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2); 58 | } -------------------------------------------------------------------------------- /pages/personal/home/weather.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jing-Wenxing/RedLine/0537ea2a612684d58d70db19a7c7ccc2d39b9a2e/pages/personal/home/weather.jpg -------------------------------------------------------------------------------- /pages/personal/modification/modification.js: -------------------------------------------------------------------------------- 1 | // pages/personal/modification/modification.js 2 | wx.cloud.init({ 3 | env: 'minipro-4x4pl', 4 | traceUser: true, 5 | }) 6 | 7 | Page({ 8 | 9 | /** 10 | * 页面的初始数据 11 | */ 12 | data: { 13 | psrsonal: { 14 | username: '', 15 | firstname: '', 16 | lastname: '', 17 | grade: '', 18 | profession: '', 19 | class: '', 20 | phonenumber: '', 21 | wxnumber: '', 22 | qqnumber: '', 23 | company: '', 24 | area: [], 25 | resume: '', 26 | } 27 | }, 28 | 29 | /** 30 | * 生命周期函数--监听页面加载 31 | */ 32 | onLoad: function (options) { 33 | wx.showLoading({ 34 | title: '加载中', 35 | mask: true 36 | }); 37 | var that = this; 38 | wx.cloud.callFunction({ 39 | name: 'profileService', 40 | data: { 41 | action:'getProfile', 42 | }, 43 | success: function(res) { 44 | that.setData({ 45 | psrsonal : res.result.data[0] 46 | }) 47 | wx.hideLoading() 48 | }, 49 | fail: function(res){ 50 | wx.hideLoading() 51 | wx.showToast({ 52 | title: '提交失败,请重试', 53 | icon: 'none', 54 | duration: 1000 55 | }) 56 | } 57 | }) 58 | }, 59 | 60 | /** 61 | * 生命周期函数--监听页面初次渲染完成 62 | */ 63 | onReady: function () { 64 | 65 | }, 66 | 67 | /** 68 | * 生命周期函数--监听页面显示 69 | */ 70 | onShow: function () { 71 | this.onLoad() 72 | }, 73 | 74 | /** 75 | * 生命周期函数--监听页面隐藏 76 | */ 77 | onHide: function () { 78 | 79 | }, 80 | 81 | /** 82 | * 生命周期函数--监听页面卸载 83 | */ 84 | onUnload: function () { 85 | 86 | }, 87 | 88 | /** 89 | * 页面相关事件处理函数--监听用户下拉动作 90 | */ 91 | onPullDownRefresh: function () { 92 | 93 | }, 94 | 95 | /** 96 | * 页面上拉触底事件的处理函数 97 | */ 98 | onReachBottom: function () { 99 | 100 | }, 101 | 102 | /** 103 | * 用户点击右上角分享 104 | */ 105 | onShareAppMessage: function () { 106 | 107 | } 108 | }) -------------------------------------------------------------------------------- /pages/personal/modification/modification.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /pages/personal/modification/modification.wxml: -------------------------------------------------------------------------------- 1 | 2 | 资料 3 | 4 | 5 | 6 | 7 | 账户信息 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 昵称 20 | 21 | 22 | {{psrsonal.username}} 23 | 24 | 25 | 26 | 27 | 姓名 28 | 29 | 30 | {{psrsonal.firstname}} {{psrsonal.lastname}} 31 | 32 | 33 | 34 | 35 | 年级 36 | 37 | 38 | {{psrsonal.grade}} 级 39 | 40 | 41 | 42 | 43 | 专业 44 | 45 | 46 | {{psrsonal.profession}} 47 | 48 | 49 | 50 | 51 | 班级 52 | 53 | 54 | {{psrsonal.class}} 班 55 | 56 | 57 | 58 | 59 | 60 | 61 | 联系方式 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 手机号 74 | 75 | 76 | {{psrsonal.phonenumber}} 77 | 78 | 79 | 80 | 81 | 微信号 82 | 83 | 84 | {{psrsonal.wxnumber}} 85 | 86 | 87 | 88 | 89 | QQ号 90 | 91 | 92 | {{psrsonal.qqnumber}} 93 | 94 | 95 | 96 | 97 | 98 | 99 | 工作信息 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 公司 112 | 113 | 114 | {{psrsonal.company}} 115 | 116 | 117 | 118 | 119 | 地点 120 | 121 | 122 | {{psrsonal.area[0]}} {{psrsonal.area[1]}} {{psrsonal.area[2]}} 123 | 124 | 125 | 126 | 127 | 简历 128 | 129 | 130 | {{psrsonal.resume}} 131 | 132 | 133 | -------------------------------------------------------------------------------- /pages/personal/modification/modification.wxss: -------------------------------------------------------------------------------- 1 | /* pages/personal/modification/modification.wxss */ -------------------------------------------------------------------------------- /pages/personal/workresume/workresume.js: -------------------------------------------------------------------------------- 1 | // pages/personal/workresume/workresume.js 2 | wx.cloud.init({ 3 | env: 'minipro-4x4pl', 4 | traceUser: true, 5 | }) 6 | var myDate = new Date() 7 | 8 | Page({ 9 | 10 | /** 11 | * 页面的初始数据 12 | */ 13 | data: { 14 | title: '', 15 | save: true, 16 | gradearray: [], 17 | classarray: ['1', '2', '3', '4', '5', '6', '7', '8', ], 18 | professionarray: ['国际经济与贸易', '金融学', '市场营销', '会计学', '法学', '人力资源管理', '旅游管理', '财务管理', '英语', '日语', '汉语言文学', '播音与主持艺术', '广播电视编导', '摄影', '视觉传达设计', '艺术设计', '环境设计', '工业设计', '产品设计', '园林', '风景园林', '电子信息工程', '计算机科学与技术', '软件工程', '土木工程', '物流工程', '食品科学与工程', '工程管理', ], 19 | psrsonal: { 20 | username: '', 21 | signature: '', 22 | firstname: '', 23 | lastname: '', 24 | grade: '', 25 | profession: '', 26 | class: '', 27 | phonenumber: '', 28 | wxnumber: '', 29 | qqnumber: '', 30 | company: '', 31 | area: [], 32 | resume: '', 33 | } 34 | }, 35 | bindGradeChange: function (e) { 36 | var url = 'psrsonal.grade' 37 | this.setData({ 38 | [url]: this.data.gradearray[e.detail.value] 39 | }) 40 | }, 41 | bindClassChange: function (e) { 42 | var url = 'psrsonal.class' 43 | this.setData({ 44 | [url]: this.data.classarray[e.detail.value] 45 | }) 46 | }, 47 | bindProfessionChange: function (e) { 48 | var url = 'personal.profession' 49 | this.setData({ 50 | [url]: this.data.professionarray[e.detail.value] 51 | }) 52 | }, 53 | bindAreaChange: function (e) { 54 | var url = 'psrsonal.area' 55 | this.setData({ 56 | [url]: e.detail.value 57 | }) 58 | }, 59 | saveupdate() { 60 | var form = this.data.psrsonal 61 | var id = form._id 62 | var verify = true 63 | wx.showLoading({ 64 | title: '保存中', 65 | mask: true 66 | }); 67 | 68 | form['city'] = form['area'][1] 69 | if(form['phonenumber'] != null && form['phonenumber'].length != 11){ 70 | wx.showToast({ 71 | title: '手机号应为11位', 72 | icon: 'none', 73 | duration: 1000 74 | }) 75 | verify = false 76 | } 77 | 78 | if(verify){ 79 | delete form._id; 80 | wx.cloud.callFunction({ 81 | name: 'profileService', 82 | data: { 83 | action:'setProfile', 84 | Collectionid: id, 85 | updateData: form 86 | }, 87 | success: function(res) { 88 | wx.hideLoading() 89 | console.log(res) 90 | wx.showToast({ 91 | title: '提交成功', 92 | icon: 'success', 93 | duration: 1000 94 | }) 95 | }, 96 | fail: function(res){ 97 | wx.hideLoading() 98 | wx.showToast({ 99 | title: '提交失败', 100 | icon: 'none', 101 | duration: 1000 102 | }) 103 | } 104 | }) 105 | this.setData({ 106 | save: false, 107 | }) 108 | } 109 | 110 | }, 111 | inputs(e) { 112 | let that = this; 113 | let value = e.detail.value; 114 | var str = e.currentTarget.dataset.name; 115 | that.setData({ 116 | [str]: value, 117 | save: true 118 | }); 119 | }, 120 | /** 121 | * 生命周期函数--监听页面加载 122 | */ 123 | onLoad: function (options) { 124 | wx.showLoading({ 125 | title: '加载中', 126 | mask: true 127 | }); 128 | var that = this; 129 | wx.cloud.callFunction({ 130 | name: 'profileService', 131 | data: { 132 | action:'getProfile', 133 | }, 134 | success: function(res) { 135 | that.setData({ 136 | psrsonal : res.result.data[0] 137 | }) 138 | wx.hideLoading() 139 | }, 140 | fail: function(res){ 141 | wx.hideLoading() 142 | wx.showToast({ 143 | title: '获取失败,请重试', 144 | icon: 'none', 145 | duration: 1000 146 | }) 147 | } 148 | }) 149 | 150 | // 获取年份列表 151 | var year = myDate.getFullYear(); 152 | var gradearray = [] 153 | 154 | for (let i = year; i >= 2002; i--) { 155 | gradearray.push(i.toString()) 156 | } 157 | 158 | this.setData({ 159 | title: options.title, 160 | gradearray: gradearray, 161 | }); 162 | }, 163 | 164 | /** 165 | * 生命周期函数--监听页面初次渲染完成 166 | */ 167 | onReady: function () { 168 | 169 | }, 170 | 171 | /** 172 | * 生命周期函数--监听页面显示 173 | */ 174 | onShow: function () { 175 | 176 | }, 177 | 178 | /** 179 | * 生命周期函数--监听页面隐藏 180 | */ 181 | onHide: function () { 182 | 183 | }, 184 | 185 | /** 186 | * 生命周期函数--监听页面卸载 187 | */ 188 | onUnload: function () { 189 | 190 | }, 191 | 192 | /** 193 | * 页面相关事件处理函数--监听用户下拉动作 194 | */ 195 | onPullDownRefresh: function () { 196 | 197 | }, 198 | 199 | /** 200 | * 页面上拉触底事件的处理函数 201 | */ 202 | onReachBottom: function () { 203 | 204 | }, 205 | 206 | /** 207 | * 用户点击右上角分享 208 | */ 209 | onShareAppMessage: function () { 210 | 211 | } 212 | }) -------------------------------------------------------------------------------- /pages/personal/workresume/workresume.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /pages/personal/workresume/workresume.wxml: -------------------------------------------------------------------------------- 1 | 2 | {{title}} 3 | 4 | 5 | 6 | 7 | 8 | 昵称 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 年级 34 | 35 | 36 | 37 | 38 | {{psrsonal.grade}} 级 39 | 40 | 41 | 42 | 43 | 44 | 45 | 专业 46 | 47 | 48 | 49 | 50 | {{psrsonal.profession}} 专业 51 | 52 | 53 | 54 | 55 | 56 | 57 | 班级 58 | 59 | 60 | 61 | 62 | {{psrsonal.class}} 班 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 手机号 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 微信号 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | QQ号 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 公司 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 地点 108 | 109 | 110 | 111 | 112 | {{psrsonal.area[0]}} {{psrsonal.area[1]}} {{psrsonal.area[2]}} 113 | 114 | 115 | 116 | 117 | 118 | 119 | 简历 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /pages/personal/workresume/workresume.wxss: -------------------------------------------------------------------------------- 1 | @import "/lib/weui.wxss"; -------------------------------------------------------------------------------- /pages/public/usergroups/usergroups.js: -------------------------------------------------------------------------------- 1 | // pages/public/usergroups/usergroups.js 2 | Page({ 3 | 4 | /** 5 | * 页面的初始数据 6 | */ 7 | data: { 8 | groups : [], 9 | uid: '', 10 | groupList: [ 11 | { 12 | isShow: true, 13 | avatarurl: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big99008.jpg', 14 | groupname: '计算机科学与技术', 15 | grouptag: ['信工院'], 16 | description: '' 17 | } 18 | ] 19 | }, 20 | 21 | /** 22 | * 生命周期函数--监听页面加载 23 | */ 24 | onLoad: function (options) { 25 | console.log(options.uid) 26 | this.setData({ 27 | uid: options.uid 28 | }) 29 | 30 | wx.showLoading({ 31 | title: '加载中', 32 | mask: true 33 | }); 34 | var that = this; 35 | 36 | wx.cloud.callFunction({ 37 | name: 'profileService', 38 | data: { 39 | action:'getOtherProfile', 40 | oid: options.uid 41 | }, 42 | success: function(res) { 43 | console.log(res.result.data[0].group) 44 | that.setData({ 45 | groups : res.result.data[0].group 46 | }) 47 | }, 48 | fail: function(res){ 49 | wx.hideLoading() 50 | wx.showToast({ 51 | title: '获取失败,请重试', 52 | icon: 'none', 53 | duration: 1000 54 | }) 55 | console.log(res) 56 | } 57 | }) 58 | 59 | wx.cloud.callFunction({ 60 | name: 'circleService', 61 | data: { 62 | action:'getGroupById', 63 | idList: that.data.groups 64 | }, 65 | success: function(res) { 66 | console.log(res) 67 | that.setData({ 68 | groupList : res.result.data 69 | }) 70 | wx.hideLoading() 71 | }, 72 | fail: function(res){ 73 | wx.hideLoading() 74 | wx.showToast({ 75 | title: '获取失败,请重试', 76 | icon: 'none', 77 | duration: 1000 78 | }) 79 | } 80 | }) 81 | 82 | 83 | }, 84 | 85 | /** 86 | * 生命周期函数--监听页面初次渲染完成 87 | */ 88 | onReady: function () { 89 | 90 | }, 91 | 92 | /** 93 | * 生命周期函数--监听页面显示 94 | */ 95 | onShow: function () { 96 | 97 | }, 98 | 99 | /** 100 | * 生命周期函数--监听页面隐藏 101 | */ 102 | onHide: function () { 103 | 104 | }, 105 | 106 | /** 107 | * 生命周期函数--监听页面卸载 108 | */ 109 | onUnload: function () { 110 | 111 | }, 112 | 113 | /** 114 | * 页面相关事件处理函数--监听用户下拉动作 115 | */ 116 | onPullDownRefresh: function () { 117 | 118 | }, 119 | 120 | /** 121 | * 页面上拉触底事件的处理函数 122 | */ 123 | onReachBottom: function () { 124 | 125 | }, 126 | 127 | /** 128 | * 用户点击右上角分享 129 | */ 130 | onShareAppMessage: function () { 131 | 132 | } 133 | }) -------------------------------------------------------------------------------- /pages/public/usergroups/usergroups.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /pages/public/usergroups/usergroups.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ta的圈子 4 | 5 | 6 | 7 | 8 | 9 | 10 | {{item.iconname}} 11 | 12 | 13 | 14 | {{item.groupname}} 15 | 16 | 17 | 18 | {{item}} 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /pages/public/usergroups/usergroups.wxss: -------------------------------------------------------------------------------- 1 | /* pages/public/usergroups/usergroups.wxss */ -------------------------------------------------------------------------------- /pages/public/userpage/userpage.js: -------------------------------------------------------------------------------- 1 | // pages/public/userpage/userpage.js 2 | Page({ 3 | 4 | /** 5 | * 页面的初始数据 6 | */ 7 | data: { 8 | uid: '', 9 | people: { 10 | username: '', 11 | signature: '' 12 | } 13 | }, 14 | 15 | /** 16 | * 生命周期函数--监听页面加载 17 | */ 18 | onLoad: function (options) { 19 | var that = this; 20 | wx.showLoading({ 21 | title: '加载中', 22 | mask: true 23 | }); 24 | 25 | this.setData({ 26 | uid: options.uid 27 | }) 28 | 29 | wx.cloud.callFunction({ 30 | name: 'profileService', 31 | data: { 32 | action:'getOtherProfile', 33 | oid: options.uid 34 | }, 35 | success: function(res) { 36 | console.log(res.result.data) 37 | that.setData({ 38 | people:res.result.data 39 | }) 40 | wx.hideLoading() 41 | }, 42 | fail: function(res){ 43 | wx.hideLoading() 44 | wx.showToast({ 45 | title: '获取失败,请重试', 46 | icon: 'none', 47 | duration: 1000 48 | }) 49 | } 50 | }) 51 | 52 | }, 53 | 54 | /** 55 | * 生命周期函数--监听页面初次渲染完成 56 | */ 57 | onReady: function () { 58 | var that = this 59 | 60 | console.log(that.data.uid) 61 | }, 62 | 63 | /** 64 | * 生命周期函数--监听页面显示 65 | */ 66 | onShow: function () { 67 | 68 | }, 69 | 70 | /** 71 | * 生命周期函数--监听页面隐藏 72 | */ 73 | onHide: function () { 74 | 75 | }, 76 | 77 | /** 78 | * 生命周期函数--监听页面卸载 79 | */ 80 | onUnload: function () { 81 | 82 | }, 83 | 84 | /** 85 | * 页面相关事件处理函数--监听用户下拉动作 86 | */ 87 | onPullDownRefresh: function () { 88 | 89 | }, 90 | 91 | /** 92 | * 页面上拉触底事件的处理函数 93 | */ 94 | onReachBottom: function () { 95 | 96 | }, 97 | 98 | /** 99 | * 用户点击右上角分享 100 | */ 101 | onShareAppMessage: function () { 102 | 103 | } 104 | }) -------------------------------------------------------------------------------- /pages/public/userpage/userpage.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /pages/public/userpage/userpage.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ta的页面 4 | 5 | 6 | 7 | 8 | 9 | 10 | {{people.username}} 11 | 12 | {{people.signature}} 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ta的资料 21 | 22 | 23 | 24 | 25 | 26 | 27 | ta的圈子 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /pages/public/userpage/userpage.wxss: -------------------------------------------------------------------------------- 1 | .UCenter-bg { 2 | background-image: url(https://pic.gksec.com/2020/07/31/7daa2b117debc/weather.jpg); 3 | background-size: cover; 4 | height: 500rpx; 5 | display: flex; 6 | justify-content: center; 7 | padding-top: 40rpx; 8 | overflow: hidden; 9 | position: relative; 10 | flex-direction: column; 11 | align-items: center; 12 | color: #fff; 13 | font-weight: 300; 14 | text-shadow: 0 0 3px rgba(0, 0, 0, 0.3); 15 | } 16 | 17 | .UCenter-bg text { 18 | opacity: 0.8; 19 | } 20 | 21 | .UCenter-bg image { 22 | width: 200rpx; 23 | height: 200rpx; 24 | } 25 | 26 | .UCenter-bg .gif-wave{ 27 | position: absolute; 28 | width: 100%; 29 | bottom: 0; 30 | left: 0; 31 | z-index: 99; 32 | mix-blend-mode: screen; 33 | height: 100rpx; 34 | } 35 | 36 | map,.mapBox{ 37 | left: 0; 38 | z-index: 99; 39 | mix-blend-mode: screen; 40 | height: 100rpx; 41 | } 42 | 43 | map,.mapBox{ 44 | width: 750rpx; 45 | height: 300rpx; 46 | } -------------------------------------------------------------------------------- /pages/public/userprofile/userprofile.js: -------------------------------------------------------------------------------- 1 | // pages/public/userprofile/userprofile.js 2 | Page({ 3 | 4 | /** 5 | * 页面的初始数据 6 | */ 7 | data: { 8 | uid: '', 9 | psrsonal: { 10 | signature: '', 11 | firstname: '', 12 | lastname: '', 13 | grade: '', 14 | profession: '', 15 | class: '', 16 | phonenumber: '', 17 | wxnumber: '', 18 | qqnumber: '', 19 | company: '', 20 | area: '', 21 | resume: '', 22 | } 23 | }, 24 | 25 | /** 26 | * 生命周期函数--监听页面加载 27 | */ 28 | onLoad: function (options) { 29 | var that = this 30 | wx.showLoading({ 31 | title: '加载中', 32 | mask: true 33 | }); 34 | 35 | this.setData({ 36 | uid: options.uid 37 | }) 38 | 39 | wx.cloud.callFunction({ 40 | name: 'profileService', 41 | data: { 42 | action:'getOtherProfile', 43 | oid: options.uid 44 | }, 45 | success: function(res) { 46 | console.log(res.result.data) 47 | that.setData({ 48 | psrsonal:res.result.data[0] 49 | }) 50 | wx.hideLoading() 51 | }, 52 | fail: function(res){ 53 | wx.hideLoading() 54 | wx.showToast({ 55 | title: '获取失败,请重试', 56 | icon: 'none', 57 | duration: 1000 58 | }) 59 | console.log(res) 60 | } 61 | }) 62 | }, 63 | 64 | /** 65 | * 生命周期函数--监听页面初次渲染完成 66 | */ 67 | onReady: function () { 68 | 69 | }, 70 | 71 | /** 72 | * 生命周期函数--监听页面显示 73 | */ 74 | onShow: function () { 75 | 76 | }, 77 | 78 | /** 79 | * 生命周期函数--监听页面隐藏 80 | */ 81 | onHide: function () { 82 | 83 | }, 84 | 85 | /** 86 | * 生命周期函数--监听页面卸载 87 | */ 88 | onUnload: function () { 89 | 90 | }, 91 | 92 | /** 93 | * 页面相关事件处理函数--监听用户下拉动作 94 | */ 95 | onPullDownRefresh: function () { 96 | 97 | }, 98 | 99 | /** 100 | * 页面上拉触底事件的处理函数 101 | */ 102 | onReachBottom: function () { 103 | 104 | }, 105 | 106 | /** 107 | * 用户点击右上角分享 108 | */ 109 | onShareAppMessage: function () { 110 | 111 | } 112 | }) -------------------------------------------------------------------------------- /pages/public/userprofile/userprofile.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /pages/public/userprofile/userprofile.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ta的资料 4 | 5 | 6 | 7 | 8 | 9 | 10 | 个人信息 11 | 12 | 13 | 14 | 15 | 16 | 17 | 姓名 18 | 19 | 20 | {{psrsonal.firstname}} {{psrsonal.lastname}} 21 | 22 | 23 | 24 | 25 | 年级 26 | 27 | 28 | {{psrsonal.grade}} 级 29 | 30 | 31 | 32 | 33 | 专业 34 | 35 | 36 | {{psrsonal.profession}} 37 | 38 | 39 | 40 | 41 | 班级 42 | 43 | 44 | {{psrsonal.class}} 班 45 | 46 | 47 | 48 | 49 | 50 | 51 | 联系方式 52 | 53 | 54 | 55 | 56 | 57 | 58 | 手机号 59 | 60 | 61 | {{psrsonal.phonenumber}} 62 | 63 | 64 | 65 | 66 | 微信号 67 | 68 | 69 | {{psrsonal.wxnumber}} 70 | 71 | 72 | 73 | 74 | QQ号 75 | 76 | 77 | {{psrsonal.qqnumber}} 78 | 79 | 80 | 81 | 82 | 83 | 84 | 工作信息 85 | 86 | 87 | 88 | 89 | 90 | 91 | 公司 92 | 93 | 94 | {{psrsonal.company}} 95 | 96 | 97 | 98 | 99 | 地点 100 | 101 | 102 | {{psrsonal.area}} 103 | 104 | 105 | 106 | 107 | 简历 108 | 109 | 110 | {{psrsonal.resume}} 111 | 112 | 113 | -------------------------------------------------------------------------------- /pages/public/userprofile/userprofile.wxss: -------------------------------------------------------------------------------- 1 | /* pages/public/userprofile/userprofile.wxss */ -------------------------------------------------------------------------------- /project.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "项目配置文件", 3 | "packOptions": { 4 | "ignore": [] 5 | }, 6 | "setting": { 7 | "urlCheck": true, 8 | "es6": true, 9 | "enhance": false, 10 | "postcss": true, 11 | "preloadBackgroundData": false, 12 | "minified": true, 13 | "newFeature": false, 14 | "coverView": true, 15 | "nodeModules": false, 16 | "autoAudits": false, 17 | "showShadowRootInWxmlPanel": true, 18 | "scopeDataCheck": false, 19 | "uglifyFileName": false, 20 | "checkInvalidKey": true, 21 | "checkSiteMap": true, 22 | "uploadWithSourceMap": true, 23 | "compileHotReLoad": false, 24 | "babelSetting": { 25 | "ignore": [], 26 | "disablePlugins": [], 27 | "outputPath": "" 28 | }, 29 | "useIsolateContext": true, 30 | "useCompilerModule": false, 31 | "userConfirmedUseCompilerModuleSwitch": false 32 | }, 33 | "compileType": "miniprogram", 34 | "libVersion": "2.12.0", 35 | "appid": "wx4d1dffc384e768a2", 36 | "projectname": "RedLine%203.0", 37 | "debugOptions": { 38 | "hidedInDevtools": [] 39 | }, 40 | "scripts": {}, 41 | "isGameTourist": false, 42 | "simulatorType": "wechat", 43 | "simulatorPluginLibVersion": {}, 44 | "condition": { 45 | "search": { 46 | "current": -1, 47 | "list": [] 48 | }, 49 | "conversation": { 50 | "current": -1, 51 | "list": [] 52 | }, 53 | "game": { 54 | "current": -1, 55 | "list": [] 56 | }, 57 | "plugin": { 58 | "current": -1, 59 | "list": [] 60 | }, 61 | "gamePlugin": { 62 | "current": -1, 63 | "list": [] 64 | }, 65 | "miniprogram": { 66 | "current": -1, 67 | "list": [] 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /sitemap.json: -------------------------------------------------------------------------------- 1 | { 2 | "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", 3 | "rules": [{ 4 | "action": "allow", 5 | "page": "*" 6 | }] 7 | } --------------------------------------------------------------------------------