| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- import common from './util';
- var app = getApp();
- function getData(url, callback) {
- //console.log("加密前的结果为===", url);
- var url = common.Encrypt(url);
- //console.log("加密后的结果为===",url);
- wx.request({
- url: app.globalData.serverUrl + url,
- success: function (res) {
- if (res.statusCode)
- common.checkError(res.statusCode);
- var data = res.data.result;
- callback(data);
- },
- fail: function () {
- wx.showToast({
- title: '网络故障,请稍候再试!',
- duration: 3000
- });
- },
- });
- }
- function postData(url, postData, callback) {
- var url = common.Encrypt(url);
- //console.log("加密后的结果为===",url);
- wx.request({
- url: app.globalData.serverUrl + url,
- method: "POST",
- data: postData,
- success: function (res) {
- if (res.statusCode)
- common.checkError(res.statusCode);
- var data = res.data.result;
- callback(data);
- },
- fail: function () {
- wx.showToast({
- title: '网络故障,请稍候再试!',
- duration: 3000
- });
- },
- });
- }
- function getLocalHost(callback) {
- if (!app.globalData.IsProduction) {
- var url = common.Encrypt("Ping");
- wx.request({
- url: app.globalData.serverUrlLocalhost + url,
- success: function (res) {
- app.globalData.serverUrl = app.globalData.serverUrlLocalhost;
- callback();
- },
- fail: function () {
- app.globalData.serverUrl = app.globalData.serverUrlServer;
- callback();
- },
- });
- }
- else {
- app.globalData.serverUrl = app.globalData.serverUrlServer;
- callback();
- }
- }
- function payMoney(payType, buyType, money, detail, callback) {
- console.log(money);
- if (app.globalData.userInfo.UserID == 1)
- money = 0.01;
- else if (app.globalData.userInfo.UserID == 5)
- money = 0.01;
- //登录认证
- wx.login({
- success: function (res) {
- if (res.code) {
- console.log('获取用户登录态成功!' + res.code);
- //预支付
- getData('ProductPayLogin500?code=' + res.code + '&payType=' + payType + '&buyType=' + buyType + '&money=' + money + '&detail=' + detail + '&productID=' + app.globalData.ProgramID, function (data) {
- if (data && data.timeStamp) {
- //微信支付
- wx.requestPayment({
- 'timeStamp': data.timeStamp.toString(),
- 'nonceStr': data.nonceStr,
- 'package': data.package,
- 'signType': 'MD5',
- 'paySign': data.paySign,
- 'success': function (res3) {
- console.log("success:" + res3);
- callback(data);
- },
- 'fail': function (err) {
- if (err && err.errMsg && err.errMsg.indexOf("fail cancel")) {
- }
- else {
- wx.showToast({
- title: '服务器忙,请稍候再试!',
- duration: 3000
- });
- }
- }
- });
- }
- });
- } else {
- console.log('获取用户登录态失败!' + res.errMsg);
- wx.showToast({
- title: '服务器忙,请稍候再试!',
- duration: 3000
- });
- }
- }
- });
- }
- function getProgramList() {
- return [
- {
- ID: 166,
- Name: "秒过学习",
- Name2: "家长帮助孩子快速提高学习成绩",
- ImageUrl: "product_icon_mg_70x70.png",
- appId: 'wx84b3feac6069eec3',
- path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
- IsShow: true,
- IsShow2: true,
- Category: "",
- },
- {
- ID: 164,
- Name: "口算",
- Name2: "透视问题刻意练习",
- ImageUrl: "product_icon_ksxq_70x70.png",
- appId: 'wxa5441bbf344692ba',
- path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
- IsShow: true,
- IsShow2: true,
- Category: "数学系列",
- },
- {
- ID: 105,
- Name: "计算题",
- Name2: "竖式计算打印批改",
- ImageUrl: "product_icon_jst_70x70.png",
- appId: 'wx1fef080f74481cbd',
- path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
- IsShow: true,
- IsShow2: true,
- Category: "数学系列",
- },
- {
- ID: 106,
- Name: "识字",
- Name2: "课本同步汉字发言组词",
- ImageUrl: "product_icon_sz_70x70.png",
- appId: 'wx313a8f2c0741efe1',
- path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
- IsShow: false,
- IsShow2: true,
- Category: "语文系列",
- },
- {
- ID: 98,
- Name: "汉语拼音",
- Name2: "纯正发音练习",
- ImageUrl: "product_icon_py_70x70.png",
- appId: 'wx331e8dd070f01d0e',
- path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
- IsShow: true,
- IsShow2: true,
- Category: "语文系列",
- },
- {
- ID: 99,
- Name: "自然拼读",
- Name2: "真正英语国家母语学习法",
- ImageUrl: "product_icon_pd_70x70.png",
- appId: 'wxb54a6d5aff836ee3',
- path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
- IsShow: true,
- IsShow2: true,
- Category: "英语系列",
- },
- {
- ID: 89,
- Name: "数学口算练习",
- Name2: "帮助孩子快速提高口算能力",
- ImageUrl: "product_icon_kslx_70x70.png",
- appId: 'wx46a7b4c420e6d38f',
- path: 'pages/index/start?SourceID=' + app.globalData.ProgramID,
- IsShow: false,
- IsShow2: false,
- Category: "",
- },
- ];
- }
- function getProgramListOld() {
- var list = [
- {
- ID: 166,
- ImageUrl: "10001.png",
- appId: 'wx84b3feac6069eec3',
- path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
- },
- {
- ID: 164,
- ImageUrl: "03001.png",
- ImageUrl2: "02018.png",
- appId: 'wxa5441bbf344692ba',
- path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
- },
- {
- ID: 105,
- ImageUrl: "03005.png",
- ImageUrl2: "02033.png",
- appId: 'wx1fef080f74481cbd',
- path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
- },
- {
- ID: 99,
- ImageUrl: "03002.png",
- ImageUrl2: "02020.png",
- appId: 'wxb54a6d5aff836ee3',
- path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
- },
- {
- ID: 98,
- ImageUrl: "03003.png",
- ImageUrl2: "02019.png",
- appId: 'wx331e8dd070f01d0e',
- path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
- },
- {
- ID: 90,
- ImageUrl: "03004.png",
- ImageUrl2: "02021.png",
- appId: 'wxa5e33c61fe37dd01',
- path: 'pages/index/index?SourceID=' + app.globalData.ProgramID,
- },
- {
- ID: 127,
- ImageUrl2: "02034.png",
- appId: 'wxaa1a8b48d9853872',
- path: 'pages/index/game?SourceID=' + app.globalData.ProgramID,
- },
- ];
- return list;
- }
- function gotoFeedback(){
- wx.navigateToMiniProgram({
- appId: "wx80059777521b897c",
- path: "pages/index/feedback",
- extraData: {
- },
- success(res) {
- // 打开成功
- }
- });
- }
- module.exports = {
- getData: getData,
- postData: postData,
- payMoney: payMoney,
- getLocalHost: getLocalHost,
- getProgramList: getProgramList,
- getProgramListOld: getProgramListOld,
- gotoFeedback: gotoFeedback,
- }
|