123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- // pages/luckDraw/recordPrize.js
- import LuckDraw from '../../api/luck-draw'
- import { parseTime } from '../../utils/util'
- import {getMobileCache, getPhoneNumberNew as getPhoneNumberSync} from '../../utils/user'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- page: 1,
- pageSize: 10,
- lock: false,
- noResult: false,
- noMore: false,
- isLogin: false,
- mobileTop: 'TONY WU',
- userDrawItemList: [],
- showCustomPreview: false,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- if (!options.activityId) {
- this.popMessage ('入参错误');
- wx.navigateTo({
- url: './index',
- })
- return
- }
- this.data.activityId = options.activityId
- this.setData({
- isLogin: getMobileCache() != ''
- })
- if(this.data.isLogin){
- this.getUserDrawRecord();
- }
-
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- getUserDrawRecord: function() {
- LuckDraw.getUserDrawRecord({
- page: this.data.page,
- pageSize: this.data.pageSize,
- mobile: getMobileCache(),
- activityId: this.data.activityId,
- }).then(res => {
- if (res.code == 200) {
- this.uaerPrizeListView(res.data)
- }
- this.data.lock = false
- }).catch(_ => {
- console.log(_)
- this.data.lock = false
- })
- },
- uaerPrizeListView: function(data) {
- if (!Array.isArray(data) || data.length == 0) {
- console.log("抽奖记录数据为空");
- if (this.data.page == 1) {
- this.setData({
- noResult: true
- })
- } else {
- this.setData({
- noMore: true
- })
- }
- return
- }
- data.forEach(v => {
- let beginTime = v.couponBeginTimestamp
- let endTime = v.couponEndTimestamp
- let createTime = v.createTime
- v.couponBeginTimestamp = parseTime(beginTime, "{y}.{m}.{d}")
- v.couponEndTimestamp = parseTime(endTime, "{y}.{m}.{d}")
- v.createTime = parseTime(createTime, "{y}.{m}.{d} {h}:{i}")
- })
- this.data.userDrawItemList = this.data.userDrawItemList.concat(...data)
- this.setData({
- userDrawItemList: this.data.userDrawItemList
- })
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- if (this.data.lock || this.data.noMore) {
- return
- }
- this.data.lock = true
- this.data.page++
- this.getUserDrawRecord()
- },
-
- toLookHitPhoto(e) {
- console.log(e)
- let url = e.currentTarget.dataset.src;
- this.setData({
- showCustomPreview: true,
- previewImgSrc: url,
- })
- },
- closePreviewImage() {
- this.setData({
- showCustomPreview: false
- })
- },
- turnPrize: function() {
- console.log("开始查看")
- if (this.isLock || !this.data.isLogin) {
- return
- }
- },
- // 授权手机号
- getPhoneNumber(e) {
- getPhoneNumberSync(e, _ => {
- this.setData({
- isLogin: true,
- mobileTop:getMobileCache(),
- })
- console.log(this.data.mobileTop)
- this.getUserDrawRecord()
- })
- },
- })
|