Commit b810da1c by biao

Merge branch 'master' of http://gitlib.occloud.net/biao/ZhiNanZhen

* 'master' of http://gitlib.occloud.net/biao/ZhiNanZhen:
  1
  1

# Conflicts:
#	src/wx/app.js
parents 4fb63f60 6341be4a
//app.js
App({
url: 'https://www.koala-online.cn/compass/if/',
onLaunch: function () {
var that = this;
//调用wx用户登陆
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
wx.showToast({
title: '123'+res,
})
wx.request({
url: that.url + 'ajax_check_user_registed.php',
data: {
code: res.code
},
header: {
'content-type': 'application/json' // 默认值
},
success(res) {
//保存返回的openId和unionId
let config = {
openId: res.data.result.openId,
unionId: res.data.result.unionId,
registed: res.data.result.registed
};
// wx.showToast({
// title: "unionId=" + res.data.result.unionId,
// icon: 'success',
// duration: 2000
// });
wx.setStorage({
key: 'config',
data: config,
});
},
fail: function (res) {
wx.showToast({
title: "失败111",
icon: 'success',
duration: 2000
});
},
complete: function (res) {
},
})
}
})
var config = wx.getStorageSync('config');
//获取并保存用户的经纬度信息
wx.getLocation({
type: 'wgs84',
success: function (res) {
let location={
latitude: res.latitude,
longitude: res.longitude
};
wx.setStorage({
key:'location',
data: location,
})
}
})
},
//判断用户是否已经注册
checkUser:function(code,openid){
},
globalData: {
userInfo: null
},
})
\ No newline at end of file
...@@ -82,13 +82,14 @@ Page({ ...@@ -82,13 +82,14 @@ Page({
success: function (resp) { success: function (resp) {
console.log(resp) console.log(resp)
if(resp.data.status=='OK'){ if(resp.data.status=='OK'){
if(resp.data.haveBuy&&!resp.data.is_free || resp.data.is_free){ if (resp.data.result.courseMediaDat.haveBuy && !resp.data.result.courseMediaDat.is_free || resp.data.result.courseMediaDat.is_free){
that.setData({ that.setData({
play:1, play:1,
playUrl:resp.data.result.courseMediaDat.media playUrl:resp.data.result.courseMediaDat.media
}) })
}else{ }else{
that.setData({ that.setData({
playUrl: resp.data.result.courseMediaDat.media,
fufeiPage:1, fufeiPage:1,
money: resp.data.result.courseMediaDat.price money: resp.data.result.courseMediaDat.price
}) })
...@@ -192,8 +193,45 @@ Page({ ...@@ -192,8 +193,45 @@ Page({
}) })
}, },
surefufei(){ surefufei(){
this.setData({ var that=this;
fufeiPage: 0 wx.getStorage({
key: 'config',
success: function(res) {
if(res){
wx.request({
url: app.url + 'ajax_buy_course_media.php',
data: {
unionId:res.data.unionId,
openId:res.data.openId,
mediaId: that.data.mediaId
},
success:function(resp){
console.log(resp)
if(resp.data.status=='OK'){
var result = JSON.parse(resp.data.result);
wx.requestPayment({
timeStamp: result.timeStamp,
nonceStr: result.nonceStr,
package: result.package,
signType: 'MD5',
paySign: result.paySign,
success(res) {
that.setData({
fufeiPage: 0,
play:1
})
},
fail(res) { }
})
}
}
})
}
},
}) })
// this.setData({
// fufeiPage: 0
// })
} }
}) })
\ No newline at end of file
...@@ -32,7 +32,10 @@ Page({ ...@@ -32,7 +32,10 @@ Page({
var location = wx.getStorageSync('location'); var location = wx.getStorageSync('location');
var latitude = location.latitude; var latitude = location.latitude;
var longitude = location.longitude; var longitude = location.longitude;
wx: wx.request({ wx.showToast({
title: location,
})
wx.request({
url: app.url + 'ajax_get_user_role.php', url: app.url + 'ajax_get_user_role.php',
data: { data: {
unionId: config.unionId, unionId: config.unionId,
...@@ -93,7 +96,11 @@ Page({ ...@@ -93,7 +96,11 @@ Page({
that.getIndexData(); that.getIndexData();
} }
}, },
fail: function (res) { }, fail: function (res) {
wx.showToast({
title: '数据获取异常',
})
},
complete: function (res) { }, complete: function (res) { },
}) })
}, },
......
...@@ -32,12 +32,18 @@ Page({ ...@@ -32,12 +32,18 @@ Page({
onShow: function () { onShow: function () {
//如果用户已经注册则跳转到首页 //如果用户已经注册则跳转到首页
var config = wx.getStorageSync('config'); var config = wx.getStorageSync('config');
if (config.registed == true) { setTimeout(
//跳转到首页 function(){
wx.switchTab({ if (config.registed == true) {
url: '../index/index', //跳转到首页
}); wx.switchTab({
} url: '../index/index',
});
}
},
200
)
}, },
/** /**
...@@ -49,7 +55,8 @@ Page({ ...@@ -49,7 +55,8 @@ Page({
//家校/家园用户注册 //家校/家园用户注册
regist(e){ regist(e){
//获取本地存储的openId和unionId
var config = wx.getStorageSync('config');
var that = this; var that = this;
// 获取用户信息 // 获取用户信息
wx.getUserInfo({ wx.getUserInfo({
...@@ -61,10 +68,7 @@ Page({ ...@@ -61,10 +68,7 @@ Page({
if (this.userInfoReadyCallback) { if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res) this.userInfoReadyCallback(res)
} }
//获取本地存储的openId和unionId
var config = wx.getStorageSync('config');
wx.request({ wx.request({
url: app.url + 'ajax_user_register.php', url: app.url + 'ajax_user_register.php',
data: { data: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment