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({
success: function (resp) {
console.log(resp)
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({
play:1,
playUrl:resp.data.result.courseMediaDat.media
})
}else{
that.setData({
playUrl: resp.data.result.courseMediaDat.media,
fufeiPage:1,
money: resp.data.result.courseMediaDat.price
})
......@@ -192,8 +193,45 @@ Page({
})
},
surefufei(){
this.setData({
fufeiPage: 0
var that=this;
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({
var location = wx.getStorageSync('location');
var latitude = location.latitude;
var longitude = location.longitude;
wx: wx.request({
wx.showToast({
title: location,
})
wx.request({
url: app.url + 'ajax_get_user_role.php',
data: {
unionId: config.unionId,
......@@ -93,7 +96,11 @@ Page({
that.getIndexData();
}
},
fail: function (res) { },
fail: function (res) {
wx.showToast({
title: '数据获取异常',
})
},
complete: function (res) { },
})
},
......
......@@ -32,6 +32,8 @@ Page({
onShow: function () {
//如果用户已经注册则跳转到首页
var config = wx.getStorageSync('config');
setTimeout(
function(){
if (config.registed == true) {
//跳转到首页
wx.switchTab({
......@@ -39,6 +41,10 @@ Page({
});
}
},
200
)
},
/**
* 用户点击右上角分享
......@@ -49,7 +55,8 @@ Page({
//家校/家园用户注册
regist(e){
//获取本地存储的openId和unionId
var config = wx.getStorageSync('config');
var that = this;
// 获取用户信息
wx.getUserInfo({
......@@ -62,9 +69,6 @@ Page({
this.userInfoReadyCallback(res)
}
//获取本地存储的openId和unionId
var config = wx.getStorageSync('config');
wx.request({
url: app.url + 'ajax_user_register.php',
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