diff --git a/app.json b/app.json index 5c7e403..9248edf 100644 --- a/app.json +++ b/app.json @@ -57,6 +57,19 @@ "pages/changeToIssue/changeToIssue" ] }, + { + "root": "subpages/associationNew", + "name": "associationNew", + "pages": [ + "pages/associationlist/associationlist", + "pages/community/community", + "pages/gMembersList/gMembersList", + "pages/gOfficialsList/gOfficialsList", + "pages/talklist/talklist", + "pages/eventlist/eventlist", + "pages/addTopic/addTopic" + ] + }, { "root": "subpages/discussion", "name": "discussion", diff --git a/pages/indexNew/indexNew.js b/pages/indexNew/indexNew.js index 8d551cb..fc9d5b8 100644 --- a/pages/indexNew/indexNew.js +++ b/pages/indexNew/indexNew.js @@ -506,7 +506,7 @@ Page({ }, dqhd() { wx.navigateTo({ - url: `../association/association` + url: `../../subpages/associationNew/pages/associationlist/associationlist` }) }, // 积分排名 diff --git a/pages/toRegister/toRegister.js b/pages/toRegister/toRegister.js index c9751a7..9080fc3 100644 --- a/pages/toRegister/toRegister.js +++ b/pages/toRegister/toRegister.js @@ -21,7 +21,7 @@ Page({ // } // }) let that = this - const versionNum = '1.3.0' + const versionNum = '1.4.0' api.getScanSwitch(versionNum).then(function (res) { console.log(res.data) let state = res.data.scanFlag diff --git a/project.config.json b/project.config.json index 0215a71..1086aa5 100644 --- a/project.config.json +++ b/project.config.json @@ -7,9 +7,23 @@ "urlCheck": false, "es6": true, "postcss": true, + "preloadBackgroundData": false, "minified": true, "newFeature": true, - "autoAudits": false + "coverView": true, + "autoAudits": false, + "showShadowRootInWxmlPanel": true, + "scopeDataCheck": false, + "checkInvalidKey": true, + "checkSiteMap": true, + "uploadWithSourceMap": true, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + }, + "useCompilerModule": false, + "userConfirmedUseCompilerModuleSwitch": false }, "compileType": "miniprogram", "libVersion": "2.8.2", diff --git a/subpages/associationNew/components/communityList/communityList.js b/subpages/associationNew/components/communityList/communityList.js new file mode 100644 index 0000000..72daebb --- /dev/null +++ b/subpages/associationNew/components/communityList/communityList.js @@ -0,0 +1,27 @@ +Component({ + data: { + + }, + properties: { + associationList: { + type: Array, + value: [], + observer: function (value) { + if (value.length > 0) { + console.log(value) + } + } + } + }, + methods: { + navigateToAss (e) { + console.log('navigateToAss') + if (e.currentTarget.dataset.join === '0'){ + this.triggerEvent('joinGroupCallBack',{partyGroupId: e.currentTarget.dataset.code}) + } + wx.navigateTo({ + url: `/subpages/associationNew/pages/community/community?code=${e.currentTarget.dataset.code}` + }) + } + } +}) \ No newline at end of file diff --git a/subpages/associationNew/components/communityList/communityList.json b/subpages/associationNew/components/communityList/communityList.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/subpages/associationNew/components/communityList/communityList.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/subpages/associationNew/components/communityList/communityList.wxml b/subpages/associationNew/components/communityList/communityList.wxml new file mode 100644 index 0000000..993fc00 --- /dev/null +++ b/subpages/associationNew/components/communityList/communityList.wxml @@ -0,0 +1,13 @@ + + + + + {{item.partyGroupName}} + + + + \ No newline at end of file diff --git a/subpages/associationNew/components/communityList/communityList.wxss b/subpages/associationNew/components/communityList/communityList.wxss new file mode 100644 index 0000000..dddab1a --- /dev/null +++ b/subpages/associationNew/components/communityList/communityList.wxss @@ -0,0 +1,44 @@ +.hover-btn { + box-shadow: 0 0 10rpx rgba(63, 63, 63, 0.1); +} +.community-item{ + width: 690rpx; + height: 300rpx; + border-radius: 10rpx; + position: relative; + margin: 0 auto; + margin-top: 28rpx; +} +.community-item image{ + width: 100%; + height: 100%; + position: absolute; + border-radius: 10rpx; +} +.community-item .cover-image{ + width: 100%; + height: 100%; + position: absolute; + background: rgba(0, 0, 0, 0.6); + border-radius: 10rpx; + text-align: center; + display: flex; + flex-direction: column; + justify-content: center; +} +.community-item .cover-image .community-name{ + color: white; + font-size: 48rpx; +} +.community-item .cover-image .community-add{ + width: 150rpx; + height: 46rpx; + text-align: left; + padding: 0; + margin-top: 32rpx; + border: 0px; +} +.community-item .cover-image .community-add image{ + width: 100%; + height: 100%; +} \ No newline at end of file diff --git a/subpages/associationNew/components/membersList/membersList.js b/subpages/associationNew/components/membersList/membersList.js new file mode 100644 index 0000000..7b79713 --- /dev/null +++ b/subpages/associationNew/components/membersList/membersList.js @@ -0,0 +1,100 @@ +Component({ + data: { + }, + properties: { + currentUser: { + type: Object, + value: {} + }, + gMembersList: { + type: Array, + value: [], + observer: function (value) { + if (value.length > 0) { + console.log(value) + } + } + }, + gOfficialsList: { + type: Array, + value: [], + observer: function (value) { + if (value.length > 0) { + console.log(value) + } + } + } + }, + methods: { + onNoSpeak (e) { + var _this = this; + wx.showActionSheet({ + itemList: ['取消禁言','禁言1天', '禁言1周', '禁言1月', '永久禁言'], + success (res) { + // console.log(e.currentTarget.dataset.groupUserId,res.tapIndex) + let data = { + groupUserId: e.currentTarget.dataset.groupUserId, + bannedFlag: res.tapIndex.toString() + } + _this.triggerEvent('bannedChange',data) + }, + fail (res) { + console.log(e.currentTarget.dataset.groupUserId,res.errMsg) + } + }) + }, + onPhone (e) { + if (this.getSysInfo()){ + wx.showModal({ + title: '拨打电话', + content: `您确定拨打${e.currentTarget.dataset.number}`, + cancelColor: '#29B9A5', + confirmColor: '#29B9A5', + success: (res) => { + if (res.confirm) { + console.log('用户点击确定') + wx.makePhoneCall({ + phoneNumber: e.currentTarget.dataset.number + }) + } else if (res.cancel) { + console.log('用户点击取消') + } + } + }) + } else { + wx.makePhoneCall({ + phoneNumber: e.currentTarget.dataset.number + }) + } + }, + getSysInfo () { + wx.getSystemInfo({ + success:function(res){ + if(res.platform == "devtools"){ +             return false + }else if(res.platform == "ios"){ +             return false + }else if(res.platform == "android"){ +             return true + } + } + }) + }, + gLevelUp (e) { + console.log(e.currentTarget.dataset.groupUserId) + let parm = { + groupUserId: e.currentTarget.dataset.groupUserId, + identityFlag: '1' + } + this.triggerEvent('modifyIdentity',parm) + }, + gLevelDown (e) { + console.log(e.currentTarget.dataset.groupUserId) + let parm = { + groupUserId: e.currentTarget.dataset.groupUserId, + identityFlag: '2' + } + this.triggerEvent('modifyIdentity',parm) + } + } +}) \ No newline at end of file diff --git a/subpages/associationNew/components/membersList/membersList.json b/subpages/associationNew/components/membersList/membersList.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/subpages/associationNew/components/membersList/membersList.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/subpages/associationNew/components/membersList/membersList.wxml b/subpages/associationNew/components/membersList/membersList.wxml new file mode 100644 index 0000000..5b82e93 --- /dev/null +++ b/subpages/associationNew/components/membersList/membersList.wxml @@ -0,0 +1,56 @@ + + + + + + + {{item.nickname}} + + + + + + + + + + + + + + + + {{item.name}} + {{item.mobile}} + + + + + + {{item.motto}} + + + + \ No newline at end of file diff --git a/subpages/associationNew/components/membersList/membersList.wxss b/subpages/associationNew/components/membersList/membersList.wxss new file mode 100644 index 0000000..13e200d --- /dev/null +++ b/subpages/associationNew/components/membersList/membersList.wxss @@ -0,0 +1,164 @@ +.hover-btn { + box-shadow: 0 0 10rpx rgba(63, 63, 63, 0.1); +} +.line { + width: 690rpx; + height: 2rpx; + margin: 0 auto; + background: rgba(240, 240, 240, 1); +} +.members-item{ + background: rgba(255, 255, 255, 1); + margin-top: 20rpx; + position: relative; +} +.members-item .item-top{ + width: 750rpx; + height: 130rpx; + display: flex; + flex-direction: row; + justify-content: left; + align-items: center; +} +.members-item .item-top .head-icon{ + width: 90rpx; + height: 90rpx; + border-radius: 50%; + margin-left: 29rpx; +} +.members-item .item-top .user-name{ + font-size: 32rpx; + font-family: PingFang SC; + font-weight: 500; + color: rgba(0, 0, 0, 1); + margin-left: 20rpx; +} +.members-item .item-top .leader-logo{ + width: 59rpx; + height: 28rpx; + margin-left: 8rpx; +} +.members-item .item-bottom{ + height: 100rpx; + width: 750rpx; + position: relative; +} +.members-item .item-bottom .levelup-btn{ + display: inline-block; + width: 180rpx; + height: 48rpx; + padding: 0; + position: relative; + border: none; + margin-left: 29rpx; + margin-top: 26rpx; +} +.members-item .item-bottom .takeout-btn{ + display: inline-block; + width: 140rpx; + height: 48rpx; + padding: 0; + position: relative; + border: none; + z-index: 0; + margin-left: 20rpx; +} +.members-item .item-bottom .forbidden-btn{ + display: inline-block; + width: 170rpx; + height: 48rpx; + padding: 0; + position: absolute; + z-index: 0; + margin-left: 20rpx; + right: 32rpx; + top: 26rpx; + border: 1rpx solid rgba(241, 86, 28, 1); + border-radius: 23rpx; +} +.levelup-btn image, .takeout-btn image, .forbidden-btn image, .call-btn image{ + width: 100%; + height: 100%; + position: absolute; + left: 0; + top: 0; +} +.forbidden-btn image{ + width: 24rpx; + height: 14rpx; + position: absolute; + left: 135rpx; + top: 18rpx; +} +.levelup-btn text, .takeout-btn text{ + font-size: 26rpx; + font-family: PingFang SC; + font-weight: bold; + color: rgba(255, 255, 255, 1); + z-index: 1; + position: absolute; + left: 25rpx; + top: 0; + height: 48rpx; + line-height: 48rpx; +} +.forbidden-btn text{ + font-size: 26rpx; + font-family: PingFang SC; + font-weight: 500; + color: rgba(242, 80, 27, 1); + z-index: 1; + position: absolute; + left: 28rpx; + top: 0; + height: 48rpx; + line-height: 48rpx; +} +.disForbidden-btn { + border: 1rpx solid rgba(170, 170, 170, 1) !important; +} +.disForbidden-btn text{ + color: rgba(170, 170, 170, 1) !important; +} + +.members-item .item-top .call-btn{ + width: 156rpx; + height: 56rpx; + padding: 0; + position: absolute; + border: none; + right: 31rpx; +} +.members-item .item-top .np-info{ + display: flex; + flex-direction: column; +} +.members-item .item-top .user-phone{ + font-size: 32rpx; + font-family: PingFang SC; + font-weight: 500; + color: rgba(240, 133, 38, 1); + margin-left: 20rpx; +} +.members-item .item-bottom2{ + height: 100rpx; + width: 750rpx; + position: relative; + display: flex; + align-items: center; +} +.member-label{ + margin-left: 30rpx; + margin-right: 37rpx; + font-size: 28rpx; + font-family: PingFang SC; + font-weight: 500; + color: rgba(153, 153, 153, 1); + display: -webkit-box; + overflow: hidden; + text-overflow: ellipsis; + word-wrap: break-word; + white-space: normal !important; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; +} diff --git a/subpages/associationNew/images/add.png b/subpages/associationNew/images/add.png new file mode 100644 index 0000000..e8a088e Binary files /dev/null and b/subpages/associationNew/images/add.png differ diff --git a/subpages/associationNew/images/arrowd.png b/subpages/associationNew/images/arrowd.png new file mode 100644 index 0000000..814bd49 Binary files /dev/null and b/subpages/associationNew/images/arrowd.png differ diff --git a/subpages/associationNew/images/arrowd2.png b/subpages/associationNew/images/arrowd2.png new file mode 100644 index 0000000..57e427d Binary files /dev/null and b/subpages/associationNew/images/arrowd2.png differ diff --git a/subpages/associationNew/images/btn1.png b/subpages/associationNew/images/btn1.png new file mode 100644 index 0000000..e303889 Binary files /dev/null and b/subpages/associationNew/images/btn1.png differ diff --git a/subpages/associationNew/images/btn2.png b/subpages/associationNew/images/btn2.png new file mode 100644 index 0000000..3769d78 Binary files /dev/null and b/subpages/associationNew/images/btn2.png differ diff --git a/subpages/associationNew/images/call.png b/subpages/associationNew/images/call.png new file mode 100644 index 0000000..85994e3 Binary files /dev/null and b/subpages/associationNew/images/call.png differ diff --git a/subpages/associationNew/images/comment.png b/subpages/associationNew/images/comment.png new file mode 100644 index 0000000..a1af885 Binary files /dev/null and b/subpages/associationNew/images/comment.png differ diff --git a/subpages/associationNew/images/give.png b/subpages/associationNew/images/give.png new file mode 100644 index 0000000..910694a Binary files /dev/null and b/subpages/associationNew/images/give.png differ diff --git a/subpages/associationNew/images/give_2.png b/subpages/associationNew/images/give_2.png new file mode 100644 index 0000000..36035d2 Binary files /dev/null and b/subpages/associationNew/images/give_2.png differ diff --git a/subpages/associationNew/images/ic_dingwei@2x.png b/subpages/associationNew/images/ic_dingwei@2x.png new file mode 100644 index 0000000..a3640ff Binary files /dev/null and b/subpages/associationNew/images/ic_dingwei@2x.png differ diff --git a/subpages/associationNew/images/ic_huifu@2x.png b/subpages/associationNew/images/ic_huifu@2x.png new file mode 100644 index 0000000..b66ac8c Binary files /dev/null and b/subpages/associationNew/images/ic_huifu@2x.png differ diff --git a/subpages/associationNew/images/icon_close.png b/subpages/associationNew/images/icon_close.png new file mode 100644 index 0000000..5e08d97 Binary files /dev/null and b/subpages/associationNew/images/icon_close.png differ diff --git a/subpages/associationNew/images/ig_tianjiatupian@2x.png b/subpages/associationNew/images/ig_tianjiatupian@2x.png new file mode 100644 index 0000000..5f437fe Binary files /dev/null and b/subpages/associationNew/images/ig_tianjiatupian@2x.png differ diff --git a/subpages/associationNew/images/leader-logo.png b/subpages/associationNew/images/leader-logo.png new file mode 100644 index 0000000..a27b847 Binary files /dev/null and b/subpages/associationNew/images/leader-logo.png differ diff --git a/subpages/associationNew/images/loading.gif b/subpages/associationNew/images/loading.gif new file mode 100644 index 0000000..915c198 Binary files /dev/null and b/subpages/associationNew/images/loading.gif differ diff --git a/subpages/associationNew/images/next.png b/subpages/associationNew/images/next.png new file mode 100644 index 0000000..470884b Binary files /dev/null and b/subpages/associationNew/images/next.png differ diff --git a/subpages/associationNew/images/speack.png b/subpages/associationNew/images/speack.png new file mode 100644 index 0000000..4d989ff Binary files /dev/null and b/subpages/associationNew/images/speack.png differ diff --git a/subpages/associationNew/images/story.png b/subpages/associationNew/images/story.png new file mode 100644 index 0000000..03a0f31 Binary files /dev/null and b/subpages/associationNew/images/story.png differ diff --git a/subpages/associationNew/pages/addTopic/addTopic.js b/subpages/associationNew/pages/addTopic/addTopic.js new file mode 100644 index 0000000..9f5ae9e --- /dev/null +++ b/subpages/associationNew/pages/addTopic/addTopic.js @@ -0,0 +1,308 @@ +import { $wuxActionSheet } from '../../../../dist/index' +import { addTopic } from '../../utils/api' +const QQMapWX = require('../../utils/qqmap-wx-jssdk') +const config = require('../../../../utils/config') + +Page({ + data: { + topicValue: '', + imageList: [], + qqmapsdk: '', + addressValue: '', + imageId: 1, + location: { + latitude: '', + longitude: '' + }, + partyGroupId: '', + topicType:'',//0:事好儿鼓个掌 1:话对捧个场 + addTopicPrevious: 0 + }, + onShow () { + + }, + onLoad (options) { + const qqmapsdk = new QQMapWX({ + key: 'CMJBZ-4DECI-JXGGN-5B4WU-QLV2H-B5BEJ' + }) + this.setData({ + qqmapsdk, + partyGroupId: options.partyGroupId, + topicType: options.topicType, + }) + if(options.topicType == 0){ + wx.setNavigationBarTitle({ + title: '事好儿鼓个掌' + }) + }else{ + wx.setNavigationBarTitle({ + title: '话对捧个场' + }) + } + this.getLocation() + }, + // 话题内容框 值双向绑定 + bindTopicValue (e) { + this.setData({ + topicValue: e.detail.value + }) + console.log(this.data.topicValue) + }, + // 地址框 值双向绑定 + bindAddressValue (e) { + this.setData({ + addressValue: e.detail.value + }) + console.log(this.data.addressValue) + }, + // 选择图片 + chooseImage () { + const that = this + $wuxActionSheet().showSheet({ + buttons: [{ + text: '拍照' + }, + { + text: '从相册中获取' + }, + ], + buttonClicked(index, item) { + if (index === 0) { + wx.chooseImage({ + count: 1, + sizeType: ['original', 'compressed'], + sourceType: ['camera'], + success (res) { + const imageList = [...that.data.imageList] + imageList.push({ + img: res.tempFilePaths[0], + upload: true, + id: that.data.imageId++, + ossUrl: '' + }) + that.setData({ + imageList + }) + wx.uploadFile({ + url: config.BASEURL() + 'group/topic/upload', + filePath: res.tempFilePaths[0], + name: 'file', + header: { + 'Content-Type': 'multipart/form-data' + }, + success (fileres) { + const data = JSON.parse(fileres.data) + if (data.code === 0 && data.msg === 'success') { + imageList[imageList.length - 1].ossUrl = data.data + imageList[imageList.length - 1].upload = false + } else { + imageList.pop() + wx.showToast({ + title: '上传图片失败,请重试', + icon: 'none', + duration: 2000 + }) + } + that.setData({ + imageList + }) + }, + fail (err) { + console.log(err) + imageList.pop() + wx.showToast({ + title: '上传图片失败,请重试', + icon: 'none', + duration: 2000 + }) + that.setData({ + imageList + }) + } + }) + } + }) + } else if (index === 1) { + wx.chooseImage({ + count: 3 - that.data.imageList.length, + sizeType: ['original', 'compressed'], + sourceType: ['album'], + success (res) { + let imageList = [] + res.tempFilePaths.forEach(item => { + imageList.push({ + img: item, + upload: true, + id: that.data.imageId++, + ossUrl: '' + }) + }) + that.setData({ + imageList: [...that.data.imageList, ...imageList] + }) + imageList.forEach((item, index) => { + (function (index) { + wx.uploadFile({ + url: `${config.BASEURL()}group/topic/upload`, + filePath: imageList[index].img, + name: 'file', + header: { + 'Content-Type': 'multipart/form-data' + }, + success (fileRes) { + const data = JSON.parse(fileRes.data) + if (data.code === 0 && data.msg === 'success') { + imageList[index].ossUrl = data.data + imageList[index].upload = false + + } else { + imageList.splice(index, 1) + wx.showToast({ + title: '上传图片失败,请重试', + icon: 'none', + duration: 2000 + }) + } + that.data.imageList = that.data.imageList.slice(0, that.data.imageList.length - res.tempFilePaths.length) + that.setData({ + imageList: [...that.data.imageList, ...imageList] + }) + }, + fail (err) { + console.log(err) + imageList.splice(index, 1) + wx.showToast({ + title: '上传图片失败,请重试', + icon: 'none', + duration: 2000 + }) + that.data.imageList = that.data.imageList.slice(0, that.data.imageList.length - res.tempFilePaths.length) + that.setData({ + imageList: [...that.data.imageList, ...imageList] + }) + } + }) + })(index) + }) + } + }) + } + return true + }, + cancelText: '取消', + cancel() {}, + destructiveButtonClicked() {}, + }) + }, + // 获取经纬度 + getLocation () { + wx.getLocation({ + type: 'gcj02', + success: (res) => { + console.log('经纬度', res) + this.reverseGeocoder(res) + this.setData({ + location: { + latitude: res.latitude, + longitude: res.longitude + } + }) + } + }) + }, + // 逆地址解析 + reverseGeocoder ({latitude, longitude}) { + this.data.qqmapsdk.reverseGeocoder({ + location: { + latitude, + longitude + }, + success: (res) => { + console.log('逆地址解析', res) + if (res.message === 'query ok') { + this.setData({ + addressValue: res.result.address + }) + } + } + }) + }, + // throttleAddTopic () { + // let now = new Date() + // if (now - this.data.addTopicPrevious > 2000) { + // this.addTopic() + // this.data.addTopicPrevious = now + // } + // }, + // 添加话题事件 + addTopic () { + if (this.data.topicValue === '') { + wx.showToast({ + title: '请输入-话题内容', + icon: 'none', + duration: 2000 + }) + return false + } else if (this.data.addressValue === '') { + wx.showToast({ + title: '请输入-地址', + icon: 'none', + duration: 2000 + }) + return false + } + const imagesList = [] + if (this.data.imageList.length > 0) { + const isUploadingStatus = this.data.imageList.some(item => item.upload) + if (isUploadingStatus) { + wx.showToast({ + title: '请等待图片上传完成', + icon: 'none', + duration: 2000 + }) + return false + } + this.data.imageList.forEach(item => { + imagesList.push(item.ossUrl) + }) + } + const para = { + topicType:this.data.topicType,//话题类型:0:事好儿鼓个掌 1:话对捧个场 + topicContent: this.data.topicValue,//话题内容 + topicAddress: this.data.addressValue,//话题地址 + topicLatitude: this.data.location.latitude,//话题位置纬度 + topicLongitude: this.data.location.longitude,//话题位置经度 + partyGroupId:this.data.partyGroupId,//党群ID + images: imagesList + } + wx.showLoading({ + title: '加载中', + }) + addTopic(para).then(res => { + wx.hideLoading() + console.log(res) + wx.showToast({ + title: '发布成功', + icon: 'none', + duration: 2000 + }) + var pages = getCurrentPages() + // var prePages = pages[pages.length - 2] + setTimeout(() => { + // prePages.pullRefreshGetTopicList() + wx.navigateBack() + }, 1000) + }).catch(err => { + console.log(err) + }) + }, + // 删除图片 + deleteImage (e) { + const index = this.data.imageList.findIndex((item,index) => index === e.currentTarget.dataset.index) + this.data.imageList.splice(index, 1) + const imageList = this.data.imageList + this.setData({ + imageList + }) + } +}) \ No newline at end of file diff --git a/subpages/associationNew/pages/addTopic/addTopic.json b/subpages/associationNew/pages/addTopic/addTopic.json new file mode 100644 index 0000000..bab6638 --- /dev/null +++ b/subpages/associationNew/pages/addTopic/addTopic.json @@ -0,0 +1,6 @@ +{ + "usingComponents": { + "wux-actionsheet": "../../../../dist/actionsheet/index" + }, + "navigationBarTitleText": "" +} \ No newline at end of file diff --git a/subpages/associationNew/pages/addTopic/addTopic.wxml b/subpages/associationNew/pages/addTopic/addTopic.wxml new file mode 100644 index 0000000..fe98c38 --- /dev/null +++ b/subpages/associationNew/pages/addTopic/addTopic.wxml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/subpages/associationNew/pages/eventlist/eventlist.wxss b/subpages/associationNew/pages/eventlist/eventlist.wxss new file mode 100644 index 0000000..92790df --- /dev/null +++ b/subpages/associationNew/pages/eventlist/eventlist.wxss @@ -0,0 +1,213 @@ +page { + background: #f7f7f7; +} + +.item-list { + width: 100%; + padding: 40rpx 29rpx 20rpx 29rpx; + background: #fff; + margin-top: 20rpx; +} + +.user-info { + width: calc(100% - 58rpx); + height: 64rpx; + display: flex; + align-items: center; +} + +.user-info image { + width: 64rpx; + height: 64rpx; +} + +.user-info .name-date { + margin-left: 14rpx; + height: 100%; + display: flex; + flex-direction: column; +} + +.user-info .name-date .name { + font-size: 28rpx; + font-weight: bold; + color: rgba(51, 51, 51, 1); +} + +.user-info .name-date .date { + font-size: 20rpx; + font-weight: 500; + color: rgba(153, 153, 153, 1); +} + +.details-info { + width: calc(100% - 58rpx); + font-size: 36rpx; + font-weight: 500; + color: rgba(51, 51, 51, 1); + line-height: 54rpx; +} + +.image-list { + width: calc(100% - 58rpx); + margin-top: 30rpx; + display: grid; + grid-template-columns: repeat(auto-fit, minmax(216rpx, 1fr)); + grid-gap: 7rpx; +} + +.image-list .image-item { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 8rpx; +} + +.attitude { + width: calc(100% - 158rpx); + margin-top: 21rpx; + display: flex; + align-items: center; + justify-content: space-between; + /* justify-content: center; */ + height: 28rpx; + padding: 0 50rpx; +} + +.attitude .all { + display: flex; + align-items: center; +} + +.attitude .all image { + width: 28rpx; + height: 28rpx; +} + +.attitude .all .give-data { + font-size: 24rpx; + font-weight: 500; + color: rgba(51, 51, 51, 1); + margin-left: 9rpx; + /* width: 196rpx; */ +} + +.attitude .all .give-data.color { + color: #FFB103; +} + +.comment { + width: calc(100% - 98rpx); + padding: 26rpx 20rpx; + background: #F2F2F2; + border-radius: 8rpx; + margin-top: 25rpx; +} + +.comment .comment-list { + width: 100%; + margin-top: 11rpx; + font-size: 28rpx; + color: #999999; +} + +.comment .comment-list text { + color: #333333; +} + +/* 评论样式 */ +.release { + align-items: flex-end; + /*底部对齐*/ + box-sizing: border-box; + position: fixed; + left: 0; + bottom: 0; + width: 100%; + padding: 13rpx 20rpx; + background-color: #fff; + font-size: 28rpx; + z-index: 999; +} + +.replyinfo1 { + display: flex; + justify-content: space-between; + /*两端对齐*/ + font-size: 35rpx; +} + +.replyinfo2 { + display: flex; + justify-content: space-between; + /*两端对齐*/ +} + +.release textarea { + width: calc(100% - 200rpx); + min-height: 34rpx; + max-height: 102rpx; + /*最多显示三行*/ + border-width: 15rpx 20rpx; + /*使用padding与预期留白不一致,故使用border*/ + border-style: solid; + border-color: #F2F2F2; + line-height: 34rpx; + font-size: 28rpx; + background-color: #F2F2F2; + border-radius: 4rpx; +} + +.release .text { + font-size: 40rpx; + color: #c9c9c9; +} + +.cancel { + width: 240rpx; + height: 64rpx; + line-height: 64rpx; + text-align: center; + color: #6c0; + margin: 0 3px; + padding: 0; +} + +.release .submit { + width: 160rpx; + height: 60rpx; + line-height: 60rpx; + text-align: center; + margin: 0 3px; + padding: 0; + font-size: 32rpx; + font-weight: 500; + color: rgba(255, 255, 255, 1); + background: linear-gradient(to right, #e95027, #db1a1f); + border-radius: 50rpx; +} + + +.pro-box .info .text .delete { + color: #f68135; + border-radius: 50rpx; + border: 1px solid #f68135; + font-size: 28 rpx; + width: 150rpx; + height: 48rpx; + text-align: center; +} + +.addIssue { + width: 178rpx; + height: 178rpx; + position: fixed; + bottom: 30%; + right: 14rpx; +} + +.addIssue image { + width: 100%; + height: 100%; + object-fit: cover; +} \ No newline at end of file diff --git a/subpages/associationNew/pages/gMembersList/gMembersList.js b/subpages/associationNew/pages/gMembersList/gMembersList.js new file mode 100644 index 0000000..5d8a042 --- /dev/null +++ b/subpages/associationNew/pages/gMembersList/gMembersList.js @@ -0,0 +1,115 @@ +import { + getPartyUserList, + postUserBanned, + postModifyIdentity +} from '../../utils/api' +Page({ + + /** + * 页面的初始数据 + */ + data: { + currentUser: {}, + gMembersList: [], + loadMoreVisible: false, + loadMoreType: 'none', + preloadVisible: true, + pageNo: 1, + pageSize: 10, + partyGroupId: '' + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.data.partyGroupId = options.partyGroupId + this.getPartyUserList() + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + this.setData({ + loadMoreVisible: true + }) + if (this.data.loadMoreType === 'loading') { + this.setData({ + pageNo: this.data.pageNo + 1 + }) + this.getPartyUserList() + } + }, + // 获取群成员列表 + getPartyUserList () { + const para = { + pageIndex: this.data.pageNo, + pageSize: this.data.pageSize, + partyGroupId: this.data.partyGroupId + } + wx.showLoading({ + title:'' + }) + getPartyUserList(para).then(res => { + console.log('获取群成员列表', res) + this.setData({ + currentUser: {...res.data.currentUser}, + gMembersList: [...this.data.gMembersList, ...res.data.otherUsers], + loadMoreType: res.data.otherUsers.length === this.data.pageSize ? 'loading': 'none', + preloadVisible: false + }) + if (this.data.loadMoreType === 'none' && this.data.gMembersList.length !== 0) { + this.setData({ + loadMoreVisible: true + }) + } + wx.hideLoading() + }).catch(err => { + console.log(err) + this.setData({ + gMembersList: [], + loadMoreType: 'none', + preloadVisible: false + }) + }) + }, + bannedChangeCallBack (e) { + console.log(e.detail) + const para = {...e.detail} + postUserBanned(para).then(res => { + console.log('用户禁言', res) + this.data.gMembersList.forEach(item => { + if (item.id === e.detail.groupUserId) { + item.bannedFlag = e.detail.bannedFlag + } + }) + this.setData({ + gMembersList: this.data.gMembersList + }) + }).catch(err => { + console.log(err) + }) + }, + modifyIdentityCallBack (e) { + console.log(e.detail) + const para = {...e.detail} + postModifyIdentity(para).then(res => { + console.log('修改用户身份', res) + this.setData({ + gMembersList: [], + currentUser: {} + }) + this.getPartyUserList(); + }).catch(err => { + console.log(err) + }) + } +}) diff --git a/subpages/associationNew/pages/gMembersList/gMembersList.json b/subpages/associationNew/pages/gMembersList/gMembersList.json new file mode 100644 index 0000000..60ea339 --- /dev/null +++ b/subpages/associationNew/pages/gMembersList/gMembersList.json @@ -0,0 +1,8 @@ +{ + "usingComponents": { + "load-more": "../../../../components/loadMore/loadMore", + "members-list": "../../components/membersList/membersList", + "no-data": "../../../../components/nodata/nodata" + }, + "navigationBarTitleText": "群成员" +} \ No newline at end of file diff --git a/subpages/associationNew/pages/gMembersList/gMembersList.wxml b/subpages/associationNew/pages/gMembersList/gMembersList.wxml new file mode 100644 index 0000000..cf553f4 --- /dev/null +++ b/subpages/associationNew/pages/gMembersList/gMembersList.wxml @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file diff --git a/subpages/associationNew/pages/gMembersList/gMembersList.wxss b/subpages/associationNew/pages/gMembersList/gMembersList.wxss new file mode 100644 index 0000000..575bdf7 --- /dev/null +++ b/subpages/associationNew/pages/gMembersList/gMembersList.wxss @@ -0,0 +1,7 @@ +/* subpages/associationNew/pages/associationlist/associationlist.wxss */ +page { + width:100%; + height: auto; + overflow-y: auto; + background: #f7f7f7; +} \ No newline at end of file diff --git a/subpages/associationNew/pages/gOfficialsList/gOfficialsList.js b/subpages/associationNew/pages/gOfficialsList/gOfficialsList.js new file mode 100644 index 0000000..f107e79 --- /dev/null +++ b/subpages/associationNew/pages/gOfficialsList/gOfficialsList.js @@ -0,0 +1,74 @@ +import { getOfficialsList } from '../../utils/api' +Page({ + /** + * 页面的初始数据 + */ + data: { + partyGroupId: '', + gOfficialsList: [], + loadMoreVisible: false, + loadMoreType: 'none', + preloadVisible: true, + pageNo: 1, + pageSize: 10 + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.data.partyGroupId = options.partyGroupId + this.getOfficialsList(); + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + this.setData({ + loadMoreVisible: true + }) + if (this.data.loadMoreType === 'loading') { + this.setData({ + pageNo: this.data.pageNo + 1 + }) + this.getOfficialsList() + } + }, + + // 官小带个长 列表 + getOfficialsList () { + const para = { + pageIndex: this.data.pageNo, + pageSize: this.data.pageSize, + partyGroupId: this.data.partyGroupId + } + getOfficialsList(para).then(res => { + console.log('获取官小带个长列表', res) + this.setData({ + gOfficialsList: [...this.data.gOfficialsList, ...res.data], + loadMoreType: res.data.length === this.data.pageSize ? 'loading': 'none', + preloadVisible: false + }) + if (this.data.loadMoreType === 'none' && this.data.gOfficialsList.length !== 0) { + this.setData({ + loadMoreVisible: true + }) + } + }).catch(err => { + console.log(err) + this.setData({ + gOfficialsList: [], + loadMoreType: 'none', + preloadVisible: false + }) + }) + } +}) diff --git a/subpages/associationNew/pages/gOfficialsList/gOfficialsList.json b/subpages/associationNew/pages/gOfficialsList/gOfficialsList.json new file mode 100644 index 0000000..38bcac3 --- /dev/null +++ b/subpages/associationNew/pages/gOfficialsList/gOfficialsList.json @@ -0,0 +1,8 @@ +{ + "usingComponents": { + "load-more": "../../../../components/loadMore/loadMore", + "no-data": "../../../../components/nodata/nodata", + "members-list": "../../components/membersList/membersList" + }, + "navigationBarTitleText": "官小带个长" +} \ No newline at end of file diff --git a/subpages/associationNew/pages/gOfficialsList/gOfficialsList.wxml b/subpages/associationNew/pages/gOfficialsList/gOfficialsList.wxml new file mode 100644 index 0000000..262051a --- /dev/null +++ b/subpages/associationNew/pages/gOfficialsList/gOfficialsList.wxml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/subpages/associationNew/pages/gOfficialsList/gOfficialsList.wxss b/subpages/associationNew/pages/gOfficialsList/gOfficialsList.wxss new file mode 100644 index 0000000..70a5b21 --- /dev/null +++ b/subpages/associationNew/pages/gOfficialsList/gOfficialsList.wxss @@ -0,0 +1,6 @@ +page { + width:100%; + height: auto; + overflow-y: auto; + background: #f7f7f7; +} \ No newline at end of file diff --git a/subpages/associationNew/pages/talklist/talklist.js b/subpages/associationNew/pages/talklist/talklist.js new file mode 100644 index 0000000..7007d83 --- /dev/null +++ b/subpages/associationNew/pages/talklist/talklist.js @@ -0,0 +1,66 @@ +// subpages/associationNew/pages/talklist/talklist.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/subpages/associationNew/pages/talklist/talklist.json b/subpages/associationNew/pages/talklist/talklist.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/subpages/associationNew/pages/talklist/talklist.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/subpages/associationNew/pages/talklist/talklist.wxml b/subpages/associationNew/pages/talklist/talklist.wxml new file mode 100644 index 0000000..5f4236a --- /dev/null +++ b/subpages/associationNew/pages/talklist/talklist.wxml @@ -0,0 +1,2 @@ + +subpages/associationNew/pages/talklist/talklist.wxml diff --git a/subpages/associationNew/pages/talklist/talklist.wxss b/subpages/associationNew/pages/talklist/talklist.wxss new file mode 100644 index 0000000..0d69917 --- /dev/null +++ b/subpages/associationNew/pages/talklist/talklist.wxss @@ -0,0 +1 @@ +/* subpages/associationNew/pages/talklist/talklist.wxss */ \ No newline at end of file diff --git a/subpages/associationNew/utils/api.js b/subpages/associationNew/utils/api.js new file mode 100644 index 0000000..f7b3817 --- /dev/null +++ b/subpages/associationNew/utils/api.js @@ -0,0 +1,121 @@ +const request = require('../../../utils/request') +/** + *获取图片 + */ +export function getImageUrl() { + return request.get('imgConfig/getImgUrl/1') +} +/** + *进入党群 + */ +export function getJoinGroup({partyGroupId}) { + return request.get('partyGroup/group/join',{ + partyGroupId + }) +} +/** + *党群名称列表 + */ +export function getPartyGroupList() { + return request.get('partyGroup/group/list') +} +/** + * 群成员列表 + */ +export function getPartyUserList({pageIndex, pageSize, partyGroupId}) { + return request.get('partyGroup/user/list',{ + pageIndex, + pageSize, + partyGroupId + }) +} +/** + * 官小带个长列表 + */ +export function getOfficialsList({pageIndex, pageSize, partyGroupId}) { + return request.get('partyGroup/officials/list',{ + pageIndex, + pageSize, + partyGroupId + }) +} +/** + * 当前用户信息 + */ +export function getCurrentUserInfo(partyGroupId) { + return request.get('partyGroup/user/currentUserInfo/'+partyGroupId) +} +/** + * 用户身份修改 + */ +export function postModifyIdentity({groupUserId, identityFlag}) { + return request.post('partyGroup/user/modifyIdentity',{ + groupUserId, + identityFlag + }) +} +/** + * 用户禁言 + */ +export function postUserBanned({groupUserId, bannedFlag}) { + return request.post('partyGroup/user/banned',{ + groupUserId, + bannedFlag + }) +} + +/** + * 话题列表 + */ +export function topiclist({pageIndex,pageSize,timestamp,topicType,partyGroupId}) { + return request.get('partyGroup/topic/list',{ + pageIndex, + pageSize, + timestamp, + topicType, + partyGroupId, + }) +} + + +/** + * 发布话题 + */ + +export function addTopic({topicType, topicContent,topicAddress,topicLatitude,topicLongitude,partyGroupId,images}) { + return request.post('partyGroup/topic/submit',{ + topicType, + topicContent, + topicAddress, + topicLatitude, + topicLongitude, + partyGroupId, + images + }) +} + +/** + * 话题评论 + */ + +export function commentSubmit({topicId, faCommentId,content}) { + return request.post('partyGroup/comment/submit',{ + topicId, + faCommentId, + content + }) +} + +/** + * 表态话题(赞/踩) + */ +export function statement({attitude, topicId}) { + return request.post('partyGroup/topic/statement',{ + topicId, + attitude + }) +} + + + + diff --git a/subpages/associationNew/utils/filters.wxs b/subpages/associationNew/utils/filters.wxs new file mode 100644 index 0000000..47cfb1c --- /dev/null +++ b/subpages/associationNew/utils/filters.wxs @@ -0,0 +1,65 @@ +var GROUP_LEADER='0'; +var GROUP_LEADER_2='1'; +var GROUP_MEMBER='2'; + +var getIdentity = function (btnType,mypower,userpower) { + if (btnType === 0) { + if (mypower === GROUP_LEADER && userpower === GROUP_MEMBER) { + return true + } else { + return false + } + } else if (btnType === 1) { + if (mypower === GROUP_LEADER && userpower === GROUP_LEADER_2) { + return true + } else { + return false + } + } else { + if (mypower === GROUP_LEADER && userpower !== GROUP_LEADER) { + return true + } else if (mypower === GROUP_LEADER_2 && userpower === GROUP_MEMBER) { + return true + } else { + return false + } + } +} +var getBanned = function (code) { + var index = parseInt(code) + return [ + ' 未禁言', + '禁言1天', + '禁言1周', + '禁言1月', + '永久禁言' + ][index] +} +var disabledBanned = function (identity,uIdentity) { + if (identity === GROUP_LEADER) { + return true + } else if (identity === GROUP_LEADER_2) { + if (uIdentity !== GROUP_MEMBER) { + return false + } else { + return true + } + } else { + return false + } +} +var forbiddenClass = function(identity,uIdentity){ + if (identity === GROUP_LEADER_2 && uIdentity === GROUP_LEADER_2) { + return true + } else if (identity === GROUP_MEMBER) { + return true + } else { + return false + } +} +module.exports = { + getIdentity: getIdentity, + getBanned: getBanned, + disabledBanned:disabledBanned, + forbiddenClass:forbiddenClass +} \ No newline at end of file diff --git a/subpages/associationNew/utils/qqmap-wx-jssdk.js b/subpages/associationNew/utils/qqmap-wx-jssdk.js new file mode 100644 index 0000000..9724e31 --- /dev/null +++ b/subpages/associationNew/utils/qqmap-wx-jssdk.js @@ -0,0 +1,1123 @@ +/** + * 微信小程序JavaScriptSDK + * + * @version 1.2 + * @date 2019-03-06 + * @author v_ylyue@tencent.com + */ + +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 = { + /** + * md5加密方法 + * 版权所有©2011 Sebastian Tschan,https://blueimp.net + */ + 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) { + /* append padding */ + 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); + }, + /** + * 得到md5加密后的sig参数 + * @param {Object} requestParam 接口参数 + * @param {String} sk签名字符串 + * @param {String} featrue 方法名 + * @return 返回加密后的sig参数 + */ + 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; + }, + /** + * 得到终点query字符串 + * @param {Array|String} 检索数据 + */ + 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; + }, + /** + * 处理终点location数组 + * @return 返回终点数组 + */ + 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; + }, + + /** + * 计算两点间直线距离 + * @param a 表示纬度差 + * @param b 表示经度差 + * @return 返回的是距离,单位m + */ + 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 + }); + }, + + /** + * 获取location参数 + */ + 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 () { }; + }, + + /** + * 验证param对应的key值是否为空 + * + * @param {Object} param 接口参数 + * @param {String} key 对应参数的key + */ + 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; + }, + + /** + * 验证参数中是否存在检索词keyword + * + * @param {Object} param 接口参数 + */ + checkKeyword(param){ + return !this.checkParamKeyEmpty(param, 'keyword'); + }, + + /** + * 验证location值 + * + * @param {Object} param 接口参数 + */ + 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; + }, + + /** + * 构造错误数据结构 + * @param {Number} errCode 错误码 + * @param {Number} errMsg 错误描述 + */ + buildErrorConfig(errCode, errMsg) { + return { + status: errCode, + message: errMsg + }; + }, + + /** + * + * 数据处理函数 + * 根据传入参数不同处理不同数据 + * @param {String} feature 功能名称 + * search 地点搜索 + * suggest关键词提示 + * reverseGeocoder逆地址解析 + * geocoder地址解析 + * getCityList获取城市列表:父集 + * getDistrictByCityId获取区县列表:子集 + * calculateDistance距离计算 + * @param {Object} param 接口参数 + * @param {Object} data 数据 + */ + 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) {//判断是否返回周边poi + 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); + } + }, + + /** + * 构造微信请求参数,公共属性处理 + * + * @param {Object} param 接口参数 + * @param {Object} param 配置项 + * @param {String} feature 方法名 + */ + 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 { + + /** + * 构造函数 + * + * @param {Object} options 接口参数,key 为必选参数 + */ + constructor(options) { + if (!options.key) { + throw Error('key值不能为空'); + } + this.key = options.key; + }; + + /** + * POI周边检索 + * + * @param {Object} options 接口参数对象 + * + * 参数对象结构可以参考 + * @see http://lbs.qq.com/webservice_v1/guide-search.html + */ + 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); + }; + + /** + * sug模糊检索 + * + * @param {Object} options 接口参数对象 + * + * 参数对象结构可以参考 + * http://lbs.qq.com/webservice_v1/guide-suggestion.html + */ + 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")); + } + }; + + /** + * 逆地址解析 + * + * @param {Object} options 接口参数对象 + * + * 请求参数结构可以参考 + * http://lbs.qq.com/webservice_v1/guide-gcoder.html + */ + 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); + }; + + /** + * 地址解析 + * + * @param {Object} options 接口参数对象 + * + * 请求参数结构可以参考 + * http://lbs.qq.com/webservice_v1/guide-geocoder.html + */ + 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')); + }; + + + /** + * 获取城市列表 + * + * @param {Object} options 接口参数对象 + * + * 请求参数结构可以参考 + * http://lbs.qq.com/webservice_v1/guide-region.html + */ + 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')); + }; + + /** + * 获取对应城市ID的区县列表 + * + * @param {Object} options 接口参数对象 + * + * 请求参数结构可以参考 + * http://lbs.qq.com/webservice_v1/guide-region.html + */ + 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')); + }; + + /** + * 用于单起点到多终点的路线距离(非直线距离)计算: + * 支持两种距离计算方式:步行和驾车。 + * 起点到终点最大限制直线距离10公里。 + * + * 新增直线距离计算。 + * + * @param {Object} options 接口参数对象 + * + * 请求参数结构可以参考 + * http://lbs.qq.com/webservice_v1/guide-distance.html + */ + 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); + } + }; + + /** + * 路线规划: + * + * @param {Object} options 接口参数对象 + * + * 请求参数结构可以参考 + * https://lbs.qq.com/webservice_v1/guide-road.html + */ + direction(options) { + var that = this; + options = options || {}; + Utils.polyfillParam(options); + + if (Utils.checkParamKeyEmpty(options, 'to')) { + return; + } + + var requestParam = { + output: 'json', + key: that.key + }; + + //to格式处理 + if (typeof options.to == 'string') { + requestParam.to = options.to; + } else { + requestParam.to = options.to.latitude + ',' + options.to.longitude; + } + //初始化局部请求域名 + var SET_URL_DIRECTION = null; + //设置默认mode属性 + 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; \ No newline at end of file diff --git a/utils/config.js b/utils/config.js index b705e92..c74543c 100644 --- a/utils/config.js +++ b/utils/config.js @@ -6,6 +6,7 @@ module.exports = { }; function BASEURL() { + // return 'https://eug-test.elinkit.com.cn/js/epdc-api/api/' //党群1+1 // return 'https://eug-test.elinkit.com.cn/js/epdc-api/api/' // 锦水测试环境 // return 'https://eug-test.elinkit.com.cn/epdc-api/api/' // 测试环境 接口地址 // return "http://219.146.91.110:9094/epdc-api/api/" // 测试环境 ip接口地址