Browse Source

活动详情

免登逻辑
master
Myth 4 years ago
parent
commit
59d39575a1
  1. 55
      app.js
  2. 25
      pages/index/index.js
  3. 5
      pages/info/activityInfo/index.wxml
  4. 18
      pages/info/activityInfo/index.wxss
  5. 16
      pages/pbService/web/index.js
  6. 6
      project.private.config.json
  7. 39
      utils/https.js

55
app.js

@ -2,6 +2,12 @@
import commonApi from "./utils/https/common" import commonApi from "./utils/https/common"
App({ App({
onLaunch: function (options) { onLaunch: function (options) {
if(options.query.authCode){
wx.setStorageSync('authCode', options.query.authCode)
}
else {
wx.removeStorageSync('authCode')
}
this.updateApp() this.updateApp()
let rect = wx.getSystemInfoSync(); let rect = wx.getSystemInfoSync();
this.globalData.safeBottom = rect.safeArea?(rect.safeArea.bottom - rect.safeArea.height):0 this.globalData.safeBottom = rect.safeArea?(rect.safeArea.bottom - rect.safeArea.height):0
@ -11,37 +17,28 @@ App({
this.globalData.uuid = res.data.uuid; this.globalData.uuid = res.data.uuid;
wx.setStorageSync('uuid', res.data.uuid) wx.setStorageSync('uuid', res.data.uuid)
}) })
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
// 获取用户信息 // 获取用户信息
wx.getSetting({ // wx.getSetting({
success: res => { // success: res => {
if (res.authSetting['scope.userInfo']) { // if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 // // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({ // wx.getUserInfo({
success: res => { // success: res => {
// 可以将 res 发送给后台解码出 unionId // // 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo // this.globalData.userInfo = res.userInfo
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 // // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况 // // 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) { // if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res) // this.userInfoReadyCallback(res)
} // }
} // }
}) // })
} // }
} // }
}) // })
this.getShareCategoryId() this.getShareCategoryId()
}, },
// 更新提示 // 更新提示
@ -178,7 +175,7 @@ App({
'OFFLINE_WAIT':'线下退款处理中' 'OFFLINE_WAIT':'线下退款处理中'
}, },
codeState:['未使用','已使用','已失效','已取消'], codeState:['未使用','已使用','已失效','已取消'],
weburl:"", weburl:"https://wechat.b2c.zj-trip.net",
pay_methods:{ pay_methods:{
NONE:"无需支付", NONE:"无需支付",
WEIXIN:"微信支付", WEIXIN:"微信支付",

25
pages/index/index.js

@ -2,6 +2,7 @@
//获取应用实例 //获取应用实例
let app = getApp() let app = getApp()
import commonApi from "../../utils/https/common" import commonApi from "../../utils/https/common"
import userApi from "../../utils/https/user"
import util from "../../utils/util" import util from "../../utils/util"
Page({ Page({
data: { data: {
@ -353,7 +354,6 @@ Page({
} }
break; break;
case 3: case 3:
console.log(item.tdata);
if((item.tdata.indexOf('http://')!=-1 || item.tdata.indexOf('https://')!=-1) && item.tdata.indexOf('m.cloud.sz-trip.com')==-1){ if((item.tdata.indexOf('http://')!=-1 || item.tdata.indexOf('https://')!=-1) && item.tdata.indexOf('m.cloud.sz-trip.com')==-1){
// 外部h5 // 外部h5
console.log(item.tdata) console.log(item.tdata)
@ -387,10 +387,33 @@ Page({
} }
break; break;
case 4: case 4:
if(item.tdata.appid=='wxe5ca0f71e918e352' && wx.getStorageSync('jstrip_userid')){
// 如果是苏心游的小程序 直接把authCode带过去
userApi.user_post("user/getJumpThirdAppCode",{}).then(res=>{
let weburl = item.tdata.page
if(weburl.indexOf('?')!=-1){
weburl += '&authCode='+res.data;
}
else {
weburl += '?authCode='+res.data
}
wx.navigateToMiniProgram({
appId: item.tdata.appid,
path:weburl
})
}).catch(err=>{
wx.navigateToMiniProgram({
appId: item.tdata.appid,
path:item.tdata.page
})
})
}
else {
wx.navigateToMiniProgram({ wx.navigateToMiniProgram({
appId: item.tdata.appid, appId: item.tdata.appid,
path:item.tdata.page path:item.tdata.page
}) })
}
break; break;
default: default:
break; break;

5
pages/info/activityInfo/index.wxml

@ -37,9 +37,12 @@
wx:if="{{info && info.scene_data && info.scene_data.id}}" class="scene-box"> wx:if="{{info && info.scene_data && info.scene_data.id}}" class="scene-box">
<image src="{{info.scene_data.headimg}}" mode="aspectFill"></image> <image src="{{info.scene_data.headimg}}" mode="aspectFill"></image>
<view class="scene-info"> <view class="scene-info">
<view class="scene-title-box">
<view class="scene-title textOver">{{info.scene_data.title}}</view> <view class="scene-title textOver">{{info.scene_data.title}}</view>
<view>查看 >></view>
</view>
<view class="scene-address textOver2">{{info.scene_data.address}}</view> <view class="scene-address textOver2">{{info.scene_data.address}}</view>
<view class="scene-btn">查看详情</view> <!-- <view class="scene-btn">查看详情</view> -->
</view> </view>
</navigator> </navigator>
<view style="height:230rpx" wx:if="{{info && info.scene_data && info.scene_data.id}}"></view> <view style="height:230rpx" wx:if="{{info && info.scene_data && info.scene_data.id}}"></view>

18
pages/info/activityInfo/index.wxss

@ -100,7 +100,7 @@
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
width: 697rpx; width: 697rpx;
height: 193rpx; height: 140rpx;
background: #FFFFFF; background: #FFFFFF;
box-shadow: 0px 0px 16rpx 0px rgba(0, 0, 0, 0.14); box-shadow: 0px 0px 16rpx 0px rgba(0, 0, 0, 0.14);
border-radius: 13rpx; border-radius: 13rpx;
@ -113,23 +113,33 @@
} }
.scene-box image { .scene-box image {
display: block; display: block;
width: 253rpx; width: 120rpx;
margin: 20rpx; margin: 20rpx;
height: 153rpx; height: 100rpx;
flex-shrink: 0; flex-shrink: 0;
margin-right: 26rpx; margin-right: 26rpx;
} }
.scene-info { .scene-info {
flex: 1; flex: 1;
width: 400rpx; width: 500rpx;
margin: 20rpx; margin: 20rpx;
margin-left: 0; margin-left: 0;
} }
.scene-title-box {
display: flex;
font-size: 24rpx;
color: #0B898E;
justify-content: space-between;
align-items: center;
}
.scene-title { .scene-title {
color: #000; color: #000;
font-size: 31rpx; font-size: 31rpx;
font-weight: 500; font-weight: 500;
} }
.scene-title-box view:nth-child(2){
flex-shrink: 0;
}
.scene-address { .scene-address {
color: #999; color: #999;
font-size: 25rpx; font-size: 25rpx;

16
pages/pbService/web/index.js

@ -29,6 +29,22 @@ Page({
}) })
}) })
} }
else if(app.globalData.weburl.indexOf('m.jszhwlpt.com')!=-1 || app.globalData.weburl.indexOf('wechat.b2c.zj-trip.net')!=-1){
// 如果是去苏心游或者镇江的话
userApi.user_post("user/getJumpThirdAppCode",{}).then(res=>{
let weburl = app.globalData.weburl
if(weburl.indexOf('?')!=-1){
weburl += '&original_sys_name=jdsz&auth_code='+res.data;
}
else {
weburl += '?original_sys_name=jdsz&auth_code='+res.data
}
this.setData({
info:res.data,
webUrl:weburl
})
})
}
else { else {
this.setData({ this.setData({
webUrl:app.globalData.weburl webUrl:app.globalData.weburl

6
project.private.config.json

@ -13,9 +13,9 @@
"miniprogram": { "miniprogram": {
"list": [ "list": [
{ {
"name": "pages/order/joinOrder/success/index", "name": "pages/index/index",
"pathName": "pages/order/joinOrder/index", "pathName": "pages/index/index",
"query": "id=1001", "query": "authCode=2c290d21383ccd3350747bba95f306f0",
"scene": null "scene": null
}, },
{ {

39
utils/https.js

@ -103,6 +103,39 @@ function _post(url,data={}) {
} }
function user_post(url,data={}){ function user_post(url,data={}){
console.log(wx.getStorageSync('authCode'))
if(wx.getStorageSync('authCode')){
// 如果有授权码的话 用授权码去获取下用户信息
return new Promise((resolved,rejected)=>{
_post("/uservice/user/loginWithUserCenterAuthCode",{
auth_code:wx.getStorageSync('authCode')
}).then(res=>{
if(res && res.data){
wx.setStorageSync('jstrip_userid', res.data.id)
wx.setStorageSync('jstrip_token', res.data.token)
wx.setStorageSync('jstrip_userInfo', res.data)
wx.removeStorageSync('authCode')
}
user_post_new(url,data).then(res=>{
resolved(res)
}).catch(err=>{
rejected(err)
})
}).catch(err=>{
user_post_new(url,data).then(res=>{
resolved(res)
}).catch(err=>{
rejected(err)
})
})
})
}
else {
return user_post_new(url,data)
}
}
function user_post_new(url,data={}){
var token = wx.getStorageSync("jstrip_token"),userId = wx.getStorageSync("jstrip_userid"); var token = wx.getStorageSync("jstrip_token"),userId = wx.getStorageSync("jstrip_userid");
//为了用户体验,加一个loading效果 //为了用户体验,加一个loading效果
wx.showLoading({ title: '加载中', mask: true }); wx.showLoading({ title: '加载中', mask: true });
@ -140,7 +173,11 @@ function user_post(url,data={}){
header: header, header: header,
success: (res) => { success: (res) => {
wx.hideLoading(); wx.hideLoading();
if (res.data.code == 401) { console.log(url)
if(url.indexOf('user/getJumpThirdAppCode')!=-1){
}
else if (res.data.code == 401) {
// 登录出现问题,需要重新登录 // 登录出现问题,需要重新登录
wx.removeStorageSync("jstrip_userid"); wx.removeStorageSync("jstrip_userid");
wx.removeStorageSync("jstrip_token"); wx.removeStorageSync("jstrip_token");

Loading…
Cancel
Save