@@ -67,9 +67,9 @@ Page({ | |||
*/ | |||
onShow: function () { | |||
this.getOssAuthForm() | |||
const openId = wx.getStorageSync('openId') | |||
const openid = wx.getStorageSync('openid') | |||
let form = this.data.form | |||
form.openid = openId | |||
form.openid = openid | |||
this.setData({form}) | |||
}, | |||
bindValue(e) { |
@@ -19,7 +19,7 @@ Page({ | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad(options) { | |||
const openid = wx.getStorageSync('openId') | |||
const openid = wx.getStorageSync('openid') | |||
let params = this.data.params | |||
params.openid = openid | |||
this.setData({params}) |
@@ -21,7 +21,7 @@ Page({ | |||
*/ | |||
onLoad: function (options) { | |||
let params = this.data.params | |||
params.openid = wx.getStorageSync('openId') | |||
params.openid = wx.getStorageSync('openid') | |||
this.setData({params}) | |||
}, | |||
@@ -10,12 +10,6 @@ Page({ | |||
current: "", | |||
}, | |||
onLoad: function() { | |||
let positionParams = wx.getStorageSync('positionParams') | |||
let params = this.data.params | |||
params.provinceCode = positionParams.provinceCode || '' | |||
params.cityCode = positionParams.cityCode || '' | |||
params.districtCode = positionParams.districtCode || '' | |||
this.setData({ | |||
params, | |||
current: "/index/westreamAct/page" |
@@ -14,11 +14,6 @@ Page({ | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad(options) { | |||
let positionParams = wx.getStorageSync('positionParams') | |||
let params = this.data.params | |||
params.provinceCode = positionParams.provinceCode || '' | |||
params.cityCode = positionParams.cityCode || '' | |||
params.districtCode = positionParams.districtCode || '' | |||
this.setData({ | |||
params, | |||
current: "/index/westreamKnow/page" |
@@ -1,5 +1,5 @@ | |||
// package_first/pages/upload/index.js | |||
import {getUserInfo} from '../../../utils/getUserInfo.js' | |||
import {getOpenidData} from '../../../utils/getUserInfo.js' | |||
Page({ | |||
@@ -17,11 +17,6 @@ Page({ | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad(options) { | |||
let positionParams = wx.getStorageSync('positionParams') | |||
let params = this.data.params | |||
params.provinceCode = positionParams.provinceCode || '' | |||
params.cityCode = positionParams.cityCode || '' | |||
params.districtCode = positionParams.districtCode || '' | |||
this.setData({ params }) | |||
}, | |||
@@ -43,13 +38,13 @@ Page({ | |||
}, | |||
/* 跳转上报问题页面 */ | |||
uploadBeauty(e) { | |||
const openId = wx.getStorageSync('openId') | |||
if(openId) { | |||
const openid = wx.getStorageSync('openid') | |||
if(openid) { | |||
wx.navigateTo({ | |||
url: '/package_first/pages/uploadBeauty/index', | |||
}) | |||
} else { | |||
getUserInfo().then(res=> { | |||
getOpenidData().then(res=> { | |||
wx.navigateTo({ | |||
url: '/package_first/pages/uploadBeauty/index', | |||
}) |
@@ -78,11 +78,7 @@ Page({ | |||
/* 获取河流数据 */ | |||
getRiversOption() { | |||
const positionParams = wx.getStorageSync('positionParams') | |||
const riverParams = {} | |||
riverParams.provinceCode = positionParams.provinceCode | |||
riverParams.cityCode = positionParams.cityCode | |||
riverParams.distritCode = positionParams.distritCode | |||
getRivers(riverParams).then((res)=> { | |||
if(res.code === 0) { | |||
this.setData({ | |||
@@ -254,7 +250,7 @@ Page({ | |||
}) | |||
Promise.all(temp).then((res)=> { | |||
let form = this.data.form; | |||
let openid = wx.getStorageSync('openId') | |||
let openid = wx.getStorageSync('openid') | |||
form.image = res.join(',') | |||
form.openid = openid | |||
uploadBeauty(form).then(res => { |
@@ -1,6 +1,6 @@ | |||
// pages/FirstPage/index.js | |||
import {getAnnounce, getOnlive} from '../../api/home.js' | |||
import {getUserInfo} from '../../utils/getUserInfo.js' | |||
import {getOnlive} from '../../api/home.js' | |||
import {getOpenidData} from '../../utils/getUserInfo.js' | |||
Page({ | |||
/** | |||
@@ -44,11 +44,8 @@ Page({ | |||
infoList: ['name', 'location', 'note'], | |||
liveNum: 0, // 在线人数 | |||
list: [], // 河道展示 | |||
current: '', | |||
current: '/stream/index', | |||
params: { | |||
provinceCode: '', | |||
cityCode: '', | |||
districtCode: '', | |||
page: 1, | |||
limit: 3 | |||
} | |||
@@ -61,17 +58,8 @@ Page({ | |||
this.getTabBar().setData({ | |||
selected: 0 | |||
}) | |||
let positionParams = wx.getStorageSync('positionParams') | |||
if(Object.keys(positionParams).length) { | |||
let params = this.data.params | |||
let data = {} | |||
data.provinceCode = positionParams.provinceCode || '' | |||
data.cityCode = positionParams.cityCode || '' | |||
data.districtCode = positionParams.districtCode || '' | |||
params = Object.assign(this.data.params, data) | |||
this.setData({params, current:'/stream/index'}) | |||
this.getAnnouncementList(data) | |||
} else { | |||
let tenant = wx.getStorageSync('tenant') | |||
if(!Object.keys(tenant).length) { | |||
const path = '/pages/FirstPage/index' | |||
const fromType = 'tabbar' | |||
wx.redirectTo({ | |||
@@ -84,19 +72,6 @@ Page({ | |||
// this.getOnliveNum() | |||
}, | |||
// 获取公告数据 | |||
async getAnnouncementList(data) { | |||
const params = { | |||
page: 1, | |||
limit: 1, | |||
...data | |||
} | |||
const res = await getAnnounce(params) | |||
if(res.code === 0) { | |||
const announcementList = res.data.records | |||
this.setData({announcementList}) | |||
} | |||
}, | |||
/* 更新数据 */ | |||
updateList(e) { | |||
@@ -109,16 +84,7 @@ Page({ | |||
}, | |||
// 获取在线人数 | |||
getOnliveNum() { | |||
let params = {} | |||
if(wx.getStorageSync('positionParams')) { | |||
const {provinceCode, cityCode, districtCode} = wx.getStorageSync('positionParams') | |||
params = { | |||
provinceCode: provinceCode|| '', | |||
cityCode: cityCode || '', | |||
districtCode:districtCode|| '' | |||
} | |||
} | |||
getOnlive(params).then(res=> { | |||
getOnlive().then(res=> { | |||
if(res.code === 0) { | |||
this.setData({liveNum: 21346 + res.data}) | |||
} | |||
@@ -143,10 +109,10 @@ Page({ | |||
let title = e.currentTarget.dataset.title | |||
if(title !== '敬请期待') { | |||
// 判断是否有权限 | |||
let positionParams = wx.getStorageSync('positionParams') | |||
let tenant = wx.getStorageSync('tenant') | |||
let path = e.currentTarget.dataset.path | |||
let type = e.currentTarget.dataset.type | |||
if(Object.keys(positionParams).length) { | |||
if(Object.keys(tenant).length) { | |||
if(type === 'tabbar') { | |||
wx.switchTab({ | |||
url: path, | |||
@@ -167,13 +133,13 @@ Page({ | |||
// 上报问题 | |||
uploadProblem(e) { | |||
let detail = e.currentTarget.dataset.detail | |||
let openId = wx.getStorageSync('openId') | |||
if(openId) { | |||
let openid = wx.getStorageSync('openid') | |||
if(openid) { | |||
wx.navigateTo({ | |||
url: '/package_A/pages/report/index?data=' + JSON.stringify(detail), | |||
}) | |||
} else { | |||
getUserInfo().then(res=> { | |||
getOpenidData().then(res=> { | |||
wx.navigateTo({ | |||
url: '/package_A/pages/report/index?data=' + JSON.stringify(detail), | |||
}) |
@@ -1,5 +1,5 @@ | |||
// pages/all/index.js | |||
import {getUserInfo} from '../../utils/getUserInfo.js' | |||
import {getOpenidData} from '../../utils/getUserInfo.js' | |||
import {getCityTree} from '../../api/feeddback.js' | |||
Page({ | |||
@@ -13,7 +13,7 @@ Page({ | |||
}, | |||
name: '', | |||
list: [], | |||
current: "", | |||
current: "/stream/index", | |||
}, | |||
/** | |||
@@ -23,20 +23,6 @@ Page({ | |||
this.getTabBar().setData({ | |||
selected: 1 | |||
}) | |||
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 { | |||
const path = '/pages/all/index' | |||
const fromType = 'tabbar' | |||
wx.redirectTo({ | |||
url: `/pages/login/login?path=${path}&fromType=${fromType}`, | |||
}) | |||
} | |||
}, | |||
/** | |||
@@ -66,13 +52,13 @@ Page({ | |||
/* 跳转上报问题页面 */ | |||
uploadProblem(e) { | |||
let detail = e.currentTarget.dataset.detail | |||
let openId = wx.getStorageSync('openId') | |||
if(openId) { | |||
let openid = wx.getStorageSync('openid') | |||
if(openid) { | |||
wx.navigateTo({ | |||
url: '/package_A/pages/report/index?data=' + JSON.stringify(detail), | |||
}) | |||
} else { | |||
getUserInfo().then(res=> { | |||
getOpenidData().then(res=> { | |||
wx.navigateTo({ | |||
url: '/package_A/pages/report/index?data=' + JSON.stringify(detail), | |||
}) |
@@ -1,6 +1,7 @@ | |||
// pages/login/login.js | |||
import {getCityTree} from '../../api/feeddback.js' | |||
import {getCityNameCode, getTenantData} from '../../api/login.js' | |||
import {getCityNameCode, getTenantData, getUserData, enterMini} from '../../api/login.js' | |||
import {getOpenidData, getUserMessage} from '../../utils/getUserInfo.js' | |||
import {getLocatonPermission} from '../../utils/getUserLocation.js' | |||
Page({ | |||
@@ -86,6 +87,10 @@ Page({ | |||
districtCurrent: positionParams.districtCurrent, | |||
districtOptions: positionParams.districtOptions | |||
}) | |||
wx.setStorage({ | |||
key: 'positionParams', | |||
data: positionParams | |||
}) | |||
} else { | |||
this.getUserLocation() | |||
} | |||
@@ -97,6 +102,14 @@ Page({ | |||
const {tenantCurrent, tenantId} = tenantObj | |||
this.setData({tenantCurrent, tenantId}) | |||
} | |||
const openid = wx.getStorageSync('openid') | |||
if(openid) { | |||
this.setData({openid}) | |||
} else { | |||
getOpenidData().then(res=> { | |||
this.setData({openid: res.openid}) | |||
}) | |||
} | |||
}, | |||
validate(name) { | |||
let formRules = this.data.formRules; | |||
@@ -282,28 +295,25 @@ Page({ | |||
goHome() { | |||
this.validateForm().then(res => { | |||
if(res) { | |||
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.cityOptions = this.data.cityOptions | |||
positionParams.districtOptions = this.data.districtOptions | |||
wx.setStorage({ | |||
key: 'positionParams', | |||
data: positionParams | |||
const params = {} | |||
params.tenantId = this.data.tenantId | |||
params.openid = this.data.openid | |||
enterMini(params).then(item=> { | |||
if(item.code === 0) { | |||
// 进入首页 | |||
const path = this.data.path | |||
const fromType = this.data.fromType | |||
if(fromType === 'page') { | |||
wx.redirectTo({ | |||
url: path, | |||
}) | |||
} else { | |||
wx.switchTab({ | |||
url: path, | |||
}) | |||
} | |||
} | |||
}) | |||
const path = this.data.path | |||
const fromType = this.data.fromType | |||
if(fromType === 'page') { | |||
wx.redirectTo({ | |||
url: path, | |||
}) | |||
} else { | |||
wx.switchTab({ | |||
url: path, | |||
}) | |||
} | |||
} | |||
}) | |||
} |
@@ -1,38 +1,20 @@ | |||
import {getOpenId, getUserData} from '../api/login.js' | |||
export function getUserInfo() { | |||
export function getOpenidData() { | |||
return new Promise((resolve)=> { | |||
wx.getUserProfile({ | |||
desc: '用于完善会员资料', | |||
success: (r)=> { | |||
wx.login({ | |||
success: result=> { | |||
let code = result.code | |||
getOpenId(code).then(i=> { | |||
if(i.code === 0) { | |||
const openId = i.data | |||
getUserData(openId).then(m=> { | |||
let userInfo = {} | |||
userInfo.nickname = m.data.nickname | |||
userInfo.headimgurl = m.data.headimgurl | |||
wx.setStorage({ | |||
key: 'openId', | |||
data: openId | |||
}) | |||
wx.setStorage({ | |||
key: 'userInfo', | |||
data:userInfo | |||
}) | |||
resolve({ | |||
openId: openId, | |||
userInfo: userInfo | |||
}) | |||
}) | |||
} | |||
}) | |||
} | |||
}) | |||
} | |||
wx.login({ | |||
success: result=> { | |||
let code = result.code | |||
getOpenId(code).then(i=> { | |||
if(i.code === 0) { | |||
const openid = i.data | |||
wx.setStorage({ | |||
key: 'openid', | |||
data: openid | |||
}) | |||
resolve({openid}) | |||
} | |||
}) | |||
} | |||
}) | |||
}) | |||
} | |||
} |