Commit 7de55db2 by shijiuyan

1

parent bac032f6
...@@ -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
...@@ -29,73 +29,85 @@ Page({ ...@@ -29,73 +29,85 @@ Page({
var that=this; var that=this;
//获取用户当前的经纬度信息并调用接口判断用户身份 //获取用户当前的经纬度信息并调用接口判断用户身份
var config = wx.getStorageSync('config'); var config = wx.getStorageSync('config');
var location = wx.getStorageSync('location'); setTimeout(function(){
var latitude = location.latitude; wx.getStorage({
var longitude = location.longitude; key: 'location',
wx: wx.request({ success: function(resp) {
url: app.url + 'ajax_get_user_role.php', var location = resp.data;
data: { var latitude = resp.data.latitude;
unionId: config.unionId, var longitude = resp.data.longitude;
latitude: latitude, wx.showToast({
longitude: longitude title: config.unionId,
},
header: { 'content-type': 'application/json' },
method: 'GET',
dataType: 'json',
success: function (res) {
console.log(res)
if(res.statusCode==200){
//保存用户当前的省市区县信息
location.province = res.data.result.province
location.city = res.data.result.city
location.district = res.data.result.district
wx.setStorage({
key: 'location',
data: location,
})
//保存用户名称信息
config.name = res.data.result.name
wx.setStorage({
key: 'config',
data: config,
}) })
wx.request({
url: app.url + 'ajax_get_user_role.php',
data: {
unionId: config.unionId,
latitude: latitude,
longitude: longitude
},
header: { 'content-type': 'application/json' },
method: 'GET',
dataType: 'json',
success: function (res) {
console.log(res)
if (res.statusCode == 200) {
//保存用户当前的省市区县信息
location.province = res.data.result.province
location.city = res.data.result.city
location.district = res.data.result.district
wx.setStorage({
key: 'location',
data: location,
})
//保存用户名称信息
config.name = res.data.result.name
wx.setStorage({
key: 'config',
data: config,
})
//未注册用户的话。跳转到社会人士注册页面 //未注册用户的话。跳转到社会人士注册页面
if (res.data.status =="REGIST") { if (res.data.status == "REGIST") {
//页面跳转 //页面跳转
wx.redirectTo({ wx.redirectTo({
url: '../socialUserRegister/socialUserRegister', url: '../socialUserRegister/socialUserRegister',
}); });
} }
that.setData({ that.setData({
roleTitle: res.data.result.name, roleTitle: res.data.result.name,
role:res.data.result.role, role: res.data.result.role,
childAge: res.data.result.childAge childAge: res.data.result.childAge
})
//菜单控制[亲子活动]
if (res.data.result.role == 1 || res.data.result.childAge == 1) {
that.setData({
showFamily: true
})
}
//菜单控制[社会实践]
if (res.data.result.role == 2 || res.data.result.childAge == 2) {
that.setData({
showSocial: true
})
}
//菜单控制[消息]
if (res.data.result.role == 4) {
that.setData({
showNews: false
})
}
that.getIndexData();
}
},
fail: function (res) { },
complete: function (res) { },
}) })
//菜单控制[亲子活动] },
if (res.data.result.role == 1 || res.data.result.childAge==1) { })
that.setData({ },1000);
showFamily: true
})
}
//菜单控制[社会实践]
if (res.data.result.role == 2 || res.data.result.childAge == 2) {
that.setData({
showSocial: true
})
}
//菜单控制[消息]
if (res.data.result.role == 4) {
that.setData({
showNews: false
})
}
that.getIndexData();
}
},
fail: 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
)
}, },
/** /**
......
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