浏览代码

首页增加当前位置

pull/36/head
余菲 1年前
父节点
当前提交
0cd3ef7fde
共有 3 个文件被更改,包括 37 次插入10 次删除
  1. +2
    -2
      environment.js
  2. +3
    -1
      pages/FirstPage/index.js
  3. +32
    -7
      pages/login/login.js

+ 2
- 2
environment.js 查看文件

@@ -1,6 +1,6 @@
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",
release: "https://qmhh.t-aaron.com/api"
}

+ 3
- 1
pages/FirstPage/index.js 查看文件

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



+ 32
- 7
pages/login/login.js 查看文件

@@ -50,6 +50,7 @@ Page({
// 隐藏返回图标
wx.hideHomeButton();
let positionParams = wx.getStorageSync('positionParams')
console.log(positionParams);
let options = this.data.provinceOptions
if(options.length === 0) {
let provinceOptions = wx.getStorageSync('provinceOptions')
@@ -88,10 +89,6 @@ Page({
districtCurrent: positionParams.districtCurrent,
districtOptions: positionParams.districtOptions
})
wx.setStorage({
key: 'positionParams',
data: positionParams
})
} else {
this.getUserLocation()
}
@@ -170,7 +167,7 @@ Page({
*/
getListByName(obj) {
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
params.provinceCode = obj.provinceCode
params.cityCode = obj.cityCode
@@ -179,16 +176,19 @@ Page({
provinceOptions.forEach((item,index)=> {
if(item.citycode === obj.provinceCode) {
provinceCurrent = index
provinceName = item.name
cityOptions = item?.itemList || []
if(cityOptions.length) {
cityOptions.forEach((i, j)=> {
if(i.citycode === obj.cityCode) {
cityCurrent = j
cityName = i.name
districtOptions = i?.itemList || []
if (districtOptions.length) {
districtOptions.forEach((m, n) => {
if(m.citycode === obj.districtCode) {
districtCurrent = n
districtName = m.name
}
})
}
@@ -198,7 +198,7 @@ Page({
}
})
}
this.setData({provinceCurrent, cityCurrent, districtCurrent, cityOptions, districtOptions, params})
this.setData({provinceCurrent, provinceName, cityCurrent,cityName, districtCurrent,districtName, cityOptions, districtOptions, params})
},

/* 获取省市区 */
@@ -229,9 +229,11 @@ Page({
let params = this.data.params
let code = this.data[type+'Options'][current].citycode
params[type+'Code'] = code
let name = this.data[type+'Options'][current].name
let itemList = this.data[type+'Options'][current].itemList || []
if(type === 'province') {
this.setData({
provinceName: name,
provinceCurrent: current,
cityOptions: itemList,
cityCurrent: -1,
@@ -241,13 +243,17 @@ Page({
params.districtCode = ""
} else if(type === 'city') {
this.setData({
cityName: name,
districtOptions: itemList,
cityCurrent: current,
districtCurrent: -1
})
params.districtCode = ""
} else if(type === 'district') {
this.setData({districtCurrent: current})
this.setData({
districtCurrent: current,
districtName: name
})
}
this.setData({
params: params
@@ -285,10 +291,29 @@ Page({
})
}
},
// 存储省市区信息
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() {
this.setAreaInfo()
this.validateForm().then(res => {
if(res) {
enterMini({openid: this.data.openid, unionid: this.data.unionid, tenantId: this.data.tenantId}).then(item=> {

正在加载...
取消
保存