| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- import common from '../../utils/util';
- import server from '../../utils/main';
- const app = getApp();
- var interval = 0;
- var isPaying = false;
- var hanziNumber = 0;
- var isMiaoguoADShow=false;
- Page({
- data: {
- Version: app.globalData.Version,
- List: [
- {
- ImageUrl: "home_plate_11.png",
- Url: "../main/list?id=1",
- },
- {
- ImageUrl: "home_plate_12.png",
- Url: "../main/list?id=2",
- },
- {
- ImageUrl: "home_plate_21.png",
- Url: "../main/list?id=3",
- },
- {
- ImageUrl: "home_plate_22.png",
- Url: "../main/list?id=4",
- },
- {
- ImageUrl: "home_plate_31.png",
- Url: "../main/list?id=5",
- },
- {
- ImageUrl: "home_plate_32.png",
- Url: "../main/list?id=6",
- },
- {
- ImageUrl: "home_plate_41.png",
- Url: "../main/list?id=7",
- },
- {
- ImageUrl: "home_plate_42.png",
- Url: "../main/list?id=8",
- },
- {
- ImageUrl: "home_plate_51.png",
- Url: "../main/list?id=9",
- },
- {
- ImageUrl: "home_plate_52.png",
- Url: "../main/list?id=10",
- },
- {
- ImageUrl: "home_plate_61.png",
- Url: "../main/list?id=11",
- },
- {
- ImageUrl: "home_plate_62.png",
- Url: "../main/list?id=12",
- },
- ],
- NickName: "陌生用户",
- IsMember: 1,
- NewUserNumber: 2,
- AvatarUrl: "",
- DayNumber: "0",
- ReviewCount: "0",
- FinishedCount: "0",
- IsAccredit: false,
- IsMemberForeverRemind: 0,
- IsMiaoguoAD: false,
- IsMiaoguoAD2:0,
- IsShowGift:0,
- },
- onLoad: function (options) {
- //app.globalData.userInfo.UserID=5;
- this.setData({
- Height: common.getSystemHeight(),
- ListProgram: server.getProgramListOld(),
- IsShowGift:app.globalData.userInfo.IsShowGift,
- });
- var that = this;
-
- isMiaoguoADShow = false;
- },
- onShow: function () {
- this.setData({
- 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 (wx.getStorageSync("HasActivate") == 1) {
- wx.navigateTo({
- url: '../../package4/main/activate',
- });
- }
- else {
- this.getData();
- if (app.globalData.goto) {
- var url = "../main/list?id=1";
- if (app.globalData.goto == "test")
- url = '../main/test';
- wx.navigateTo({
- url: url,
- });
- app.globalData.goto = "";
- }
- }
- 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;
- }
- },
- getData: function () {
- var that = this;
- server.getData('GetHanziRecordData?UserID=' + app.globalData.userInfo.UserID + "&Version=" + app.globalData.Version, function (data) {
- if (data) {
- if (!data.DayNumber)
- data.DayNumber = 0;
- var finishedCount = 0;
- if (data.FinishedList)
- finishedCount = data.FinishedList.length;
- var reviewCount = 0;
- if (data.ReviewList)
- reviewCount = data.ReviewList.length;
- hanziNumber = 0;
- var arr = JSON.parse(wx.getStorageSync("HanziAll"));
- for (var k = 0; k < data.FinishedList.length; k++) {
- for (var i = 0; i < arr.length; i++) {
- var b1 = false;
- for (var j = 0; j < arr[i].Units.length; j++) {
- var item = arr[i].Units[j];
- if (item.ID == data.FinishedList[k].UnitID) {
- hanziNumber += item.Words.length;
- for (var n = 0; n < item.Words.length; n++) {
- for (var l = 0; l < data.ReviewList.length; l++) {
- if (data.ReviewList[l].WordID == item.Words[n].ID) {
- hanziNumber--;
- }
- }
- }
- b1 = true;
- break;
- }
- }
- if (b1)
- break;
- }
- }
- if (!hanziNumber) {
- hanziNumber = 0;
- }
- that.setData({
- IsAccredit:true,
- DayNumber: data.DayNumber,
- HanziNumber: hanziNumber,
- FinishedCount: finishedCount,
- ReviewCount: reviewCount,
- });
- wx.setStorageSync("FinishedList", data.FinishedList);
- wx.setStorageSync("ReviewList", data.ReviewList);
- }
- });
- var UnitCustom = wx.getStorageSync("UnitCustom");
- if (!UnitCustom) {
- var that = this;
- server.getData('GetHanziCustomList?UserID=' + app.globalData.userInfo.UserID, function (data) {
- if (data && data.length > 0) {
- for (var n = 0; n < data.length; n++) {
- if (data[n].List)
- data[n].List = JSON.parse(data[n].List);
- }
- wx.setStorageSync("UnitCustom", data);
- }
- });
- }
- },
- 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;
- },
- gotoSearch: function (e) {
- wx.navigateTo({
- url: "../main/search",
- });
- },
- gotoReview: function () {
- if (this.data.IsShow == 1 && this.data.IsMember == 0) {
- wx.navigateTo({
- url: '../../package4/main/buyad',
- })
- }
- else {
- wx.navigateTo({
- url: '../main/review',
- });
- }
- },
- gotoTest: function (e) {
- wx.navigateTo({
- url: '../main/test',
- });
- },
- 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',
- });
- }
- },
- updateMember: function () {
- if (app.globalData.userInfo.UserID == 1) {
- if (app.globalData.userInfo.IsMember == 1) {
- app.globalData.userInfo.IsMember = 0;
- this.setData({
- IsMember: false,
- });
- }
- else {
- app.globalData.userInfo.IsMember = 1;
- this.setData({
- IsMember: true,
- });
- }
- }
- },
- 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,
- }
- },
- })
|