123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- safeAreaTop:50+app.data.safeAreaTop,
- claimTaskFlag:false,
- authorizeFlag:false,
- userList:[],
- token:'',
- user_id:'',
- isReset:false,
- isOneFalg:true,
- timeType:1,
- minute: 600,
- timeMsg:'',
- timer:1,
- isIOS:false,
- deleteTaskFlag:false,
- delete_user_id:''
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.uploadClaim()
- var info = wx.getSystemInfoSync()
- if (info.platform === 'android') {
- this.setData({isIOS:false})
- } else {
- this.setData({isIOS:true})
- }
- },
- onShow: function () {
- this.uploadClaim()
- },
- switchPlatform(){//日期切换
- var _this = this;
- wx.showActionSheet({
- itemList: ['昨天', '近7天', '近30天'],
- success (res) {
- _this.setData({
- timeType:res.tapIndex == 0 ? 1 : res.tapIndex == 1 ? 7 : res.tapIndex == 2 ? 30 : 1
- })
- },
- fail (res) {
- }
- })
- },
- goUserDetail(e){
- var data = e.currentTarget.dataset.data;
- if(data.no_user){
- this.setData({
- claimTaskFlag:true,
- user_id:data.user_id
- })
- }else{
- wx.navigateTo({
- url: '/pages/claim/claimDetail/index?user_id='+data.user_id,
- })
- }
-
- },
- uploadClaim(){//更新数据
- this.setData({authorizeFlag:false})
- if(wx.getStorageSync('claim_token')&&wx.getStorageSync('claim_token')!=''){
- wx.showLoading({
- title: '加载中',
- })
- app.func.req('/api/sphClaim/getData', 'get', {
- user_id:this.data.user_id,
- token:wx.getStorageSync('claim_token')
- }, (res) => {
- wx.hideLoading()
- if(res && res.errno == 0){
- var data = wx.getStorageSync('claim')
- if(!data||data==''){data={}}
- data[res.rst.user_id] = res.rst;
- wx.setStorageSync('claim', data)
- wx.setStorageSync('claim_token', '')
- this.init()
- }else{
- this.init()
- // wx.showToast({
- // title: res.err,
- // icon: 'none',
- // duration: 2000
- // })
- }
- },()=>{
- this.init()
- wx.hideLoading()
- })
- }else{
- this.init()
- }
- },
- init(){
- wx.showLoading({
- title: '加载中',
- })
- app.func.req('/api/sphClaimInfo/list', 'get', {}, (res) => {
- wx.hideLoading()
- wx.stopPullDownRefresh()
- if(res && res.errno == 0){
- var user_arr = res.rst;
- var local_claim = wx.getStorageSync('claim')
- user_arr.forEach((item)=>{
- if(local_claim[item.user_id]){
- item.post = local_claim[item.user_id].indicator.post;
- }else{
- item.no_user = true
- }
- })
- this.setData({
- isOneFalg:false,
- userList:user_arr,
- })
- }else{
- wx.showToast({
- title: res.err,
- icon: 'none',
- duration: 2000
- })
- }
- },()=>{
- wx.stopPullDownRefresh()
- wx.hideLoading()
- })
- },
- claimButtonEvent(){//添加视频号
- this.setData({claimTaskFlag:true,isReset:false,user_id:''})
- },
- againActivationEvent(e){//重新激活
- var user_id = e.currentTarget.dataset.user_id
- this.setData({isReset:true,user_id:user_id})
- this.getToken()
- },
- cancelTask(){
- this.setData({claimTaskFlag:false,authorizeFlag:false,deleteTaskFlag:false})
- },
- closeClaimMask(){
- this.setData({
- authorizeFlag:false
- })
- this.uploadClaim()
- },
- getToken(){
- this.setData({
- claimTaskFlag:false,
- authorizeFlag:true,
- })
- },
- deleteEvent(e){
- var user_id = e.currentTarget.dataset.user_id;
- this.setData({
- delete_user_id:user_id,
- deleteTaskFlag:true
- })
- },
- deleteVideoNum(){//删除视频号
- wx.showLoading({
- title: '加载中',
- })
- app.func.req('/api/sphClaim/delete', 'post', {
- uid:this.data.delete_user_id
- }, (res) => {
- wx.hideLoading()
- if(res && res.errno == 0){
- var local_claim = wx.getStorageSync('claim'),obj={}
- if(local_claim&&local_claim!=''){
- for(var i in local_claim){
- if(i!=this.data.delete_user_id){
- obj[i] = local_claim[i]
- }
- }
- wx.setStorageSync('claim', obj)
- }
- this.setData({deleteTaskFlag:false})
- this.init()
- }else{
- wx.showToast({
- title: res.err,
- icon: 'none',
- duration: 2000
- })
- }
- },()=>{
- wx.hideLoading()
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- clearInterval(this.data.timer);
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- this.uploadClaim()
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|