作者 niufei

应微信审核要求,修改用户登录逻辑和分享逻辑

... ... @@ -54,7 +54,10 @@ App({
success: function(res) { //返回取得的数据
if (res.data.code == '20000') {
resolve(res.data.data);
} else if (res.data.code == '10001') { //用户未
} else if (res.data.code == '10001') { //用户未登录
wx.reLaunch({
url: "/pages/start/start"
})
} else if (res.data.code == '40000') {
wx.showModal({
... ...
{
"pages": [
"pages/index/index",
"pages/start/start",
"pages/index/index",
"pages/my/my",
"pages/more/more",
"pages/admin/admin",
... ...
... ... @@ -169,7 +169,6 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
console.log(options)
wx.setNavigationBarTitle({
title: options.type == 2 ? '志愿者工时管理' : '志愿者审核',
})
... ...
... ... @@ -175,47 +175,7 @@ Page({
// type: parseInt(e.detail.value) +1
// })
// },
start(e) {
let that = this;
let tem = e.currentTarget.dataset.tem;
app.globalData.userInfo = e.detail.userInfo;
wx.login({
success: function(s) {
let url = 'wxapp/public/getSessionKey';
if (s.code) {
var code = s.code;
var param = {
code: code
}
app.post(url, param).then((res) => {
that.login(res.openid, res.session_key, e.detail.encryptedData, e.detail.iv, tem);
}).catch((errMsg) => {
})
}
}
});
},
login(openid, session_key, encrypted_data, iv, tem) {
let that = this;
let param = {
openid: openid,
session_key: session_key,
encrypted_data: encrypted_data,
iv: iv
}
let url = 'wxapp/public/login';
app.post(url, param).then((res) => {
wx.setStorageSync('token', res.token);
that.setData({
ifempower: true
})
that.uploadImage(tem);
}).catch((errMsg) => {
})
},
//选择省市区
getarea() {
let that = this;
... ...
<view class='avator_box' wx:if="{{!page_type}}">
<view class='upimg' bindtap='{{ifempower?"uploadImages":""}}' data-tem='1'>
<!-- <button open-type='getUserInfo' bindgetuserinfo='start' class='inofbtn' if='{{!ifempower}}' data-tem='1'></button> -->
<image src='{{photo}}' wx:if='{{photo}}' mode="aspectFill"></image>
<view class='iconfont icon-xiangji' wx:if='{{!photo}}'></view>
</view>
... ...
... ... @@ -278,15 +278,6 @@
justify-content: center;
}
.inofbtn {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 10;
opacity: 0;
}
.applybtn:active {
opacity: 0.7;
... ...
... ... @@ -13,7 +13,7 @@ Page({
cover_type: false
},
//查看更多报名用户信息(审核端)
look_more(e){
look_more(e) {
wx.navigateTo({
url: '/pages/enroll/enroll?status=' + e.currentTarget.dataset.status + '&id=' + this.data.id + '&user_id=' + e.currentTarget.dataset.user_id + '&join_id=' + e.currentTarget.dataset.join_id
})
... ... @@ -37,10 +37,10 @@ Page({
})
},
//保存海报到本地
save_poster(){
save_poster() {
wx.downloadFile({
url: this.data.poster,
success: (res)=>{
success: (res) => {
if (res.statusCode === 200) {
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
... ... @@ -55,7 +55,7 @@ Page({
}
}
})
},
// 改变弹窗状态
change_cover(e) {
... ... @@ -147,7 +147,7 @@ Page({
datalist: res,
"datalist.button_status": Number(res.button_status)
})
if (that.data.status == '1'){
if (that.data.status == '1') {
that.get_poster()
that.join_info()
}
... ... @@ -180,7 +180,7 @@ Page({
get_token() {
let that = this
wx.login({
success: function (s) {
success: function(s) {
let url = 'wxapp/public/getSessionKey';
if (s.code) {
var code = s.code;
... ... @@ -211,12 +211,52 @@ Page({
}
});
},
start(e) {
let that = this
wx.login({
success: function (s) {
let url = 'wxapp/public/getSessionKey';
if (s.code) {
var code = s.code;
var param = {
code: code
}
app.post(url, param).then((res) => {
that.login(res.openid, res.session_key)
}).catch((errMsg) => {
})
}
}
});
},
login(openid, session_key) {
wx.showLoading({
title: '加载中',
})
let that = this
let param = {
openid: openid,
session_key: session_key
}
let url = 'wxapp/public/get_token'
app.post(url, param).then((res) => {
wx.setStorageSync('token', res.token)
wx.hideLoading()
that.getdatalist()
}).catch((errMsg) => {
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
let that = this
if (options.scene){
if (options.scene) {
wx.setNavigationBarTitle({
title: '活动详情'
})
... ... @@ -224,13 +264,7 @@ Page({
status: 1,
id: options.scene
})
if (wx.getStorageSync('token')){
that.getdatalist();
} else {
wx.reLaunch({
url: '/pages/start/start?id=' + options.scene + '&type=1',
})
}
that.start()
} else {
if (options.type == 1) {
wx.setNavigationBarTitle({
... ... @@ -272,8 +306,8 @@ Page({
that.getSystemInfo()
}
}
},
... ... @@ -288,7 +322,8 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function() {
if (wx.getStorageSync('page_type')){
wx.hideShareMenu()
if (wx.getStorageSync('page_type')) {
wx.removeStorageSync('page_type')
this.getdatalist()
}
... ...
... ... @@ -48,52 +48,12 @@ Page({
})
},
//判断是否登陆
get_token() {
let that = this;
wx.login({
success: function(s) {
let url = 'wxapp/public/getSessionKey';
if (s.code) {
var code = s.code;
var param = {
code: code
}
app.post(url, param).then((res) => {
let url = 'wxapp/public/get_token'
let params = {
openid: res.openid
}
app.post(url, params).then((res) => {
if (res.data) {
wx.setStorageSync('token', res.data);
that.setData({
datalist: [],
activity_page: 0,
activity: []
})
that.getdatalist();
} else {
wx.redirectTo({
url: '/pages/start/start'
})
}
}).catch((err) => {
})
}).catch((errMsg) => {
})
}
}
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
let that = this
that.get_token()
wx.hideShareMenu()
},
/**
... ... @@ -107,7 +67,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function() {
this.getdatalist()
},
... ... @@ -136,19 +96,7 @@ Page({
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
// let that = this
// if (that.data.page_type == false) {
// wx.showToast({
// title: '暂无更多数据',
// icon: 'none',
// duration: 1000
// })
// return false
// }
// that.setData({
// activity_page: that.data.activity_page + 1
// })
// that.getdatalist()
},
/**
... ...
... ... @@ -34,7 +34,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
wx.hideShareMenu()
},
/**
... ...
// pages/start/start.js
const app = getApp();
Page({
... ... @@ -9,11 +8,7 @@ Page({
},
start(e) {
let that = this;
app.globalData.userInfo = e.detail.userInfo;
// wx.switchTab({
// url: '/pages/index/index'
// })
let that = this
wx.login({
success: function(s) {
let url = 'wxapp/public/getSessionKey';
... ... @@ -23,7 +18,7 @@ Page({
code: code
}
app.post(url, param).then((res) => {
that.login(res.openid, res.session_key, e.detail.encryptedData, e.detail.iv);
that.login(res.openid, res.session_key)
}).catch((errMsg) => {
})
... ... @@ -31,27 +26,26 @@ Page({
}
});
},
login(openid, session_key, encrypted_data, iv) {
let that = this;
login(openid, session_key) {
let that = this
let param = {
openid: openid,
session_key: session_key,
encrypted_data: encrypted_data,
iv: iv
session_key: session_key
}
let url = 'wxapp/public/login';
let url = 'wxapp/public/get_token'
app.post(url, param).then((res) => {
wx.setStorageSync('token', res.token);
if(that.data.type){
wx.reLaunch({
url: "/pages/img_txt/img_txt?id=" + this.data.id + '&status=1',
})
} else {
wx.showLoading({
title: '正在开启',
mask: true
})
wx.setStorageSync('token', res.token)
setTimeout(() => {
wx.hideLoading()
wx.switchTab({
url: '/pages/index/index',
url: '/pages/index/index'
})
}
}, 1500)
}).catch((errMsg) => {
})
... ... @@ -61,12 +55,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
if (options.type){
this.setData({
type: true,
id: options.id
})
}
this.start()
},
/**
... ...
<view class='start'>
<view class='start_main'>
<view class='start_mainimg'>
<image src='../../imgs/renwu@2x.png'></image>
<image src='/imgs/renwu@2x.png'></image>
</view>
<view class='start_bigtxt'>白求恩志愿者服务队</view>
<view class='start_minitxt'>Bethune Volunteer Service Team</view>
</view>
<button class='start_btn' open-type='getUserInfo' bindgetuserinfo='start'>立即开启</button>
<image src='../../imgs/qidongye_bg@2x.png'></image>
<view class='start_btn'>立即开启</view>
<image src='/imgs/qidongye_bg@2x.png'></image>
</view>
\ No newline at end of file
... ...
... ... @@ -40,7 +40,7 @@ Page({
})
return
}
wx. ({
wx.chooseImage({
count: allow_image,
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
... ...
... ... @@ -29,10 +29,10 @@
<view class="title">图片上传</view>
<view class="img_arr">
<view class="img_item" wx:for="{{imgarr}}" wx:key="index">
<image src="{{item}}" mode="aspectFill" class="show_img" catchtap="look_img" data-index="{{index}}"/>
<image class="del" src="/imgs/del.png" catchtap="del_img" data-index="{{index}}" wx:if="{{!user_id}}"/>
<image src="{{item}}" mode="aspectFill" class="show_img" catchtap="look_img" data-index="{{index}}" />
<image class="del" src="/imgs/del.png" catchtap="del_img" data-index="{{index}}" wx:if="{{!user_id}}" />
</view>
<image class="img_item" src="/imgs/add_img.png" mode="aspectFill" bindtap="upimg" wx:if="{{!user_id}}"/>
<image class="img_item" src="/imgs/add_img.png" mode="aspectFill" bindtap="upimg" wx:if="{{!user_id}}" />
</view>
</view>
... ... @@ -42,7 +42,7 @@
<view class="title">
<image src="/imgs/must.png" /> 感想汇报
</view>
<textarea class="word" placeholder="请输入内容,内容最多500字" bindinput="get_word" value="{{word}}" disabled="{{user_id}}"/>
<textarea class="word" placeholder="请输入内容,内容最多500字" bindinput="get_word" value="{{word}}" disabled="{{user_id}}" />
</view>
<view class="submit" bindtap="submit" wx:if="{{!user_id}}">确认</view>
\ No newline at end of file
... ...