diff --git a/app.js b/app.js index 0144990..485f0f5 100644 --- a/app.js +++ b/app.js @@ -30,7 +30,6 @@ App({ navigationHeight: 40 }, user:{}, - share:false, - keyWord:"" + share:false } }) diff --git a/app.json b/app.json index 6a4eef2..f73edce 100644 --- a/app.json +++ b/app.json @@ -115,6 +115,18 @@ } ] }, + "permission": { + "scope.userLocation": { + "desc": "亿联社区将获取您的位置信息" + } + }, + "requiredPrivateInfos": [ + "getLocation", + "chooseLocation" + ], + "navigateToMiniProgramAppIdList": [ + "wx50ebeb95943868cd" + ], "networkTimeout": { "request": 60000 }, diff --git a/components/dist/date-picker-view/index.js b/components/dist/date-picker-view/index.js new file mode 100644 index 0000000..c568e7d --- /dev/null +++ b/components/dist/date-picker-view/index.js @@ -0,0 +1,477 @@ +import baseComponent from '../helpers/baseComponent' +import classNames from '../helpers/classNames' +import locales from './locales/index' +import { props } from './props' + +const DATETIME = 'datetime' +const DATE = 'date' +const TIME = 'time' +const MONTH = 'month' +const YEAR = 'year' +const ONE_DAY = 24 * 60 * 60 * 1000 + +function fomartArray(min, max, step = 1) { + let i = min + let result = [] + while (i <= max) { + result.push(i) + i+=step + } + return result +} + +function getDaysInMonth(date) { + return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate() +} + +function pad(n) { + return n < 10 ? `0${n}` : n + '' +} + +function cloneDate(date) { + return new Date(+date) +} + +function setMonth(date, month) { + date.setDate(Math.min(date.getDate(), getDaysInMonth(new Date(date.getFullYear(), month)))) + date.setMonth(month) +} + +function valueToDate(value, props = {}) { + if (!Array.isArray(value)) { + if (typeof value === 'string') { + value = value.replace(/\-/g, '/') + } + if (!isNaN(Number(value))) { + value = Number(value) + } + return new Date(value) + } + + const { mode, use12Hours } = props + const now = new Date() + const year = now.getFullYear() + const month = now.getMonth() + const day = now.getDate() + const newValue = value.map((v) => Number(v)) + if (use12Hours && [DATETIME, TIME].includes(mode)) { + const hourIndex = mode === DATETIME ? 3 : 0 + const ampmIndex = newValue.length - 1 + const ampm = Number(newValue[ampmIndex]) + let nhour = Number(newValue[hourIndex]) + + if (ampm === 1) { + if (nhour <= 12) { + nhour += 12 + } + nhour = nhour >= 24 ? 0 : nhour + } else { + if (nhour === 0) { + nhour = 12 + } + if (nhour > 12) { + nhour -= 12 + } + nhour = nhour >= 12 ? 0 : nhour + } + + newValue.splice(hourIndex, 1, nhour) + newValue.splice(ampmIndex, 1) + } + if (mode === TIME) { + newValue.unshift(day) + newValue.unshift(month) + newValue.unshift(year) + } else if (mode === MONTH) { + newValue.push(day) + } else if (mode === YEAR) { + newValue.push(month) + newValue.push(day) + } + while (newValue.length <= 6) { + newValue.push(0) + } + return new Date(...newValue) +} + +baseComponent({ + properties: props, + data: { + inputValue: [], + options: [], + }, + observers: { + inputValue() { + this.updatedCols() + }, + value(value) { + this.setValue(value) + }, + ['mode, minuteStep, use12Hours, minDate, maxDate, minHour, maxHour, minMinute, maxMinute, lang']() { + this.setValue(this.data.inputValue) + }, + }, + methods: { + getDefaultMinDate() { + if (!this.defaultMinDate) { + this.defaultMinDate = new Date(2000, 1, 1, 0, 0, 0) + } + return this.defaultMinDate + }, + getDefaultMaxDate() { + if (!this.defaultMaxDate) { + this.defaultMaxDate = new Date(2030, 1, 1, 23, 59, 59) + } + return this.defaultMaxDate + }, + getMinDate() { + return this.data.minDate ? valueToDate(this.data.minDate, this.data) : this.getDefaultMinDate() + }, + getMaxDate() { + return this.data.maxDate ? valueToDate(this.data.maxDate, this.data) : this.getDefaultMaxDate() + }, + getDateMember(type = 'min', member = 'year') { + const methods = { + min: 'getMinDate', + max: 'getMaxDate', + year: 'getFullYear', + month: 'getMonth', + day: 'getDate', + hour: 'getHours', + minute: 'getMinutes', + } + return this[methods[type]]()[methods[member]]() + }, + getDisplayHour(rawHour) { + // 12 hour am (midnight 00:00) -> 12 hour pm (noon 12:00) -> 12 hour am (midnight 00:00) + if (this.data.use12Hours) { + if (rawHour === 0) { + rawHour = 12 + } + if (rawHour > 12) { + rawHour -= 12 + } + return rawHour + } + return rawHour + }, + setHours(date, hour) { + if (this.data.use12Hours) { + const dh = date.getHours() + let nhour = hour + nhour = dh >= 12 ? hour + 12 : hour + nhour = nhour >= 24 ? 0 : nhour // Make sure no more than one day + date.setHours(nhour) + } else { + date.setHours(hour) + } + }, + setAmPm(date, index) { + if (index === 0) { + date.setTime(+date - ONE_DAY / 2) + } else { + date.setTime(+date + ONE_DAY / 2) + } + }, + getNewDate(values, index) { + const value = parseInt(values[index], 10) + const { mode } = this.data + let newValue = cloneDate(this.getDate()) + if (mode === DATETIME || mode === DATE || mode === YEAR || mode === MONTH) { + switch (index) { + case 0: + newValue.setFullYear(value) + break + case 1: + setMonth(newValue, value) + break + case 2: + newValue.setDate(value) + break + case 3: + this.setHours(newValue, value) + break + case 4: + newValue.setMinutes(value) + break + case 5: + this.setAmPm(newValue, value) + break + default: + break + } + } else if (mode === TIME) { + switch (index) { + case 0: + this.setHours(newValue, value) + break + case 1: + newValue.setMinutes(value) + break + case 2: + this.setAmPm(newValue, value) + break + default: + break + } + } + return this.clipDate(newValue) + }, + clipDate(date) { + const { mode } = this.data + const minDate = this.getMinDate() + const maxDate = this.getMaxDate() + if (mode === DATETIME) { + if (date < minDate) { + return cloneDate(minDate) + } + if (date > maxDate) { + return cloneDate(maxDate) + } + } else if (mode === DATE || mode === YEAR || mode === MONTH) { + if (+date + ONE_DAY <= minDate) { + return cloneDate(minDate) + } + if (date >= +maxDate + ONE_DAY) { + return cloneDate(maxDate) + } + } else if (mode === TIME) { + const maxHour = maxDate.getHours() + const maxMinutes = maxDate.getMinutes() + const minHour = minDate.getHours() + const minMinutes = minDate.getMinutes() + const hour = date.getHours() + const minutes = date.getMinutes() + if (hour < minHour || hour === minHour && minutes < minMinutes) { + return cloneDate(minDate) + } + if (hour > maxHour || hour === maxHour && minutes > maxMinutes) { + return cloneDate(maxDate) + } + } + return date + }, + getDate(d) { + const date = d ? d : this.data.value + return this.clipDate(date ? valueToDate(date, this.data) : this.getMinDate()) + }, + getDateData(date) { + const { mode, lang } = this.data + const locale = locales[lang] + const selYear = date.getFullYear() + const selMonth = date.getMonth() + + const minDateYear = this.getDateMember('min', 'year') + const maxDateYear = this.getDateMember('max', 'year') + const minDateMonth = this.getDateMember('min', 'month') + const maxDateMonth = this.getDateMember('max', 'month') + const minDateDay = this.getDateMember('min', 'day') + const maxDateDay = this.getDateMember('max', 'day') + + const years = fomartArray(minDateYear, maxDateYear).map((i) => ({ + value: i + '', + label: i + locale.year + '', + })) + + if (mode === YEAR) { + return [years] + } + + const minMonth = minDateYear === selYear ? minDateMonth : 0 + const maxMonth = maxDateYear === selYear ? maxDateMonth : 11 + const months = fomartArray(minMonth, maxMonth).map((i) => ({ + value: i + '', + label: i + 1 + locale.month + '', + })) + + if (mode === MONTH) { + return [years, months] + } + + const minDay = minDateYear === selYear && minDateMonth === selMonth ? minDateDay : 1 + const maxDay = maxDateYear === selYear && maxDateMonth === selMonth ? maxDateDay : getDaysInMonth(date) + + const days = fomartArray(minDay, maxDay).map((i) => ({ + value: i + '', + label: i + locale.day + '', + })) + + return [years, months, days] + }, + getTimeData(date) { + let { minHour, maxHour, minMinute, maxMinute } = this.data + const { mode, minuteStep, use12Hours, lang } = this.data + const locale = locales[lang] + const minDateMinute = this.getDateMember('min', 'minute') + const maxDateMinute = this.getDateMember('max', 'minute') + const minDateHour = this.getDateMember('min', 'hour') + const maxDateHour = this.getDateMember('max', 'hour') + const hour = date.getHours() + + if (mode === DATETIME) { + const year = date.getFullYear() + const month = date.getMonth() + const day = date.getDate() + const minDateYear = this.getDateMember('min', 'year') + const maxDateYear = this.getDateMember('max', 'year') + const minDateMonth = this.getDateMember('min', 'month') + const maxDateMonth = this.getDateMember('max', 'month') + const minDateDay = this.getDateMember('min', 'day') + const maxDateDay = this.getDateMember('max', 'day') + if (minDateYear === year && minDateMonth === month && minDateDay === day) { + minHour = minDateHour + if (minDateHour === hour) { + minMinute = minDateMinute + } + } + if (maxDateYear === year && maxDateMonth === month && maxDateDay === day) { + maxHour = maxDateHour + if (maxDateHour === hour) { + maxMinute = maxDateMinute + } + } + } else { + minHour = minDateHour + if (minDateHour === hour) { + minMinute = minDateMinute + } + maxHour = maxDateHour + if (maxDateHour === hour) { + maxMinute = maxDateMinute + } + } + + let hours = [] + if (minHour === 0 && maxHour === 0 || minHour !== 0 && maxHour !== 0) { + minHour = this.getDisplayHour(minHour) + } else if (minHour === 0 && use12Hours) { + minHour = 1 + hours.push({ + value: '0', + label: locale.hour ? '12' + locale.hour : '12', + }) + } + maxHour = this.getDisplayHour(maxHour) + hours = [...hours, ...fomartArray(minHour, maxHour).map((i) => ({ + value: i + '', + label: locale.hour ? i + locale.hour + '' : pad(i), + }))] + + const minutes = [] + const selMinute = date.getMinutes() + for (let i = minMinute; i <= maxMinute; i += minuteStep) { + minutes.push({ + value: i + '', + label: locale.minute ? i + locale.minute + '' : pad(i), + }) + if (selMinute > i && selMinute < i + minuteStep) { + minutes.push({ + value: selMinute + '', + label: locale.minute ? selMinute + locale.minute + '' : pad(selMinute), + }) + } + } + + const ampm = [{ value: '0', label: locale.am }, { value: '1', label: locale.pm }] + + return [hours, minutes].concat(use12Hours ? [ampm] : []) + }, + getValueCols(d) { + const { mode, use12Hours } = this.data + const date = this.getDate(d) + let cols = [] + let value = [] + + if (mode === YEAR) { + return { + cols: this.getDateData(date), + value: [date.getFullYear() + ''], + } + } + + if (mode === MONTH) { + return { + cols: this.getDateData(date), + value: [date.getFullYear() + '', date.getMonth() + ''], + } + } + + if (mode === DATETIME || mode === DATE) { + cols = this.getDateData(date) + value = [date.getFullYear() + '', date.getMonth() + '', date.getDate() + ''] + } + + if (mode === DATETIME || mode === TIME) { + cols = cols.concat(this.getTimeData(date)) + const hour = date.getHours() + const selMinute = date.getMinutes() + let dtValue = [hour + '', selMinute + ''] + let nhour = hour + if (use12Hours) { + nhour = hour === 0 ? 12 : (hour > 12 ? hour - 12 : hour) + dtValue = [nhour + '', selMinute + '', (hour >= 12 ? 1 : 0) + ''] + } + value = value.concat(dtValue) + } + + return { + value, + cols, + } + }, + onValueChange(e) { + const { value, index } = e.detail + const newDate = this.getNewDate(value, index) + const { value: newValue, cols: newCols } = this.getValueCols(newDate) + const values = this.getValue(newValue, newCols) + this.triggerEvent('valueChange', { ...e.detail, ...values, date: +newDate }) + }, + updatedCols() { + const { cols } = this.getValueCols() + this.setData({ cols }) + }, + updated(inputValue) { + if (this.data.inputValue !== inputValue) { + this.setData({ + inputValue, + }) + } + }, + setValue(value = this.data.inputValue) { + const { value: inputValue } = this.getValueCols() + this.updated(inputValue) + }, + getValue(value = this.data.inputValue, cols = this.data.cols) { + this.picker = this.picker || this.selectComponent('#wux-picker') + return { + ...this.picker.getValue(value, cols), + date: +this.getDate(), + } + }, + }, + attached() { + this.setValue(this.data.value) + }, +}) + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/dist/date-picker-view/index.json b/components/dist/date-picker-view/index.json new file mode 100644 index 0000000..f0f8d8d --- /dev/null +++ b/components/dist/date-picker-view/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "wux-multi-picker-view": "../multi-picker-view/index" + } +} diff --git a/components/dist/date-picker-view/index.wxml b/components/dist/date-picker-view/index.wxml new file mode 100644 index 0000000..cd857a4 --- /dev/null +++ b/components/dist/date-picker-view/index.wxml @@ -0,0 +1,16 @@ + diff --git a/components/dist/date-picker-view/index.wxss b/components/dist/date-picker-view/index.wxss new file mode 100644 index 0000000..e69de29 diff --git a/components/dist/date-picker-view/locales/en.js b/components/dist/date-picker-view/locales/en.js new file mode 100644 index 0000000..3e22610 --- /dev/null +++ b/components/dist/date-picker-view/locales/en.js @@ -0,0 +1,9 @@ +export default { + year: '', + month: '', + day: '', + hour: '', + minute: '', + am: 'AM', + pm: 'PM', +} diff --git a/components/dist/date-picker-view/locales/index.js b/components/dist/date-picker-view/locales/index.js new file mode 100644 index 0000000..b1de86c --- /dev/null +++ b/components/dist/date-picker-view/locales/index.js @@ -0,0 +1,9 @@ +import en from './en' +import zh_CN from './zh_CN' +import zh_TW from './zh_TW' + +export default { + en, + zh_CN, + zh_TW, +} \ No newline at end of file diff --git a/components/dist/date-picker-view/locales/zh_CN.js b/components/dist/date-picker-view/locales/zh_CN.js new file mode 100644 index 0000000..8686d35 --- /dev/null +++ b/components/dist/date-picker-view/locales/zh_CN.js @@ -0,0 +1,9 @@ +export default { + year: '年', + month: '月', + day: '日', + hour: '时', + minute: '分', + am: '上午', + pm: '下午', +} diff --git a/components/dist/date-picker-view/locales/zh_TW.js b/components/dist/date-picker-view/locales/zh_TW.js new file mode 100644 index 0000000..d086fb1 --- /dev/null +++ b/components/dist/date-picker-view/locales/zh_TW.js @@ -0,0 +1,9 @@ +export default { + year: '年', + month: '月', + day: '日', + hour: '時', + minute: '分', + am: '上午', + pm: '下午', +} diff --git a/components/dist/date-picker-view/props.js b/components/dist/date-picker-view/props.js new file mode 100644 index 0000000..96afa09 --- /dev/null +++ b/components/dist/date-picker-view/props.js @@ -0,0 +1,86 @@ +export const props = { + prefixCls: { + type: String, + value: 'wux-date-picker', + }, + multiPickerPrefixCls: { + type: String, + value: 'wux-picker', + }, + pickerPrefixCls: { + type: String, + value: 'wux-picker-col', + }, + value: { + type: null, + value: null, + }, + itemHeight: { + type: Number, + value: 34, + }, + itemStyle: { + type: [String, Object, Array], + value: '', + }, + indicatorStyle: { + type: [String, Object, Array], + value: '', + }, + indicatorClass: { + type: String, + value: '', + }, + maskStyle: { + type: [String, Object, Array], + value: '', + }, + maskClass: { + type: String, + value: '', + }, + labelAlign: { + type: String, + value: 'center', + }, + mode: { + type: String, + value: 'datetime', + }, + minuteStep: { + type: Number, + value: 1, + }, + use12Hours: { + type: Boolean, + value: false, + }, + minDate: { + type: null, + value: null, + }, + maxDate: { + type: null, + value: null, + }, + minHour: { + type: Number, + value: 0, + }, + maxHour: { + type: Number, + value: 23, + }, + minMinute: { + type: Number, + value: 0, + }, + maxMinute: { + type: Number, + value: 59, + }, + lang: { + type: String, + value: 'zh_CN', + }, +} diff --git a/components/dist/date-picker/index.js b/components/dist/date-picker/index.js new file mode 100644 index 0000000..36a4f95 --- /dev/null +++ b/components/dist/date-picker/index.js @@ -0,0 +1,23 @@ +import baseComponent from '../helpers/baseComponent' +import popupMixin from '../helpers/popupMixin' +import { props } from '../date-picker-view/props' +import { formatDate } from './utils' + +const platformProps = { + labelPropName: 'label', + format(values, props) { + const o = { + datetime: 'yyyy-MM-dd hh:mm', + date: 'yyyy-MM-dd', + year: 'yyyy', + month: 'yyyy-MM', + time: 'hh:mm', + } + return formatDate(values.date, o[props.mode]) + }, +} + +baseComponent({ + behaviors: [popupMixin('#wux-picker', platformProps)], + properties: props, +}) diff --git a/components/dist/date-picker/index.json b/components/dist/date-picker/index.json new file mode 100644 index 0000000..238ad24 --- /dev/null +++ b/components/dist/date-picker/index.json @@ -0,0 +1,7 @@ +{ + "component": true, + "usingComponents": { + "wux-popup": "../popup/index", + "wux-date-picker-view": "../date-picker-view/index" + } +} diff --git a/components/dist/date-picker/index.wxml b/components/dist/date-picker/index.wxml new file mode 100644 index 0000000..ac3c35a --- /dev/null +++ b/components/dist/date-picker/index.wxml @@ -0,0 +1,45 @@ + + + + + {{ toolbar.cancelText }} + {{ toolbar.title }} + {{ toolbar.confirmText }} + + + + + + diff --git a/components/dist/date-picker/index.wxss b/components/dist/date-picker/index.wxss new file mode 100644 index 0000000..2405eeb --- /dev/null +++ b/components/dist/date-picker/index.wxss @@ -0,0 +1,57 @@ +.wux-date-picker__toolbar { + position: relative; + width: 100%; + font-size: 34rpx; + line-height: 1.5; + color: rgba(0,0,0,.85); + background-color: #f7f7f8 +} +.wux-date-picker__toolbar::before { + content: " "; + position: absolute; + left: 0; + top: 0; + right: 0; + height: 1PX; + border-top: 1PX solid #d9d9d9; + color: #d9d9d9; + transform-origin: 0 0; + transform: scaleY(.5) +} +.wux-date-picker__inner { + height: 88rpx; + display: -ms-flexbox; + display: flex; + text-align: center +} +.wux-date-picker__title { + position: absolute; + display: block; + width: 100%; + padding: 0; + font-size: 34rpx; + font-weight: 400; + line-height: 88rpx; + color: rgba(0,0,0,.85); + text-align: center; + white-space: nowrap +} +.wux-date-picker__button { + position: absolute; + box-sizing: border-box; + height: 88rpx; + line-height: 88rpx; + padding: 0 30rpx; + z-index: 10 +} +.wux-date-picker__button--cancel { + left: 0; + color: #b2b2b2 +} +.wux-date-picker__button--confirm { + right: 0; + color: #33cd5f +} +.wux-date-picker__button--hover { + background-color: #ececec +} \ No newline at end of file diff --git a/components/dist/date-picker/utils.js b/components/dist/date-picker/utils.js new file mode 100644 index 0000000..5fcb700 --- /dev/null +++ b/components/dist/date-picker/utils.js @@ -0,0 +1,23 @@ +export function formatDate(date, fmt) { + if (!(date instanceof Date)) { + date = new Date(date) + } + const o = { + 'M+': date.getMonth() + 1, + 'd+': date.getDate(), + 'h+': date.getHours(), + 'm+': date.getMinutes(), + 's+': date.getSeconds(), + 'q+': Math.floor((date.getMonth() + 3) / 3), + 'S': date.getMilliseconds(), + } + if (/(y+)/.test(fmt)) { + fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)) + } + for (const k in o) { + if (new RegExp(`(${k})`).test(fmt)) { + fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length))) + } + } + return fmt +} diff --git a/images/work/shareBg.png b/images/work/shareBg.png new file mode 100644 index 0000000..27a6c0e Binary files /dev/null and b/images/work/shareBg.png differ diff --git a/pages/work/work.js b/pages/work/work.js index 62e2574..6fd10a6 100644 --- a/pages/work/work.js +++ b/pages/work/work.js @@ -12,7 +12,8 @@ Page({ SearchRecordsList:[], communitySelfInspList:[], - communitySelfInspTop:{} + communitySelfInspTop:{}, + questionnaireUrl:'' }, /** @@ -114,10 +115,10 @@ Page({ * 用户点击右上角分享 */ onShareAppMessage() { - return { - title: '亿星社区', - path: '' - + return{ + title:`${this.data.communitySelfInspTop.agencyName}${this.data.communitySelfInspTop.monthName}月份满意度调查`, + path:'/pages/webView/webView?url=' + this.data.questionnaireUrl, + imageUrl:'../../images/work/shareBg.png' } }, onShareTimeline(){ @@ -152,9 +153,8 @@ Page({ return } wx.navigateTo({ - url: `/subpages/searchResult/pages/searchResult/searchResult?type=${this.data.setlectVal}`, + url: `/subpages/searchResult/pages/searchResult/searchResult?type=${this.data.setlectVal}&keyWord=${this.data.keyWord}`, }) - console.log(this.data.setlectVal); if(this.data.setlectVal == 'house'){ // 获取当前的搜索记录 let records = wx.getStorageSync('searchRecords') || []; @@ -203,7 +203,43 @@ Page({ url: '/subpages/communitySelfInsp/pages/synthesis/synthesis', }) }, - handelClickCopy() { + handelClickShare(e) { + // $wuxActionSheet().showSheet({ + // // titleText: '自定义操作', + // buttons: [ + // { + // text: '分享给朋友', + // openType:'share' + // }, + // { + // text: '分享给朋友圈', + // openType:'share' + + // }, + // ], + // buttonClicked(index, item) { + // index === 0 && + // wx.showShareMenu({ + // menus:['shareAppMessage'] + // }) + + + + // index === 1 && + // wx.showShareMenu({ + // menus:['shareTimeline'] + // }) + + // return true + // }, + // cancelText: '取消', + // cancel() {}, + // // destructiveText: '删除', + // destructiveButtonClicked() {}, + // }) + this.setData({ + questionnaireUrl:e.currentTarget.dataset.item.questionnaireUrl + }) wx.showShareImageMenu({ menus:['shareAppMessage', 'shareTimeline'] }) diff --git a/pages/work/work.wxml b/pages/work/work.wxml index 53517cf..13fa1d9 100644 --- a/pages/work/work.wxml +++ b/pages/work/work.wxml @@ -57,7 +57,7 @@ - + 满意度自查 @@ -66,9 +66,11 @@ - {{communitySelfInspTop.agencyName}}{{communitySelfInspTop.monthName}}月份满意度自查 + + {{communitySelfInspTop.agencyName}}{{communitySelfInspTop.monthName}}月份满意度自查 + 已提交 {{communitySelfInspTop.personQty?communitySelfInspTop.personQty:'--'}} - 查看统计 + 查看统计 diff --git a/project.private.config.json b/project.private.config.json index bbbc93a..ad7f2a0 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -8,6 +8,20 @@ "condition": { "miniprogram": { "list": [ + { + "name": "诉求摸排", + "pathName": "subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "查询结果", + "pathName": "subpages/searchResult/pages/searchResult/searchResult", + "query": "type=resi&keyWord=马", + "launchMode": "default", + "scene": null + }, { "name": "回访记录详情", "pathName": "subpages/communitySelfInsp/pages/followUpDetail/followUpDetail", @@ -64,13 +78,6 @@ "launchMode": "default", "scene": null }, - { - "name": "查询结果", - "pathName": "subpages/searchResult/pages/searchResult/searchResult", - "query": "type=resi&keyWord=小程序", - "launchMode": "default", - "scene": null - }, { "name": "新增居民", "pathName": "subpages/addResi/pages/addResi/addResi", diff --git a/subpages/addResi/pages/addResi/addResi.js b/subpages/addResi/pages/addResi/addResi.js index a58baa4..6882941 100644 --- a/subpages/addResi/pages/addResi/addResi.js +++ b/subpages/addResi/pages/addResi/addResi.js @@ -239,8 +239,11 @@ Page({ console.log(err); }) }, + // 获取婚姻信息 getFamilyInfoDetailById(){ api.getFamilyInfoDetailById(this.data.resiId).then(res=>{ + console.log(this.data.marriageList); + console.log(res); this.setData({ 'form.familyInfoDto':res.data, marriageName:this.data.marriageList.filter(item=>item.value ==res.data.marriage)[0].label @@ -386,8 +389,11 @@ Page({ if (this.data.isFirstLoadGrid) { // 编辑回填逻辑 const id = this.data.form.gridId; + console.log(id); + console.log(this.data.gridList); const temp = this.data.gridList.filter(item => item.value == id); - const gridName = '' + console.log(temp); + let gridName = '' if(temp.length != 0){ gridName = temp[0].label }else{ @@ -430,7 +436,14 @@ Page({ if (this.data.isFirstLoadVillage) { // 编辑回填逻辑 const id = this.data.form.villageId; - const villageName = this.data.villageList.filter(item => item.value == id)[0].label; + const temp = this.data.villageList.filter(item => item.value == id); + let villageName = '' + if(temp.length != 0){ + villageName = temp[0].label + }else{ + this.showToast('小区信息有误') + return + } this.setData({ villageName: villageName, "form.villageId": id @@ -439,6 +452,7 @@ Page({ this.setData({ isFirstLoadVillage: false }); + console.log(this.data.villageList,'小区'); } else { // 正常修改逻辑 const selectedIndex = e.detail.value; @@ -465,7 +479,14 @@ Page({ bindPickerChangebuilding(e){ if (this.data.isFirstLoadBuilding) { const id = this.data.form.buildId; - const buildingName = this.data.buildingList.filter(item => item.value == id)[0].label; + const temp = this.data.buildingList.filter(item => item.value == id); + let buildingName = '' + if(temp.length != 0){ + buildingName = temp[0].label + }else{ + this.showToast('小区信息有误') + return + } this.setData({ buildingName: buildingName, "form.buildId": id @@ -493,7 +514,14 @@ Page({ bindPickerChangeUnit(e){ if (this.data.isFirstLoadUnit) { const id = this.data.form.unitId; - const unitName = this.data.unitList.filter(item => item.value == id)[0].label; + const temp = this.data.unitList.filter(item => item.value == id); + let unitName = '' + if(temp.length != 0){ + unitName = temp[0].label + }else{ + this.showToast('楼栋信息有误') + return + } this.setData({ unitName: unitName, "form.unitId": id, @@ -518,7 +546,14 @@ Page({ bindPickerChangeHouse(e){ if (this.data.isFirstLoadHouse) { const id = this.data.form.homeId; - const houseName = this.data.houseList.filter(item => item.value == id)[0].label; + const temp = this.data.houseList.filter(item => item.value == id); + let houseName = '' + if(temp.length != 0){ + houseName = temp[0].label + }else{ + this.showToast('房屋信息有误') + return + } this.setData({ houseName: houseName, "form.homeId": id diff --git a/subpages/addhouse/pages/addhouse/addhouse.js b/subpages/addhouse/pages/addhouse/addhouse.js index 652cfa4..a98e041 100644 --- a/subpages/addhouse/pages/addhouse/addhouse.js +++ b/subpages/addhouse/pages/addhouse/addhouse.js @@ -127,6 +127,7 @@ Page({ }) await this.setDataAsync({ form:res.data, + 'form.sysCoding':res.data.ownerIdCard, gridId:res.data.gridId }); setTimeout(()=>{ diff --git a/subpages/communitySelfInsp/pages/historyQuery/historyQuery.js b/subpages/communitySelfInsp/pages/historyQuery/historyQuery.js index 9fd55d6..f109d92 100644 --- a/subpages/communitySelfInsp/pages/historyQuery/historyQuery.js +++ b/subpages/communitySelfInsp/pages/historyQuery/historyQuery.js @@ -78,13 +78,17 @@ Page({ */ onShareAppMessage() { return{ - title:'问卷调查', - path:'/pages/webView/webView?url=' + this.data.url + title:`${this.data.agencyName}${this.data.monthName}月份满意度调查`, + path:'/pages/webView/webView?url=' + this.data.questionnaireUrl, + imageUrl:'../../../../images/work/shareBg.png' } }, share(e){ + console.log(e); this.setData({ - url:e.currentTarget.dataset.url + url:e.currentTarget.dataset.item.questionnaireUrl, + agencyName:e.currentTarget.dataset.item.agencyName, + monthName:e.currentTarget.dataset.item.monthName }) }, getTable(){ diff --git a/subpages/communitySelfInsp/pages/historyQuery/historyQuery.wxml b/subpages/communitySelfInsp/pages/historyQuery/historyQuery.wxml index b838fe6..12b8da0 100644 --- a/subpages/communitySelfInsp/pages/historyQuery/historyQuery.wxml +++ b/subpages/communitySelfInsp/pages/historyQuery/historyQuery.wxml @@ -18,7 +18,7 @@ - + {{item.synthesisScore}}分 diff --git a/subpages/demandCheck/images/IC_guanbi@2x.png b/subpages/demandCheck/images/IC_guanbi@2x.png new file mode 100644 index 0000000..beaa347 Binary files /dev/null and b/subpages/demandCheck/images/IC_guanbi@2x.png differ diff --git a/subpages/demandCheck/images/del.png b/subpages/demandCheck/images/del.png new file mode 100644 index 0000000..6e5c4e3 Binary files /dev/null and b/subpages/demandCheck/images/del.png differ diff --git a/subpages/demandCheck/images/dianji.png b/subpages/demandCheck/images/dianji.png new file mode 100644 index 0000000..f9c8297 Binary files /dev/null and b/subpages/demandCheck/images/dianji.png differ diff --git a/subpages/demandCheck/images/ic_delete@2x.png b/subpages/demandCheck/images/ic_delete@2x.png new file mode 100644 index 0000000..d7c62f3 Binary files /dev/null and b/subpages/demandCheck/images/ic_delete@2x.png differ diff --git a/subpages/demandCheck/images/ic_yitidingwei@2x.png b/subpages/demandCheck/images/ic_yitidingwei@2x.png new file mode 100644 index 0000000..d4b80cd Binary files /dev/null and b/subpages/demandCheck/images/ic_yitidingwei@2x.png differ diff --git a/subpages/demandCheck/images/ic_yueduliang.png b/subpages/demandCheck/images/ic_yueduliang.png new file mode 100644 index 0000000..7d6f21f Binary files /dev/null and b/subpages/demandCheck/images/ic_yueduliang.png differ diff --git a/subpages/demandCheck/images/icon_close.png b/subpages/demandCheck/images/icon_close.png new file mode 100644 index 0000000..5e08d97 Binary files /dev/null and b/subpages/demandCheck/images/icon_close.png differ diff --git a/subpages/demandCheck/images/ig_tianjiatupian@2x.png b/subpages/demandCheck/images/ig_tianjiatupian@2x.png new file mode 100644 index 0000000..a01eeb0 Binary files /dev/null and b/subpages/demandCheck/images/ig_tianjiatupian@2x.png differ diff --git a/subpages/demandCheck/images/loading.gif b/subpages/demandCheck/images/loading.gif new file mode 100644 index 0000000..915c198 Binary files /dev/null and b/subpages/demandCheck/images/loading.gif differ diff --git a/subpages/demandCheck/images/mkf.png b/subpages/demandCheck/images/mkf.png new file mode 100644 index 0000000..74600d1 Binary files /dev/null and b/subpages/demandCheck/images/mkf.png differ diff --git a/subpages/demandCheck/images/right-sword.png b/subpages/demandCheck/images/right-sword.png new file mode 100644 index 0000000..4c6f0ce Binary files /dev/null and b/subpages/demandCheck/images/right-sword.png differ diff --git a/subpages/demandCheck/images/save.png b/subpages/demandCheck/images/save.png new file mode 100644 index 0000000..55ad2a3 Binary files /dev/null and b/subpages/demandCheck/images/save.png differ diff --git a/subpages/demandCheck/images/tupian.png b/subpages/demandCheck/images/tupian.png new file mode 100644 index 0000000..a0544fc Binary files /dev/null and b/subpages/demandCheck/images/tupian.png differ diff --git a/subpages/demandCheck/images/xiaobofang.png b/subpages/demandCheck/images/xiaobofang.png new file mode 100644 index 0000000..65fd3bf Binary files /dev/null and b/subpages/demandCheck/images/xiaobofang.png differ diff --git a/subpages/demandCheck/images/xiaozanting.png b/subpages/demandCheck/images/xiaozanting.png new file mode 100644 index 0000000..6813144 Binary files /dev/null and b/subpages/demandCheck/images/xiaozanting.png differ diff --git a/subpages/demandCheck/images/yuyin.png b/subpages/demandCheck/images/yuyin.png new file mode 100644 index 0000000..6a000c3 Binary files /dev/null and b/subpages/demandCheck/images/yuyin.png differ diff --git a/subpages/demandCheck/images/zanting.png b/subpages/demandCheck/images/zanting.png new file mode 100644 index 0000000..7b6ae0b Binary files /dev/null and b/subpages/demandCheck/images/zanting.png differ diff --git a/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.js b/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.js index f29956f..53a331f 100644 --- a/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.js +++ b/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.js @@ -1,67 +1,1012 @@ +var api = require('../../../../../utils/api') import { $wuxActionSheet } from '../../../../../components/dist/index' - +const QQMapWX = require('../../../../../utils/qqmap-wx-jssdk') +const config = require('../../../../../utils/config') +const app = getApp() +var recorderManager = wx.getRecorderManager(); +var timer; Page({ - /** - * 页面的初始数据 - */ - data: { - + /** + * 页面的初始数据 + */ + data: { + fmData: { + time:'', + grid:'' }, + minDate:'2018-01-01 00:00:00', + timeLabel:'', + + placeholderShow: true, + uploadImageList: [], + streetList: [], // 街道 + imageId: 1, + addressContent: '', + address: '', - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) { + overDuration: 600000, + duration: 0, + url: '', + hasStop: false, + hasStart: false, // 录音开始 暂停 + isStart: false, // 是否开启录音 + recordingTime: '00:00', + recordingLength: 0, + setInter: null, + + recorderData: {}, // 录音文件数据 + recorderTimeMax: "", // 00:00 + recorderTimeCur: "", // 00:00 + showRecord: false, // 是否显示录音sheet + isRecord: 0, // 是否开始录音 0-未开始 1-正在录音 2-录音完成 + recordingTime: 0, // 计时器 + isPlayAudio: false, // 上传的音频播放状态 + audioTimeline: 0, // 当前播放值 + uploadRecord: { + uploaded: true, + url: "" }, + recorderDuration: "", // 录音时长 + submitDisabled: false, - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() { + // 时间组件 + visibleTime: false, - }, + angencyList:[{ + agencyName:'测试', + agencyId:'cnmmmm', + subAgencyList:[ + { + agencyName:'测试1', + agencyId:'cnmmmm1', + subAgencyList:[ + { + agencyId:'cnmmmm2', + agencyName:'测试2', + subAgencyList:null + } + ] + } + ] + }], + defaultFieldNames:{label:'agencyName',value:'agencyId',children:'subAgencyList'}, + angencyVisible:false, + angencyValue:[], + }, - /** - * 生命周期函数--监听页面显示 - */ - onShow() { + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + this.data.qqMapWX = new QQMapWX({ + key: 'CMJBZ-4DECI-JXGGN-5B4WU-QLV2H-B5BEJ' + }) + this.getLocation().then(() => { + this.reverseLocation() + }) + this.setData({ + 'fmData.time':Date.now(), + }) + this.getAgencygridtree() + }, + // 组织树 + getAgencygridtree(){ + api.getAgencygridtree().then(res=>{ + this.setData({ + angencyList:[res.data] + }) + console.log(this.data.angencyList); + }).catch(err=>{ + console.log(err); + }) + }, - }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide() { + // 触底函数 + onReachBottom() { + if (this.projectlist) { + this.projectlist.onReachBottom() + } + }, - }, + toughGetLocation() { + this.getLocation(false); + wx.chooseLocation({ + success: res => { + console.log('resadddres', res) + const { fmData } = this.data; + this.setData({ + fmData: { + ...fmData, + addressContent: res.address, + longitude: res.longitude, + latitude: res.latitude + }, + }); + } + }) + }, + showRecordSheet () { + this.setData({ + showRecord: true, + recorderData: {}, + recorderTimeMax: "00:00", + recorderTimeCur: "00:00", + isRecord: 0, + recordingTime: 0, + uploadRecord: { + uploaded: true, + url: "" + } + }) +}, + // 获取经纬度 + getLocation() { + return new Promise((resolve, reject) => { + const _this = this + wx.getLocation({ + type: 'gcj02', + success(res) { + if (res.latitude && res.longitude) { + _this.setData({ + 'personalInfo.issueLatitude': res.latitude, + 'personalInfo.issueLongitude': res.longitude + }) + resolve(true) + } + }, + fail(err) { + reject(err) + } + }) + }) + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload() { + + // 提交按钮 + submitPersonalInfo() { + if (!this.data.addressContent) { + return this.showToast('请选择事件位置') + } + if (!this.data.personalInfo.streetId) { + return this.showToast('请选择所属街道') + } + if (!this.data.personalInfo.communityId) { + return this.showToast('请选择所属社区') + } + if (!this.data.personalInfo.gridId) { + return this.showToast('请选择所属网格') + } + if (!this.data.personalInfo.contactName) { + return this.showToast('请填写联系人姓名') + } - }, + if (!this.data.personalInfo.mobile) { + return this.showToast('请填写手机号') + } + if (!this.data.personalInfo.itemContent) { + return this.showToast('请填写问题描述') + } + if (this.data.personalInfo.itemContent.length < 11) { + return this.showToast('问题描述不少于 10 字') + } + // 如果我上报时候没有提交“详细地址”,电脑pc端的位置就是应该显示事件位置 + if (!this.data.personalInfo.issueAddress || this.data.personalInfo.issueAddress.length == 0) { + this.setData({ + 'personalInfo.issueAddress': this.data.addressContent + }) + } else { + this.setData({ + 'personalInfo.issueAddress': this.data.addressContent + this.data.personalInfo.issueAddress + }) + } + const imagesList = [] + if (this.data.uploadImageList.length > 0) { + const isUploadDown = this.data.uploadImageList.some(item => !item.uploaded) + if (isUploadDown) { + wx.showToast({ + title: '请等待图片上传完成', + icon: 'none', + duration: 1000 + }) + return false + } + } + if (this.data.uploadImageList.length > 0) { + this.data.uploadImageList.forEach(item => { + imagesList.push(item.ossUrl) + }) + } + this.setData({ + 'personalInfo.images': imagesList, + 'personalInfo.itemVoice': this.data.uploadRecord.url, + 'personalInfo.duration': this.data.recorderDuration + }) + if (this.data.isNewUser) { // 新用户 + this.setData({ + formSub: true + }) + this.getTokenV3() // 通过gridId 拿到userId + } else { // 老用户 + console.log('直接调接口') + this.submitItem() + // this.submitPersonalInfoByWx() + } + }, - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { + + + // 提交接口 + submitItem() { + wx.showLoading({ + title: '提交中...', + mask: true + }) + this.setData({ + submitDisabled: true + }) + const para = this.data.personalInfo + submitItem(para).then(res => { + wx.hideLoading() + if (res.data) { + wx.showModal({ + title: '提示', + content: `您的诉求我们已经查收,正在快马加鞭办理,请您耐心等待\r\n诉求编号为:${res.data}`, + confirmText: '确认', + showCancel: false, + success: res => { + this.setData({ + submitDisabled: false, + 'personalInfo.nickname': '', + 'personalInfo.itemContent': '', + 'personalInfo.itemVoice': '', + 'personalInfo.duration': '', + 'personalInfo.images': [], + 'personalInfo.contactName': '', + 'personalInfo.issueAddress': '', + uploadImageList: [], + recorderData: {}, + uploadRecord: { + uploaded: true, + url: "" + }, + }) + this.projectlist = this.selectComponent('#projectlist') + } + }) + } else { + wx.showToast({ + title: "提交失败,请重试~", + icon: "none", + duration: 1500 + }) + this.setData({ + submitDisabled: false + }) + } + }).catch(err => { + console.log(err) + wx.hideLoading() + this.setData({ + submitDisabled: false + }) + }) + }, + // 我是居民/我是党员/我是企业 tab切换 - }, + // 详细地址 + bindIssueAddressInput(e) { + this.setData({ + 'personalInfo.issueAddress': e.detail.value + }) + }, + bindContactNameInput(e) { + this.setData({ + 'personalInfo.contactName': e.detail.value + }) + }, + // 手机号 双向绑定 + bindMobileInput(e) { + this.setData({ + 'personalInfo.mobile': e.detail.value + }) + }, + // 双向绑定 地址输入框 + bindAddressInput(e) { + this.setData({ + addressContent: e.detail.value + }) + }, + // 解决ios占位符遮挡问题 + bindTextareaFocus() { + this.setData({ + placeholderShow: false, + }) + }, + // 解决ios占位符遮挡问题 + bindTextareaBlur(e) { + this.setData({ + 'personalInfo.itemContent': e.detail.value + }) + if (this.data.personalInfo.itemContent.length == 0) { + this.setData({ + placeholderShow: true + }) + } + }, + // 双向绑定 内容输入框 + bindTextareaInput(e) { + this.setData({ + 'personalInfo.itemContent': e.detail.value + }) + }, + + + + + // 点击空白,隐藏sheet + onHideSheet() { + this.setData({ + showRecord: false + }) + }, + + // + countRecordTimeline() { + clearInterval(this.data.setInter) + this.data.setInter = setInterval(() => { + this.setData({ + recordingTime: this.data.recordingTime + 1 + }, () => { + if (this.data.recordingTime < 10) { + this.setData({ + recorderTimeCur: "00:0" + this.data.recordingTime + }) + } else { + this.setData({ + recorderTimeCur: "00:" + this.data.recordingTime + }) + } + if (!this.data.showRecord) { + let max = Math.ceil(this.data.recorderData.duration / 1000) + let value = parseFloat(this.data.recordingTime / max).toFixed(2) + this.setData({ + audioTimeline: value * 100 + }) + } + }) + }, 1000) + }, + + sliderchange() { + let max = Math.ceil(this.data.recorderData.duration / 1000) + let value = parseFloat(this.data.recordingTime / max).toFixed(2) + this.setData({ + audioTimeline: value * 100 + }) + }, + + handleTimeChange(e) { + let { personalInfo } = this.data + const { dateTimeArray, dateTime } = e.detail + personalInfo.reportTime = `${dateTimeArray[0][dateTime[0]]}-${dateTimeArray[1][dateTime[1]]}-${dateTimeArray[2][dateTime[2]]} ${dateTimeArray[3][dateTime[3]]}:${dateTimeArray[4][dateTime[4]]}:${dateTimeArray[5][dateTime[5]]}` + console.log('change', e.detail) + this.setData({ + personalInfo + }) + }, + + // 录音end + // 选择图片 上传弹窗 - 上传图片方式 - 选择图片 - 上传图片 - 回调赋值 + chooseImage() { + if (this.data.uploadImageList.length > 9) { + wx.showToast({ + title: "最多上传10张照片", + icon: "none" + }) + return + } + const _this = this + $wuxActionSheet().showSheet({ + buttons: [ + { text: '拍照' }, + { text: '从相册中获取' }, + ], + className: 'dialog-class', + buttonClicked(index) { + if (index === 0) { + wx.chooseImage({ + count: 1, + sizeType: ['original', 'compressed'], + sourceType: ['camera'], + success(res) { + let deleteLength = _this.data.uploadImageList.length + const uploadImageList = [..._this.data.uploadImageList] + if (res.tempFiles[0].size <= 5 * 1024 * 1024) { + uploadImageList.push({ + uploaded: false, + ossUrl: '', + imgUrl: res.tempFiles[0].path, + imageId: ++_this.data.imageId + }) + } else { + _this.showToast('图片上限5M,请压缩后重试~') + return false + } + _this.setData({ + uploadImageList + }) + wx.uploadFile({ + url: `${config.BASEURL()}oss/file/uploadvariedfile`, + filePath: res.tempFilePaths[0], + name: 'file', + header: { + 'Content-type': 'application/json;charset=UTF-8', + 'Authorization': wx.getStorageSync('token') + }, + success(fileRes) { + if (!JSON.parse(fileRes.data).data) { + _this.showToast('图片上传失败,请重试~') + // 删除 + const index = _this.data.uploadImageList.findIndex(item => item.imageId === _this.data.imageId) + if (index > -1) { + _this.data.uploadImageList.splice(index, 1) + _this.setData({ + uploadImageList: _this.data.uploadImageList + }) + } + } else { + uploadImageList[uploadImageList.length - 1].uploaded = true + uploadImageList[uploadImageList.length - 1].ossUrl = JSON.parse(fileRes.data).data + _this.setData({ + uploadImageList + }) + } + + }, + fail(fileRes) { + _this.setData({ + uploadImageList: [] + }) + _this.showToast('图片上传失败,请重试~') + } + }) + } + }) + } else if (index === 1) { + wx.chooseImage({ + count: 1, + sizeType: ['original', 'compressed'], + sourceType: ['album'], + success(res) { + let deleteLength = _this.data.uploadImageList.length + const uploadImageList = [] + const endIndex = _this.data.uploadImageList.length + res.tempFiles.forEach(item => { + if (item.size <= 5 * 1024 * 1024) { + uploadImageList.push({ + uploaded: false, + ossUrl: '', + imgUrl: item.path, + imageId: ++_this.data.imageId + }) + } else { + _this.showToast('图片上限5M,请压缩后重试~') + } + }) + _this.setData({ + uploadImageList: [..._this.data.uploadImageList, ...uploadImageList] + }) + uploadImageList.forEach((item, index) => { + return (function (index) { + wx.uploadFile({ + url: `${config.BASEURL()}oss/file/uploadvariedfile`, + filePath: res.tempFilePaths[index], + name: 'file', + header: { + 'Content-type': 'application/json;charset=UTF-8', + 'Authorization': wx.getStorageSync('token') + }, + success(fileRes) { + if (!JSON.parse(fileRes.data).data) { + _this.showToast('图片上传失败,请重试~') + _this.data.uploadImageList.splice(deleteLength, _this.data.uploadImageList.length - deleteLength) + _this.setData({ + uploadImageList: _this.data.uploadImageList + }) + } else { + uploadImageList[index].uploaded = true + uploadImageList[index].ossUrl = JSON.parse(fileRes.data).data + _this.data.uploadImageList = _this.data.uploadImageList.slice(0, endIndex) + _this.setData({ + uploadImageList: [..._this.data.uploadImageList, ...uploadImageList] + }) + } + console.log(_this.data.uploadImageList.length, '图片上传长度'); + }, + fail(fileRes) { + _this.setData({ + uploadImageList: [] + }) + _this.showToast('图片上传失败,请重试~') + } + }) + })(index) + }) + } + }) + } + return true + }, + cancelText: '取消', + cancel() { }, + destructiveButtonClicked() { }, + }) + }, + // 删除选中的图片 + deleteImage(e) { + const index = this.data.uploadImageList.findIndex(item => item.imageId === e.currentTarget.dataset.imageid) + if (index > -1) { + this.data.uploadImageList.splice(index, 1) + this.setData({ + uploadImageList: this.data.uploadImageList + }) + } + }, + // 代码简化,弹窗统一封装 + showToast(title) { + wx.showToast({ + title: title, + icon: 'none', + duration: 2000 + }) + }, - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { + // 街道社区 + getDeptTree() { + getDeptTree().then(res => { + this.setData({ + streetList: res.data[0].children + }) + if (this.data.personalInfo.streetId && this.data.personalInfo.communityId) { + this.data.streetList.forEach(element => { + if (element.value == this.data.personalInfo.streetId) { + this.setData({ + 'personalInfo.street': element.label, + communityList: element.children // 社区 + }) + // 循环社区 + element.children.forEach(community => { + if (community.value == this.data.personalInfo.communityId) { + this.setData({ + 'personalInfo.community': community.label, + gridList: community.children + // 'personalInfo.grid': community.children[0].label, // 网格默认选择第一个 + // 'personalInfo.gridId': community.children[0].value // 网格 + }) + } + }); + } + }); + } + }).catch(err => { + console.log(err) + }) + }, + // 单选点击事件 + inputSyncPicker(e) { + let { + detail: { value }, + currentTarget: { + dataset: { idKey, nameKey, listName, subname, subindex }, + }, + } = e; + let item = this.data[listName][value]; + let { personalInfo } = this.data; + if (subname && subindex !== undefined) { + personalInfo[subname][subindex][idKey] = item.value; + personalInfo[subname][subindex][nameKey] = item.label; + } else { + personalInfo[idKey] = item.value; + personalInfo[nameKey] = item.label; + } + + this.setData({ personalInfo }); + + this.dataHandle(listName) + + }, + dataHandle(listName) { + if (listName == 'streetList') { + this.setData({ + communityList: [], + gridList: [], + 'personalInfo.community': '', // 社区 + 'personalInfo.communityId': '', // 社区 + 'personalInfo.grid': '', // 网格 + 'personalInfo.gridId': '' // 网格 + }) + } else if (listName == 'communityList') { + this.setData({ + gridList: [], + 'personalInfo.grid': '', // 网格 + 'personalInfo.gridId': '' // 网格 + }) + } + if (this.data.personalInfo.streetId) { // 选择街道 + this.data.streetList.forEach((element, index) => { + if (this.data.personalInfo.streetId == element.value) { + this.setData({ + communityList: element.children + }) + } + }); + } + if (this.data.personalInfo.communityId) { // 选择社区 + this.data.communityList.forEach((element, index) => { + if (this.data.personalInfo.communityId == element.value) { + this.setData({ + gridList: element.children + // 'personalInfo.grid': element.children[0].label, // 网格默认选择第一个 + // 'personalInfo.gridId': element.children[0].value // 网格 + }) + } + }); + } + }, + // 逆地址解析 + reverseLocation() { + const _this = this + this.data.qqMapWX.reverseGeocoder({ + location: { + latitude: _this.data.personalInfo.issueLatitude, + longitude: _this.data.personalInfo.issueLongitude + }, + success(res) { + _this.setData({ + fmData: { + addressContent: res.result.address, + address: res.result.address, + }, + }) + }, + fail(err) { + console.debug(err) + } + }) + }, + + onConfirmDate(e) { + console.log(e); + this.setData({ + 'fmData.time': e.detail.label, + timeLabel: e.detail.displayValue.join(' '), + visibleTime:false + }) + console.log(this.data.fmData.time) + }, + // onVisibleChange(e) { + // this.setData({ + // // timeLabel: e.detail.displayValue.join(' '), + // }) + // }, + onCancel(){ + this.setData({ + visibleTime:false + }) + }, + showTimePicker(){ + this.setData({ + visibleTime:true + }) + }, + onPageScroll: function (e) { + if (this.projectlist) { + this.projectlist.onPageScroll(e) + } + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + + /** + * 用户点击右上角分享 + */ + // /page/user?id=123 + onShareAppMessage() { + return { + path: 'pages/peopleLivelihood/peopleLivelihood', + } + }, + handleRecordDel() { + const { hasStop, isStart } = this.data + console.log('hasStop---', this.data.hasStop) + if (isStart && !hasStop) { + recorderManager.stop() + } + // if (!hasStop && hasStart) recorderManager.stop(); + // recorderManager.stop(); + clearInterval(timer) + timer = null + this.setData({ + recordingTime: '00:00', + recordingLength: 0, + hasStart: false, + isStart: false, + hasStop: false, + url: '', + duration: 0 + }) + }, + handleRecord() { + let { hasStart } = this.data + console.log(hasStart); + if (hasStart) this.recortPause() + else this.recortResume() + }, + handleOpenRecord() { + this.setData({ + isStart: true, + }); + console.log('opppppp') + this.recordStart() + }, + // 录音暂停 + recortPause() { + recorderManager.pause(); + this.setData({ + hasStart: false + }) + clearInterval(timer) + timer = null + }, + // 录音继续 + recortResume() { + this.recordingTimer() + recorderManager.resume(); + this.setData({ + hasStart: true + }) + + }, + + uploadRecord(file, duration) { + console.log(file,duration); + wx.uploadFile({ + url: `${config.BASEURL()}oss/file/uploadvoice`, + filePath: file, + name: "file", + header: { + "Content-type": "multipart/form-data", + 'Authorization': wx.getStorageSync('token') + }, + success: (fileRes) => { + wx.hideLoading() + console.log('ressss', fileRes) + if (!JSON.parse(fileRes.data).data) { + wx.showToast({ + title: "录音上传失败,请重试~", + icon: "none", + duration: 1500 + }) + this.setData({ + "uploadRecord.uploaded": true, + "uploadRecord.url": "", + recorderDuration: "", + recorderData: {} + }) + } else { + this.setData({ + "uploadRecord.uploaded": true, + "uploadRecord.url": JSON.parse(fileRes.data).data + }) + console.log(this.data.uploadRecord); + } }, + fail: (fileRes) => { + console.log(fileRes); + wx.showToast({ + title: "录音上传失败,请重试~", + icon: "none", + duration: 1500 + }) + this.setData({ + "uploadRecord.uploaded": true, + "uploadRecord.url": "", + recorderDuration: "", + recorderData: {} + }) + } + }) + }, + // 录音开始 + recordStart() { + this.setData({ + hasStart: true, + }); + const options = { + duration: this.data.overDuration, + format: 'mp3', + type: 'voice' + }; + this.recordingTimer() + recorderManager.start(options); + recorderManager.onStart(res => { + console.log('recorder start', res); + }); + recorderManager.onPause(res => { + console.log('onPause', res) + }) + console.log(recorderManager); + recorderManager.onResume(res => { + console.log('onResume', res) + }) + recorderManager.onStop((res) => { + console.log('recorder stop', res); + const { tempFilePath, duration } = res; + this.setData({ + hasStop: true, + url: tempFilePath, + duration + }) + // + }); + recorderManager.onFrameRecorded(res => { + console.log('onFrameRecorded', res) + }) + recorderManager.onError((res) => { + console.log('recorder onError', res); + wx.showToast({ + title: res.errMsg, + icon: 'none', + duration: 1500 + }) + }); + }, + // 录音暂停 + recortPause() { + recorderManager.pause(); + this.setData({ + hasStart: false + }) + clearInterval(timer) + timer = null + }, + // 录音继续 + recortResume() { + this.recordingTimer() + recorderManager.resume(); + this.setData({ + hasStart: true + }) - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { + }, + // 录音结束 + recordStop() { + const { url, duration, hasStop } = this.data + this.setData({ + hasStart: false + }) + wx.showLoading({ + title: '录音上传中...' + }) + console.log(url, duration, hasStop) + + if (hasStop) { + this.uploadRecord(url, 600000) + console.log('hasStop', hasStop) + } else { + console.log('hasStopeee', hasStop) + recorderManager.stop(); + clearInterval(timer) + timer = null + recorderManager.onStop((res) => { + console.log('recorder stop1111', res); + const { tempFilePath, duration } = res; + this.uploadRecord(tempFilePath, duration) + // + }); } + + }, + + recordingTimer() { + clearInterval(timer) + timer = null + timer = setInterval(() => { + let { overDuration, recordingLength } = this.data + if (recordingLength * 1000 >= overDuration) { + wx.showToast({ + title: '录音已超时,已停止录音', + icon: 'none', + duration: 1500 + }) + console.log('lllllllll超时了') + recorderManager.stop(); + clearInterval(timer) + timer = null + this.setData({ + hasStart: false + }) + return + } + let time = this.data.recordingLength + 1; + this.setData({ + recordingLength: time, + recordingTime: this.formatTime(time) + }); + console.log('timer,还在执行') + }, 1000); + }, + formatTime(num) { + let min = parseInt(num / 60) + let second = num % 60 + min = min >= 10 ? min : '0' + min + second = second >= 10 ? second : '0' + second + return min + ':' + second + }, + hancleCancle() { + this.handleRecordDel() + this.setData({ + showRecord:false + }) + }, + hidePicker(){ + this.setData({ + angencyVisible:false + }) + }, + showPicker(){ + this.setData({ + angencyVisible:true + }) + }, + onConfirmAngecy(e){ + console.log(e); + this.setData({ + agencyName:e.detail.label, + 'form.grid':e.detail.value[e.detail.value.length - 1], + angencyVisible:false + }) + console.log(this.form); + }, + onValueChange(e){ + console.log(e); + } }) \ No newline at end of file diff --git a/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.json b/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.json index 3928faa..417343b 100644 --- a/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.json +++ b/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.json @@ -1,3 +1,11 @@ { - "usingComponents": {} + "usingComponents": { + "wux-actionsheet": "../../../../../components/dist/actionsheet/index", + "wux-segmented-control": "../../../../../components/dist/segmented-control/index", + "wux-date-picker": "../../../../../components/dist/date-picker/index", + "wux-cell-group": "../../../../../components/dist/cell-group/index", + "wux-picker": "../../../../../components/dist/picker/index" + + }, + "navigationBarTitleText": "诉求摸排" } \ No newline at end of file diff --git a/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.wxml b/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.wxml index 5456114..e2c619c 100644 --- a/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.wxml +++ b/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.wxml @@ -1,43 +1,18 @@ - + + + + * - 事件位置 - - - {{addressContent}} - - - - - - - - 详细地址 - - - - - + 所属组织 - - - - - * - 所属街道 - - - + - - - * - 所属社区 - - - - {{personalInfo.community}} - 请选择 - - - - - - - - * - 所属网格 - - - - {{personalInfo.grid}} - 请选择 - - + + --> + {{agencyName?agencyName:'请选择'}} * - 是否公开 + 诉求类型 - 不公开 - 公开 + 事件上报 + 居民需求 - - - - * - 联系人姓名 - - - - - - - - - - * - 手机号 - - - - - - - - - - * - 手机号 - - - - - - - - - - * - 验证码 - - - - - - + - {{getMobileType === 'wx' ? '*如若获取手机号异常,请点击切换至手机号/验证码注册方式' : '*点击可切回至从微信获取手机号注册方式'}} @@ -169,15 +47,20 @@ * - 问题描述 + 事件描述 - - + + 您也可以语音输入描述 + + + + + + 上传图片 + - - + + - + - - - - - - - - - - - - - - - - {{recorderTimeCur}} - {{recorderTimeMax}} - - - - - + + + + + + + + + + + 取消 - - - - - - + + + + + + + + + + + + + - + - - - + + - \ No newline at end of file + + + 点击发布语音内容 + 限10分钟内 + + + + + + + + \ No newline at end of file diff --git a/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.wxss b/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.wxss index d0fe8c8..f38dc28 100644 --- a/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.wxss +++ b/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.wxss @@ -1,158 +1,939 @@ -/* subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck.wxss */ +page { + width: 100%; + height: auto; + overflow-y: auto; + background: #f7f7f7; + padding-bottom: 20rpx; + box-sizing: border-box; +} +.complete-info { + width: 100%; + height: 100%; + background: #f7f7f7; +} + + + + .content { - width: 100%; - min-height: calc(100vh - 100rpx); - margin-top: 100rpx; - } + width: 100%; + min-height: calc(100vh - 100rpx); +} + +.content-list { + width: 100%; + min-height: calc(100vh - 100rpx); + margin-top: 100rpx; + padding: 20rpx 20rpx 0rpx 20rpx; + box-sizing: border-box; +} + +/* 内容 */ + +.personal-info { + width: 100%; + height: 100%; + box-sizing: border-box; + padding: 0 20rpx; + overflow: hidden; +} + +.basic-info { + width: 100%; + background: #fff; + border-radius: 16rpx; + box-sizing: border-box; + padding: 0 20rpx; + margin-top: 20rpx; +} + +.border-bottom { + border-bottom: 1rpx solid #eaeaea; +} +.no-border-bottom{ + border-bottom: 1rpx solid #fff !important; +} +.note { + font-size: 22rpx; + color: #999; + line-height: 62rpx; +} + + +.add-issue { + width: 100%; + height: 100%; + background: #f7f7f7; + box-sizing: border-box; + padding: 0rpx 20rpx 0; +} + +.add-issue .issue-content { + width: 100%; + height: auto; + border-radius: 16rpx; + background: #fff; + box-sizing: border-box; + padding: 0rpx 20rpx 45rpx; +} +.add-issue .issue-content textarea { + margin-top: 15rpx; + width: 100%; + height: 298rpx; + background-color: #f7f7f7; + padding:30rpx; + font-size: 34rpx; + color: #333; + line-height: 50rpx; + position: relative; +} +.add-issue .issue-content textarea .textarea-placeholder { + font-size: 32rpx; + color: #999; + line-height: 50rpx; + position: absolute; + left: 0; + top: 0; +} +/* ???????? */ + + .image-list { + width: 100%; + display: grid; + grid-template-columns: 214rpx 214rpx 214rpx; + grid-template-rows: 214rpx; + grid-gap: 17rpx; + height: 214rpx; + margin-top:80rpx ; +} +.image-list-2 { + height: 428rpx !important; +} +.image-list-3 { + height: 642rpx !important; +} +.image-list-4 { + height: 856rpx !important; +} + .image-list .image-item { + width: 100%; + height: 100%; + position: relative; +} + .image-list image { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 8rpx; +} + .image-list .image-item .loading { + position: absolute; + left: 25%; + top: 25%; + width: 50%; + height: 50%; +} + .image-list .image-item .close { + position: absolute; + top: -10rpx; + right: -10rpx; + width: 40rpx; + height: 40rpx; +} +.add-issue .image-box { + width: 100%; + height: auto; + border-radius: 16rpx; + background: #fff; + margin-top: 20rpx; + box-sizing: border-box; + padding: 34rpx 24rpx; + position: relative; + /* display: flex; + align-items: center; */ +} +.image-box .image-list-label { + position: absolute; + top: 35rpx; +} +.yg-zp{ + font-size: 32rpx; + font-family: Source Han Serif SC; + font-weight: 400; + color: #333; +} +.yg-zp-1{ + margin-top: 15rpx; + font-size: 25rpx; + font-family: Source Han Serif SC; + font-weight: 400; + color: #999; +} +.add-issue .image-box .add-icon { + /* margin-top: 40rpx; */ + width: 80rpx; + height: 80rpx; + margin-right: 40rpx; +} +.sheet-bg { + width: 100%; + height: 100%; + position: fixed; + top: 0; + left: 0; + z-index: 999; + background-color: rgba(0, 0, 0, 0.6); +} + +/* record start */ +.record-actionsheet { + height: 472rpx; + width: 100%; + background-color: #ffffff; + border-radius: 30rpx 30rpx 0 0; + position: fixed; + z-index: 999; + bottom: 0; + transition: all .2s linear; +} +.record-actionsheet-hide { + bottom: -480rpx; + transition: all .2s linear; +} +.record-actionsheet .top-menu { + display: flex; + align-items: center; + justify-content: space-between; + height: 80rpx; +} +.record-actionsheet .top-menu .button { + width: 120rpx; + height: 80rpx; + line-height: 80rpx; + text-align: center; +} +.record-actionsheet .top-menu .cancel { + color: #5b5b5b; +} +.record-actionsheet .top-menu .confirm { + color: #f61717; +} +.record-actionsheet .close-icon { + width: 80rpx; + height: 80rpx; + display: flex; + align-items: center; + justify-content: center; +} +.record-actionsheet .close-icon image { + width: 30rpx; + height: 30rpx; +} +.record-actionsheet .text-status { + color: #5b5b5b; + text-align: center; +} +.record-actionsheet .status-icon { + width: 100%; + height: 210rpx; + text-align: center; + margin-top: 50rpx; +} +.record-actionsheet .status-icon .icon { + width: 210rpx; + height: 210rpx; +} +.record-actionsheet .text-tip { + font-size: 26rpx; + color: #9e9e9e; + text-align: center; +} +/* record end */ + +/* audio start */ +.audio { + width: 670rpx; + height: 116rpx; + background-color: #f3f3f3; + border-radius: 10r; + display: flex; + position: relative; + margin-top: 40rpx; +} +.audio .control-button { + width: 100rpx; + height: 100%; + display: flex; + align-items: center; + justify-content: center; +} +.audio .control-button image { + width: 60rpx; + height: 60rpx; +} +.audio .control-line { + display: flex; + flex-direction: column; + justify-content: center; +} +.audio .control-line .control-slider { + width: 500rpx; + margin: 10rpx 36rpx; +} +.audio .control-line .line-time { + margin: 0 10px; + display: flex; + align-items: center; + justify-content: space-between; +} +.audio .control-line .line-time .time-text { + color: #aaaaaa; + font-size: 24rpx; +} +.audio .delete-audio { + position: absolute; + right: -20rpx; + top: -20rpx; +} +.audio .delete-audio image { + width: 60rpx; + height: 60rpx; +} +/* audio end */ + +.add-issue .issue-location { + width: 100%; + height: 210rpx; + border-radius: 16rpx; + background: #fff; + margin-top: 20rpx; + box-sizing: border-box; + padding: 34rpx 18rpx 9rpx 25rpx; +} +.add-issue .issue-location { + width: 100%; + height: 210rpx; + border-radius: 16rpx; + background: #fff; + margin-top: 20rpx; + box-sizing: border-box; + padding: 34rpx 18rpx 9rpx 25rpx; +} +.add-issue .issue-location .address { + width:70%; + height: 80rpx; + display: flex; + align-items: center; +} +.add-issue .issue-location textarea { + width:100%; + height: 88rpx; + color: #333; + font-size: 34rpx; + line-height: 46rpx; +} +.add-issue .issue-location .address-placeholder { + font-size: 32rpx; + color: #999; +} +.add-issue .issue-location .address image { + width: 26rpx; + height:26rpx; +} +.add-issue .issue-location .address view { + color: #999; + font-size: 26rpx; + margin-left: 14rpx; +} + +/* 重新定位 */ +.flexBox{ + display: flex; + width: 100%; + box-sizing: border-box; +} +.refresh{ + margin-top: 20rpx; + margin-left: 30rpx; +} +.refresh image { + width: 34rpx; + height: 34rpx; + float: left; + position: relative; + top: 5rpx; +} + +.refresh-name { + font-size: 28rpx; + font-weight: 500; + color: rgba(0, 179, 152, 1); + float: left; + margin-left: 10rpx; +} + +.tip{ + margin-top: 20rpx; + font-size: 22rpx; + font-weight: 400; + color: #BCBCBC; +} + +.wux-actionsheet__button { + font-size: 34rpx !important; + color: #333 !important; +} + + +/* picker */ +.item { + border-bottom: 1rpx solid #e7eeee; + padding: 25rpx 0; + line-height: 60rpx; + display: flex; + justify-content: space-between; +} +.item .field { +position: relative; +box-sizing: border-box; +width: 300rpx; +padding-left: 25rpx; +} + +.field-d { + width: 220rpx !important; +} +.value-d{ + width: 450rpx !important; +} +.item .field.mobile-field { +width: 250rpx !important; +} +.item .field .must { +position: absolute; +top: 0; +left: 0; +margin: 0 auto; +color: #F61616; +font-size: 30rpx; +} + +.item .field .field-text { +font-size: 32rpx; +font-family: Source Han Serif SC; +font-weight: 400; +color: #333; +} + +.item .value { + position: relative; + width: 410rpx; + display: flex; + font-size: 32rpx; + font-family: Source Han Serif SC; + font-weight: 400; + color: #333; + line-height: 60rpx; +} + +.item .value-dl { + position: relative; + width: 410rpx; + display: flex; + font-size: 32rpx; + font-family: Source Han Serif SC; + font-weight: 400; + color: #333; + line-height: 60rpx; + align-items: center; +} + +.di-name{ + margin-right: 14rpx; + text-align: right; + width: calc(100% - 30rpx); +} + +.di-but{ + width: 30rpx; + height: 34rpx; +} + +.item .value input { +text-align: right; +font-size: 34rpx; +color: #333; +height: 100%; +width: 100%; +} +.item .value .picker { +position: relative; +width: 100%; +padding-right: 40rpx; +text-align: right; +} + +.item .value .picker .z-weak { +color: #999; +} + +.item .value .picker .menu-arrow { +position: absolute; +top: 20rpx; +right: 0; +width: 16rpx; +height: 23rpx; +} +.item .value-mobile { +position: relative; +width: 410rpx; +display: flex; +font-size: 32rpx; +font-family: Source Han Serif SC; +font-weight: 400; +color: #333; +line-height: 60rpx; +display: flex; +justify-content: flex-end; +} +.item .value-mobile .get-code { +padding: 0 15rpx; +height: 60rpx; +line-height: 60rpx; +background: linear-gradient(to right, #F40C0C, #FF4E4E); +color: #fff; +font-size: 24rpx; +border-radius: 6rpx; +margin: 0; +margin-left: 25rpx; +} +.item .value-mobile .button-hover { +background: rgb(175, 1, 1); +} +.item .value-mobile input { +text-align: right; +font-size: 34rpx; +color: #333; +height: 100%; +width: 55%; +} +.placeholder-style { +font-size: 28rpx; +color: #999; +} + +.is-open{ +margin-top: 20rpx; +padding: 0 20rpx; +box-sizing: border-box; +height: 30rpx; +font-size: 30rpx; +font-weight: 400; +color: #333333; +line-height: 30rpx; +} + +.submit-button { +width: 100%; +height: 84rpx; +display: flex; +align-items: center; +justify-content: center; +margin: 80rpx 0 65rpx; +} +.submit-button button { +height: 84rpx; +line-height: 84rpx; +width: 560rpx; +padding: 0; +text-align: center; +color: #fff; +font-size: 33rpx; +border-radius: 84rpx; +background: linear-gradient(to right, #82b4fd, #3e93fe); +} +/* .submit-button .hover-submit { +background: rgb(175, 1, 1); +} */ + +.radio-group { + height: 100%; + display: flex; + align-items: center; + color: #999; + font-size: 28rpx; +} +.radio-group radio + radio { + margin-left: 20rpx; +} + + +.tip_bg{ + position: absolute; + overflow: hidden; + top: 0; + z-index: 9999; + width: 100%; + height: auto; + padding-bottom: 40rpx; + box-sizing: border-box; + /* background: rgba(0, 0, 0, 0.6); */ + background: #f7f7f7; + /* display: flex; + justify-content: center; */ +} +/* 新样式 */ +.tip-top{ + height: 433rpx; + width: 100%; +} +.tip-top image { + height: 433rpx; + width: 100%; +} + +.info-1 { + width: 100%; + /* margin-left: 20rpx; */ + height: auto; + z-index: 9999; + position: relative; + margin-top: -20rpx; + /* background: red; */ +} + +.info-2 { + height: auto; + width: calc(100% - 40rpx); + margin-left: 20rpx; + background: #FFFFFF; + border-radius: 10rpx; + margin-top: 20rpx; + padding: 40rpx; + box-sizing: border-box; +} + +.info-2 .info-2-title { + width: 100%; + height: 54rpx; +} +.info-2 .info-2-title.top{ + margin-top: 54rpx; +} +.info-2 .info-2-name{ + font-size: 33rpx; + font-weight: 800; + color: #FEFEFE; + line-height: 54rpx; + position: absolute; + margin-left: 24rpx; +} + +.info-2 .info-2-title .tou{ + width: 380rpx; + height: 54rpx; +} + +.info-2 .info-2-info{ + margin-top: 38rpx; + width: 100%; + height: auto; + font-size: 28rpx; + font-weight: 500; + color: #333333; + line-height: 50rpx; +} +.list{ + display: flex; +} +.list-name{ + width: 40rpx +} +.list-cont{ + width: calc(100% - 40rpx); +} +.end{ + /* position: absolute; */ + margin-top: 40rpx; + width: 100%; + height: 80rpx; + bottom: 20rpx; + display: flex; + align-items: center; + justify-content: center; +} +.end .end-but { + text-align: center; + border-radius: 50rpx; + width: 350rpx; + height: 80rpx; + line-height: 80rpx; + font-size: 30rpx; + color: #fff; +} + + +.end .bg1 { + background: #ffb2b5; +} +.end .bg2 { + + background: linear-gradient(to right, #f40f0f, #ff4c4c); +} + +.info-1 image{ + top: 0; + width: 100%; + height: 100%; + position: absolute; + z-index: 10; +} + +.info-1 .top-c { + padding: 44rpx 40rpx; + box-sizing: border-box; + position: inherit; + /* position: absolute; */ + z-index: 999; + font-size: 28rpx; + font-weight: 500; + color: #333333; + line-height: 50rpx; + z-index: 99; + height: 285rpx; +} + +/* end */ +.tip-info{ + position: relative; + border-radius: 10rpx; + margin-top: 150rpx; + z-index: 100; + width: 80%; + height: 950rpx; + background: #fff; + /* opacity: 1; */ +} +.tip-info .title{ + padding: 30rpx 35rpx 10rpx 35rpx; + box-sizing: border-box; + position: relative; + width: 100%; + height: auto; + text-align: center; + line-height: 45rpx; + font-size: 30rpx; +} + +.tip-info .title .close{ + position: absolute; + width: 60rpx; + height: 60rpx; + background: red; + top: 10rpx; + right: 20rpx; +} +.tip-info .tip-content{ + max-height: 650rpx; + overflow-y: auto; + width: 100%; + height: auto; + padding: 10rpx 30rpx; + box-sizing: border-box; +} +.tip-info .tip-content .h1{ + width: 100%; + height: auto; + font-size: 30rpx; + line-height: 45rpx; + font-weight: 600; +} +.tip-info .tip-content .h2{ + width: 100%; + height: auto; + font-size: 26rpx; + line-height: 45rpx; +} + +.tip-info .tip-content .h3{ + text-align: right; + width: 100%; + height: auto; + font-size: 26rpx; + line-height: 45rpx; +} + + +.sound-operate { + display: flex; + justify-content: center; + align-items: center; + margin: 40rpx 0 30rpx 0; - .personal-info { +} +.sound-operate-del, + .sound-operate-finish { + width: 60rpx; + height: 60rpx; + + + } + .sound-operate-del image, + .sound-operate-finish image { + display: block; width: 100%; height: 100%; + } + .sound-operate-btn { + margin: 0 60rpx; + + } + .sound-circel { + width: 160rpx; + height: 160rpx; box-sizing: border-box; - padding: 0 20rpx; + background: #e9f2fe; + border-radius: 50%; overflow: hidden; + + } - .basic-info { - width: 100%; - background: #fff; - border-radius: 16rpx; + .sound-circle-bd { + width: 124rpx; + height: 124rpx; box-sizing: border-box; - padding: 0 20rpx; - margin-top: 20rpx; + margin: 18rpx auto; + border: 16rpx solid #5e9fff; + background-color: #5e9fff; + overflow: hidden; + border-radius: 50%; + -webkit-border-radius: 50%; + -moz-border-radius: 50%; + -ms-border-radius: 50%; + -o-border-radius: 50%; } - - .item { - border-bottom: 1rpx solid #e7eeee; - padding: 25rpx 0; - line-height: 60rpx; - display: flex; - justify-content: space-between; + .sound-circle-bg { + background: #5d9fff; } - .item .field { - position: relative; - box-sizing: border-box; - width: 300rpx; - padding-left: 25rpx; + @-webkit-keyframes list { + 0% { + -webkit-transform: scaley(1); + transform: scaley(1); + } + + 50% { + -webkit-transform: scaley(0.4); + transform: scaley(0.4); + } + 100% { + -webkit-transform: scaley(1); + transform: scaley(1); + } } + @keyframes list { + 0% { + -webkit-transform: scaley(1); + transform: scaley(1); + } - .field-d { - width: 220rpx !important; + 50% { + -webkit-transform: scaley(0.4); + transform: scaley(0.4); + } + + 100% { + -webkit-transform: scaley(1); + transform: scaley(1); + } } - .value-d{ - width: 450rpx !important; + .sound-play { + display: flex; + justify-content: center; + align-items: center; + height: 100%; + } - .item .field.mobile-field { - width: 250rpx !important; + .sound-cancle { + padding: 20rpx; + font-size: 24rpx; + color: #999999; + text-align: right; } - .item .field .must { - position: absolute; - top: 0; - left: 0; - margin: 0 auto; - color: #F61616; - font-size: 30rpx; + .sound-wrapper { + margin-top: 80rpx; + font-family: Source Han Serif SC; + font-weight: 500; + text-align: center; } - - .item .field .field-text { - font-size: 32rpx; - font-family: Source Han Serif SC; - font-weight: 400; - color: #333; + .sound-time { + width: 80rpx; + margin: 0 auto; + font-size: 30rpx; + color: #333333; + line-height: 1; + letter-spacing: 2rpx; } - - .item .value { - position: relative; - width: 410rpx; - display: flex; - font-size: 32rpx; - font-family: Source Han Serif SC; - font-weight: 400; - color: #333; - line-height: 60rpx; + .sound-tips { + font-size: 26rpx; + color: #999999; + text-align: center; } - - .item .value-dl { - position: relative; - width: 410rpx; + + .sound-operate { display: flex; - font-size: 32rpx; - font-family: Source Han Serif SC; - font-weight: 400; - color: #333; - line-height: 60rpx; + justify-content: center; align-items: center; + margin: 40rpx 0 30rpx 0; + } - - .di-name{ - margin-right: 14rpx; - text-align: right; - width: calc(100% - 30rpx); - } - - .di-but{ - width: 30rpx; - height: 34rpx; + .sound-operate-del, + .sound-operate-finish { + width: 60rpx; + height: 60rpx; } - - .item .value input { - text-align: right; - font-size: 34rpx; - color: #333; - height: 100%; - width: 100%; - } - .item .value .picker { - position: relative; - width: 100%; - padding-right: 40rpx; - text-align: right; + + .sound-play .sound-play-item { + background-color: #fff; + width: 6rpx; + height: 40rpx; + border-radius: 6rpx; + margin-right: 7rpx; + -webkit-animation-fill-mode: both; + animation-fill-mode: both; + animation: list 1s 0s infinite cubic-bezier(0.85, 0.25, 0.37, 0.85); + -webkit-border-radius: 6rpx; + -moz-border-radius: 6rpx; + -ms-border-radius: 6rpx; + -o-border-radius: 6rpx; + -webkit-animation: list 1s 0s infinite cubic-bezier(0.85, 0.25, 0.37, 0.85); } - - .item .value .picker .z-weak { - color: #999; + .sound-play .sound-play-item:nth-child(1) { + -webkit-animation-delay: 0.1s !important; + animation-delay: 0.1s !important; } - - .item .value .picker .menu-arrow { - position: absolute; - top: 20rpx; - right: 0; - width: 16rpx; - height: 23rpx; + .sound-play .sound-play-item:nth-child(2) { + -webkit-animation-delay: 0.2s !important; + animation-delay: 0.2s !important; } - .item .value-mobile { - position: relative; - width: 410rpx; - display: flex; - font-size: 32rpx; - font-family: Source Han Serif SC; - font-weight: 400; - color: #333; - line-height: 60rpx; - display: flex; - justify-content: flex-end; + .sound-play .sound-play-item:nth-child(3) { + -webkit-animation-delay: 0.3s !important; + animation-delay: 0.3s !important; } - .item .value-mobile .get-code { - padding: 0 15rpx; - height: 60rpx; - line-height: 60rpx; - background: linear-gradient(to right, #F40C0C, #FF4E4E); - color: #fff; - font-size: 24rpx; - border-radius: 6rpx; - margin: 0; - margin-left: 25rpx; + .sound-play .sound-play-item:nth-child(4) { + -webkit-animation-delay: 0.4s !important; + animation-delay: 0.4s !important; } - .item .value-mobile .button-hover { - background: rgb(175, 1, 1); + .sound-play-stop .sound-play-item { + animation-play-state: paused; } - .item .value-mobile input { - text-align: right; - font-size: 34rpx; - color: #333; - height: 100%; - width: 55%; + .mkf-img{ + display: flex; + align-items: center; + color: #999; + font-size: 26rpx; + font-family: PingFang SC; } - .placeholder-style { - font-size: 28rpx; - color: #999; + .mkf-img image{ + width: 50rpx; + height: 50rpx; } \ No newline at end of file diff --git a/subpages/gatherInformation/pages/gatherInformation/gatherInformation.wxml b/subpages/gatherInformation/pages/gatherInformation/gatherInformation.wxml index 420ea00..514720a 100644 --- a/subpages/gatherInformation/pages/gatherInformation/gatherInformation.wxml +++ b/subpages/gatherInformation/pages/gatherInformation/gatherInformation.wxml @@ -1,7 +1,8 @@ - {{typeVal =='resi'?'居民信息采集':typeVal=='house'?'房屋信息采集':'全部信息'}} , {{collectTypeVal =='add'?'新增':collectTypeVal =='edit'?'修改':collectTypeVal == 'del'?'删除':''}} + {{typeVal =='resi'?'居民信息采集':typeVal=='house'?'房屋信息采集':'全部信息'}} + diff --git a/subpages/searchResult/pages/searchResult/searchResult.js b/subpages/searchResult/pages/searchResult/searchResult.js index 545acbd..1a2119b 100644 --- a/subpages/searchResult/pages/searchResult/searchResult.js +++ b/subpages/searchResult/pages/searchResult/searchResult.js @@ -30,9 +30,8 @@ Page({ share:app.globalData.share, title:options.type =='resi'?'居民查询结果':'房屋查询结果', type:options.type, - keyWord:app.globalData.keyWord + keyWord:options.keyWord }) - console.log(this.data.keyWord,'dataK'); this.getTable() }, @@ -47,7 +46,6 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - console.log(this.data.keyWord,'show'); }, /** @@ -103,7 +101,6 @@ Page({ loadMoreType: res.data.list.length === this.data.pageSize ? 'more' : 'none', tableData: this.data.tableData.concat(res.data.list), }) - console.log(this.data.loadMoreType); if (this.data.tableData.length == 0) { this.setData({ loadMoreVisible: false, @@ -122,7 +119,6 @@ Page({ loadMoreType: res.data.list.length === this.data.pageSize ? 'more' : 'none', tableData: this.data.tableData.concat(res.data.list), }) - console.log(this.data.loadMoreType); if (this.data.tableData.length == 0) { this.setData({ loadMoreVisible: false, @@ -155,7 +151,6 @@ Page({ } }, handelClickedit(e){ - console.log(e); if(this.data.type == 'resi'){ wx.navigateTo({ url: `/subpages/addResi/pages/addResi/addResi?type=edit&resiId=${e.currentTarget.dataset.item.resiId}`, diff --git a/utils/api.js b/utils/api.js index 7173c9c..7ebd1ad 100644 --- a/utils/api.js +++ b/utils/api.js @@ -34,7 +34,8 @@ module.exports = { getFollowUpList, followUpSave, followUpDelete, - logout + logout, + getAgencygridtree } // 消息列表 function getIntelligentMessage(param){ @@ -177,3 +178,7 @@ function followUpSave (parm) { function followUpDelete (parm) { return fly.post(`governance/satisfaction/communitySelfInsp/followUp/delete/${parm}`,) } +// 获取组织树 +function getAgencygridtree () { + return fly.post(`gov/org/customeragency/agencygridtree`,) +} diff --git a/utils/qqmap-wx-jssdk.js b/utils/qqmap-wx-jssdk.js new file mode 100644 index 0000000..9724e31 --- /dev/null +++ b/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