|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- // pages/everyday/everyday.js
- const app = getApp()
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- imgUrl: app.globalData.urlStatic,//图片路径
- showClose:false,
- maskShow: false,
- taskShow: false,
- taskName:'集齐启辰星【大灯】碎片',
- taskImgUrl:'https://www.jiyou-tech.com/2020/496_qichen/static/star/everyday/taskImg1.png',
- isSign:true,
- isShare:false,
- picturlName:[],
- picturlList: ['picturePuzzle1', 'picturePuzzle1'],
- picturlCurrent:0,
- isRegister:false,//是否已注册
- shareId:null,
- },
- /**
- * 关闭任务窗
- */
- hiddenTask:function(){
- this.setData({
- maskShow: false,
- taskShow: false
- })
- },
- /**
- * 签到
- */
- signIn() {
- app.wxRequest(app.globalData.urlRoot +"task/signToday",{},res=>{
- if (res.code == 200) {
- if (!this.data.shareId) {
- this.setData({
- maskShow: false
- })
- } else {
- this.setData({
- taskName: '集齐启辰星【大灯】碎片1/4',
- taskImgUrl: 'https://www.jiyou-tech.com/2020/496_qichen/static/star/everyday/taskImg2.png',
- isSign: false,
- isShare: true,
- showClose: true
- })
- }
- }else{
- wx.showToast({
- title: res.msg,
- icon:"none"
- })
- }
- },this,"POST");
- },
- /**
- * 下个碎片
- */
- nextPicturl(){
- var max = this.data.picturlList.length-1;
- var current = this.data.picturlCurrent + 1;
- if (current <= max){
- this.setData({
- picturlCurrent: current
- })
- }
- },
- //上一个碎片
- prevPicturl(){
- var current = this.data.picturlCurrent - 1;
- if (current >= 0) {
- this.setData({
- picturlCurrent: current
- })
- }
- },
- /**
- * 星探任务
- */
- goScout(){
- wx.navigateTo({
- url: '../scout/scout'
- })
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- app.globalData.nowPage = 2;
- if (app.globalData.openid) {
- this.loadFun();
- } else {
- app.globalData.openidSuccessFuc = this.loadFun;
- }
- },
- loadFun: function () {
- this.getTaskProgress();
- this.getOrderInfo();
- this.getShareId();
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- this.useShareId();
- return {
- title: '我正在参与“星探计划”,快来帮我 解锁内饰碎片吧,共享大奖!',
- imageUrl: "",
- path: "/pages/everyday/everyday"
- }
- },
- getTaskProgress: function () {//获取任务完成度
- app.wxRequest(app.globalData.urlRoot + "task/getTaskProgress", { taskType: 1 }, res => {
- if (res.code == 200) {
- for(let i=0;i<res.data.length;i++){
- this.data.picturlName.push(res.data[i].taskName);
- }
- this.setData({
- picturlName: this.data.picturlName
- })
- } else {
- wx.showToast({
- title: res.msg,
- icon: "none"
- })
- }
- }, this);
- },
- getOrderInfo: function () {//查询是否已注册
- app.wxRequest(app.globalData.urlRoot + "userInfo/getOrderInfo", {}, res => {
- if (res.code == 200) {
- if (res.data) {
- this.setData({
- isRegister: true
- })
- // app.globalData.isRegister = true;
- app.globalData.userMobile = res.data.mobile;
- }
- } else {
- console.log(res.msg)
- }
- }, this);
- },
- receive:function(){//领取购车红包
- if (this.data.isRegister){
- wx.redirectTo({
- url: '../myCenter/myCenter'
- })
- }else{
- wx.navigateTo({
- url: '../receiveRegister/receiveRegister',
- })
- }
- },
- getSignInfo: function () {//查看当日是否签到
- app.wxRequest(app.globalData.urlRoot + "task/getSignInfo", {}, res => {
- if(res.code==200){
- if (res.data.state==0) {//未签到
- this.setData({
- showClose: false,
- maskShow: true,
- taskShow: true,
- isSign: true
- })
- }else{
- if (this.data.shareId){
- this.setData({
- showClose: true,
- maskShow: true,
- taskShow: true,
- isShare: true
- })
- }
- }
- }
- },this)
- },
- getShareId: function () {//获取分享id(查询今日是否已被助力)
- app.wxRequest(app.globalData.urlRoot + "task/getShareId", {}, res => {
- this.getSignInfo();
- if (res.code == 200) {
- this.data.shareId = res.data.shareId;
- }
- }, this)
- },
- useShareId: function () {//发起助力
- app.wxRequest(app.globalData.urlRoot + "task/useShareId", { shareId:this.data.shareId}, res => {
- console.log(res);
- this.setData({
- maskShow:false
- })
- }, this,"POST")
- }
- })
|