|
@@ -1,10 +1,33 @@
|
|
// pages/signIn/record/record.js
|
|
// pages/signIn/record/record.js
|
|
|
|
+import SignIn from '../../../api/signIn'
|
|
|
|
+import { parseTime } from '../../../utils/util'
|
|
|
|
+import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../../utils/user'
|
|
Page({
|
|
Page({
|
|
|
|
|
|
/**
|
|
/**
|
|
* 页面的初始数据
|
|
* 页面的初始数据
|
|
*/
|
|
*/
|
|
data: {
|
|
data: {
|
|
|
|
+ page: 1,
|
|
|
|
+ pageSize: 10,
|
|
|
|
+ lock: false,
|
|
|
|
+ noResult: false,
|
|
|
|
+ noMore: false,
|
|
|
|
+ noCoupon: false,
|
|
|
|
+ noDetail: false,
|
|
|
|
+ noUtility: false,
|
|
|
|
+ isLogin: false,
|
|
|
|
+ hiddenCoupon: false,
|
|
|
|
+ hiddenDetail: false,
|
|
|
|
+ hiddenUtility: false,
|
|
|
|
+ mobileTop: 'TONY WU',
|
|
|
|
+ couponNum: 0,
|
|
|
|
+ productNum: 0,
|
|
|
|
+ activityId: 1,
|
|
|
|
+ couponList: [],
|
|
|
|
+ detailList: [],
|
|
|
|
+ stateList: [],
|
|
|
|
+ notUseNum: 0
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
@@ -12,7 +35,259 @@ Page({
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
*/
|
|
onLoad: function (options) {
|
|
onLoad: function (options) {
|
|
|
|
+ this.setData({
|
|
|
|
+ isLogin: getMobileCache() != ''
|
|
|
|
+ })
|
|
|
|
+ if(this.data.isLogin){
|
|
|
|
+ this.setData({
|
|
|
|
+ hiddenCoupon: false,
|
|
|
|
+ hiddenDetail: true,
|
|
|
|
+ hiddenUtility: true,
|
|
|
|
+ noCoupon: true,
|
|
|
|
+ noDetail: false,
|
|
|
|
+ noUtility: false,
|
|
|
|
+ })
|
|
|
|
+ this.getUserAwardCouponList();
|
|
|
|
+ this.getUserAwardCouponNum();
|
|
|
|
+ this.getUserSignInList();
|
|
|
|
+ this.getCouponStateList();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 优惠券数据
|
|
|
|
+ getUserAwardCouponList: function() {
|
|
|
|
+ SignIn.getUserAwardCouponList({
|
|
|
|
+ page: this.data.page,
|
|
|
|
+ pageSize: this.data.pageSize,
|
|
|
|
+ mobile: "16602120168",
|
|
|
|
+ activityId: this.data.activityId
|
|
|
|
+ }).then(res => {
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
+ this.userCouponListView(res.data)
|
|
|
|
+ }
|
|
|
|
+ this.data.lock = false
|
|
|
|
+ }).catch(_ => {
|
|
|
|
+ console.log(_)
|
|
|
|
+ this.data.lock = false
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ userCouponListView: function(data) {
|
|
|
|
+ if (!Array.isArray(data) || data.length == 0) {
|
|
|
|
+ console.log("优惠券数据为空");
|
|
|
|
+ if (this.data.page == 1) {
|
|
|
|
+ this.setData({
|
|
|
|
+ mobileTop:getMobileCache(),
|
|
|
|
+ noResult: true
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ this.setData({
|
|
|
|
+ mobileTop:getMobileCache(),
|
|
|
|
+ noMore: true
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ data.forEach(v => {
|
|
|
|
+ let beginTime = v.coupon.couponBeginTimestamp
|
|
|
|
+ let endTime = v.coupon.couponEndTimestamp
|
|
|
|
+ v.coupon.couponBeginTimestamp = parseTime(beginTime, "{y}.{m}.{d}")
|
|
|
|
+ v.coupon.couponEndTimestamp = parseTime(endTime, "{y}.{m}.{d}")
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ this.data.couponList = this.data.couponList.concat(...data)
|
|
|
|
+ this.setData({
|
|
|
|
+ mobileTop:getMobileCache(),
|
|
|
|
+ couponList: this.data.couponList
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
|
|
|
|
+ //未使用的券数量
|
|
|
|
+ getUserAwardCouponNum: function() {
|
|
|
|
+ SignIn.getUserAwardCouponNum({
|
|
|
|
+ page: this.data.page,
|
|
|
|
+ pageSize: this.data.pageSize,
|
|
|
|
+ mobile: "16602120168",
|
|
|
|
+ activityId: this.data.activityId
|
|
|
|
+ }).then(res => {
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
+ this.setData({
|
|
|
|
+ notUseNum: res.data.notUseNum
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ this.data.lock = false
|
|
|
|
+ }).catch(_ => {
|
|
|
|
+ console.log(_)
|
|
|
|
+ this.data.lock = false
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 签到明细
|
|
|
|
+ getUserSignInList: function() {
|
|
|
|
+ SignIn.getUserSignInList({
|
|
|
|
+ page: this.data.page,
|
|
|
|
+ pageSize: this.data.pageSize,
|
|
|
|
+ mobile: "16602120168",
|
|
|
|
+ activityId: this.data.activityId
|
|
|
|
+ }).then(res => {
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
+ this.userDetailListView(res.data)
|
|
|
|
+ }
|
|
|
|
+ this.data.lock = false
|
|
|
|
+ }).catch(_ => {
|
|
|
|
+ console.log(_)
|
|
|
|
+ this.data.lock = false
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ userDetailListView: function(data) {
|
|
|
|
+ if (!Array.isArray(data) || data.length == 0) {
|
|
|
|
+ console.log("获取明细数据为空");
|
|
|
|
+ if (this.data.page == 1) {
|
|
|
|
+ this.setData({
|
|
|
|
+ mobileTop:getMobileCache(),
|
|
|
|
+ noResult: true
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ this.setData({
|
|
|
|
+ mobileTop:getMobileCache(),
|
|
|
|
+ noMore: true
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ data.forEach(v => {
|
|
|
|
+ let crateTime = v.crateTime
|
|
|
|
+ v.crateTime = parseTime(crateTime, "{y}-{m}-{d} {h}:{i}")
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ this.data.detailList = this.data.detailList.concat(...data)
|
|
|
|
+ this.setData({
|
|
|
|
+ mobileTop:getMobileCache(),
|
|
|
|
+ detailList: this.data.detailList
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 使用失效
|
|
|
|
+ getCouponStateList: function() {
|
|
|
|
+ SignIn.getUserAwardCouponUseStateList({
|
|
|
|
+ page: this.data.page,
|
|
|
|
+ pageSize: this.data.pageSize,
|
|
|
|
+ mobile: "16602120168",
|
|
|
|
+ activityId: this.data.activityId
|
|
|
|
+ }).then(res => {
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
+ this.userStateListView(res.data)
|
|
|
|
+ }
|
|
|
|
+ this.data.lock = false
|
|
|
|
+ }).catch(_ => {
|
|
|
|
+ console.log(_)
|
|
|
|
+ this.data.lock = false
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ userStateListView: function(data) {
|
|
|
|
+ if (!Array.isArray(data) || data.length == 0) {
|
|
|
|
+ console.log("使用失效数据为空");
|
|
|
|
+ if (this.data.page == 1) {
|
|
|
|
+ this.setData({
|
|
|
|
+ mobileTop:getMobileCache(),
|
|
|
|
+ noResult: true
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ this.setData({
|
|
|
|
+ mobileTop:getMobileCache(),
|
|
|
|
+ noMore: true
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ data.forEach(v => {
|
|
|
|
+ let crateTime = v.crateTime
|
|
|
|
+ v.crateTime = parseTime(crateTime, "{y}-{m}-{d} {h}:{i}")
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ this.data.stateList = this.data.stateList.concat(...data)
|
|
|
|
+ this.setData({
|
|
|
|
+ mobileTop:getMobileCache(),
|
|
|
|
+ stateList: this.data.stateList
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 授权手机号
|
|
|
|
+ getPhoneNumber(e) {
|
|
|
|
+ getPhoneNumberSync(e, _ => {
|
|
|
|
+ this.setData({
|
|
|
|
+ isLogin: true,
|
|
|
|
+ mobileTop: getMobileCache(),
|
|
|
|
+ // hidden1: false,
|
|
|
|
+ // hidden2: true,
|
|
|
|
+ })
|
|
|
|
+ this.getUserAwardCouponList();
|
|
|
|
+ this.getUserAwardCouponNum();
|
|
|
|
+ this.getUserSignInList();
|
|
|
|
+ this.getCouponStateList();
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 优惠券
|
|
|
|
+ getCoupon(e) {
|
|
|
|
+ this.setData({
|
|
|
|
+ hiddenCoupon: false,
|
|
|
|
+ hiddenDetail: true,
|
|
|
|
+ hiddenUtility: true,
|
|
|
|
+ page: 1,
|
|
|
|
+ goodsType: 1,
|
|
|
|
+ noMore: false,
|
|
|
|
+ noResult: false,
|
|
|
|
+ noCoupon: true,
|
|
|
|
+ noDetail: false,
|
|
|
|
+ noUtility: false,
|
|
|
|
+ })
|
|
|
|
+ this.data.couponList= [],
|
|
|
|
+ this.data.detailList= [],
|
|
|
|
+ this.data.stateList= [],
|
|
|
|
+ this.getUserAwardCouponList()
|
|
|
|
+ },
|
|
|
|
+ //明细
|
|
|
|
+ getDetail(e) {
|
|
|
|
+ this.setData({
|
|
|
|
+ hiddenCoupon: true,
|
|
|
|
+ hiddenDetail: false,
|
|
|
|
+ hiddenUtility: true,
|
|
|
|
+ page: 1,
|
|
|
|
+ goodsType: 2,
|
|
|
|
+ noMore: false,
|
|
|
|
+ noResult: false,
|
|
|
|
+ noDetail: true,
|
|
|
|
+ noCoupon: false,
|
|
|
|
+ noUtility: false,
|
|
|
|
+ })
|
|
|
|
+ this.data.couponList= [],
|
|
|
|
+ this.data.detailList= [],
|
|
|
|
+ this.data.stateList= [],
|
|
|
|
+ this.getUserSignInList()
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ //使用失效
|
|
|
|
+ getUtility(e) {
|
|
|
|
+ this.setData({
|
|
|
|
+ hiddenCoupon: true,
|
|
|
|
+ hiddenDetail: true,
|
|
|
|
+ hiddenUtility: false,
|
|
|
|
+ page: 1,
|
|
|
|
+ goodsType: 2,
|
|
|
|
+ noMore: false,
|
|
|
|
+ noResult: false,
|
|
|
|
+ noUtility: true,
|
|
|
|
+ noCoupon: false,
|
|
|
|
+ noDetail: false,
|
|
|
|
+ })
|
|
|
|
+ this.data.couponList= [],
|
|
|
|
+ this.data.detailList= [],
|
|
|
|
+ this.data.stateList= [],
|
|
|
|
+ this.getCouponStateList()
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -54,7 +329,12 @@ Page({
|
|
* 页面上拉触底事件的处理函数
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
*/
|
|
onReachBottom: function () {
|
|
onReachBottom: function () {
|
|
-
|
|
|
|
|
|
+ if (this.data.lock || this.data.noMore) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ this.data.lock = true
|
|
|
|
+ this.data.page++
|
|
|
|
+ this.getUserAwardCouponList()
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|