| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- import common from '../../utils/util';
- import server from '../../utils/main';
- const app = getApp();
- var code;
- var imageIndex = 0;
- var arrBuildImageSource = [];
- var arrBuildImageTarget = [];
- var isMiaoguoADShow = false;
- Page({
- data: {
- version: app.globalData.version,
- FileUrl: app.globalData.fileUrl,
- NickName: "陌生用户",
- IsMember: 1,
- AvatarUrl: "",
- IsAccredit: false,
- IsMiaoguoAD: false,
- IsMiaoguoAD2: 0,
- },
- onLoad: function () {
- var that = this;
- this.setData({
- Height: server.getWindowHeight(),
- ProgramList: server.getProgramListOld(),
- IsShowGift:app.globalData.userInfo.IsShowGift,
- });
- wx.login({
- success: function (res0) {
- code = res0.code;
- }
- });
- isMiaoguoADShow = false;
- },
- onUnload: function () {
- },
- onShow: function () {
- var that = this;
- var list = wx.getStorageSync("AnswerList");
- var answerLength = 0;
- if (list && list.length > 0) {
- answerLength = list.length;
- }
- var errorCount = 0;
- var listError = wx.getStorageSync("ErrorList");
- if (listError && listError.length > 0) {
- errorCount = listError.length;
- }
- this.setData({
- AnswerLength: answerLength,
- ErrorCount: errorCount,
- IsLocked: app.globalData.IsLocked,
- IsShow: app.globalData.userInfo.IsShow,
- IsMember: app.globalData.userInfo.IsMember,
- NickName: app.globalData.userInfo.NickName,
- AvatarUrl: app.globalData.userInfo.AvatarUrl,
- });
- if (app.globalData.userInfo.NickName=="陌生用户" && app.globalData.userInfo.IsShow>0) {
- this.setData({
- IsRemind:true,
- });
- }
- else{
- that.setData({
- IsAccredit: true,
- IsRemind:false,
- });
- that.downloadUserAvatar();
- common.getStorageValue(that, "HelpHidden1", false, function () {
- that.showHelp();
- });
- }
- if (wx.getStorageSync("HasActivate") == 1) {
- wx.navigateTo({
- url: '../../package4/main/activate',
- });
- }
-
- common.getStorageValue(this, "IsMiaoguoAD", true, function () { });
- var miaoguoADTime = wx.getStorageSync("miaoguoADTime");
- if (miaoguoADTime) {
- if (this.data.IsShow == 1 && this.data.IsMember == 1 && isMiaoguoADShow && common.formatTime(new Date()) >= miaoguoADTime) {
- this.setData({
- IsMiaoguoAD2: 1,
- });
- }
- }
- else {
- wx.setStorageSync("miaoguoADTime", common.formatTime(common.addDate("d", 1, new Date())));
- }
- isMiaoguoADShow = true;
- if (app.globalData.IsShowMiaoguo){
- this.setData({
- IsShowMiaoguo:1,
- });
- app.globalData.IsShowMiaoguo=false;
- }
- },
- downloadUserAvatar: function () {
- var avatar = wx.getStorageSync("Avatar");
- if (!avatar) {
- var that = this;
- wx.downloadFile({
- url: app.globalData.userInfo.AvatarUrl,
- success(res) {
- if (res.statusCode === 200) {
- wx.setStorageSync("Avatar", res.tempFilePath);
- }
- }
- });
- }
- },
- gotoList: function (e) {
- server.playSound("/sounds/click.mp3");
- var id = e.currentTarget.dataset.id;
- var categoryArray = [{}, { Num: 1, Name: "一年级", Array: [1, 2] }, { Num: 2, Name: "二年级", Array: [3, 4] }, { Num: 3, Name: "三年级", Array: [5, 6] }, { Num: 4, Name: "四年级及以上", Array: [7] }];
- wx.navigateTo({
- url: '../main/list?id=' + categoryArray[id].Array.join(",") + "&name=" + categoryArray[id].Name + "&num=" + categoryArray[id].Num,
- });
- this.closeHelp();
- },
- goto: function (e) {
- var url = e.currentTarget.dataset.url;
- wx.navigateTo({
- url: url
- });
- if (e.currentTarget.dataset.id == "topAD") {
- this.setData({
- IsMiaoguoAD2: 0,
- });
- wx.setStorageSync('IsMiaoguoAD', false);
- wx.setStorageSync("miaoguoADTime", common.formatTime(common.addDate("d", 15, new Date())));
- }
- app.globalData.userInfo.IsShowGift=0;
- },
- gotoHelp: function () {
- wx.redirectTo({
- url: '../main/help',
- });
- },
- gotoAnswer: function () {
- wx.navigateTo({
- url: '../main/answer',
- });
- },
- gotoErrorList(e) {
- wx.navigateTo({
- url: '../main/detail?id=-1',
- });
- },
- switchProgram: function (e) {
- wx.navigateToMiniProgram({
- appId: e.currentTarget.dataset.appid,
- path: "pages/index/index?SourceID="+app.globalData.ProgramID,
- extraData: {
- },
- success(res) {
- // 打开成功
- }
- });
- },
- gotoMemberCenter: function () {
- if (app.globalData.userInfo.NickName=="陌生用户" && app.globalData.userInfo.IsShow>0) {
- //请去授权
- wx.navigateTo({
- url: './accredit?type=accredit',
- });
- }
- else if (app.globalData.userInfo.IsShow>0) {
- wx.navigateTo({
- url: './userinfo',
- });
- }
- },
- gotoFeedback: function () {
- server.gotoFeedback();
- },
- showHelp: function () {
- if (!this.data.HelpHidden1) {
- this.audioCtx = wx.createAudioContext('myAudio');
- var str = "那么,就从选题目开始吧。在计算题工厂里包括了小学数学全年级最重要的知识点。其中“四年级及以上”,这个栏目囊括了四到六年级的题型。请选一个年级继续。";
- server.playAudio(this.audioCtx, str);
- }
- },
- closeHelp: function () {
- this.setData({
- HelpHidden1: true,
- });
- wx.setStorageSync("HelpHidden1", true);
- this.audioCtx = wx.createAudioContext('myAudio');
- this.audioCtx.pause();
- },
- buildShareImage: function () {
- this.closeMenu();
- imageIndex = 0;
- arrBuildImageSource = [];
- for (var i = 2; i < 6; i++)
- arrBuildImageSource.push("../images/programsystem_screenshot_pic0" + i + ".png");
- arrBuildImageTarget = [];
- this.buildImage();
- },
- buildImage: function () {
- var that = this;
- var ctx = wx.createCanvasContext("MyCanvas", this);
- ctx.drawImage(arrBuildImageSource[imageIndex], 0, 0, 400, 300);
- var avatar = wx.getStorageSync("Avatar");
- if (avatar) {
- ctx.drawImage(avatar, 15, 250, 40, 40);
- ctx.drawImage("../images/universalpic_mask_face_size01.png", 13, 248, 44, 44);
- ctx.fillStyle = "#ffffff";
- ctx.setFontSize(14);
- ctx.fillText(app.globalData.userInfo.NickName, 65, 264);
- }
- ctx.draw(true, function (n) {
- wx.canvasToTempFilePath({
- x: 0,
- y: 0,
- width: 400,
- height: 300,
- canvasId: 'MyCanvas',
- success: function (res2) {
- console.log(res2.tempFilePath);
- arrBuildImageTarget.push(res2.tempFilePath);
- if (arrBuildImageTarget.length < arrBuildImageSource.length) {
- imageIndex++;
- that.buildImage();
- }
- else {
- wx.previewImage({
- current: arrBuildImageTarget[0], // 当前显示图片的http链接
- urls: arrBuildImageTarget // 需要预览的图片http链接列表
- });
- }
- }
- })
- });
- },
- close: function (e) {
- this.setData({
- IsMiaoguoAD2: 0,
- IsShowGift:0,
- });
- var num = e.currentTarget.dataset.num;
- if (num > 0) {
- var time = common.addDate("d", Number(num), new Date());
- time = common.formatTime(time);
- wx.setStorageSync("miaoguoADTime", time);
- }
- app.globalData.userInfo.IsShowGift=0;
- },
- showMiaoguo:function(){
- this.setData({
- IsShowMiaoguo: 1,
- IsMiaoguoAD2: 0,
- });
- app.globalData.userInfo.IsShowGift=0;
- wx.setStorageSync("miaoguoADTime", common.formatTime(common.addDate("d", 15, new Date())));
- },
- closeMiaoguo:function(){
- this.setData({
- IsShowMiaoguo: 0,
- });
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: 'pages/index/index?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|