作者 niufei

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

@@ -54,7 +54,10 @@ App({ @@ -54,7 +54,10 @@ App({
54 success: function(res) { //返回取得的数据 54 success: function(res) { //返回取得的数据
55 if (res.data.code == '20000') { 55 if (res.data.code == '20000') {
56 resolve(res.data.data); 56 resolve(res.data.data);
57 - } else if (res.data.code == '10001') { //用户未 57 + } else if (res.data.code == '10001') { //用户未登录
  58 + wx.reLaunch({
  59 + url: "/pages/start/start"
  60 + })
58 61
59 } else if (res.data.code == '40000') { 62 } else if (res.data.code == '40000') {
60 wx.showModal({ 63 wx.showModal({
1 { 1 {
2 "pages": [ 2 "pages": [
3 - "pages/index/index",  
4 "pages/start/start", 3 "pages/start/start",
  4 + "pages/index/index",
5 "pages/my/my", 5 "pages/my/my",
6 "pages/more/more", 6 "pages/more/more",
7 "pages/admin/admin", 7 "pages/admin/admin",
@@ -169,7 +169,6 @@ Page({ @@ -169,7 +169,6 @@ Page({
169 * 生命周期函数--监听页面加载 169 * 生命周期函数--监听页面加载
170 */ 170 */
171 onLoad: function(options) { 171 onLoad: function(options) {
172 - console.log(options)  
173 wx.setNavigationBarTitle({ 172 wx.setNavigationBarTitle({
174 title: options.type == 2 ? '志愿者工时管理' : '志愿者审核', 173 title: options.type == 2 ? '志愿者工时管理' : '志愿者审核',
175 }) 174 })
@@ -175,47 +175,7 @@ Page({ @@ -175,47 +175,7 @@ Page({
175 // type: parseInt(e.detail.value) +1 175 // type: parseInt(e.detail.value) +1
176 // }) 176 // })
177 // }, 177 // },
178 - start(e) {  
179 - let that = this;  
180 - let tem = e.currentTarget.dataset.tem;  
181 - app.globalData.userInfo = e.detail.userInfo;  
182 - wx.login({  
183 - success: function(s) {  
184 - let url = 'wxapp/public/getSessionKey';  
185 - if (s.code) {  
186 - var code = s.code;  
187 - var param = {  
188 - code: code  
189 - }  
190 - app.post(url, param).then((res) => {  
191 - that.login(res.openid, res.session_key, e.detail.encryptedData, e.detail.iv, tem);  
192 - }).catch((errMsg) => {  
193 -  
194 - })  
195 - }  
196 - }  
197 - });  
198 - },  
199 - login(openid, session_key, encrypted_data, iv, tem) {  
200 - let that = this;  
201 - let param = {  
202 - openid: openid,  
203 - session_key: session_key,  
204 - encrypted_data: encrypted_data,  
205 - iv: iv  
206 - }  
207 - let url = 'wxapp/public/login';  
208 - app.post(url, param).then((res) => {  
209 - wx.setStorageSync('token', res.token);  
210 - that.setData({  
211 - ifempower: true  
212 - })  
213 - that.uploadImage(tem);  
214 - }).catch((errMsg) => {  
215 -  
216 - })  
217 - },  
218 - 178 +
219 //选择省市区 179 //选择省市区
220 getarea() { 180 getarea() {
221 let that = this; 181 let that = this;
1 <view class='avator_box' wx:if="{{!page_type}}"> 1 <view class='avator_box' wx:if="{{!page_type}}">
2 <view class='upimg' bindtap='{{ifempower?"uploadImages":""}}' data-tem='1'> 2 <view class='upimg' bindtap='{{ifempower?"uploadImages":""}}' data-tem='1'>
3 - <!-- <button open-type='getUserInfo' bindgetuserinfo='start' class='inofbtn' if='{{!ifempower}}' data-tem='1'></button> -->  
4 <image src='{{photo}}' wx:if='{{photo}}' mode="aspectFill"></image> 3 <image src='{{photo}}' wx:if='{{photo}}' mode="aspectFill"></image>
5 <view class='iconfont icon-xiangji' wx:if='{{!photo}}'></view> 4 <view class='iconfont icon-xiangji' wx:if='{{!photo}}'></view>
6 </view> 5 </view>
@@ -278,15 +278,6 @@ @@ -278,15 +278,6 @@
278 justify-content: center; 278 justify-content: center;
279 } 279 }
280 280
281 -.inofbtn {  
282 - position: absolute;  
283 - top: 0;  
284 - left: 0;  
285 - width: 100%;  
286 - height: 100%;  
287 - z-index: 10;  
288 - opacity: 0;  
289 -}  
290 281
291 .applybtn:active { 282 .applybtn:active {
292 opacity: 0.7; 283 opacity: 0.7;
@@ -13,7 +13,7 @@ Page({ @@ -13,7 +13,7 @@ Page({
13 cover_type: false 13 cover_type: false
14 }, 14 },
15 //查看更多报名用户信息(审核端) 15 //查看更多报名用户信息(审核端)
16 - look_more(e){ 16 + look_more(e) {
17 wx.navigateTo({ 17 wx.navigateTo({
18 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 18 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
19 }) 19 })
@@ -37,10 +37,10 @@ Page({ @@ -37,10 +37,10 @@ Page({
37 }) 37 })
38 }, 38 },
39 //保存海报到本地 39 //保存海报到本地
40 - save_poster(){ 40 + save_poster() {
41 wx.downloadFile({ 41 wx.downloadFile({
42 url: this.data.poster, 42 url: this.data.poster,
43 - success: (res)=>{ 43 + success: (res) => {
44 if (res.statusCode === 200) { 44 if (res.statusCode === 200) {
45 wx.saveImageToPhotosAlbum({ 45 wx.saveImageToPhotosAlbum({
46 filePath: res.tempFilePath, 46 filePath: res.tempFilePath,
@@ -55,7 +55,7 @@ Page({ @@ -55,7 +55,7 @@ Page({
55 } 55 }
56 } 56 }
57 }) 57 })
58 - 58 +
59 }, 59 },
60 // 改变弹窗状态 60 // 改变弹窗状态
61 change_cover(e) { 61 change_cover(e) {
@@ -147,7 +147,7 @@ Page({ @@ -147,7 +147,7 @@ Page({
147 datalist: res, 147 datalist: res,
148 "datalist.button_status": Number(res.button_status) 148 "datalist.button_status": Number(res.button_status)
149 }) 149 })
150 - if (that.data.status == '1'){ 150 + if (that.data.status == '1') {
151 that.get_poster() 151 that.get_poster()
152 that.join_info() 152 that.join_info()
153 } 153 }
@@ -180,7 +180,7 @@ Page({ @@ -180,7 +180,7 @@ Page({
180 get_token() { 180 get_token() {
181 let that = this 181 let that = this
182 wx.login({ 182 wx.login({
183 - success: function (s) { 183 + success: function(s) {
184 let url = 'wxapp/public/getSessionKey'; 184 let url = 'wxapp/public/getSessionKey';
185 if (s.code) { 185 if (s.code) {
186 var code = s.code; 186 var code = s.code;
@@ -211,12 +211,52 @@ Page({ @@ -211,12 +211,52 @@ Page({
211 } 211 }
212 }); 212 });
213 }, 213 },
  214 +
  215 +
  216 +
  217 + start(e) {
  218 + let that = this
  219 + wx.login({
  220 + success: function (s) {
  221 + let url = 'wxapp/public/getSessionKey';
  222 + if (s.code) {
  223 + var code = s.code;
  224 + var param = {
  225 + code: code
  226 + }
  227 + app.post(url, param).then((res) => {
  228 + that.login(res.openid, res.session_key)
  229 + }).catch((errMsg) => {
  230 +
  231 + })
  232 + }
  233 + }
  234 + });
  235 + },
  236 + login(openid, session_key) {
  237 + wx.showLoading({
  238 + title: '加载中',
  239 + })
  240 + let that = this
  241 + let param = {
  242 + openid: openid,
  243 + session_key: session_key
  244 + }
  245 + let url = 'wxapp/public/get_token'
  246 + app.post(url, param).then((res) => {
  247 + wx.setStorageSync('token', res.token)
  248 + wx.hideLoading()
  249 + that.getdatalist()
  250 + }).catch((errMsg) => {
  251 +
  252 + })
  253 + },
214 /** 254 /**
215 * 生命周期函数--监听页面加载 255 * 生命周期函数--监听页面加载
216 */ 256 */
217 onLoad: function(options) { 257 onLoad: function(options) {
218 let that = this 258 let that = this
219 - if (options.scene){ 259 + if (options.scene) {
220 wx.setNavigationBarTitle({ 260 wx.setNavigationBarTitle({
221 title: '活动详情' 261 title: '活动详情'
222 }) 262 })
@@ -224,13 +264,7 @@ Page({ @@ -224,13 +264,7 @@ Page({
224 status: 1, 264 status: 1,
225 id: options.scene 265 id: options.scene
226 }) 266 })
227 - if (wx.getStorageSync('token')){  
228 - that.getdatalist();  
229 - } else {  
230 - wx.reLaunch({  
231 - url: '/pages/start/start?id=' + options.scene + '&type=1',  
232 - })  
233 - } 267 + that.start()
234 } else { 268 } else {
235 if (options.type == 1) { 269 if (options.type == 1) {
236 wx.setNavigationBarTitle({ 270 wx.setNavigationBarTitle({
@@ -272,8 +306,8 @@ Page({ @@ -272,8 +306,8 @@ Page({
272 that.getSystemInfo() 306 that.getSystemInfo()
273 } 307 }
274 } 308 }
275 -  
276 - 309 +
  310 +
277 311
278 }, 312 },
279 313
@@ -288,7 +322,8 @@ Page({ @@ -288,7 +322,8 @@ Page({
288 * 生命周期函数--监听页面显示 322 * 生命周期函数--监听页面显示
289 */ 323 */
290 onShow: function() { 324 onShow: function() {
291 - if (wx.getStorageSync('page_type')){ 325 + wx.hideShareMenu()
  326 + if (wx.getStorageSync('page_type')) {
292 wx.removeStorageSync('page_type') 327 wx.removeStorageSync('page_type')
293 this.getdatalist() 328 this.getdatalist()
294 } 329 }
@@ -48,52 +48,12 @@ Page({ @@ -48,52 +48,12 @@ Page({
48 48
49 }) 49 })
50 }, 50 },
51 - //判断是否登陆  
52 - get_token() {  
53 - let that = this;  
54 - wx.login({  
55 - success: function(s) {  
56 - let url = 'wxapp/public/getSessionKey';  
57 - if (s.code) {  
58 - var code = s.code;  
59 - var param = {  
60 - code: code  
61 - }  
62 - app.post(url, param).then((res) => {  
63 - let url = 'wxapp/public/get_token'  
64 - let params = {  
65 - openid: res.openid  
66 - }  
67 - app.post(url, params).then((res) => {  
68 - if (res.data) {  
69 - wx.setStorageSync('token', res.data);  
70 - that.setData({  
71 - datalist: [],  
72 - activity_page: 0,  
73 - activity: []  
74 - })  
75 - that.getdatalist();  
76 - } else {  
77 - wx.redirectTo({  
78 - url: '/pages/start/start'  
79 - })  
80 - }  
81 - }).catch((err) => {  
82 -  
83 - })  
84 - }).catch((errMsg) => {  
85 -  
86 - })  
87 - }  
88 - }  
89 - });  
90 - }, 51 +
91 /** 52 /**
92 * 生命周期函数--监听页面加载 53 * 生命周期函数--监听页面加载
93 */ 54 */
94 onLoad: function(options) { 55 onLoad: function(options) {
95 - let that = this  
96 - that.get_token() 56 + wx.hideShareMenu()
97 }, 57 },
98 58
99 /** 59 /**
@@ -107,7 +67,7 @@ Page({ @@ -107,7 +67,7 @@ Page({
107 * 生命周期函数--监听页面显示 67 * 生命周期函数--监听页面显示
108 */ 68 */
109 onShow: function() { 69 onShow: function() {
110 - 70 + this.getdatalist()
111 71
112 }, 72 },
113 73
@@ -136,19 +96,7 @@ Page({ @@ -136,19 +96,7 @@ Page({
136 * 页面上拉触底事件的处理函数 96 * 页面上拉触底事件的处理函数
137 */ 97 */
138 onReachBottom: function() { 98 onReachBottom: function() {
139 - // let that = this  
140 - // if (that.data.page_type == false) {  
141 - // wx.showToast({  
142 - // title: '暂无更多数据',  
143 - // icon: 'none',  
144 - // duration: 1000  
145 - // })  
146 - // return false  
147 - // }  
148 - // that.setData({  
149 - // activity_page: that.data.activity_page + 1  
150 - // })  
151 - // that.getdatalist() 99 +
152 }, 100 },
153 101
154 /** 102 /**
@@ -34,7 +34,7 @@ Page({ @@ -34,7 +34,7 @@ Page({
34 * 生命周期函数--监听页面加载 34 * 生命周期函数--监听页面加载
35 */ 35 */
36 onLoad: function(options) { 36 onLoad: function(options) {
37 - 37 + wx.hideShareMenu()
38 }, 38 },
39 39
40 /** 40 /**
1 -// pages/start/start.js  
2 const app = getApp(); 1 const app = getApp();
3 Page({ 2 Page({
4 3
@@ -9,11 +8,7 @@ Page({ @@ -9,11 +8,7 @@ Page({
9 8
10 }, 9 },
11 start(e) { 10 start(e) {
12 - let that = this;  
13 - app.globalData.userInfo = e.detail.userInfo;  
14 - // wx.switchTab({  
15 - // url: '/pages/index/index'  
16 - // }) 11 + let that = this
17 wx.login({ 12 wx.login({
18 success: function(s) { 13 success: function(s) {
19 let url = 'wxapp/public/getSessionKey'; 14 let url = 'wxapp/public/getSessionKey';
@@ -23,7 +18,7 @@ Page({ @@ -23,7 +18,7 @@ Page({
23 code: code 18 code: code
24 } 19 }
25 app.post(url, param).then((res) => { 20 app.post(url, param).then((res) => {
26 - that.login(res.openid, res.session_key, e.detail.encryptedData, e.detail.iv); 21 + that.login(res.openid, res.session_key)
27 }).catch((errMsg) => { 22 }).catch((errMsg) => {
28 23
29 }) 24 })
@@ -31,27 +26,26 @@ Page({ @@ -31,27 +26,26 @@ Page({
31 } 26 }
32 }); 27 });
33 }, 28 },
34 - login(openid, session_key, encrypted_data, iv) {  
35 - let that = this; 29 + login(openid, session_key) {
  30 + let that = this
36 let param = { 31 let param = {
37 openid: openid, 32 openid: openid,
38 - session_key: session_key,  
39 - encrypted_data: encrypted_data,  
40 - iv: iv 33 + session_key: session_key
41 } 34 }
42 - let url = 'wxapp/public/login'; 35 + let url = 'wxapp/public/get_token'
43 app.post(url, param).then((res) => { 36 app.post(url, param).then((res) => {
44 - wx.setStorageSync('token', res.token);  
45 - if(that.data.type){  
46 - wx.reLaunch({  
47 - url: "/pages/img_txt/img_txt?id=" + this.data.id + '&status=1',  
48 - })  
49 - } else { 37 + wx.showLoading({
  38 + title: '正在开启',
  39 + mask: true
  40 + })
  41 + wx.setStorageSync('token', res.token)
  42 + setTimeout(() => {
  43 + wx.hideLoading()
50 wx.switchTab({ 44 wx.switchTab({
51 - url: '/pages/index/index', 45 + url: '/pages/index/index'
52 }) 46 })
53 - }  
54 - 47 + }, 1500)
  48 +
55 }).catch((errMsg) => { 49 }).catch((errMsg) => {
56 50
57 }) 51 })
@@ -61,12 +55,7 @@ Page({ @@ -61,12 +55,7 @@ Page({
61 * 生命周期函数--监听页面加载 55 * 生命周期函数--监听页面加载
62 */ 56 */
63 onLoad: function(options) { 57 onLoad: function(options) {
64 - if (options.type){  
65 - this.setData({  
66 - type: true,  
67 - id: options.id  
68 - })  
69 - } 58 + this.start()
70 }, 59 },
71 60
72 /** 61 /**
1 <view class='start'> 1 <view class='start'>
2 <view class='start_main'> 2 <view class='start_main'>
3 <view class='start_mainimg'> 3 <view class='start_mainimg'>
4 - <image src='../../imgs/renwu@2x.png'></image> 4 + <image src='/imgs/renwu@2x.png'></image>
5 </view> 5 </view>
6 <view class='start_bigtxt'>白求恩志愿者服务队</view> 6 <view class='start_bigtxt'>白求恩志愿者服务队</view>
7 <view class='start_minitxt'>Bethune Volunteer Service Team</view> 7 <view class='start_minitxt'>Bethune Volunteer Service Team</view>
8 </view> 8 </view>
9 - <button class='start_btn' open-type='getUserInfo' bindgetuserinfo='start'>立即开启</button>  
10 - <image src='../../imgs/qidongye_bg@2x.png'></image> 9 + <view class='start_btn'>立即开启</view>
  10 + <image src='/imgs/qidongye_bg@2x.png'></image>
11 </view> 11 </view>
@@ -40,7 +40,7 @@ Page({ @@ -40,7 +40,7 @@ Page({
40 }) 40 })
41 return 41 return
42 } 42 }
43 - wx. ({ 43 + wx.chooseImage({
44 count: allow_image, 44 count: allow_image,
45 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 45 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
46 sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 46 sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
@@ -29,10 +29,10 @@ @@ -29,10 +29,10 @@
29 <view class="title">图片上传</view> 29 <view class="title">图片上传</view>
30 <view class="img_arr"> 30 <view class="img_arr">
31 <view class="img_item" wx:for="{{imgarr}}" wx:key="index"> 31 <view class="img_item" wx:for="{{imgarr}}" wx:key="index">
32 - <image src="{{item}}" mode="aspectFill" class="show_img" catchtap="look_img" data-index="{{index}}"/>  
33 - <image class="del" src="/imgs/del.png" catchtap="del_img" data-index="{{index}}" wx:if="{{!user_id}}"/> 32 + <image src="{{item}}" mode="aspectFill" class="show_img" catchtap="look_img" data-index="{{index}}" />
  33 + <image class="del" src="/imgs/del.png" catchtap="del_img" data-index="{{index}}" wx:if="{{!user_id}}" />
34 </view> 34 </view>
35 - <image class="img_item" src="/imgs/add_img.png" mode="aspectFill" bindtap="upimg" wx:if="{{!user_id}}"/> 35 + <image class="img_item" src="/imgs/add_img.png" mode="aspectFill" bindtap="upimg" wx:if="{{!user_id}}" />
36 </view> 36 </view>
37 </view> 37 </view>
38 38
@@ -42,7 +42,7 @@ @@ -42,7 +42,7 @@
42 <view class="title"> 42 <view class="title">
43 <image src="/imgs/must.png" /> 感想汇报 43 <image src="/imgs/must.png" /> 感想汇报
44 </view> 44 </view>
45 - <textarea class="word" placeholder="请输入内容,内容最多500字" bindinput="get_word" value="{{word}}" disabled="{{user_id}}"/> 45 + <textarea class="word" placeholder="请输入内容,内容最多500字" bindinput="get_word" value="{{word}}" disabled="{{user_id}}" />
46 </view> 46 </view>
47 47
48 <view class="submit" bindtap="submit" wx:if="{{!user_id}}">确认</view> 48 <view class="submit" bindtap="submit" wx:if="{{!user_id}}">确认</view>