Commit 7de55db2 by shijiuyan

1

parent bac032f6
......@@ -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
......@@ -29,73 +29,85 @@ Page({
var that=this;
//获取用户当前的经纬度信息并调用接口判断用户身份
var config = wx.getStorageSync('config');
var location = wx.getStorageSync('location');
var latitude = location.latitude;
var longitude = location.longitude;
wx: 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,
setTimeout(function(){
wx.getStorage({
key: 'location',
success: function(resp) {
var location = resp.data;
var latitude = resp.data.latitude;
var longitude = resp.data.longitude;
wx.showToast({
title: config.unionId,
})
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") {
//页面跳转
wx.redirectTo({
url: '../socialUserRegister/socialUserRegister',
});
}
that.setData({
roleTitle: res.data.result.name,
role:res.data.result.role,
childAge: res.data.result.childAge
//未注册用户的话。跳转到社会人士注册页面
if (res.data.status == "REGIST") {
//页面跳转
wx.redirectTo({
url: '../socialUserRegister/socialUserRegister',
});
}
that.setData({
roleTitle: res.data.result.name,
role: res.data.result.role,
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({
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) { },
})
},
})
},1000);
},
/**
......
......@@ -32,12 +32,18 @@ Page({
onShow: function () {
//如果用户已经注册则跳转到首页
var config = wx.getStorageSync('config');
if (config.registed == true) {
//跳转到首页
wx.switchTab({
url: '../index/index',
});
}
setTimeout(
function(){
if (config.registed == true) {
//跳转到首页
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