admin
2020-12-22 28a4cfadc0a78d1bfec093e0694f420aaf3a725c
'api完善'
34个文件已修改
1个文件已添加
1576 ■■■■ 已修改文件
.tea/entryFiles-production/index$.web.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.tea/entryFiles-production/index$.worker.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app.acss 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app.js 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/activity-detail/activity-detail.axml 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/activity-detail/activity-detail.js 120 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/advice/advice.axml 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/advice/advice.js 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/assist-friends/assist-friends.axml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/assist-friends/assist-friends.js 104 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/assist-process/assist-process.axml 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/assist-process/assist-process.js 108 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/join-statistic/join-statistic.acss 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/join-statistic/join-statistic.axml 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/join-statistic/join-statistic.js 147 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/lucky-coupon/lucky-coupon.js 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/lucky-record/lucky-record.js 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/mine/mine.axml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/mine/mine.js 167 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/msg-record/msg-record.axml 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/msg-record/msg-record.js 180 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/msg-setting/msg-setting.axml 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/msg-setting/msg-setting.js 50 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/reward-announcement/reward-announcement.axml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/reward-announcement/reward-announcement.js 106 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/rewards/rewards.axml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/rewards/rewards.js 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/scan-record/scan-record.js 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/sponsor-activity/sponsor-activity.js 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/sponsor-signup/sponsor-signup.js 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/web/web.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
util/api.js 99 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
util/help.js 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
util/http.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
util/user.js 101 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.tea/entryFiles-production/index$.web.js
@@ -28,8 +28,8 @@
require('../../pages/join-statistic/join-statistic?hash=96494a69a77c04a2a41944933b5875740b0d9262');
require('../../pages/advice/advice?hash=c38b953af6bdab8fe399141b33dd1ad1ceb7ea7f');
require('../../pages/activity-detail/activity-detail?hash=3ff7dd30a3ea0de70909d48b0b8ce5bda62ef62e');
require('../../pages/assist-process/assist-process?hash=c6818e0a77e4e2f8365cc6ed1a93960827e43474');
require('../../pages/lucky-coupon/lucky-coupon?hash=c6818e0a77e4e2f8365cc6ed1a93960827e43474');
require('../../pages/assist-process/assist-process?hash=f1b7dc4ca438ceda80574161c70b1f25cb9fb567');
require('../../pages/lucky-coupon/lucky-coupon?hash=f1b7dc4ca438ceda80574161c70b1f25cb9fb567');
require('../../pages/msg-record/msg-record?hash=59bab5c4a4a4ec930e168925c97c3057ac83fa7d');
require('../../pages/assist-friends/assist-friends?hash=59bab5c4a4a4ec930e168925c97c3057ac83fa7d');
require('../../pages/msg-setting/msg-setting?hash=5f504890acbcf3bad0486fc198ac7448dd406718');
.tea/entryFiles-production/index$.worker.js
@@ -57,8 +57,8 @@
require('../../pages/join-statistic/join-statistic?hash=96494a69a77c04a2a41944933b5875740b0d9262');
require('../../pages/advice/advice?hash=c38b953af6bdab8fe399141b33dd1ad1ceb7ea7f');
require('../../pages/activity-detail/activity-detail?hash=3ff7dd30a3ea0de70909d48b0b8ce5bda62ef62e');
require('../../pages/assist-process/assist-process?hash=c6818e0a77e4e2f8365cc6ed1a93960827e43474');
require('../../pages/lucky-coupon/lucky-coupon?hash=c6818e0a77e4e2f8365cc6ed1a93960827e43474');
require('../../pages/assist-process/assist-process?hash=f1b7dc4ca438ceda80574161c70b1f25cb9fb567');
require('../../pages/lucky-coupon/lucky-coupon?hash=f1b7dc4ca438ceda80574161c70b1f25cb9fb567');
require('../../pages/msg-record/msg-record?hash=59bab5c4a4a4ec930e168925c97c3057ac83fa7d');
require('../../pages/assist-friends/assist-friends?hash=59bab5c4a4a4ec930e168925c97c3057ac83fa7d');
require('../../pages/msg-setting/msg-setting?hash=5f504890acbcf3bad0486fc198ac7448dd406718');
app.acss
@@ -192,6 +192,7 @@
.btn-primary {
  background: #0080FF;
  color: white;
}
.btn-ghost-hover {
app.js
@@ -1,16 +1,36 @@
var help = require('./util/help.js');
var help = require('/util/help.js');
var api = require('./util/api.js');
const user = require('./util/user.js');
App({
  themeColor: "#0080FF",
  appKey: '1000001',
  baseUrl:'http://192.168.3.122:8083',
  version: 1,
  logined: false,
  baseUrl: 'http://192.168.3.122:8083',
  onLaunch(options) {
    // 第一次打开
    // options.query == {number:1}
    console.info('App onLaunch');
    my.hideFavoriteMenu();
    api.getConfig({
      success: function (res) {
        if (res.code == 0) {
          //保存参数
          help.cacheConfig(res.data);
        }
      }
    });
    user.init();
  },
  //全局分享函数
  onShareAppMessage(obj) {
  },
  onShow(options) {
    // 从后台被 scheme 重新打开
    // options.query == {number:1}
pages/activity-detail/activity-detail.axml
@@ -86,10 +86,13 @@
          </view>
        </view>
        <view style="display:flex;  justify-content: space-between;margin:60rpx 0 40rpx 0;">
          <button type="ghost" open-type="share" hover-class="btn-ghost-hover" onTap="onAssistClick" style="width:238rpx;">
          <button type="ghost" open-type="{{!logined?'getAuthorize':'share'}}" onGetAuthorize="onGetAuthorize" onError="onAuthError" scope='userInfo' hover-class="btn-ghost-hover" onTap="onAssistClick" style="width:238rpx;">
    好友助力
          </button>
          <button type="primary" class="btn-primary" hover-class="btn-primary-hover" onTap="{{activity.joined?'onMyCouponClick':'onFreeLuckyClick'}}" style="width:392rpx;">
          <button a:if="{{!logined}}" open-type="getAuthorize" onGetAuthorize="onGetAuthorize" onError="onAuthError" scope='userInfo' type="primary" class="btn-primary" hover-class="btn-primary-hover" style="width:392rpx;">
    {{activity.joined?'幸运券':'免费抽奖'}}
          </button>
          <button a:else type="primary" class="btn-primary" hover-class="btn-primary-hover" onTap="{{activity.joined?'onMyCouponClick':'onFreeLuckyClick'}}" style="width:392rpx;">
    {{activity.joined?'幸运券':'免费抽奖'}}
          </button>
        </view>
@@ -152,8 +155,7 @@
        <view class="cut-line"></view>
        <view onTap="mianZe">免责申明</view>
        <view class="cut-line"></view>
        <view onTap="onComplaintClick">我要投诉</view>
        <view class="cut-line"></view>
        <!--<view onTap="onComplaintClick">我要投诉</view><view class="cut-line"></view> -->
        <view onTap="onMsgSettingClick">消息设置</view>
      </view>
      <view style="height:81rpx;"></view>
@@ -173,9 +175,8 @@
    免责申明
      </view>
      <view class="content" decode="true">
        <text>
      我们天天领现金-淘拼团作为提供发起及参与抽奖的小程序平台,不对任何第三方发起人行为承担责任,活动中所包含的所有奖品均由活动发起者提供并发放。
我们天天领现金-淘拼团会在法律范围内规范、监督、督促用户遵守相关法律和平台使用规则,营造良好、公平、公正、真实的平台环境,感谢支持。
        <text decode="true">
      {{activity.disclaimers}}
        </text>
      </view>
      <button type="primary" class="btn-primary" hover-class="btn-primary-hover" onTap="closeMianZeModal">
pages/activity-detail/activity-detail.js
@@ -1,10 +1,12 @@
var help = require('../../util/help.js');
var api = require('../../util/api.js');
var help = require('/util/help.js');
var api = require('/util/api.js');
import parse from 'mini-html-parser2';
import user from '/util/user';
var $this;
var leftTimeInterval;
Page({
  data: {
    logined: getApp().logined,
    leftTime: {//剩余时间
      hh: "00",
      mm: "00",
@@ -13,6 +15,8 @@
    leftTimeMS: 0,
    checkFollow: false,
    showFollow: false,
    //关注条件结果
    joinConditionResult: {},
    //免责弹框
    showMianZeModal: false,
    //参与抽奖成功弹框
@@ -33,8 +37,6 @@
    assistProcessDesc: [],
    //中奖公示
    drawnAnouncementDesc: [],
  },
  onShareAppMessage() {
@@ -47,16 +49,16 @@
    console.log(query);
    help.setPageNavBar("抽奖详情");
    $this.setData({
      joinInfo: query.joinInfo
      joinInfo: query.joinInfo,
      logined:getApp().logined
    });
    api.getActivityDetail({
      showErrorToast: true,
      showLoading: true,
      id: query.id,
      success: function (res) {
        if (res.code != 0) {
          my.showToast({
            content: res.msg
          });
          return;
        }
@@ -109,7 +111,7 @@
        }, 100);
        //封装助力进度的富文本
        $this.loadRichTextNode(help.getAssistProcessHtml(1), function (nodes) {
        $this.loadRichTextNode(help.getAssistProcessHtml(data.assistCount), function (nodes) {
          $this.setData({
            assistProcessDesc: nodes
@@ -117,15 +119,20 @@
        });
        //封装中奖公示的富文本
        $this.loadRichTextNode(help.getDowanAnouncementHtml("2020.02.02 02:02"), function (nodes) {
        $this.loadRichTextNode(help.getDowanAnouncementHtml(data.actualOpenDate), function (nodes) {
          $this.setData({
            drawnAnouncementDesc: nodes
          });
        });
        // 是否需要展示关注组件
        switch ($this.data.activity.activity.sponsorAd.jump.jumpType) {
          case 'alipayLife': //支付宝生活号
            $this.showFollowView();
            break;
        }
      }
      },
      showLoading: true,
    })
@@ -140,9 +147,6 @@
    var item = my.createSelectorQuery()
      .select('#beizhu');
    console.log(item);
  },
  loadRichTextNode(html, callback) {
@@ -151,6 +155,30 @@
      if (!err) {
        callback(nodes);
      }
    });
  },
  //授权成功
  onGetAuthorize(res) {
    user.login({
      success: function (data) {
        $this.setData({
          logined: true,
          user: data
        });
        my.showToast({
          content: '登录成功'
        })
      }, fail(e) {
        my.showToast({
          content: '登录失败'
        })
      }
    })
  },
  //授权失败
  onAuthError(event) {
    my.showToast({
      content: '授权失败'
    });
  },
@@ -233,20 +261,12 @@
      checkFollow: true,
      showFollow: true
    });
    // setTimeout(() => {
    //   this.setData({
    //     checkFollow: false,
    //     showFollow: true
    //   });
    // });
  },
  //关注回调
  checkFollowCb(e) {
    // e.detail对象里会有followed字段,可以用来判断关注状态
    console.log("是否关注:" + e.detail.followed);
    $this.data.joinConditionResult.attentioned = e.detail.followed;
    this.setData({
      checkFollow: false,
      showFollow: false,
@@ -262,39 +282,73 @@
  },
  //关注面板关闭
  closeCb(e) {
    $this.data.joinConditionResult.attentioned = e.detail.followed;
    console.log("是否关注:" + e.detail.followed);
  },
  //免费抽奖
  onFreeLuckyClick() {
    //关闭助力弹框
    this.closeAssistModal();
    this.requestJoin();
    var result = new Array();
    //获取参加条件
    console.log($this.data.activity.joinCondition.conditions);
    for (var i = 0; i < $this.data.activity.joinCondition.conditions.length; i++) {
      const key = $this.data.activity.joinCondition.conditions[i];
      console.log("key:" + key);
      switch (key) {
        case 'attention':
          console.log("关注:" + $this.data.joinConditionResult.attentioned);
          if ($this.data.joinConditionResult.attentioned) {
            result.push(true);
          } else {
            result.push(false);
            my.showToast({
              content: '请先关注生活号'
            });
            return;
          }
          break;
      }
    }
    var canJoin = true;
    if (result.length != 0)
      for (var key in result) {
        if (!key) {
          canJoin = false; break;
        }
      }
    if (canJoin) {
      console.log("可以参与")
      this.requestJoin();
    }
  },
  //我的幸运券
  onMyCouponClick() {
    my.navigateTo({
      url: '/pages/lucky-coupon/lucky-coupon?activityId='+$this.data.activity.activity.id
      url: '/pages/lucky-coupon/lucky-coupon?activityId=' + $this.data.activity.activity.id
    });
  },
  //更多参与者
  onJoinerMoreClick() {
    my.navigateTo({
      url: '/pages/join-statistic/join-statistic'
      url: '/pages/join-statistic/join-statistic?activityId=' + $this.data.activity.activity.id
    });
  },
  //助力进度
  onAssistProcessClick() {
    my.navigateTo({
      url: '/pages/assist-process/assist-process'
      url: '/pages/assist-process/assist-process?activityId=' + $this.data.activity.activity.id
    });
  },
  //中奖公示
  onDrawnAnouncementClick() {
    my.navigateTo({
      url: '/pages/reward-announcement/reward-announcement'
      url: '/pages/reward-announcement/reward-announcement?activityId=' + $this.data.activity.activity.id
    });
  },
@@ -341,6 +395,7 @@
  //参与抽奖
  requestJoin() {
    api.joinLucky({
      showErrorToast: true,
      activityId: this.data.activity.activity.id,
      showLoading: true,
      success: function (res) {
@@ -353,15 +408,14 @@
            activity: activity
          });
        } else {
          my.showToast({
            content: res.msg
          });
        }
      }
    })
  },
  requestAssist() {
    my.showToast({
      content: '助力信息:' + $this.data.joinInfo
    })
    if (!$this.data.joinInfo)
      return;
    api.assist({
pages/advice/advice.axml
@@ -1,6 +1,9 @@
<view>
  <view class="body">
    <textarea maxlength="150" placeholder="你的意见很宝贵,感谢你的任何想法。"></textarea>
    <button type="primary" class="btn-primary"  hover-class="btn-primary-hover" onTap="onClick">确认反馈</button>
  <form onSubmit="bindFormSubmit">
    <textarea maxlength="150" name="content" placeholder="你的意见很宝贵,感谢你的任何想法。"></textarea>
    <button form-type="submit" type="primary" class="btn-primary"  hover-class="btn-primary-hover">确认反馈</button>
  </form>
  </view>
</view>
pages/advice/advice.js
@@ -1,12 +1,54 @@
var help = require("../../util/help.js");
var help = require('/util/help.js');
const api = require("/util/api.js");
Page({
  data: {},
  onLoad() {
    help.setPageNavBar("意见反馈");
  },
  onClick(){
  bindFormSubmit(e) {
    const content = e.detail.value.content;
    if (help.isNullOrEmpty(content)) {
      my.showToast({
        content: '请填写意见'
      });
      return;
    }
    my.getStorage({
      key: 'advice_time',
      success: (result) => {
        if (result.data == null || result.data < new Date().getTime()) {
          api.advice({
            showErrorToast: true,
            showLoading: true,
            content: content,
            success: function (res) {
              if (res.code == 0) {
                my.showToast({
                  content: '提交成功'
                });
                my.setStorage({
                  key: 'advice_time',
                  data: new Date().getTime()+1000*60*5
                });
              }
            }
          });
        } else {
          my.showToast({
            content: '请稍后再试'
          });
        }
      },
      fail: () => {
      },
      complete: () => {
      }
    });
  }
});
pages/assist-friends/assist-friends.axml
@@ -10,7 +10,7 @@
       成功助力你
      </view>
    </flex>
    <scroll-view scroll-y>
    <scroll-view  a:if="{{!showEmptyDefault&&list.length>0}}" scroll-y onScrollToLower="scrollMytrip" enable-back-to-top="true">
      <view a:for="{{userList}}">
        <flex class="item" justify="between">
          <flex>
@@ -22,8 +22,10 @@
          </view>
        </flex>
      </view>
      <!-- 上拉加载 -->
      <include src="../loading_view.axml" />
      <template is="page-footer" data="{{showFooter}}"/>
    </scroll-view>
    <import src="../template/template.axml"/>
    <template a:if="{{showEmptyDefault}}" is="page-result-empty" data="{{title:'亲,暂无数据哦'}}"/>
  </view>
</view>
pages/assist-friends/assist-friends.js
@@ -1,14 +1,106 @@
var help = require('/util/help.js');
var api = require('/util/api.js');
var $this;
Page({
  data: {
    userList:[{},{},{}],
    showLoading:true
    /* 列表数据开始 */
    list: [],
    showLoading: false,
    page: 1,
    total: 0,
    showEmptyDefault: false,
    isRequesting: false,//是否正在请求中
    showFooter: false,
    /* 列表数据结束 */
  },
  onLoad() {
    my.setNavigationBar({
      title: "助力好友",
      backgroundColor: "#0080FF",
      borderBottomColor: "#0080FF"
     help.setPageNavBar("助力好友");
     $this = this;
     $this.requestAssistFriendsList(1, true);
  },
  onPullDownRefresh() {
    console.log('onPullDownRefresh', new Date());
    my.showToast({
      content: "下拉刷新触发"
    });
    this.requestAssistFriendsList(1);
  },
  //请求活动
  requestAssistFriendsList(page, first) {
    $this.setData({
      page: page,
      isRequesting: true,
      showEmptyDefault:false
    });
    api.getAssistFriendsList({
      page: page,
       showErrorToast: true,
      showLoading: first,
      success: function (res) {
        console.log(res)
        if (res.code == 0) {
          var list = res.data.data;
          //设置列表数据
          if (list != null && list.length > 0) {
            var totalList = $this.data.list.concat(list);
            if (page == 1) {
              totalList = list;
            }
            $this.setData({
              total: res.data.count,
              list: totalList,
              showFooter: totalList.length >= res.data.count
            })
          }
          //设置空列表默认显示
          if (page == 1 && (list == null || list.length == 0)) {
            $this.setData({
              showEmptyDefault: true
            })
          }
        }
      },
      fail: function () {
        //请求失败需要将页码减1
        if ($this.data.page > 1) {
          $this.setData({
            page: $this.data.page - 1
          });
        }
      },
      complete: function () {
        my.stopPullDownRefresh();
        setTimeout(() => {
          $this.setData({
            isRequesting: false,
            showLoading: false
          });
        }, 1000);
      }
    });
  },
  //到达底部
  async scrollMytrip() {
    if (this.data.isRequesting)
      return;
    try {
      console.log('scrollMytrip:');
      const { page, list, } = this.data;
      // 判断是否还有数据需要加载
      if (list.length < this.data.total) {
        //开启加载
        this.setData({ showLoading: true });
        const newPage = page + 1;
        $this.requestAssistFriendsList(newPage);
      }
    } catch (e) {
      this.setData({ showLoading: false });
      console.log('scrollMytrip执行异常:', e);
    }
  },
});
pages/assist-process/assist-process.axml
@@ -13,19 +13,21 @@
      <view class="column2">状态</view>
      <view class="column3">获得幸运券</view>
    </flex>
    <scroll-view scroll-y style="height:100%;">
      <flex class="item" direction="row" align="center" wrap="nowrap" a:for="{{friendsList}}">
    <scroll-view scroll-y style="height:100%;" onScrollToLower="scrollMytrip">
      <flex class="item" direction="row" align="center" wrap="nowrap" a:for="{{list}}">
        <flex class="column1" direction="row" wrap="wrap">
          <image mode="scaleToFill" src="/image/portrait-test.jpg"/>
          <image mode="scaleToFill" src="{{item.user.portrait}}"/>
          <view>
               <text number-of-lines="1">获得幸运券hellow 你好请问</text>
            <text number-of-lines="1">{{item.user.nickName}}</text>
          </view>
        </flex>
        <text class="column2">助力成功\n且参与抽奖</text>
        <text class="column3">+ 12张</text>
        <text class="column2">{{item.state}}</text>
        <text class="column3">+ {{item.count}}张</text>
      </flex>
      <include src="../loading_view.axml" />
      <template is="page-footer" data="{{showFooter}}"/>
    </scroll-view>
    <import src="../template/template.axml"/>
    <template a:if="{{showEmptyDefault}}" is="page-result-empty" data="{{title:'亲,暂无数据哦'}}"/>
  </view>
</view>
pages/assist-process/assist-process.js
@@ -1,11 +1,111 @@
var help = require('../../util/help.js');
var help = require('/util/help.js');
var api = require('/util/api.js');
var $this;
Page({
  data: {
    friendsList: [{}, {}, {},{}, {}],
    showLoading: true
    /* 列表数据开始 */
    list: [],
    showLoading: false,
    page: 1,
    total: 0,
    showEmptyDefault: false,
    isRequesting: false,//是否正在请求中
    showFooter: false,
    /* 列表数据结束 */
  },
  onLoad() {
  onLoad(query) {
    help.setPageNavBar("助力进度");
    console.log(query)
    $this = this;
    var activityId = query.activityId;
    $this.data.activityId = activityId;
    $this.getActivityAssistCouponList(1,true);
  },
  onPullDownRefresh() {
    console.log('onPullDownRefresh', new Date());
    my.showToast({
      content: "下拉刷新触发"
    });
    this.getActivityAssistCouponList(1);
  },
  //请求活动
  getActivityAssistCouponList(page, first) {
    $this.setData({
      page: page,
      isRequesting: true,
      showEmptyDefault: false
    });
    api.getActivityAssistCouponList({
      activityId: $this.data.activityId,
      page: page,
      showLoading: first,
      success: function (res) {
        console.log(res)
        if (res.code == 0) {
          var list = res.data.data;
          //设置列表数据
          if (list != null && list.length > 0) {
            var totalList = $this.data.list.concat(list);
            if (page == 1) {
              totalList = list;
            }
            $this.setData({
              total: res.data.count,
              list: totalList,
              showFooter: totalList.length >= res.data.count
            })
          }
          //设置空列表默认显示
          if (page == 1 && (list == null || list.length == 0)) {
            $this.setData({
              showEmptyDefault: true
            })
          }
        } else {
          my.showToast({
            content: res.msg
          });
        }
      },
      fail: function () {
        //请求失败需要将页码减1
        if ($this.data.page > 1) {
          $this.setData({
            page: $this.data.page - 1
          });
        }
      },
      complete: function () {
        my.stopPullDownRefresh();
        setTimeout(() => {
          $this.setData({
            isRequesting: false,
            showLoading: false
          });
        }, 1000);
      }
    });
  },
  //到达底部
  async scrollMytrip() {
    if (this.data.isRequesting)
      return;
    try {
      console.log('scrollMytrip:');
      const { page, list, } = this.data;
      // 判断是否还有数据需要加载
      if (list.length < this.data.total) {
        //开启加载
        this.setData({ showLoading: true });
        const newPage = page + 1;
        $this.getActivityAssistCouponList(newPage);
      }
    } catch (e) {
      this.setData({ showLoading: false });
      console.log('scrollMytrip执行异常:', e);
    }
  },
});
pages/join-statistic/join-statistic.acss
@@ -60,7 +60,7 @@
  font-weight: 400;
  font-size: 24rpx;
  margin-top: 29rpx;
  margin-bottom: 18rpx;
}
.body .content-rank .title {
pages/join-statistic/join-statistic.axml
@@ -15,37 +15,42 @@
        <view class="column4">中奖概率</view>
      </flex>
      <scroll-view scroll-y>
        <view class="notify">
        <view class="notify" a:if="{{!myRank}}">
        你未能入榜,赶快去邀请好友助力提高中奖概率
        </view>
        <flex class="item {{index==0?'active':''}}" a:for="{{rankList}}" direction="row" wrap="nowrap">
          <flex class="column1" justify="center">
            <image a:if="{{item.rank<4}}" mode="scaleToFill" src="/image/icon/icon_rank_{{item.rank}}.png"/>
            <text a:else>1888</text>
        <view style="height:18rpx;">
        </view>
        <view a:for="{{rankList}}" data-item="{{item}}" onTap="onRankClick">
          <flex class="item {{item.myRank?'active':''}}" direction="row" wrap="nowrap">
            <flex class="column1" justify="center">
              <image a:if="{{item.rank<4}}" mode="scaleToFill" src="/image/icon/icon_rank_{{item.rank}}.png"/>
              <text a:else>{{item.rank}}</text>
            </flex>
            <flex class="column2" wrap="nowrap" align="center">
              <image mode="scaleToFill" src="{{item.user.portrait}}"/>
              <text number-of-lines="1">{{item.user.nickName}}</text>
            </flex>
            <view class="column3"> ×{{item.count}}张</view>
            <flex class="column4" justify="center">
              <image mode="scaleToFill" src="/image/icon/icon_statistic_detail.png"/>
            </flex>
          </flex>
          <flex class="column2" wrap="nowrap" align="center">
            <image mode="scaleToFill" src="/image/portrait-test.jpg"/>
            <text number-of-lines="1">红袖添香</text>
          </flex>
          <view class="column3"> ×12张</view>
          <flex class="column4" justify="center">
            <image mode="scaleToFill" src="/image/icon/icon_statistic_detail.png"/>
          </flex>
        </flex>
        <view class="footer">
        </view>
        <view class="footer" a:if="{{rankList.length>0}}">
          注:仅展示前10参与者
        </view>
      </scroll-view>
    </view>
    <!--全部参与者-->
    <view class="content-joiner" a:if="{{currentType==2}}">
      <flex class="title" direction="row" justify="between" wrap="wrap">
        <view class="placeholder">共12834参与</view>
        <view class="placeholder">你是第1002参与</view>
      <flex class="title" direction="row" justify="between" wrap="wrap" a:if="{{statistic}}">
        <view class="placeholder">共{{statistic.totalJoiner}}参与</view>
        <view class="placeholder">你是第{{statistic.myPosition}}参与</view>
      </flex>
      <scroll-view scroll-y style="height:100%;">
        <flex class="joiner-list" direction="row" wrap="wrap">
          <image style="margin-right:{{(index+1)%10!=0?'4rpx;':'0;'}} margin-top:{{(index+1)>10?'4rpx;':'0;'}}" mode="scaleToFill" src="/image/portrait-test.jpg" a:for="{{joinerList}}"/>
          <image style="margin-right:{{(index+1)%10!=0?'4rpx;':'0;'}} margin-top:{{(index+1)>10?'4rpx;':'0;'}}" mode="scaleToFill" src="{{item.portrait}}" a:for="{{joinerList}}"/>
        </flex>
        <view class="load-more" a:if="{{joinerHasMore}}" onTap="onMoreJoiner">
       加载更多
@@ -54,24 +59,27 @@
        注:参与先后顺序与中奖概率无关
        </view>
      </scroll-view>
      <import src="../template/template.axml"/>
      <template a:if="{{showEmptyDefault}}" is="page-result-empty" data="{{title:'亲,暂无数据哦'}}"/>
    </view>
  </view>
  <modal class="statistic-modal" show="{{showStatistic}}" onModalClose="onStatisticClose" advice="{{true}}">
    <view class="model-content">
      <text class="title">当前中奖概率高于平均值</text>
      <view class="number">
        <image src="/image/icon/icon_percent_up.png"/>
        <image src="/image/icon/icon_percent_up.png" a:if="{{probability.offset>0}}"/>
        <image src="/image/icon/icon_percent_down.png" a:elif="{{probability.offset<0}}"/>
        <image src="/image/icon/icon_percent_equal.png" a:else/>
        <view>
          <text class="percent">10.05倍</text>
          <text class="percent">{{probability.offset}}倍</text>
        </view>
      </view>
      <view style="display:flex;  justify-content: center;  margin-bottom: 30rpx;">
        <circle-statistic-view percent="50" width="184rpx" height="184rpx"></circle-statistic-view>
        <circle-statistic-view percent="{{probability.percent}}" width="184rpx" height="184rpx"></circle-statistic-view>
      </view>
      <text>
      
 注:当前平均中奖概率是12.00%,\n
平均概率为12.00%
 注:当前平均中奖概率是{{probability.average}}%
      </text>
    </view>
  </modal>
pages/join-statistic/join-statistic.js
@@ -1,15 +1,30 @@
var help = require('../../util/help.js');
var help = require('/util/help.js');
var api = require('/util/api.js');
var $this;
Page({
  data: {
    showStatistic: true,
    showStatistic: false,
    currentType: 1,
    showLoading: true,
    rankList: [{ rank: 1 }, { rank: 3 }, {}, {}, {}],
    joinerList: [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}],
    rankList: [],
    myRank: true,
    //参与者
    joinerList: [],
    page: 1,
    total: 0,
    joinerHasMore: true
  },
  onLoad() {
  onLoad(query) {
    $this = this;
    help.setPageNavBar("参与统计");
    this.setData({
      activityId: query.activityId
    });
    setTimeout(() => {
      $this.requestRank();
    });
  },
  changeNav(event) {
    var type = help.getEventParam(event, "type");
@@ -20,13 +35,135 @@
    this.setData({
      currentType: type
    });
    switch (type) {
      case 1:
        $this.requestRank();
        break;
      case 2:
        $this.requestJoinerList(1, true)
        break;
    }
  },
  onMoreJoiner() {
    console.log("加载更多参与者信息");
    $this.requestJoinerList($this.data.page + 1, false);
  },
  onStatisticClose() {
    this.setData({
      showStatistic: false
    });
  },
  onRankClick(event) {
    var data = help.getEventParam(event, "item");
    console.log(data);
    $this.requestProbability(data.user.uid);
  },
  requestRank() {
    api.getRankList({
      showErrorToast: true,
      showLoading: true,
      page: 1,
      activityId: $this.data.activityId,
      success: function (res) {
        if (res.code == 0) {
          var list = res.data.data;
          if (res.data.myRank) {
            res.data.myRank.myRank = true;
            list.unshift(res.data.myRank);
          }
          $this.setData({
            myRank: res.data.myRank != null,
            rankList: list
          });
          console.log("myRank:" + (res.data.myRank != null))
        }
      }
    });
  },
  requestProbability(uid) {
    api.getProbability({
      showErrorToast: true,
      showLoading: true,
      activityId: $this.data.activityId,
      targetUid: uid,
      success: function (res) {
        if (res.code == 0) {
          $this.setData({
            probability: res.data
          });
          setTimeout(() => {
            $this.setData({
              showStatistic: true
            });
          });
        }
      }
    })
  },
  requestJoinerList(page, first) {
    $this.setData({
      page: page,
      isRequesting: true,
      showEmptyDefault: false
    });
    api.getJoinerList({
      activityId: $this.data.activityId,
      page: page,
      showErrorToast: true,
      showLoading: first,
      success: function (res) {
        console.log(res)
        if (res.code == 0) {
          var list = res.data.data;
          //设置列表数据
          if (list != null && list.length > 0) {
            var totalList = $this.data.joinerList.concat(list);
            if (page == 1) {
              totalList = list;
            }
            $this.setData({
              total: res.data.count,
              joinerList: totalList,
              joinerHasMore: totalList.length < res.data.count
            })
          }
          //设置空列表默认显示
          if (page == 1 && (list == null || list.length == 0)) {
            $this.setData({
              showEmptyDefault: true
            })
          }
        }
      },
      fail: function () {
        //请求失败需要将页码减1
        if ($this.data.page > 1) {
          $this.setData({
            page: $this.data.page - 1
          });
        }
      },
      complete: function () {
        setTimeout(() => {
          $this.setData({
            isRequesting: false
          });
        }, 1000);
      }
    });
  }
});
pages/lucky-coupon/lucky-coupon.js
@@ -1,5 +1,5 @@
var help = require('../../util/help.js');
var api = require('../../util/api.js');
var help = require('/util/help.js');
var api = require('/util/api.js');
var $this;
Page({
  data: {
@@ -40,6 +40,7 @@
    api.getLuckyCouponList({
      activityId: $this.data.activityId,
      page: page,
       showErrorToast: true,
      showLoading: first,
      success: function (res) {
        console.log(res)
@@ -63,10 +64,6 @@
              showEmptyDefault: true
            })
          }
        } else {
          my.showToast({
            content: res.msg
          });
        }
      },
      fail: function () {
pages/lucky-record/lucky-record.js
@@ -1,5 +1,5 @@
var help = require('../../util/help.js');
var api = require('../../util/api.js');
var help = require('/util/help.js');
var api = require('/util/api.js');
var $this;
Page({
  data: {
@@ -33,11 +33,12 @@
    $this.setData({
      page: page,
      isRequesting: true,
      showEmptyDefault:false
      showEmptyDefault: false
    });
    api.getLuckyRecord({
      page: page,
      type: $this.data.type,
      showErrorToast: true,
      showLoading: first,
      success: function (res) {
        console.log(res)
@@ -61,10 +62,6 @@
              showEmptyDefault: true
            })
          }
        } else {
          my.showToast({
            content: res.msg
          });
        }
      },
      fail: function () {
@@ -142,8 +139,8 @@
    }
    this.setData({
      type: newType,
      list:[],
      total:0
      list: [],
      total: 0
    });
    this.requestActivity(1, true);
  }
pages/mine/mine.axml
@@ -15,7 +15,7 @@
  </flex>
  <flex a:else class="user" align="center" a:if="{{logined}}">
    <image mode="scaleToFill" class="portrait" src="/image/portrait-test.jpg"/>
    <button type="ghost" class="login" open-type="getAuthorize" onGetAuthorize="onGetAuthorize" onError="onAuthError" scope='userInfo'>
    <button type="ghost" class="login" open-type="{{!logined?'getAuthorize':''}}" onGetAuthorize="onGetAuthorize" onError="onAuthError" scope='userInfo'>
    登录
    </button>
  </flex>
@@ -30,7 +30,7 @@
    <view style="height:22rpx;"></view>
    <list-item thumb="/image/icon/icon_mine_msg.png" arrow="{{true}}" thumbSize="48rpx" data-key="msg" onClick="onItemClick">
        消息记录
      <badge className="badge" slot="extra" text="{{'99+'}}" dot="{{false}}" />
      <badge className="badge" slot="extra" a:if="{{}}" text="{{msgCount}}" dot="{{false}}" />
    </list-item>
    <view style="height:22rpx;"></view>
    <list-item thumb="/image/icon/icon_mine_scan_history.png" arrow="{{true}}" thumbSize="53rpx" data-key="scanHistory" onClick="onItemClick">
pages/mine/mine.js
@@ -1,88 +1,55 @@
var help = require('../../util/help.js');
var api = require('../../util/api.js');
var help = require('/util/help.js');
var api = require('/util/api.js');
const user = require('/util/user');
var $this;
Page({
  data: {
    showLogout: false
    showLogout: false,
    logined: false
  },
  //导航栏点击过来的
  onTabItemTap(item) {
    my.getAuthCode({
      scopes: ['auth_user'],
      success: (res) => {
        my.getOpenUserInfo({
          fail: (res) => {
          },
          success: (res) => {
            console.log(res);
            let userInfo = JSON.parse(res.response).response // 以下方的报文格式解析两层 response
            console.log(userInfo);
          }
    user.getUserInfo({
      success(data) {
        $this.setData({
          logined: true,
          user: data
        });
      },
    });
      }
    })
  },
  onLoad() {
    my.setNavigationBar({
      backgroundColor: "#0080FF",
      borderBottomColor: "#0080FF"
    $this = this;
    help.setPageNavBar(null);
    my.getStorage({ key: 'user' }, function (res) {
      var user = res.data;
      console.log(user)
      if (user != null) {
        $this.setData({
          logined: true,
          user: user
        });
      }
    });
    let userData = my.getStorageSync({ key: 'user' });
    var user = userData.data;
    console.log(user)
    if (user != null) {
      this.setData({
        logined: true,
        user: user
      });
    }
    $this.requestGetUserConfig();
  },
  onGetAuthorize(res) {
    var that = this;
    my.getOpenUserInfo({
      fail: (res) => {
      },
      success: (res) => {
        let userInfo = JSON.parse(res.response).response // 以下方的报文格式解析两层 response
        if (userInfo.code == '10000') {//成功
          console.log(JSON.stringify(userInfo))
          help.rsa(JSON.stringify(userInfo), function (res) {
            api.uploadUserInfo({
              userInfo: res,
              showLoading: true,
              success: function (res) {
                if (res.code == 0) {
                  that.setData({
                    logined: true,
                    user: res.data
                  });
                  //保存用户信息
                  my.setStorage({
                    key: 'user',
                    data: res.data
                  });
                } else {
                  my.showToast({
                    content: res.msg
                  })
                }
              }
            })
          });
        } else {
          my.showToast({
            content: '授权失败'
          });
        }
    user.login({
      success: function (data) {
        $this.setData({
          logined: true,
          user: data
        });
      }, fail(e) {
        my.showToast({
          content: '登录失败'
        })
      }
    });
    })
  },
  onAuthError(event) {
    my.showToast({
@@ -108,15 +75,52 @@
      case 'scanHistory':
        path = '/pages/scan-record/scan-record';
        break;
      case 'newerCourse': break;
      case 'newerCourse':
        help.getCachedConfig(function (params) {
          if (params && params.newerCourse) {
            path = '/pages/web/web?title=新手教程&url=' + params.newerCourse;
            my.navigateTo({
              url: path
            });
            return;
          }
        });
        break;
      case 'question':
        path = '/pages/web/web?title=测试&url=http://www.baidu.com';
        help.getCachedConfig(function (params) {
          if (params && params.commonQuestion) {
            path = '/pages/web/web?title=常见问题&url=' + params.commonQuestion;
            my.navigateTo({
              url: path
            });
            return;
          }
        });
        break;
    }
    my.navigateTo({
      url: path
    });
  },
  requestGetUserConfig() {
    api.getUserConfig({
      success: function (res) {
        if (res.code == 0) {
          $this.setData({
            msgCount: res.data.msgCount
          });
        }
      }
    })
  },
  //关闭退出弹框
  onCloseLogout() {
    this.setData({
@@ -124,11 +128,22 @@
    });
  },
  onLogout() {
    this.setData({
      user: null,
      logined: false
    user.logout({
      success() {
        $this.setData({
          user: null,
          logined: false
        });
        $this.onCloseLogout();
      },
      fail() {
        my.showToast({
          content: '退出登录失败'
        });
      }
    });
    this.onCloseLogout();
  },
  onCloseLogoutShow() {
    this.setData({
pages/msg-record/msg-record.axml
@@ -1,28 +1,31 @@
<view>
  <flex class="msg-nav" justify="center" align="center">
    <image mode="scaleToFill" src="/image/icon/icon_clear_msg.png"/>
    <view>
    <view onTap="onClearUnRead">
  消息全部已读
    </view>
  </flex>
  <scroll-view scroll-y>
    <view a:for="{{msgList}}" class="item">
  <scroll-view a:if="{{!showEmptyDefault&&list.length>0}}" scroll-y onScrollToLower="scrollMytrip" enable-back-to-top="true">
    <view a:for="{{list}}" class="item">
      <flex class="header">
        <image class="msg-icon" src="/image/portrait-test.jpg"/>
        <view class="msg-type">抽奖消息
        <image class="msg-icon" src="{{item.icon}}"/>
        <view class="msg-type">{{item.name}}
        </view>
        <view class="time">3分钟前
        <view class="time">{{item.time}}
        </view>
      </flex>
      <view class="body">
        <flex class="row" justify="between" align="top" a:for="{{item.contentList}}">
        <flex class="row" justify="between" align="top" a:for-item="content" a:for="{{item.contentList}}">
          <view class="title">
          {{item.title}}
          {{content.title}}
          </view>
          <rich-text class="content" nodes=" {{item.content}}" onTap="tap"></rich-text>
        </flex>
      </view>
    </view>
    <include src="../loading_view.axml" />
    <template is="page-footer" data="{{showFooter}}"/>
  </scroll-view>
  <import src="../template/template.axml"/>
  <template a:if="{{showEmptyDefault}}" is="page-result-empty" data="{{title:'亲,暂无数据哦'}}"/>
</view>
pages/msg-record/msg-record.js
@@ -1,43 +1,153 @@
var help = require('/util/help.js');
var api = require('/util/api.js');
var $this;
Page({
  data: {
    showLoading: true,
    msgList: [{
      contentList: [{
        title: "开奖期数", content: [{
          name: 'div',
          children: [{
            type: 'text',
            text: 'Hello&nbsp;World!Hello&nbsp;World!Hello&nbsp;World!Hello&nbsp;World!Hello&nbsp;World!',
          },
          {
            name: 'img',
            attrs: {
              src: 'https://gw.alicdn.com/tps/i3/TB1yeWeIFXXXXX5XFXXuAZJYXXX-210-210.png_160x160.jpg',
              style: 'border-radius:50%;width:30rpx;margin-left:5rpx;'
            }
          },
          {
            name: 'a',
            attrs: {
              href: 'https://www.baidu.com',
              style: 'color:#0080FF;'
            },
            children: [{
              type: 'text',
              text: '查看详情'
            }]
          }
          ],
        }],
      }, {}, {}, {}]
    }, {}, {}]
    /* 列表数据开始 */
    list: [],
    showLoading: false,
    page: 1,
    total: 0,
    showEmptyDefault: false,
    isRequesting: false,//是否正在请求中
    showFooter: false,
    /* 列表数据结束 */
  },
  onLoad() {
    my.setNavigationBar({
      title: "消息记录",
      backgroundColor: "#0080FF",
      borderBottomColor: "#0080FF"
    help.setPageNavBar("消息记录");
    $this = this;
  },
  onPullDownRefresh() {
    console.log('onPullDownRefresh', new Date());
    my.showToast({
      content: "下拉刷新触发"
    });
    this.requestUserMsgList(1);
  },
  /**
   * 转为为富文本数据
   * @param {*} list
   * @param {*} callback
   */
  convertToRichText(list, callback) {
    for (var i = 0; i < list.length; i++) {
      for (var j = 0; j < list[i].contentList.length; j++) {
        help.loadRichTextNode(list[i].contentList[j].content, function (res) {
          list[i].contentList[j].content = res;
          if (i == list.length - 1 && j == list[i].contentList.length) {
            callback(list);
          }
        });
      }
    }
  },
  /**
   * 清除未读消息
   */
  onClearUnRead() {
    $this.requestSetMsgRead();
  },
  /**
   * 设置消息已读
   */
  requestSetMsgRead() {
    api.setMsgRead({
      showErrorToast: true,
      showLoading: true,
      success: function (res) {
        if (res.code == 0) {
          my.showToast({
            content: '清除成功'
          })
        }
      }
    });
  },
  //请求活动
  requestUserMsgList(page, first) {
    $this.setData({
      page: page,
      isRequesting: true,
      showEmptyDefault: false
    });
    api.getUserMsgList({
      page: page,
      showErrorToast: true,
      showLoading: first,
      success: function (res) {
        console.log(res)
        if (res.code == 0) {
          var list = res.data.data;
          //数据预处理
          $this.convertToRichText(list, function (list) {
            //设置列表数据
            if (list != null && list.length > 0) {
              var totalList = $this.data.list.concat(list);
              if (page == 1) {
                totalList = list;
              }
              $this.setData({
                total: res.data.count,
                list: totalList,
                showFooter: totalList.length >= res.data.count
              })
            }
            //设置空列表默认显示
            if (page == 1 && (list == null || list.length == 0)) {
              $this.setData({
                showEmptyDefault: true
              })
            }
          });
        }
      },
      fail: function () {
        //请求失败需要将页码减1
        if ($this.data.page > 1) {
          $this.setData({
            page: $this.data.page - 1
          });
        }
      },
      complete: function () {
        my.stopPullDownRefresh();
        setTimeout(() => {
          $this.setData({
            isRequesting: false,
            showLoading: false
          });
        }, 1000);
      }
    });
  },
  //下拉刷新
  onPullDownRefresh() {
    this.requestUserMsgList(1, false);
  },
  //到达底部
  async scrollMytrip() {
    if (this.data.isRequesting)
      return;
    try {
      console.log('scrollMytrip:');
      const { page, list, } = this.data;
      // 判断是否还有数据需要加载
      if (list.length < this.data.total) {
        //开启加载
        this.setData({ showLoading: true });
        const newPage = page + 1;
        $this.requestUserMsgList(newPage);
      }
    } catch (e) {
      this.setData({ showLoading: false });
      console.log('scrollMytrip执行异常:', e);
    }
  },
});
pages/msg-setting/msg-setting.axml
@@ -1,20 +1,21 @@
<view>
  <view style="height:20rpx;" />
  <list>
  <list a:if="{{settings}}">
    <list-item arrow="{{false}}">参加抽奖消息
      <am-switch slot="extra" checked onChange="changeMsgSetting" data-type="1"/>
      <am-switch slot="extra" checked="{{settings.joinActivityMsg}}" onChange="changeMsgSetting" data-key="joinActivityMsg"/>
    </list-item>
    <list-item arrow="{{false}}">开奖提醒消息
      <am-switch slot="extra" onChange="changeMsgSetting"  data-type="2"/>
      <am-switch slot="extra"  checked="{{settings.openActivityMsg}}" onChange="changeMsgSetting"  data-key="openActivityMsg"/>
    </list-item>
    <list-item arrow="{{false}}">成功中奖消息
      <am-switch slot="extra" onChange="changeMsgSetting"  data-type="3"/>
      <am-switch slot="extra" checked="{{settings.drawnMsg}}" onChange="changeMsgSetting"  data-key="drawnMsg"/>
    </list-item>
    <list-item arrow="{{false}}">未抽中消息
      <am-switch slot="extra" checked onChange="changeMsgSetting"  data-type="4"/></list-item>
      <am-switch slot="extra" checked="{{settings.notDrawnMsg}}" onChange="changeMsgSetting"  data-key="notDrawnMsg"/></list-item>
    <list-item arrow="{{false}}">未开抽奖消息
      <am-switch slot="extra" onChange="changeMsgSetting"  data-type="5"/></list-item>
      <am-switch slot="extra"  checked="{{settings.notOpenActivityMsg}}"  onChange="changeMsgSetting"  data-key="notOpenActivityMsg"/></list-item>
    <list-item arrow="{{false}}">成功助力消息
      <am-switch slot="extra" onChange="changeMsgSetting"  data-type="6"/></list-item>
      <am-switch slot="extra"  checked="{{settings.assistSuccessMsg}}" onChange="changeMsgSetting"  data-key="assistSuccessMsg"/></list-item>
  </list>
</view>
pages/msg-setting/msg-setting.js
@@ -1,14 +1,46 @@
var help = require('/util/help.js');
var api = require('/util/api.js');
var $this;
Page({
  data: {},
  data: {
  },
  onLoad() {
    my.setNavigationBar({
      title: "消息设置",
      backgroundColor: "#0080FF",
      borderBottomColor: "#0080FF"
    });
    $this = this;
    help.setPageNavBar("消息设置");
    $this.requestGetSettings();
  },
  changeMsgSetting(event) {
    console.log(event.target.dataset.type + ":" + event.detail.value);
  }
    console.log(event);
    var key = help.getEventParam(event, 'key');
    $this.data.settings[key] = event.detail.value;
    var params = {};
    params[key] = event.detail.value;
    $this.requestSetSettings(params);
  },
  requestGetSettings() {
    api.getMsgSettings({
      showErrorToast: true,
      showLoading: true,
      success: function (res) {
        if (res.code == 0) {
          $this.setData({
            settings: res.data
          })
        }
      }
    });
  },
  requestSetSettings(setting) {
    api.setMsgSettings({
      settings: setting,
      showLoading: false,
      success: function (res) {
        $this.setData({
          settings: res.data
        })
      }
    });
  },
});
pages/reward-announcement/reward-announcement.axml
@@ -15,13 +15,13 @@
      <scroll-view scroll-y style="height:100%;">
        <view a:for="{{awardList}}" class="award">
          <flex direction="row" wrap="wrap" align="top">
            <image class="award-way" mode="scaleToFill" src="/image/portrait-test.jpg"/>
            <rich-text class="award-name" nodes="{{item.awardName}}"></rich-text>
            <image class="award-way" mode="scaleToFill" src="{{item.award.typeIcon}}"/>
            <rich-text class="award-name" nodes="{{item.award.awardName}}"></rich-text>
          </flex>
          <flex direction="row" wrap="wrap" class="user-list">
              <image style="margin-right:{{(userIndex+1)%10!=0?'4rpx;':'0;'}} margin-top:{{(userIndex+1)>10?'4rpx;':'0;'}}" mode="scaleToFill" a:for-item="user" a:for-index="userIndex"  src="{{user.portrait}}"  a:for="{{item.userList}}"/>
          </flex>
          <view class="load-more">
          <view class="load-more" a:if="{{item.hasMore}}" data-index="{{index}}" onTap="loadMore">
     加载更多
          </view>
        </view>
pages/reward-announcement/reward-announcement.js
@@ -1,38 +1,22 @@
var help = require('../../util/help.js');
var help = require('/util/help.js');
import parse from 'mini-html-parser2';
import api from '/util/api.js';
var $this;
Page({
  data: {
    awardList: []
  },
  onLoad() {
  onLoad(query) {
    $this = this;
    help.setPageNavBar("中奖公示");
    $this.data.activityId = query.activityId;
    $this.requestDrwanInfo();
    var that=this;
  },
    var awardList =  [
      {
        userList: [{ portrait: '/image/portrait-test.jpg' }, { portrait: '/image/portrait-test.jpg' }, { portrait: '/image/portrait-test.jpg' }, { portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' }, { portrait: '/image/portrait-test.jpg' }, { portrait: '/image/portrait-test.jpg' }, { portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' }]
      }, {
          userList: [{ portrait: '/image/portrait-test.jpg' }, { portrait: '/image/portrait-test.jpg' }, { portrait: '/image/portrait-test.jpg' }, { portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' }, { portrait: '/image/portrait-test.jpg' }, { portrait: '/image/portrait-test.jpg' }, { portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' }]
      }, {
          userList: [{ portrait: '/image/portrait-test.jpg' }, { portrait: '/image/portrait-test.jpg' }, { portrait: '/image/portrait-test.jpg' }, { portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' }, { portrait: '/image/portrait-test.jpg' }, { portrait: '/image/portrait-test.jpg' }, { portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' },{ portrait: '/image/portrait-test.jpg' }]
      }
    ];
    //封装奖项的富文本
    this.loadRichTextNode(help.getAwardHtml({}), function (nodes) {
      for (var i = 0; i <awardList.length; i++) {
       awardList[i].awardName = nodes;
      }
      that.setData({
        awardList: awardList
      });
    });
  loadMore(event) {
    var index = help.getEventParam(event, "index");
    $this.requestDrawnJoinerList($this.data.awardList[index].page, index);
  },
  loadRichTextNode(html, callback) {
@@ -44,4 +28,72 @@
    });
  },
  requestDrwanInfo() {
    api.getDrawnInfo({
      activityId: $this.data.activityId,
      count: 20,
      showErrorToast: true,
      showLoading:true,
      success: function (res) {
        if (res.code == 0) {
          var data = res.data.data;
          for (var i = 0; i < data.length; i++) {
            //封装奖项的富文本
            $this.loadRichTextNode(help.getAwardHtml({ content: data[i].award.title, link: data[i].award.link, moreType: 'text' }), function (nodes) {
              data[i].award.awardName = nodes;
            });
            //计算是否还有更多
            if (data[i].userList.length < data[i].userCount) {
              data[i].hasMore = true;
            } else {
              data[i].hasMore = false;
            }
            data[i].page = 1;
          }
          $this.setData({
            awardList: data
          });
        }
      }
    });
  },
  requestDrawnJoinerList(page, index) {
    var data = $this.data.awardList;
    data[index].page = page;
    api.getDrawnJoinerList({
      showErrorToast: true,
      showLoading: true,
      page: page,
      activityId: $this.data.activityId,
      awardId: data[index].award.id,
      success: function (res) {
        if (res.code == 0) {
          data[index].userList = data[index].userList.concat(res.data.data);
          data[index].userCount = res.data.count;
          $this.setData({
            awardList: data
          });
        }
      },
      fail: function (e) {
        if (page > 1) {
          data = $this.data.awardList;
          data[index].page = page - 1;
          $this.setData({
            awardList: data
          });
        }
      }
    });
  }
});
pages/rewards/rewards.axml
@@ -2,7 +2,7 @@
  <scroll-view a:if="{{!showEmptyDefault&&list.length>0}}" style="height: 100vh;" 
        scroll-y onScrollToLower="scrollMytrip" enable-back-to-top="true">
    <notice class="notice" marqueeProps="{{loop:true}}" enableMarquee="{{true}}" show="{{showNotice}}" mode="{{noticeMode}}" onClick="onNoticeClick">
    无限循环滚动的通告栏展示情况。文字不够继续添加文字凑数。
    {{notice.content}}
    </notice>
    <import src="../template/template.axml"/>
    <template is="commonActivityListItem" a:for="{{list}}" data="{{item}}"/>
pages/rewards/rewards.js
@@ -1,5 +1,5 @@
var help = require('../../util/help.js');
var api = require('../../util/api.js');
var help = require('/util/help.js');
var api = require('/util/api.js');
var $this;
Page({
  data: {
@@ -19,12 +19,14 @@
    //过期未领弹框
    showOutDateModal: false,
    showNotice: true,
    showNotice: false,
    noticeMode: 'closable',//closable
  },
  onLoad() {
    help.setPageNavBar("天天领现金");
    $this = this;
    $this.requestNotice();
    $this.requestActivity(1, true);
  },
  //请求活动
@@ -32,12 +34,13 @@
    $this.setData({
      page: page,
      isRequesting: true,
      showEmptyDefault:false
      showEmptyDefault: false
    });
    api.getRecommendActivity({
      data: {
        page: page
      },
      showErrorToast: true,
      showLoading: first,
      success: function (res) {
        console.log(res)
@@ -61,10 +64,6 @@
              showEmptyDefault: true
            })
          }
        } else {
          my.showToast({
            content: res.msg
          });
        }
      },
      fail: function () {
@@ -84,6 +83,21 @@
          });
        }, 1000);
      }
    });
  },
  requestNotice() {
    api.getNotice({
      position: 'home',
      success(res) {
        if (res.code == 0) {
          $this.setData({
            notice: res.data,
            showNotice: true,
            noticeMode: res.data.link?'link':'closable'
          })
        }
      }
    });
@@ -152,8 +166,12 @@
      my.showToast({
        content: "进入详情"
      });
      if ($this.data.notice.link) {
        my.navigateTo({
          url: '/pages/web/web?url=' + $this.data.notice.link
        })
      }
    }
  }
pages/scan-record/scan-record.js
@@ -1,5 +1,5 @@
var help = require('../../util/help.js');
var api = require('../../util/api.js');
var help = require('/util/help.js');
var api = require('/util/api.js');
var $this;
Page({
  data: {
@@ -34,6 +34,7 @@
    });
    api.getScanActivityRecord({
      page: page,
       showErrorToast: true,
      showLoading: first,
      success: function (res) {
        console.log(res)
@@ -57,10 +58,6 @@
              showEmptyDefault: true
            })
          }
        } else {
          my.showToast({
            content: res.msg
          });
        }
      },
      fail: function () {
pages/sponsor-activity/sponsor-activity.js
@@ -1,5 +1,5 @@
var help = require('../../util/help.js');
var api = require('../../util/api.js');
var help = require('/util/help.js');
var api = require('/util/api.js');
var $this;
var $sponsorId;
var $activityId;
@@ -34,12 +34,13 @@
    $this.setData({
      page: page,
      isRequesting: true,
      showEmptyDefault:false
      showEmptyDefault: false
    });
    api.getSponsorActivity({
      page: page,
      sponsorId: $sponsorId,
      activityId: $activityId,
      showErrorToast: true,
      showLoading: first,
      success: function (res) {
        console.log(res)
@@ -63,10 +64,6 @@
              showEmptyDefault: true
            })
          }
        } else {
          my.showToast({
            content: res.msg
          });
        }
      },
      fail: function () {
pages/sponsor-signup/sponsor-signup.js
@@ -1,6 +1,17 @@
var help = require("../../util/help.js")
const source_1 = ["淘客", "测试1", "测试1", "测试1"];
const source_2 = ["测试1", "测试2", "测试3", "测试4"];
var help = require('/util/help.js');
const api = require("/util/api.js");
const source_1 = ["淘宝客",
  "招商团长",
  "C店商家",
  "B店商家",
  "直播主播",
  "商务",
  "其他"];
const source_2 = ["流量互换",
  "品质商品",
  "资源信息",
  "商务合作",
  "其他"];
Page({
  data: {
    data1: '',
@@ -40,5 +51,20 @@
      });
      return;
    }
    api.sponsorSignUp({
      showErrorToast: true,
      showLoading: true,
      identity: this.data.data1,
      provider: this.data.data2,
      phone: phone,
      success: function (res) {
        if (res.code == 0) {
          my.showToast({
            content: res.msg
          });
        }
      }
    });
  }
});
pages/web/web.js
@@ -1,4 +1,4 @@
var help = require('../../util/help.js');
var help = require('/util/help.js');
var http = require('../../util/http.js');
Page({
util/api.js
@@ -6,8 +6,19 @@
    console.log(obj.data);
    http.postApi(url, obj.data, function (res) {
      if (obj.success)
      if (obj.success) {
        obj.success(res.data);
        if (obj.showErrorToast) {
          try {
            if (res.data.code != 0) {
              my.showToast({
                content: res.data.msg
              });
            }
          } catch (e) {
          }
        }
      }
    }, function (res) {
      my.showToast({
        content: '网络请求出错'
@@ -19,6 +30,20 @@
        obj.complete();
    }, obj.showLoading);
  },
  getConfig(obj) {
    obj.data = {};
    this.commonRequest("/api/client/config/getConfig", obj);
  },
  /**
   *
   * @param {*} obj
   */
  getNotice(obj) {
    obj.data = { position: obj.position };
    this.commonRequest("/api/client/anouncement/getNotice", obj);
  },
  /**
   * 获取推荐活动
@@ -126,6 +151,75 @@
  getJoinerList(obj) {
    obj.data = { page: obj.page, activityId: obj.activityId };
    this.commonRequest("/api/client/activity/join/getJoinerList", obj);
  },
  /**
   * 活动助力列表
   * @param {*} obj
   */
  getActivityAssistCouponList(obj) {
    obj.data = { page: obj.page, activityId: obj.activityId };
    this.commonRequest("/api/client/activity/assist/getActivityAssistCouponList", obj);
  },
  /**
   * 获取中奖信息
   * @param {*} obj
   */
  getDrawnInfo(obj) {
    obj.data = { count: obj.count, activityId: obj.activityId };
    this.commonRequest("/api/client/activity/awards/getDrawnInfo", obj);
  },
  /**
   * 获取中奖参与者列表
   * @param {*} obj
   */
  getDrawnJoinerList(obj) {
    obj.data = { awardId: obj.awardId, activityId: obj.activityId, page: obj.page };
    this.commonRequest("/api/client/activity/awards/getDrawnJoinerList", obj);
  },
  /**
   * 获取助力好友
   * @param {*} obj
   */
  getAssistFriendsList(obj) {
    obj.data = { page: obj.page };
    this.commonRequest("/api/client/activity/assist/getAssistFriendsList", obj);
  },
  getUserMsgList(obj) {
    obj.data = { page: obj.page };
    this.commonRequest("/api/client/user/getUserMsgList", obj);
  },
  getUserConfig(obj) {
    obj.data = {};
    this.commonRequest("/api/client/user/getUserConfig", obj);
  },
  setMsgRead(obj) {
    obj.data = {};
    this.commonRequest("/api/client/user/setMsgRead", obj);
  },
  getMsgSettings(obj) {
    obj.data = {};
    this.commonRequest("/api/client/user/getMsgSettings", obj);
  },
  setMsgSettings(obj) {
    obj.data = obj.settings;
    this.commonRequest("/api/client/user/setMsgSettings", obj);
  },
  advice(obj) {
    obj.data = { content: obj.content };
    this.commonRequest("/api/client/config/advice", obj);
  },
  sponsorSignUp(obj) {
    obj.data = { identity: obj.identity, provider: obj.provider, phone: obj.phone };
    this.commonRequest("/api/client/config/sponsorSignUp", obj);
  }
@@ -137,6 +231,9 @@
};
module.exports = api;
util/help.js
@@ -1,13 +1,19 @@
var help = {
import parse from 'mini-html-parser2';
var help;
help = {
  getEventParam(event, name) {
    return event.target.dataset[name];
  },
  setPageNavBar(title) {
    my.setNavigationBar({
      title: title,
    var data = {
      backgroundColor: getApp().themeColor,
      borderBottomColor: getApp().themeColor
    });
    }
    if (title != null) {
      data.title = title;
    }
    my.setNavigationBar(data);
  },
  isNullOrEmpty(str) {
    if (str == undefined || str == null || str.length == 0)
@@ -30,6 +36,21 @@
    html += "</div>";
    console.log(html);
    return html;
  },
  /**
   * 通过html文件获取富文本
   * @param {*} html
   * @param {*} callback
   */
  loadRichTextNode(html, callback) {
    parse(html, (err, nodes) => {
      console.log(nodes);
      if (!err) {
        callback(nodes);
      }
    });
  },
  //获取助力进度html
@@ -75,11 +96,20 @@
      hh: h < 10 ? '0' + h : h,
    }
  },
  getUid() {
    let data = my.getStorageSync({
      key: 'uid'
  cacheConfig(params) {
    my.setStorage({
      key: 'config',
      data: params
    });
    return data.data;
  },
  getCachedConfig(callback) {
    let data = my.getStorage({
      key: 'config',
      success: function (res) {
        callback(res.data);
      }
    });
  }
util/http.js
@@ -130,6 +130,7 @@
      params = {};
    params.timestamp = new Date().getTime();
    params.appKey = getApp().appKey;
    params.version=getApp().version;
    var array = new Array();
    for (var key in params) {
util/user.js
New file
@@ -0,0 +1,101 @@
const api = require("./api.js");
const help = require("./help.js");
var user = {
  login(obj) {
    my.getOpenUserInfo({
      fail: (res) => {
      },
      success: (res) => {
        let userInfo = JSON.parse(res.response).response // 以下方的报文格式解析两层 response
        if (userInfo.code == '10000') {//成功
          console.log(JSON.stringify(userInfo))
          help.rsa(JSON.stringify(userInfo), function (res) {
            api.uploadUserInfo({
              userInfo: res,
              showErrorToast: true,
              showLoading: true,
              success: function (res) {
                if (res.code == 0) {
                  //保存用户信息
                  my.setStorage({
                    key: 'user',
                    data: res.data
                  });
                  getApp().logined = true;
                  if (obj.success) {
                    obj.success(res.data)
                  }
                }
              }
            })
          });
        } else {
          my.showToast({
            content: '授权失败'
          });
        }
      }
    });
  },
  logout(obj) {
    my.removeStorage({
      key: 'user',
      success: () => {
        getApp().logined = false;
        if (obj.success)
          obj.success();
      },
      fail: () => {
        if (obj.fail)
          obj.fail();
      },
      complete: () => {
      }
    });
  },
  getUserInfo(obj) {
    my.getStorage({
      key: 'user',
      success: (result) => {
        if (result.data) {
          getApp().logined = true;
          obj.success(result.data);
        } else {
          console.log("用户未登录")
        }
      },
      fail: () => {
      },
      complete: () => {
      }
    });
  },
  init() {
    my.getStorage({
      key: 'user',
      success: (result) => {
        if (result.data) {
          getApp().logined = true;
          console.log("用户已登录")
        } else {
          console.log("用户未登录")
        }
      },
      fail: () => {
      },
      complete: () => {
      }
    });
  }
};
module.exports = user;