You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
4.0 KiB
125 lines
4.0 KiB
import { getBaseInfo, getTaskList, getPointList, getPointProduct } from "../../../api/ztb"
|
|
const util = require('../../../utils/util')
|
|
const events = require('../../../utils/event')
|
|
import WxCountUp from '../../../utils/countup'
|
|
const app = getApp()
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
height: app.globalData.fragmentHeight,
|
|
userInfo: null,
|
|
number: 0,
|
|
taskList: null,
|
|
pointList: null,
|
|
toViewId: null
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.setData({ userInfo: app.globalData.userInfo, height: app.globalData.fragmentHeight })
|
|
this.fetchUserInfo()
|
|
this.countUp = new WxCountUp('number', 5024, {}, this)
|
|
this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog')
|
|
},
|
|
fetchUserInfo: function () {
|
|
wx.showLoading({ title: '处理中', mask: true })
|
|
getBaseInfo().then(result => {
|
|
this.countUp.update(result.data.memberRewardPoint)
|
|
})
|
|
getTaskList().then(result => {
|
|
var shareIndex = -1
|
|
for (let index = 0; index < result.data.length; index++) {
|
|
const element = result.data[index]
|
|
if(element.linkUrlJson && element.linkUrlJson.redirectInfo && element.linkUrlJson.redirectInfo.targetView == 'shareProxyOrder'){
|
|
shareIndex = index
|
|
break
|
|
}
|
|
}
|
|
if(shareIndex >= 0){
|
|
result.data.splice(shareIndex, 1)
|
|
}
|
|
this.setData({ taskList: result.data })
|
|
})
|
|
getPointList().then(result => {
|
|
this.setData({ pointList: result.data })
|
|
wx.hideLoading()
|
|
}).catch(error => {
|
|
wx.hideLoading()
|
|
})
|
|
},
|
|
lookTask: function(event){
|
|
var item = this.data.taskList[event.currentTarget.dataset.index]
|
|
var targetView = null
|
|
if(item.linkUrlJson && item.linkUrlJson.redirectInfo && item.linkUrlJson.redirectInfo.targetView){
|
|
targetView = item.linkUrlJson.redirectInfo.targetView
|
|
}
|
|
if(!targetView){
|
|
return
|
|
}
|
|
if(targetView == 'createShop'){
|
|
// 开店铺
|
|
wx.redirectTo({ url: '/pages/shop/index/index' })
|
|
} else if(targetView == 'updateShopInfo'){
|
|
// 完善店铺
|
|
wx.redirectTo({ url: '/pages/shop/index/index' })
|
|
} else if(targetView == 'createProduct'){
|
|
// 发布商品
|
|
wx.redirectTo({ url: '/pages/shop/index/index' })
|
|
} else if(targetView == 'replyArticle'){
|
|
// 回复帖子
|
|
events.emit('EventMessage', { what: 250, desc: 'Share' })
|
|
wx.navigateBack({ delta: 1 })
|
|
} else if(targetView == 'createArticle'){
|
|
// 发布帖子
|
|
wx.redirectTo({ url: '/pages/article/publish/index' })
|
|
}
|
|
},
|
|
exchangePoint: function(event){
|
|
var item = this.data.pointList[event.currentTarget.dataset.index]
|
|
if(parseInt(app.globalData.userInfo.memberRewardPoint) < parseInt(item.price)){
|
|
util.showToast('您的积分不够,赶快去赚取积分吧')
|
|
return
|
|
}
|
|
if(!app.globalData.userInfo.isAuth){
|
|
this.wuxDialog.open({
|
|
resetOnClose: true,
|
|
title: '温馨提示',
|
|
content: '您还没有进行个人信息认证,无法兑换会员,现在去进行个人信息认证?',
|
|
buttons: [{
|
|
text: '确定',
|
|
type: 'primary',
|
|
onTap(e) {
|
|
wx.navigateTo({ url: '/pages/home/idcard/index' })
|
|
}
|
|
}]
|
|
})
|
|
return
|
|
}
|
|
wx.showLoading({ title: '处理中', mask: true })
|
|
getPointProduct(item.id).then(res => {
|
|
util.showToast('兑换成功')
|
|
app.globalData.userInfo.isVIP = 1
|
|
events.emit('EventMessage', { what: 200, desc: 'Vip' })
|
|
getPointList().then(result => {
|
|
this.setData({ pointList: result.data })
|
|
wx.hideLoading()
|
|
app.globalData.userInfo.memberRewardPoint -= parseInt(item.price)
|
|
this.countUp.update(app.globalData.userInfo.memberRewardPoint)
|
|
}).catch(error => {
|
|
wx.hideLoading()
|
|
util.showToast(error)
|
|
})
|
|
}).catch((e) => {
|
|
wx.hideLoading()
|
|
})
|
|
},
|
|
toBottom: function(){
|
|
this.setData({toViewId: 'exchangeId'})
|
|
}
|
|
|
|
})
|