Browse Source

首页增加当前位置

pull/36/head
余菲 1 year ago
parent
commit
0cd3ef7fde
3 changed files with 37 additions and 10 deletions
  1. +2
    -2
      environment.js
  2. +3
    -1
      pages/FirstPage/index.js
  3. +32
    -7
      pages/login/login.js

+ 2
- 2
environment.js View File

const __request_base_url__ = { const __request_base_url__ = {
develop: "http://192.168.11.11:9061/api",
// develop: "https://qmhhapi-test.t-aaron.com/api",
// develop: "http://192.168.11.11:9061/api",
develop: "https://qmhhapi-test.t-aaron.com/api",
trial: "https://qmhhapi-test.t-aaron.com/api", trial: "https://qmhhapi-test.t-aaron.com/api",
release: "https://qmhh.t-aaron.com/api" release: "https://qmhh.t-aaron.com/api"
} }

+ 3
- 1
pages/FirstPage/index.js View File

* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
areaName: '芦淞区', // 当前区域位置
areaName: '', // 当前区域位置
announcementList: [], // 公告列表 announcementList: [], // 公告列表
// 快捷入口 // 快捷入口
entersList: [ entersList: [
if(Object.keys(tenant).length) { if(Object.keys(tenant).length) {
this.getOnliveNum() this.getOnliveNum()
} }
let areaName = wx.getStorageSync('positionParams').areaName
this.setData({areaName})
}, },





+ 32
- 7
pages/login/login.js View File

// 隐藏返回图标 // 隐藏返回图标
wx.hideHomeButton(); wx.hideHomeButton();
let positionParams = wx.getStorageSync('positionParams') let positionParams = wx.getStorageSync('positionParams')
console.log(positionParams);
let options = this.data.provinceOptions let options = this.data.provinceOptions
if(options.length === 0) { if(options.length === 0) {
let provinceOptions = wx.getStorageSync('provinceOptions') let provinceOptions = wx.getStorageSync('provinceOptions')
districtCurrent: positionParams.districtCurrent, districtCurrent: positionParams.districtCurrent,
districtOptions: positionParams.districtOptions districtOptions: positionParams.districtOptions
}) })
wx.setStorage({
key: 'positionParams',
data: positionParams
})
} else { } else {
this.getUserLocation() this.getUserLocation()
} }
*/ */
getListByName(obj) { getListByName(obj) {
let provinceOptions = this.data.provinceOptions let provinceOptions = this.data.provinceOptions
let provinceCurrent, cityCurrent, districtCurrent, cityOptions, districtOptions
let provinceCurrent,provinceName, cityCurrent, cityName,districtCurrent,districtName, cityOptions, districtOptions
let params = this.data.params let params = this.data.params
params.provinceCode = obj.provinceCode params.provinceCode = obj.provinceCode
params.cityCode = obj.cityCode params.cityCode = obj.cityCode
provinceOptions.forEach((item,index)=> { provinceOptions.forEach((item,index)=> {
if(item.citycode === obj.provinceCode) { if(item.citycode === obj.provinceCode) {
provinceCurrent = index provinceCurrent = index
provinceName = item.name
cityOptions = item?.itemList || [] cityOptions = item?.itemList || []
if(cityOptions.length) { if(cityOptions.length) {
cityOptions.forEach((i, j)=> { cityOptions.forEach((i, j)=> {
if(i.citycode === obj.cityCode) { if(i.citycode === obj.cityCode) {
cityCurrent = j cityCurrent = j
cityName = i.name
districtOptions = i?.itemList || [] districtOptions = i?.itemList || []
if (districtOptions.length) { if (districtOptions.length) {
districtOptions.forEach((m, n) => { districtOptions.forEach((m, n) => {
if(m.citycode === obj.districtCode) { if(m.citycode === obj.districtCode) {
districtCurrent = n districtCurrent = n
districtName = m.name
} }
}) })
} }
} }
}) })
} }
this.setData({provinceCurrent, cityCurrent, districtCurrent, cityOptions, districtOptions, params})
this.setData({provinceCurrent, provinceName, cityCurrent,cityName, districtCurrent,districtName, cityOptions, districtOptions, params})
}, },


/* 获取省市区 */ /* 获取省市区 */
let params = this.data.params let params = this.data.params
let code = this.data[type+'Options'][current].citycode let code = this.data[type+'Options'][current].citycode
params[type+'Code'] = code params[type+'Code'] = code
let name = this.data[type+'Options'][current].name
let itemList = this.data[type+'Options'][current].itemList || [] let itemList = this.data[type+'Options'][current].itemList || []
if(type === 'province') { if(type === 'province') {
this.setData({ this.setData({
provinceName: name,
provinceCurrent: current, provinceCurrent: current,
cityOptions: itemList, cityOptions: itemList,
cityCurrent: -1, cityCurrent: -1,
params.districtCode = "" params.districtCode = ""
} else if(type === 'city') { } else if(type === 'city') {
this.setData({ this.setData({
cityName: name,
districtOptions: itemList, districtOptions: itemList,
cityCurrent: current, cityCurrent: current,
districtCurrent: -1 districtCurrent: -1
}) })
params.districtCode = "" params.districtCode = ""
} else if(type === 'district') { } else if(type === 'district') {
this.setData({districtCurrent: current})
this.setData({
districtCurrent: current,
districtName: name
})
} }
this.setData({ this.setData({
params: params params: params
}) })
} }
}, },
// 存储省市区信息
setAreaInfo() {
let positionParams = {}
positionParams.provinceCurrent = this.data.provinceCurrent
positionParams.provinceName = this.data.provinceName
positionParams.cityCurrent = this.data.cityCurrent
positionParams.cityName = this.data.cityName
positionParams.districtCurrent = this.data.districtCurrent
positionParams.districtName = this.data.districtName
positionParams.cityOptions = this.data.cityOptions
positionParams.districtOptions = this.data.districtOptions
positionParams.areaName = this.data.districtName || this.data.cityName || this.data.provinceName || ''
positionParams = {
...positionParams,
...this.data.params
}
wx.setStorageSync('positionParams', positionParams)
},
/** /**
* 进入首页 * 进入首页
*/ */
goHome() { goHome() {
this.setAreaInfo()
this.validateForm().then(res => { this.validateForm().then(res => {
if(res) { if(res) {
enterMini({openid: this.data.openid, unionid: this.data.unionid, tenantId: this.data.tenantId}).then(item=> { enterMini({openid: this.data.openid, unionid: this.data.unionid, tenantId: this.data.tenantId}).then(item=> {

Loading…
Cancel
Save