123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- import {
- getOpenidSessionKey
- } from '../../utils/httpUtil';
- import {
- formatDate
- } from '../../utils/util';
- const app = getApp()
- import {
- hotInit
- } from '../../component/hot/hot';
- import {
- groupInit
- } from '../../component/group/group';
- import {
- myInit
- } from '../../component/my/my';
- import httpRequestApi from '../../utils/APIClient';
- import httputil from '../../utils/httpUtil';
- import {
- GetQueryString
- } from '../../utils/util';
- Page({
- data: {
- tab: [{
- name: '我的',
- templates: 'my',
- },
- {
- name: '发现',
- templates: 'hot',
- },
- {
- name: '热团',
- templates: 'group',
- },
-
-
-
-
- ],
- winH: 568,
- myIndex: 1,
- followData: [],
- recommendPageNo: 0,
- recommendTotalNo: 1,
- followPageNo: 1,
- followPageTotalNo: 1,
- myData: {},
- templates: 'hot',
- title: 'index中的title',
- jurisdictionFlag: true,
- hotInput: '12345',
- mineSettingInfo: '528',
- hide: true,
- isIOS: app.globalData.isIOS,
- ifHaveMore: true,
- indexSignDialog: false,
- indexMissionDialog: false,
- unfinishedCount: 0
- },
- jurisdiction: function () {
-
- this.setData({
- hide: !this.data.hide
- })
-
- this.onShow();
- },
-
- switcher: function ({
- currentTarget
- }) {
- if (currentTarget.dataset.index === this.data.myIndex) return;
- this.updateData(currentTarget.dataset.index);
- },
-
- updateData: function (index) {
- let myIndex = index;
- let templates = this.data.tab[myIndex].templates;
- this.setData({
- myIndex,
- templates
- });
- if (myIndex == 0) {
-
- this.setData({
- followPageNo: 1,
- })
- myInit(this);
- }
- if (myIndex == 1) {
-
-
-
- hotInit(this);
- }
- if (myIndex == 2) {
- groupInit(this);
- }
- },
- onLoad: function (options) {
- this.uid = wx.getStorageSync('uid');
- wx.getSystemInfo({
- success: (res) => {
- this.setData({
- winH: res.windowHeight
- });
- }
- });
- if (options.index) {
- this.updateData(options.index)
- }
- setTimeout(() => {
- if (wx.getStorageSync('uid')) {
- httpRequestApi.userLoginRecord().success(res => {
- if (res.data.data) {
-
- if (this.data.unfinishedCount > 0) {
- this.setData({
- indexSignDialog: true
- })
- }
- } else {
-
- let oldDay = wx.getStorageSync('oldDay');
- let newDate = new Date();
- let timeStep =(newDate.getMonth() + 1).toString() + newDate.getDate().toString()
- if (oldDay) {
- let temp = parseInt(timeStep) - parseInt(oldDay)
- if (temp > 0) {
- wx.setStorageSync('oldDay', timeStep);
- this.setData({
- indexMissionDialog: true
- })
- }
- } else {
- wx.setStorageSync('oldDay', timeStep);
- this.setData({
- indexMissionDialog: true
- })
- }
- }
- })
- }
- }, 2800)
-
-
- },
- onShow: function () {
- wx.setNavigationBarTitle({
- title: '小学课文朗读配音'
- })
-
- getOpenidSessionKey((res) => {
- hotInit(this)
- }, (error) => {
-
- wx.setStorageSync('userSourseType','normal')
- this.setData({
- hide: !this.data.hide
- })
- return;
- });
- if (this.data.myIndex === 0) {
-
- this.getUserWorksInfo(true);
- }
- },
- onHide: function(){
- const str = 'hotData.inputFocus'
- this.setData({
- [str]: false
- });
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
- getUserWorksInfo: function (flag) {
- console.log(flag)
- if (flag) {
- httpRequestApi.getUserWorksInfo().success(res => {
- const str = 'myData.user.user.nickName';
- this.setData({
- [str]: res.data.data.user.nickName
- })
- })
- return;
- }
- const userLocal = wx.getStorageSync('user')
- console.log(userLocal)
- const str = 'myData.user';
- this.setData({
- [str]: userLocal
- })
- httpRequestApi.getUserWorksInfo().success(res => {
- this.data.myData.user = res.data.data;
- httpRequestApi.userIntoPage('pages/index/index', '首页我的').success((res) => {})
- if (this.data.myData.user.myRead) {
- this.data.myData.user.myRead.gmtCreated = formatDate(this.data.myData.user.myRead.gmtCreated, 4)
- }
- this.setData({
- myData: this.data.myData,
- });
- }).fail(error => {
- console.log(error)
- })
- },
-
- onReachBottom: function () {
- console.log(this.data.myIndex )
- if (this.data.myIndex === 0) {
- this.setData({
- followPageNo: this.data.followPageNo + 1
- })
- if (this.data.followPageNo <= this.data.followPageTotalNo) {
- this.getFollowWorks(this.data.followPageNo, 3);
- } else {
- console.log('没有更多')
- this.setData({
- ifHaveMore: false
- })
- }
- }
-
- if (this.data.myIndex === 1) {
- console.log(this.data.recommendPageNo)
- console.log(this.data.recommendTotalNo)
- this.setData({
- recommendPageNo: this.data.recommendPageNo + 1
- })
- if (this.data.recommendPageNo <= this.data.recommendTotalNo) {
- this.getHotRecommendSecond(this.uid, this.data.recommendPageNo, 3);
- } else {
- console.log('没有更多')
- }
- }
- },
- onPullDownRefresh: function () {
-
- if (this.data.myIndex === 0) {
-
- }
- wx.showNavigationBarLoading()
-
- setTimeout(function () {
- wx.hideNavigationBarLoading()
- wx.stopPullDownRefresh()
- }, 1500);
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- goToMessage: function () {
- wx.navigateTo({
- url: `../../pages/social/insideMessage/insideMessage`
- });
- const str = 'hotData.unReadMessageNum';
- this.setData({
- [str]: 0
- })
- },
- toMyCollage: function (e) {
- if (app.globalData.isIOS) {
- wx.navigateTo({
- url: `../../pages/groupPage/my-group/my-group?title=我的助力`
- });
- } else {
- wx.navigateTo({
- url: `../../pages/groupPage/my-group/my-group?title=我的拼团`
- });
- }
- },
- toMyCourse: function () {
- wx.navigateTo({
- url: `../../pages/user/mycourse/mycourse?title=我的课程`
- });
- },
- goToFlower: function () {
- wx.navigateTo({
- url: `../../pages/social/littleFlower/littleFlower`
- });
- },
- signInBtn: function (e) {
- this.setData({
- indexSignDialog: false
- })
- console.log(e.detail.formId)
- httpRequestApi.postFormId(e.detail.formId).success(res => {
- console.log(res)
- })
- this.goToFlower();
- },
- missionBtn: function () {
- this.setData({
- indexMissionDialog: false
- })
- this.goToFlower();
- }
- })
|