@@ -9,6 +9,16 @@ App({ | |||
} else { | |||
this.globalData.openid = openid; | |||
} | |||
var userMobile = wx.getStorageSync('userMobile'); | |||
if (userMobile){ | |||
this.globalData.userMobile = userMobile; | |||
} | |||
var userInfoData = wx.getStorageSync("userInfoData"); | |||
if (userInfoData){ | |||
this.globalData.userInfoData = {}; | |||
this.globalData.userInfoData.avatarUrl = userInfoData.avatarUrl; | |||
this.globalData.userInfoData.nickName = userInfoData.nickName; | |||
} | |||
}, | |||
wxLogin() { | |||
wx.login({ | |||
@@ -29,7 +39,7 @@ App({ | |||
friendOpenid:"",//推荐人的openid | |||
session_key: "",//session_key | |||
openidSuccessFuc: null,//方法回调 | |||
nowPage:'0',//当前tabBar | |||
nowPage:'1',//当前tabBar | |||
isRegister:false,//是否已注册 | |||
userMobile:null,//用户手机号 | |||
isFirstLogin:true,//是否为第一次登录 | |||
@@ -159,12 +169,18 @@ App({ | |||
console.log("下面是formid"); | |||
console.log(e); | |||
this.wxRequest(this.globalData.urlRoot + "/msg/addFormId", { formid: e }, res => { | |||
// if(res.code==200){ | |||
// console.log(res.msg); | |||
// }else{ | |||
// console.log(res.msg); | |||
// } | |||
console.log(res.msg); | |||
}, this, "POST"); | |||
}, | |||
getMobile: function (encryptedData, iv, callback, thisArg){//和后台置换手机号 | |||
this.wxRequest(this.globalData.urlRoot + "userInfo/getUserPhoneNumber", { encryptedData: encryptedData, iv: iv }, res => { | |||
if(res.code == 200){ | |||
wx.setStorageSync('userMobile', res.data.decodeData.phoneNumber); | |||
this.globalData.userMobile = res.data.decodeData.phoneNumber; | |||
} | |||
if (callback && thisArg) { | |||
callback.call(thisArg, res); | |||
} | |||
}, this, "POST"); | |||
} | |||
}) |
@@ -7,7 +7,7 @@ | |||
width:750rpx; | |||
height:150rpx; | |||
box-sizing: border-box; | |||
border-top: 4rpx solid #B8B6B9; | |||
border-top: 2rpx solid #B8B6B9; | |||
display: flex; | |||
align-items: center; | |||
justify-content: center; |
@@ -13,9 +13,9 @@ Page({ | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad: function (options) { | |||
app.globalData.nowPage = 0; | |||
if (options.friendOpenid){ | |||
app.globalData.friendOpenid = options.friendOpenid; | |||
app.globalData.nowPage = 0; | |||
} | |||
}, | |||
@@ -30,8 +30,10 @@ Page({ | |||
videoList:[],//视频列表 | |||
videoVideoControls:false,//是否显示视频控件 | |||
mainShow:false, | |||
isOnce:false | |||
}, | |||
onLoad: function () { | |||
app.globalData.nowPage = 1; | |||
if (app.globalData.isFirstLogin) { | |||
this.getStartAdvertising(); | |||
}else{ | |||
@@ -78,7 +80,7 @@ Page({ | |||
} | |||
this.setData({ | |||
mainShow: true, | |||
isStartAdvertisingShow: false, | |||
isStartAdvertisingShow: this.data.isOnce ? true : app.globalData.isFirstLogin, | |||
isRegister: app.globalData.isRegister | |||
}) | |||
}, | |||
@@ -107,7 +109,7 @@ Page({ | |||
this.getUserLocation();//获取用户当前位置 | |||
} | |||
if (e.detail.errMsg=='getPhoneNumber:ok'){ | |||
app.wxRequest(app.globalData.urlRoot + "userInfo/getUserPhoneNumber", { encryptedData: e.detail.encryptedData, iv: e.detail.iv }, res => { | |||
app.getMobile(e.detail.encryptedData, e.detail.iv,res=>{ | |||
if (res.code == 200) { | |||
this.data.subscribeData.mobile = res.data.decodeData.phoneNumber; | |||
this.setData({ | |||
@@ -119,12 +121,12 @@ Page({ | |||
icon: "none" | |||
}) | |||
} | |||
}, this,"POST"); | |||
},this); | |||
} | |||
}, | |||
getUserLocation:function(e){ | |||
wx.getLocation({ | |||
type: 'gcj02', //wgs84 | |||
type: 'wgs84', // | |||
success:(res)=>{ | |||
// console.log(res); | |||
this.getDistributorList(res.longitude, res.latitude); | |||
@@ -295,14 +297,14 @@ Page({ | |||
}, this, "POST") | |||
}, | |||
getStartAdvertising: function () {//获取开屏广告 | |||
app.wxRequest(app.globalData.urlRoot +"home/getStartAdvertising",{},res=>{ | |||
app.wxRequest(app.globalData.urlRoot + "home/getStartAdvertising", {}, res => { | |||
this.data.isOnce = true; | |||
if (app.globalData.openid) { | |||
this.loadFun(); | |||
} else { | |||
app.globalData.openidSuccessFuc = this.loadFun; | |||
} | |||
if(res.code==200){ | |||
this.setData({ | |||
startAdvertisingUrl: res.data.picurl, | |||
mainShow:true | |||
@@ -314,7 +316,7 @@ Page({ | |||
}) | |||
setTimeout(()=>{ | |||
this.setData({ | |||
isStartAdvertisingShow:false | |||
isStartAdvertisingShow:false, | |||
}) | |||
},1000); | |||
}, 3000); | |||
@@ -356,6 +358,15 @@ Page({ | |||
}) | |||
app.globalData.isRegister = true; | |||
app.globalData.userMobile = res.data.mobile; | |||
}else{ | |||
if (app.globalData.userMobile) { | |||
this.data.subscribeData.mobile = app.globalData.userMobile; | |||
this.setData({ | |||
phoneInputShow:true, | |||
subscribeData: this.data.subscribeData | |||
}) | |||
this.getUserLocation(); | |||
} | |||
} | |||
} else { | |||
console.log(res.msg) |
@@ -27,7 +27,7 @@ Page({ | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad: function (options) { | |||
app.globalData.nowPage = 3; | |||
}, | |||
/** |
@@ -52,6 +52,7 @@ Page({ | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad: function (options) { | |||
app.globalData.nowPage = 4; | |||
if (options.sourcePage){ | |||
this.data.optionsData = options.sourcePage; | |||
} | |||
@@ -78,6 +79,13 @@ Page({ | |||
if (!app.globalData.isRegister) { | |||
this.getOrderInfo(); | |||
} | |||
if (app.globalData.userInfoData) { | |||
this.data.userData.avatarUrl = app.globalData.userInfoData.avatarUrl; | |||
this.data.userData.nickName = app.globalData.userInfoData.nickName; | |||
this.setData({ | |||
userData: this.data.userData | |||
}) | |||
} | |||
}, | |||
/** | |||
* 生命周期函数--监听页面初次渲染完成 | |||
@@ -339,24 +347,33 @@ Page({ | |||
app.globalData.userInfoData = {}; | |||
app.globalData.userInfoData.avatarUrl = e.detail.userInfo.avatarUrl; | |||
app.globalData.userInfoData.nickName = e.detail.userInfo.nickName; | |||
wx.setStorageSync('userInfoData', { | |||
avatarUrl: e.detail.userInfo.avatarUrl, | |||
nickName: e.detail.userInfo.nickName | |||
}) | |||
app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName); | |||
} | |||
}, | |||
getUserInfo:function(e){//获取个人信息 | |||
app.wxRequest(app.globalData.urlRoot + 'userInfo/getUserInfo', {}, res => { | |||
if(res.code==200){ | |||
// res.data.userLevel = 3; | |||
if (res.data) { | |||
this.data.userData.avatarUrl = res.data.avatarUrl; | |||
this.data.userData.nickName = res.data.nickName; | |||
this.data.userData.userLevel = res.data.userLevel; | |||
if (!app.globalData.userInfoData) { | |||
this.data.userData.avatarUrl = res.data.avatarUrl; | |||
this.data.userData.nickName = res.data.nickName; | |||
app.globalData.userInfoData = {}; | |||
app.globalData.userInfoData.avatarUrl = res.data.avatarUrl; | |||
app.globalData.userInfoData.nickName = res.data.nickName; | |||
wx.setStorageSync('userInfoData', { | |||
avatarUrl: res.data.avatarUrl, | |||
nickName: res.data.nickName | |||
}) | |||
} | |||
this.setData({ | |||
userData: this.data.userData, | |||
isLogin: true | |||
}) | |||
app.globalData.userInfoData = {}; | |||
app.globalData.userInfoData.avatarUrl = res.data.avatarUrl; | |||
app.globalData.userInfoData.nickName = res.data.nickName; | |||
} | |||
} | |||
},this) | |||
@@ -407,6 +424,15 @@ Page({ | |||
}) | |||
app.globalData.isRegister = true; | |||
app.globalData.userMobile = res.data.mobile; | |||
} else { | |||
if (app.globalData.userMobile) { | |||
this.data.subscribeData.mobile = app.globalData.userMobile; | |||
this.setData({ | |||
phoneInputShow: true, | |||
subscribeData: this.data.subscribeData | |||
}) | |||
this.getUserLocation(); | |||
} | |||
} | |||
} else { | |||
console.log(res.msg) | |||
@@ -421,7 +447,6 @@ Page({ | |||
}, | |||
getMyAwardList: function () {//获取获奖记录 | |||
app.wxRequest(app.globalData.urlRoot + "award/getMyAwardList", { awardType: this.data.recordNow},res=>{ | |||
console.log(res); | |||
if(res.code == 200){ | |||
this.setData({ | |||
recordList:res.data | |||
@@ -437,7 +462,7 @@ Page({ | |||
this.getUserLocation();//获取用户当前位置 | |||
} | |||
if (e.detail.errMsg == 'getPhoneNumber:ok') { | |||
app.wxRequest(app.globalData.urlRoot + "userInfo/getUserPhoneNumber", { encryptedData: e.detail.encryptedData, iv: e.detail.iv }, res => { | |||
app.getMobile(e.detail.encryptedData, e.detail.iv, res => { | |||
if (res.code == 200) { | |||
this.data.subscribeData.mobile = res.data.decodeData.phoneNumber; | |||
this.setData({ | |||
@@ -449,7 +474,7 @@ Page({ | |||
icon: "none" | |||
}) | |||
} | |||
}, this, "POST"); | |||
}, this); | |||
} | |||
} | |||
}) |
@@ -24,7 +24,7 @@ Page({ | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad: function (options) { | |||
app.globalData.nowPage = 2; | |||
}, | |||
/** | |||
@@ -130,8 +130,8 @@ Page({ | |||
*/ | |||
onShareAppMessage: function () { | |||
return { | |||
title: '500元购车券', | |||
imageUrl: "", | |||
title: '您有一份启辰星专属礼品待领取', | |||
imageUrl: this.data.imgUrl+"/images/posterShareImg.png", | |||
path: "/pages/coupon/coupon?friendOpenid=" + app.globalData.openid | |||
} | |||
}, |
@@ -13,7 +13,7 @@ Page({ | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad: function (options) { | |||
app.globalData.nowPage = 3; | |||
}, | |||
/** |