Selaa lähdekoodia

1944

pull/8/head
余菲 1 vuosi sitten
vanhempi
commit
127e558a9b
11 muutettua tiedostoa jossa 73 lisäystä ja 149 poistoa
  1. +2
    -2
      package_A/pages/report/index.js
  2. +1
    -1
      package_B/pages/beauties/index.js
  3. +1
    -1
      package_B/pages/records/index.js
  4. +0
    -6
      package_first/pages/announceList/index.js
  5. +0
    -5
      package_first/pages/askAdmin/index.js
  6. +4
    -9
      package_first/pages/beautyList/index.js
  7. +1
    -5
      package_first/pages/uploadBeauty/index.js
  8. +11
    -45
      pages/FirstPage/index.js
  9. +5
    -19
      pages/all/index.js
  10. +32
    -22
      pages/login/login.js
  11. +16
    -34
      utils/getUserInfo.js

+ 2
- 2
package_A/pages/report/index.js Näytä tiedosto

*/ */
onShow: function () { onShow: function () {
this.getOssAuthForm() this.getOssAuthForm()
const openId = wx.getStorageSync('openId')
const openid = wx.getStorageSync('openid')
let form = this.data.form let form = this.data.form
form.openid = openId
form.openid = openid
this.setData({form}) this.setData({form})
}, },
bindValue(e) { bindValue(e) {

+ 1
- 1
package_B/pages/beauties/index.js Näytä tiedosto

* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
const openid = wx.getStorageSync('openId')
const openid = wx.getStorageSync('openid')
let params = this.data.params let params = this.data.params
params.openid = openid params.openid = openid
this.setData({params}) this.setData({params})

+ 1
- 1
package_B/pages/records/index.js Näytä tiedosto

*/ */
onLoad: function (options) { onLoad: function (options) {
let params = this.data.params let params = this.data.params
params.openid = wx.getStorageSync('openId')
params.openid = wx.getStorageSync('openid')
this.setData({params}) this.setData({params})
}, },



+ 0
- 6
package_first/pages/announceList/index.js Näytä tiedosto

current: "", current: "",
}, },
onLoad: function() { 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({ this.setData({
params, params,
current: "/index/westreamAct/page" current: "/index/westreamAct/page"

+ 0
- 5
package_first/pages/askAdmin/index.js Näytä tiedosto

* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { 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({ this.setData({
params, params,
current: "/index/westreamKnow/page" current: "/index/westreamKnow/page"

+ 4
- 9
package_first/pages/beautyList/index.js Näytä tiedosto

// package_first/pages/upload/index.js // package_first/pages/upload/index.js
import {getUserInfo} from '../../../utils/getUserInfo.js'
import {getOpenidData} from '../../../utils/getUserInfo.js'


Page({ Page({


* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { 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 }) this.setData({ params })
}, },


}, },
/* 跳转上报问题页面 */ /* 跳转上报问题页面 */
uploadBeauty(e) { uploadBeauty(e) {
const openId = wx.getStorageSync('openId')
if(openId) {
const openid = wx.getStorageSync('openid')
if(openid) {
wx.navigateTo({ wx.navigateTo({
url: '/package_first/pages/uploadBeauty/index', url: '/package_first/pages/uploadBeauty/index',
}) })
} else { } else {
getUserInfo().then(res=> {
getOpenidData().then(res=> {
wx.navigateTo({ wx.navigateTo({
url: '/package_first/pages/uploadBeauty/index', url: '/package_first/pages/uploadBeauty/index',
}) })

+ 1
- 5
package_first/pages/uploadBeauty/index.js Näytä tiedosto



/* 获取河流数据 */ /* 获取河流数据 */
getRiversOption() { getRiversOption() {
const positionParams = wx.getStorageSync('positionParams')
const riverParams = {} const riverParams = {}
riverParams.provinceCode = positionParams.provinceCode
riverParams.cityCode = positionParams.cityCode
riverParams.distritCode = positionParams.distritCode
getRivers(riverParams).then((res)=> { getRivers(riverParams).then((res)=> {
if(res.code === 0) { if(res.code === 0) {
this.setData({ this.setData({
}) })
Promise.all(temp).then((res)=> { Promise.all(temp).then((res)=> {
let form = this.data.form; let form = this.data.form;
let openid = wx.getStorageSync('openId')
let openid = wx.getStorageSync('openid')
form.image = res.join(',') form.image = res.join(',')
form.openid = openid form.openid = openid
uploadBeauty(form).then(res => { uploadBeauty(form).then(res => {

+ 11
- 45
pages/FirstPage/index.js Näytä tiedosto

// pages/FirstPage/index.js // 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({ Page({


/** /**
infoList: ['name', 'location', 'note'], infoList: ['name', 'location', 'note'],
liveNum: 0, // 在线人数 liveNum: 0, // 在线人数
list: [], // 河道展示 list: [], // 河道展示
current: '',
current: '/stream/index',
params: { params: {
provinceCode: '',
cityCode: '',
districtCode: '',
page: 1, page: 1,
limit: 3 limit: 3
} }
this.getTabBar().setData({ this.getTabBar().setData({
selected: 0 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 path = '/pages/FirstPage/index'
const fromType = 'tabbar' const fromType = 'tabbar'
wx.redirectTo({ wx.redirectTo({
// this.getOnliveNum() // 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) { updateList(e) {
}, },
// 获取在线人数 // 获取在线人数
getOnliveNum() { 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) { if(res.code === 0) {
this.setData({liveNum: 21346 + res.data}) this.setData({liveNum: 21346 + res.data})
} }
let title = e.currentTarget.dataset.title let title = e.currentTarget.dataset.title
if(title !== '敬请期待') { if(title !== '敬请期待') {
// 判断是否有权限 // 判断是否有权限
let positionParams = wx.getStorageSync('positionParams')
let tenant = wx.getStorageSync('tenant')
let path = e.currentTarget.dataset.path let path = e.currentTarget.dataset.path
let type = e.currentTarget.dataset.type let type = e.currentTarget.dataset.type
if(Object.keys(positionParams).length) {
if(Object.keys(tenant).length) {
if(type === 'tabbar') { if(type === 'tabbar') {
wx.switchTab({ wx.switchTab({
url: path, url: path,
// 上报问题 // 上报问题
uploadProblem(e) { uploadProblem(e) {
let detail = e.currentTarget.dataset.detail let detail = e.currentTarget.dataset.detail
let openId = wx.getStorageSync('openId')
if(openId) {
let openid = wx.getStorageSync('openid')
if(openid) {
wx.navigateTo({ wx.navigateTo({
url: '/package_A/pages/report/index?data=' + JSON.stringify(detail), url: '/package_A/pages/report/index?data=' + JSON.stringify(detail),
}) })
} else { } else {
getUserInfo().then(res=> {
getOpenidData().then(res=> {
wx.navigateTo({ wx.navigateTo({
url: '/package_A/pages/report/index?data=' + JSON.stringify(detail), url: '/package_A/pages/report/index?data=' + JSON.stringify(detail),
}) })

+ 5
- 19
pages/all/index.js Näytä tiedosto

// pages/all/index.js // pages/all/index.js
import {getUserInfo} from '../../utils/getUserInfo.js'
import {getOpenidData} from '../../utils/getUserInfo.js'
import {getCityTree} from '../../api/feeddback.js' import {getCityTree} from '../../api/feeddback.js'
Page({ Page({


}, },
name: '', name: '',
list: [], list: [],
current: "",
current: "/stream/index",
}, },


/** /**
this.getTabBar().setData({ this.getTabBar().setData({
selected: 1 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}`,
})
}
}, },


/** /**
/* 跳转上报问题页面 */ /* 跳转上报问题页面 */
uploadProblem(e) { uploadProblem(e) {
let detail = e.currentTarget.dataset.detail let detail = e.currentTarget.dataset.detail
let openId = wx.getStorageSync('openId')
if(openId) {
let openid = wx.getStorageSync('openid')
if(openid) {
wx.navigateTo({ wx.navigateTo({
url: '/package_A/pages/report/index?data=' + JSON.stringify(detail), url: '/package_A/pages/report/index?data=' + JSON.stringify(detail),
}) })
} else { } else {
getUserInfo().then(res=> {
getOpenidData().then(res=> {
wx.navigateTo({ wx.navigateTo({
url: '/package_A/pages/report/index?data=' + JSON.stringify(detail), url: '/package_A/pages/report/index?data=' + JSON.stringify(detail),
}) })

+ 32
- 22
pages/login/login.js Näytä tiedosto

// pages/login/login.js // pages/login/login.js
import {getCityTree} from '../../api/feeddback.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' import {getLocatonPermission} from '../../utils/getUserLocation.js'
Page({ Page({


districtCurrent: positionParams.districtCurrent, districtCurrent: positionParams.districtCurrent,
districtOptions: positionParams.districtOptions districtOptions: positionParams.districtOptions
}) })
wx.setStorage({
key: 'positionParams',
data: positionParams
})
} else { } else {
this.getUserLocation() this.getUserLocation()
} }
const {tenantCurrent, tenantId} = tenantObj const {tenantCurrent, tenantId} = tenantObj
this.setData({tenantCurrent, tenantId}) 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) { validate(name) {
let formRules = this.data.formRules; let formRules = this.data.formRules;
goHome() { goHome() {
this.validateForm().then(res => { this.validateForm().then(res => {
if(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,
})
}
} }
}) })
} }

+ 16
- 34
utils/getUserInfo.js Näytä tiedosto

import {getOpenId, getUserData} from '../api/login.js' import {getOpenId, getUserData} from '../api/login.js'
export function getUserInfo() {
export function getOpenidData() {
return new Promise((resolve)=> { 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})
}
})
}
}) })
}) })
}
}

Loading…
Peruuta
Tallenna