123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- // 基本信息(包括userAgent)
- var baseInfo = null,
- // 基础环境信息(包括当前webview)
- baseEnv = null;
-
- // 搜索结果
- var $resultList = $('.activiy-list');
- var self;
- var docInfo;
- var myScroll;
- function initScroller(){
- //阻尼系数
- var deceleration = mui.os.ios?0.003:0.0009;
- mui('.mui-scroll-wrapper').scroll({
- scrollX: true,
- bounce: false,
- indicators: true, //是否显示滚动条
- deceleration:deceleration
- });
-
- myScroll = mui(".mui-scroll").pullToRefresh({
- down: {
- callback: function() {
- var _self = this;
- setTimeout(function() {
- load();
- _self.endPullDownToRefresh();
- }, 1000);
- }
- },
- scrollLeft: function(){
- xScroll = true;
- }
- });
- }
- function load() {
- activityList()
- }
- // 获取登录相关信息
- var getBaseInfo = function() {
- // 登录的相关信息
- var userAgent = JSON.parse(plus.storage.getItem("userAgent"))
- return {
- userAgent: userAgent,
- teamInfo: JSON.parse(plus.storage.getItem("teamInfo"))
- }
- },
- // 获取基础环境信息
- getBaseEnvPromise = function () {
- self = plus.webview.currentWebview();
- docInfo = JSON.parse(plus.storage.getItem("docInfo"));
- var env = {
- webview: plus&&plus.webview.currentWebview()
- };
- return Promise.resolve().then(function(res) {
- return env;
- });
- },
- // 初始化活动列表
- activityList = function() {
- plus.nativeUI.showWaiting();
- var obj = {
- id: self.activityId
- },
- params = {
- task: JSON.stringify(obj),
- page: 1,
- size: 1
- }
- sendPost("/doctor/healthBank/selectTask", params, queryFails, function(res) {
- if(res.status == 200) {
- var list = res.data.detailModelList;
- plus.nativeUI.closeWaiting();
- if(list.length == 0) {
- mui.toast("无具体活动详情")
- } else {
- var img = list[0].img;
- if(img){
- img = getImgUrl(img);
- }else{
- img = "../images/morenhuodong_banner02_img.png";
- }
- $("#banner").attr("src", img);
- $("#title").html(list[0].title)
- $("#organizer").html(list[0].organizer)
- $("#type").html(list[0].type)
- $("#activityTime").html(list[0].startTime + " ~ " + list[0].endTime)
- $("#location").html(list[0].location)
- $("#description").html(list[0].description)
- $(".total").html(list[0].total)
- }
- } else {
- plus.nativeUI.closeWaiting();
- queryFails(res);
- }
- }, 'post')
- },
- //查询失败回调
- queryFails = function(res) {
- if(res) {
- mui.toast(res.msg)
- } else {
- mui.toast("加载失败!")
- }
- },
- // 绑定页面事件
- bindEvents = function () {
- $resultList.on("tap", "li", function() {
- activityId = $(this).attr("data-code")
- openWebview("activity-detail.html", {
- activityId: activityId
- });
- });
- $(".award-index").on("tap", "span", function() {
- var $this = $(this),
- index = $this.index();
- if($this.hasClass("active")){
- return false;
- }
-
- $this.siblings().removeClass("active");
- $this.addClass("active");
-
- mui('.mui-slider').slider().gotoItem(parseInt(index));
- })
- //滚动切换
- document.querySelector('.mui-slider').addEventListener('slide', function(event) {
- $(".award-index span").removeClass("active");
- if (event.detail.slideNumber === 0) {
- $(".award-index span").eq(0).addClass("active");
- } else if (event.detail.slideNumber === 1) {
- $(".award-index span").eq(1).addClass("active");
- } else if (event.detail.slideNumber === 2) {
- $(".award-index span").eq(2).addClass("active");
- }
- });
- };
- // 页面业务处理流程开始
- mui.plusReady(function() {
- //获取当前页面
- self = plus.webview.currentWebview();
- initScroller();
- getBaseEnvPromise();
- //绑定事件
- bindEvents();
- //数据渲染
- activityList();
- })
|