123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399 |
- // pages/indexPages/selectHall/selectHall.js
- import {
- hqdw
- } from "../../../apis/index.js"
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- navigation: {},
- type: "",
- selectTab: [{
- label: "企业匹配的税务机关",
- value: "0"
- }, {
- label: "距离排序",
- value: "0"
- }, {
- label: "我的收藏",
- value: "1"
- }],
- selectTabIndex: 1,
- barStart: null,
- containerStyle: '',
- addressInfo: {},
- myHall: {},
- hall: [],
- nowHall: [],
- markers: [],
- searchText: "",
- searchTime: false
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- let that = this
- that.init(options)
- that.getNavigationBar()
- that.hqdw()
- },
- none() {
- return
- },
- init(e) {
- let that = this
- if (e) {
- if (e.type) {
- that.setData({
- type: e.type
- })
- }
- }
- },
- getNavigationBar() {
- let that = this
- const res = wx.getMenuButtonBoundingClientRect()
- let navigation = {
- width: res.left + 'px',
- height: res.height + 6 + 'px',
- paddingTop: res.top - 3 + 'px'
- }
- that.setData({
- navigation: navigation
- })
- },
- hqdw() {
- let that = this
- wx.getLocation({
- type: 'wgs84',
- isHighAccuracy: true,
- success(result) {
- that.setMarker(result)
- hqdw().then(res => {
- if (res.code == 200) {
- let data = JSON.parse(res.message)
- that.setData({
- addressInfo: {
- lat: result.latitude,
- lng: result.longitude,
- address: data.result.ad_info.district || data.result.ad_info.city || data.result.ad_info.province || data.result.ad_info.nation
- }
- })
- wx.setStorageSync('ADDRESS', data.result.ad_info.district || data.result.ad_info.city || data.result.ad_info.province || data.result.ad_info.nation)
- } else {
- that.setData({
- addressInfo: {
- lat: result.latitude,
- lng: result.longitude,
- address: "未知"
- }
- })
- wx.setStorageSync('ADDRESS', "未知")
- }
- })
- },
- fail: (err) => {
- hqdw().then(res => {
- if (res.code == 200) {
- let data = JSON.parse(res.message)
- that.setMarker(data.result)
- that.setData({
- addressInfo: {
- lat: data.result.location.lat,
- lng: data.result.location.lng,
- address: data.result.ad_info.district || data.result.ad_info.city || data.result.ad_info.province || data.result.ad_info.nation
- }
- })
- wx.setStorageSync('ADDRESS', data.result.ad_info.district || data.result.ad_info.city || data.result.ad_info.province || data.result.ad_info.nation)
- } else {
- that.setData({
- addressInfo: {
- lat: "",
- lng: "",
- address: "未知"
- }
- })
- wx.setStorageSync('ADDRESS', "未知")
- }
- })
- }
- })
- that.getHall()
- },
- getHall() {
- let that = this
- let myHall = wx.getStorageSync('MY_HALL')
- let index = that.data.selectTabIndex
- let hallList = wx.getStorageSync('HALL_LIST')
- if (index === 0) {
- let userinfo = wx.getStorageSync('USERINFO')
- if (userinfo.swjgdm) {
- let hall = []
- let uswjgdm = userinfo.swjgdm.substring(0, 7)
- for (let i = 0; i < hallList.length; i++) {
- let hswjgdm = hallList[i].ssswjgDm.substring(0, 7)
- if (uswjgdm == hswjgdm) {
- hall = hall.push(hallList[i])
- }
- }
- that.setData({
- hall: hall,
- myHall: myHall,
- nowHall: hall
- })
- } else {
- that.setData({
- hall: [],
- nowHall: [],
- myHall: myHall
- })
- }
- } else if (index === 1) {
- that.setData({
- hall: hallList,
- nowHall: hallList,
- myHall: myHall
- })
- } else {
- that.setData({
- hall: [],
- nowHall: [],
- myHall: myHall
- })
- }
- },
- selectHall(e) {
- let that = this
- let item = e.currentTarget.dataset.item
- wx.setStorageSync('MY_HALL', item)
- wx.navigateBack()
- },
- call(e) {
- let that = this
- let item = e.currentTarget.dataset.item
- wx.makePhoneCall({
- phoneNumber: item.kfdh,
- })
- },
- daohang(e) {
- let item = e.currentTarget.dataset.item
- wx.openLocation({
- latitude: Number(item.latitude),
- longitude: Number(item.longitude),
- scale: 18,
- name: item.bsfwtmc,
- address: item.bsfwtdz,
- complete: (res) => {
- console.log(res)
- }
- })
- },
- bardown(e) {
- let that = this
- that.setData({
- barStart: e.changedTouches[0].pageY
- })
- },
- barmove(e) {
- let that = this
- let barStart = that.data.barStart
- if (barStart) {
- let now = e.changedTouches[0].pageY
- let differ = now - barStart
- if (differ > 60) {
- that.setData({
- containerStyle: 'down'
- })
- } else if (differ < -60) {
- that.setData({
- containerStyle: ''
- })
- }
- }
- },
- setMarker(e) {
- let that = this
- let lat = e.latitude || e.lat
- let lng = e.longitude || e.lng
- let marker = {
- id: 9527,
- latitude: lat,
- longitude: lng,
- title: "",
- zIndex: 9,
- alpha: 0.9,
- iconPath: "../../../icon/address.png",
- width: "50rpx",
- height: "50rpx",
- callout: {
- content: "我的位置",
- color: "#313131",
- fontSize: 12,
- borderRadius: 5,
- bgColor: "#ffffff",
- padding: 5,
- display: "ALWAYS"
- }
- }
- that.setData({
- markers: [marker]
- })
- },
- back() {
- wx.navigateBack()
- },
- selectTab(e) {
- let that = this
- let index = e.currentTarget.dataset.index
- that.setData({
- selectTabIndex: index
- })
- let hallList = wx.getStorageSync('HALL_LIST')
- if (index === 0) {
- let userinfo = wx.getStorageSync('USERINFO')
- if (userinfo.swjgdm) {
- let hall = []
- let uswjgdm = userinfo.swjgdm.substring(0, 7)
- for (let i = 0; i < hallList.length; i++) {
- let hswjgdm = hallList[i].ssswjgDm.substring(0, 7)
- if (uswjgdm == hswjgdm) {
- hall = hall.push(hallList[i])
- }
- }
- that.setData({
- hall: hall,
- nowHall: hall
- })
- } else {
- that.setData({
- hall: [],
- nowHall: []
- })
- }
- } else if (index === 1) {
- that.setData({
- hall: hallList,
- nowHall: hallList
- })
- } else {
- that.setData({
- hall: [],
- nowHall: []
- })
- }
- },
- search(e) {
- let that = this
- let value = e.detail.value
- that.setData({
- searchText: value
- })
- that.startSearch(value)
- },
- startSearch(e) {
- let that = this
- let searchTime = that.data.searchTime
- if (e.length != 0) {
- if (!searchTime) {
- that.setData({
- searchTime: true
- })
- setTimeout(() => {
- /* */
- let hall = that.data.nowHall
- let newHall = hall.filter((item) => {
- return item.bsfwtmc.indexOf(e) != -1
- })
- that.setData({
- hall: newHall
- })
- /* */
- setTimeout(() => {
- that.setData({
- searchTime: false
- })
- }, 500);
- }, 0);
- }
- } else {
- that.getHall()
- }
- },
- // start(e) {
- // let type = e.currentTarget.dataset.type
- // wx.navigateTo({
- // url: '../selectBusiness/selectBusiness?type=' + type,
- // })
- // },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|