@@ -3,11 +3,11 @@ const {request} = require("../request/index") | |||
* 获取省市区树状数据 | |||
* @param {*} params | |||
*/ | |||
export const getCityTree = function(params) { | |||
export const getCityTree = function(data) { | |||
return request({ | |||
url: '/city/queryCityList', | |||
method: "GET", | |||
params | |||
data | |||
}) | |||
} | |||
@@ -15,11 +15,11 @@ export const getCityTree = function(params) { | |||
* 获取河流列表 | |||
* @param {*} params | |||
*/ | |||
export const getFeedbackIndex = function(params) { | |||
export const getFeedbackIndex = function(data) { | |||
return request({ | |||
url: '/stream/index', | |||
method: "GET", | |||
params | |||
data | |||
}) | |||
} | |||
/** |
@@ -7,4 +7,14 @@ export const getOpenId = function (code) { | |||
url: `/wx/openid/${code}`, | |||
method: 'GET', | |||
}) | |||
} | |||
} | |||
/** | |||
* 查询省市区对应城市代码 | |||
*/ | |||
export const getCityNameCode = function (data) { | |||
return request({ | |||
url: '/city/cityNameAndCode', | |||
method: 'GET', | |||
data | |||
}) | |||
} |
@@ -2,10 +2,10 @@ const {request} = require("../request/index") | |||
/** | |||
* 获取oss鉴权信息 | |||
*/ | |||
export const getOssAuth = function (params) { | |||
export const getOssAuth = function (data) { | |||
return request({ | |||
url: '/aliyunOss/getSecurityToken', | |||
method: 'GET', | |||
params | |||
data | |||
}) | |||
} |
@@ -3,5 +3,6 @@ | |||
<view class="main_info"> | |||
<text class="info_name">{{dataSource.name}}</text> | |||
<text class="info_area">{{dataSource.location}}</text> | |||
<text class="info_area">{{dataSource.note || ''}}</text> | |||
</view> | |||
</view> |
@@ -13,11 +13,15 @@ | |||
align-items: flex-start; | |||
} | |||
.info_name { | |||
margin-bottom: 10px; | |||
font-size: 28rpx; | |||
color: #333333; | |||
} | |||
.info_area { | |||
width: 300rpx; | |||
margin-top: 20rpx; | |||
color: #666666; | |||
font-size: 26rpx; | |||
overflow: hidden; | |||
white-space: nowrap; | |||
text-overflow: ellipsis; | |||
} |
@@ -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" | |||
} |
@@ -267,7 +267,6 @@ Page({ | |||
Promise.all(temp).then((res)=> { | |||
let form = this.data.form; | |||
form.feedbackUrl = res.join(',') | |||
feedbackPosition(form).then(res => { | |||
if (res.code === 0) { | |||
wx.reLaunch({ |
@@ -1,50 +1,40 @@ | |||
// pages/home/index.js | |||
import {getUserInfo} from '../../utils/getUserInfo.js' | |||
import {getCityTree} from '../../api/feeddback.js' | |||
import {getLocatonPermission} from '../../utils/getUserLocation.js' | |||
Page({ | |||
/** | |||
* 页面的初始数据 | |||
*/ | |||
data: { | |||
// 区域选项列表 | |||
provinceOptions: [], | |||
cityOptions: [], | |||
districtOptions: [], | |||
provinceCurrent: -1, // 当前选择省 | |||
cityCurrent: -1, | |||
districtCurrent: -1, | |||
// 列表数据筛选条件 | |||
params: { | |||
name: '' | |||
}, | |||
name: '', | |||
list: [], | |||
current: "/stream/index", | |||
current: "", | |||
}, | |||
/** | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad: function (options) { | |||
if(!wx.getStorageSync('location')) { | |||
getLocatonPermission().then((res)=> { | |||
wx.setStorage({ | |||
key: 'location', | |||
data: res | |||
}) | |||
wx.switchTab({ | |||
url: '/pages/home/index', | |||
}) | |||
}).catch(e=> { | |||
console.log(e); | |||
}) | |||
} | |||
this.getTabBar().setData({ | |||
selected: 0 | |||
}) | |||
this.getCityTreeList() | |||
let positionParams = wx.getStorageSync('positionParams') | |||
if(Object.keys(positionParams).length) { | |||
let params = this.data.params | |||
params.provinceCode = positionParams.provinceCode | |||
params.cityCode = positionParams.cityCode | |||
params.districtCode = positionParams.districtCode | |||
this.setData({params, current: '/stream/index'}) | |||
} else { | |||
wx.redirectTo({ | |||
url: '/pages/login/login', | |||
}) | |||
} | |||
}, | |||
/** | |||
@@ -54,57 +44,6 @@ Page({ | |||
}, | |||
/* 调取当前用户区域 */ | |||
/* 获取省市区 */ | |||
getCityTreeList() { | |||
getCityTree().then(res=> { | |||
this.setData({ | |||
provinceOptions: res.data | |||
}) | |||
}) | |||
}, | |||
/* 筛选 */ | |||
updateAreaChange(e) { | |||
const type = e.target.dataset.type | |||
const current = e.detail.current | |||
let params = this.data.params | |||
let code = this.data[type+'Options'][current].citycode | |||
params[type+'Code'] = code | |||
let itemList = this.data[type+'Options'][current].itemList || [] | |||
if(type === 'province') { | |||
this.setData({ | |||
provinceCurrent: current, | |||
cityOptions: itemList, | |||
cityCurrent: -1, | |||
districtCurrent: -1 | |||
}) | |||
params.cityCode = "" | |||
params.districtCode = "" | |||
params.name = '' | |||
} else if(type === 'city') { | |||
this.setData({ | |||
districtOptions: itemList, | |||
cityCurrent: current, | |||
districtCurrent: -1 | |||
}) | |||
params.districtCode = "" | |||
params.name = '' | |||
} else if(type === 'district') { | |||
this.setData({districtCurrent: current}) | |||
params.name = '' | |||
} | |||
this.setData({ | |||
params: params | |||
}) | |||
}, | |||
/* 根据current获取当前选中的值 */ | |||
getValueByCurrent(current,type) { | |||
let code = this.data[type+'Options'][current].value | |||
return code | |||
}, | |||
/* 输入河流名称搜索 */ | |||
search(e) { | |||
let params = this.data.params | |||
@@ -139,7 +78,9 @@ Page({ | |||
} | |||
}, | |||
/* 跳转至详情页 */ | |||
showDetail(e) { | |||
goSelectLocation(e) { | |||
wx.redirectTo({ | |||
url: '/pages/login/login', | |||
}) | |||
} | |||
}) |
@@ -1,11 +1,7 @@ | |||
<!--pages/home/index.wxml--> | |||
<view class="protecityct_container"> | |||
<view class="protect_head"> | |||
<view class="select_container"> | |||
<select data="{{provinceOptions}}" data-type="province" rangeKey="name" current="{{provinceCurrent}}" bind:updateChange="updateAreaChange"></select> | |||
<select disabled="{{!params.provinceCode}}" data="{{cityOptions}}" data-type="city" rangeKey="name" current="{{cityCurrent}}" bind:updateChange="updateAreaChange"></select> | |||
<select disabled="{{!params.cityCode}}" data="{{districtOptions}}" data-type="district" rangeKey="name" current="{{districtCurrent}}" bind:updateChange="updateAreaChange"></select> | |||
</view> | |||
<view class="select_location" bindtap="goSelectLocation">切换位置</view> | |||
<view class="search_container"> | |||
<image class="search_icon" src="../../assets/img/search.png"></image> | |||
<input class="task-search" type="text" placeholder="请输入河道名称进行查询" model:value="{{name}}" placeholder-class="placeholder-style" bindconfirm="search" bindblur="search"/> |
@@ -13,14 +13,18 @@ | |||
display: flex; | |||
flex-direction: column; | |||
justify-content: flex-start; | |||
align-items: flex-end; | |||
} | |||
.select_container { | |||
width: 100%; | |||
height: 82rpx; | |||
background-color: #fff; | |||
display: flex; | |||
justify-content: space-around; | |||
align-items: center; | |||
.select_location { | |||
width: 150rpx; | |||
height: 60rpx; | |||
margin-right: 30rpx; | |||
line-height: 60rpx; | |||
text-align: center; | |||
border: 1rpx solid #e0e0e0; | |||
border-radius: 10rpx; | |||
color: #999; | |||
font-size: 24rpx; | |||
} | |||
.search_container { | |||
width: 100%; |
@@ -1,66 +1,177 @@ | |||
// pages/login/login.js | |||
import {getUserInfo} from '../../utils/getUserInfo.js' | |||
import {getCityTree} from '../../api/feeddback.js' | |||
import {getCityNameCode} from '../../api/login.js' | |||
import {getLocatonPermission} from '../../utils/getUserLocation.js' | |||
Page({ | |||
/** | |||
* 页面的初始数据 | |||
*/ | |||
data: { | |||
userInfo: {}, | |||
hasUserInfo: false, | |||
canIUseGetUserProfile: false | |||
// 区域选项列表 | |||
provinceOptions: [], | |||
cityOptions: [], | |||
districtOptions: [], | |||
provinceCurrent: -1, // 当前选择省 | |||
cityCurrent: -1, | |||
districtCurrent: -1, | |||
params: {}, // 筛选条件 | |||
obj: { | |||
provinceName: '湖南省', | |||
cityName: '株洲市', | |||
districtName: '芦淞区' | |||
} | |||
}, | |||
/** | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad: function (options) { | |||
// if (wx.getUserProfile) { | |||
// this.setData({ | |||
// canIUseGetUserProfile: true | |||
// }) | |||
// } | |||
this.getCityTreeList() | |||
}, | |||
/** | |||
* 生命周期函数--监听页面初次渲染完成 | |||
*/ | |||
onReady: function () { | |||
}, | |||
/** | |||
* 生命周期函数--监听页面显示 | |||
*/ | |||
onShow: function () { | |||
// 隐藏返回图标 | |||
wx.hideHomeButton(); | |||
let positionParams = wx.getStorageSync('positionParams') | |||
if(Object.keys(positionParams).length) { | |||
let params = this.data.params | |||
params.provinceCode = positionParams.provinceCode | |||
params.cityCode = positionParams.cityCode | |||
params.districtCode = positionParams.districtCode | |||
this.setData({ | |||
params, | |||
provinceCurrent: positionParams.provinceCurrent, | |||
provinceOptions: positionParams.provinceOptions, | |||
cityCurrent: positionParams.cityCurrent, | |||
cityOptions: positionParams.cityOptions, | |||
districtCurrent: positionParams.districtCurrent, | |||
districtOptions: positionParams.districtOptions | |||
}) | |||
} else { | |||
this.getUserLocation() | |||
} | |||
}, | |||
/** | |||
* 根据name查找list | |||
*/ | |||
getListByName(obj) { | |||
let provinceOptions = this.data.provinceOptions | |||
let provinceCurrent, cityCurrent, districtCurrent, cityOptions, districtOptions | |||
let params = this.data.params | |||
if(provinceOptions.length) { | |||
provinceOptions.forEach((item,index)=> { | |||
if(item.citycode === obj.provinceCode) { | |||
provinceCurrent = index | |||
cityOptions = item?.itemList || [] | |||
if(cityOptions.length) { | |||
cityOptions.forEach((i, j)=> { | |||
if(i.citycode === obj.cityCode) { | |||
cityCurrent = j | |||
districtOptions = i?.itemList || [] | |||
if (districtOptions.length) { | |||
districtOptions.forEach((m, n) => { | |||
if(m.citycode === obj.districtCode) { | |||
districtCurrent = n | |||
} | |||
}) | |||
} | |||
} | |||
}) | |||
} | |||
} | |||
}) | |||
} | |||
this.setData({provinceCurrent, cityCurrent, districtCurrent, cityOptions, districtOptions, params}) | |||
}, | |||
/* 获取省市区 */ | |||
getCityTreeList() { | |||
getCityTree().then(res=> { | |||
this.setData({ | |||
provinceOptions: res.data | |||
}) | |||
}) | |||
}, | |||
/* 筛选 */ | |||
updateAreaChange(e) { | |||
const type = e.target.dataset.type | |||
const current = e.detail.current | |||
let params = this.data.params | |||
let code = this.data[type+'Options'][current].citycode | |||
params[type+'Code'] = code | |||
let itemList = this.data[type+'Options'][current].itemList || [] | |||
if(type === 'province') { | |||
this.setData({ | |||
provinceCurrent: current, | |||
cityOptions: itemList, | |||
cityCurrent: -1, | |||
districtCurrent: -1 | |||
}) | |||
params.cityCode = "" | |||
params.districtCode = "" | |||
} else if(type === 'city') { | |||
this.setData({ | |||
districtOptions: itemList, | |||
cityCurrent: current, | |||
districtCurrent: -1 | |||
}) | |||
params.districtCode = "" | |||
} else if(type === 'district') { | |||
this.setData({districtCurrent: current}) | |||
} | |||
this.setData({ | |||
params: params | |||
}) | |||
}, | |||
getUserProfile(e) { | |||
/* 根据current获取当前选中的值 */ | |||
getValueByCurrent(current,type) { | |||
let code = this.data[type+'Options'][current].value | |||
return code | |||
}, | |||
getUserLocation(e) { | |||
// 推荐使用 wx.getUserProfile 获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认 | |||
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 | |||
let userInfo = wx.getStorageSync('userInfo') | |||
if(!userInfo.nickName) { | |||
getUserInfo().then(res=> { | |||
this.setData({ | |||
userInfo: res.userInfo | |||
let cityObj = wx.getStorageSync('cityObj') | |||
if(!Object.keys(cityObj).length) { | |||
getLocatonPermission().then(res=> { | |||
wx.setStorage({ | |||
key: 'location', | |||
data: res | |||
}) | |||
wx.switchTab({ | |||
url: '/pages/home/index', | |||
let latLog = {} | |||
latLog.lat = res.latitude | |||
latLog.lng = res.longitude | |||
getCityNameCode(latLog).then(res=> { | |||
let cityObj = res.data | |||
this.setData({cityObj}) | |||
this.getListByName(cityObj) | |||
}) | |||
}) | |||
} else { | |||
wx.switchTab({ | |||
url: '/pages/home/index', | |||
}) | |||
} | |||
}, | |||
getUserInfo(e) { | |||
// 不推荐使用 getUserInfo 获取用户信息,预计自2021年4月13日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息 | |||
this.setData({ | |||
userInfo: e.detail.userInfo, | |||
hasUserInfo: true | |||
/** | |||
* 进入首页 | |||
*/ | |||
goHome() { | |||
let params = this.data.params | |||
let positionParams = Object.assign({}, params) | |||
positionParams.provinceCurrent = this.data.provinceCurrent | |||
positionParams.cityCurrent = this.data.cityCurrent | |||
positionParams.districtCurrent = this.data.districtCurrent | |||
positionParams.provinceOptions = this.data.provinceOptions | |||
positionParams.cityOptions = this.data.cityOptions | |||
positionParams.districtOptions = this.data.districtOptions | |||
wx.setStorage({ | |||
key: 'positionParams', | |||
data: positionParams | |||
}) | |||
}, | |||
wx.switchTab({ | |||
url: '/pages/home/index?cityParams', | |||
}) | |||
} | |||
}) |
@@ -1,4 +1,6 @@ | |||
{ | |||
"usingComponents": {}, | |||
"navigationBarTitleText": "定位" | |||
"usingComponents": { | |||
"select": "../../components/Select/index" | |||
}, | |||
"navigationBarTitleText": "全民护河" | |||
} |
@@ -1,4 +1,15 @@ | |||
<!--pages/login/login.wxml--> | |||
<view class="login_box"> | |||
<image class="logo_img" src="../../assets/img/logo.png"></image> | |||
<view class="login_main"> | |||
<text class="location_label">您的位置:</text> | |||
<view class="select_container"> | |||
<select data="{{provinceOptions}}" data-type="province" rangeKey="name" current="{{provinceCurrent}}" bind:updateChange="updateAreaChange"></select> | |||
<select disabled="{{!params.provinceCode}}" data="{{cityOptions}}" data-type="city" rangeKey="name" current="{{cityCurrent}}" bind:updateChange="updateAreaChange"></select> | |||
<select disabled="{{!params.cityCode}}" data="{{districtOptions}}" data-type="district" rangeKey="name" current="{{districtCurrent}}" bind:updateChange="updateAreaChange"></select> | |||
</view> | |||
</view> | |||
<view class="footer"> | |||
<view class="enter_btn" bindtap="goHome">进入小程序</view> | |||
</view> | |||
</view> |
@@ -4,67 +4,35 @@ | |||
height: 100vh; | |||
display: flex; | |||
flex-direction: column; | |||
justify-content: center; | |||
justify-content: flex-start; | |||
align-items: center; | |||
} | |||
.form_box { | |||
.logo_img { | |||
width: 180rpx; | |||
height: 180rpx; | |||
margin-top: 40rpx; | |||
} | |||
.login_main { | |||
width: 100%; | |||
margin-top: 40rpx; | |||
display: flex; | |||
flex-direction: column; | |||
justify-content: flex-start; | |||
align-items: flex-end; | |||
} | |||
.login_box .form-item{ | |||
padding-bottom:50rpx; | |||
position: relative; | |||
align-items: flex-start; | |||
} | |||
.login_box .form-item input{ | |||
width: 532rpx; | |||
height: 80rpx; | |||
padding-left: 20px; | |||
border-radius: 39rpx; | |||
background-color: #fafafa; | |||
} | |||
.login_box .tips{ | |||
position: absolute; | |||
bottom: 0; | |||
left:0; | |||
color: red; | |||
font-size:26rpx; | |||
transform: translate(20rpx,-10rpx); | |||
display: none; | |||
} | |||
.login_box .form-item.warning .tips{ | |||
display: block; | |||
} | |||
.check_lable { | |||
box-sizing: border-box; | |||
height: 60rpx; | |||
display: flex; | |||
justify-content: flex-end; | |||
align-items: center; | |||
color: #b0b0b0; | |||
.location_label { | |||
font-size: 34rpx; | |||
font-weight: bold; | |||
margin-left: 40rpx; | |||
} | |||
.check_contanier { | |||
.select_container { | |||
width: 100%; | |||
height: 82rpx; | |||
background-color: #fff; | |||
display: flex; | |||
justify-content: flex-end; | |||
justify-content: space-around; | |||
align-items: center; | |||
} | |||
.check_box { | |||
width: 30rpx; | |||
height: 30rpx; | |||
margin-right: 20rpx; | |||
} | |||
radio-group { | |||
width: 200rpx; | |||
align-self: flex-end !important; | |||
} | |||
checkbox .wx-checkbox-input { | |||
width: 30rpx; | |||
height: 30rpx; | |||
margin-bottom: 10rpx; | |||
} | |||
} | |||
.login_btn { | |||
margin-top: 80rpx; | |||
@@ -73,3 +41,20 @@ checkbox .wx-checkbox-input { | |||
border-radius: 39rpx; | |||
background-color: #477DF3; | |||
} | |||
.footer { | |||
margin-top: 100rpx; | |||
width: 100%; | |||
padding: 60rpx; | |||
display: flex; | |||
justify-content: center; | |||
align-items: center; | |||
} | |||
.enter_btn { | |||
width: 400rpx; | |||
height: 100rpx; | |||
border-radius: 50rpx; | |||
background-color: rgba(6, 138, 58, 0.78); | |||
color: #fff; | |||
line-height: 100rpx; | |||
text-align: center; | |||
} |