Пример #1
0
 menuItemClick(type) {
     switch (type) {
         case 0: 
             this.fun_tip();
             break;
         case 1: 
             this.fun_tip();
             break;
         case 2: 
             this.fun_tip();
             break;
         case 3: 
             this.fun_tip();
             break;
         case 4:
             React.api.showModal({
                 title: '请拨打客服电话',
                 content: '95117',
                 showCancel: true,
                 cancelColor: '#69c0ff',
                 confirmText: '拨打',
                 confirmColor: '#69c0ff'
             });
             break;
         case 5:
             React.api.showModal({
                 title: '确认退出登录',
                 showCancel: true,
                 confirmColor: '#73d13d'
             });
             break;
         default: break;
     }
 }
Пример #2
0
 componentDidMount() {
     let that = this;
     React.api.showLoading({
         title: '获取资源中',
         mask: true
     });
     React.api.request({
         url: 'http://yapi.demo.qunar.com/mock/18752/qunar/city',
         success: function(data) {
             React.api.hideLoading();
             let curData = that.cleanData(data.data);
             that.setState({data: curData});
         }
     });
 }
Пример #3
0
 fun_tip() {
     React.api.showModal({
         title: '提示',
         content: '该部分仅展示,无具体功能!',
         showCancel: false
     });
 }
Пример #4
0
 playmusic(id) {
     let that = this;
     React.api.request({
         url: bsurl + 'music/detail',
         data: {
             id: id
         },
         success: function(res) {
             
             let curplay = res.data.songs[0];
             app.globalData.curplay = curplay;
             that.setState({
                 start: 0,
                 share: {
                     id: id,
                     title: curplay.name,
                     br: res.data.privileges[0].maxbr,
                     des: (curplay.ar || curplay.artists)[0].name
                 },
                 music: curplay,
                 duration: common.formatduration(curplay.dt || curplay.duration),
                 loading: false
             });
             React.api.setNavigationBarTitle({ title: app.globalData.curplay.name });
             app.seekmusic(1);
             // common.loadrec(app.globalData.cookie, 0, 0, that.state.music.id, function (res) {
             //     that.setData({
             //       commentscount: res.total
             //     })
             //   })
         }
     });
 }
Пример #5
0
 success: e => {
     if (e.confirm) {
         var app = React.getApp();
         app.globalData.citySelect = city;
         React.api.navigateBack();
     }
 }
Пример #6
0
/* eslint-disable */
function alert(msg) {
  React.api.showModal({
    title: '',
    content: msg,
    showCancel: false,
    confirmText: '确定'
  })
} 
Пример #7
0
 setTimeout(function() {
     var animationRun = React.api.createAnimation({
         duration: 3000,
         timingFunction: 'ease'
     });
     animationRun.rotate(runDegs).step();
     that.setState({ animationData: animationRun.export() });
 }, 300);
Пример #8
0
 gotoSome(url) {
     console.log('url', url);
     if (url){
         React.api.navigateTo({ url });
     } else {
         this.fun_tip();
     }
 }
Пример #9
0
 paste() { 
   console.log('paste')
   React.api.getClipboardData({
     success: (res) => {
       console.log('data', res);
       this.setState({ copy: res.data });
     },
   });
 }
Пример #10
0
 removeStorage() {
   React.api.removeStorage({
     key: 'v1',
     success: function(data) {
       alert('handling success');
     },
     fail: function(data, code) {
       alert(`handling fail, code = ${code}`);
     }
   });
 }
Пример #11
0
 getStorage() {
   React.api.getStorage({
     key: 'v1',
     success: function(res) {
       alert(`handling success, ${res.data}`);
     },
     fail: function(data, code) {
       alert(`handling fail, code = ${code}`);
     }
   });
 }
Пример #12
0
 toCitySelect(isStartCity) {
     this.setState({isStartCity});
     let app = React.getApp();
     if (!isStartCity) {
         app.globalData.citySelect = '上海';
     } else {
         app.globalData.citySelect = '北京';
     }
     React.api.navigateTo({
         url: '../../demo/citySelect/index'
     });
 }
Пример #13
0
 setTimeout(function() {
     React.api.showModal({
         title: '恭喜',
         content: '获得' + awardsConfig[awardIndex].name,
         showCancel: false,
         success: function() {
             that.props.onOk();
         }
     });
     that.setState({
         btnDisabled: ''
     });
 }, 3300);
Пример #14
0
 getData() {
     let that = this;
     // React.api.showLoading({
     //     title: '获取资源中',
     //     mask: true
     // });
     React.api.request({
         url: 'http://yapi.demo.qunar.com/mock/18752/qunar/question',
         success: function(data) {
             // React.api.hideLoading();
             that.setState({ data: data.data });
         }
     });
 }
Пример #15
0
 itemClick(city){
     React.api.showModal({
         title: '提示',
         content:
     '当前选择城市为:' + city,
         success: e => {
             if (e.confirm) {
                 var app = React.getApp();
                 app.globalData.citySelect = city;
                 React.api.navigateBack();
             }
         }
     });
 }
Пример #16
0
 componentDidMount() {
     let that = this;
     // React.api.showLoading({
     //     title: '获取资源中',
     //     mask: true
     // });
     React.api.request({
         url: 'http://yapi.demo.qunar.com/mock/18752/qunar/scenic',
         success: function(data) {
             // React.api.hideLoading();
             // console.log('data', data.data);
             that.setState({ data: data.data });
         }
     });
 }
Пример #17
0
    getLottery() {
        var that = this;

        // 抽奖逻辑
        var awardIndex =
      this.props.awardIndex !== undefined
          ? this.props.awardIndex
          : Math.floor(Math.random() * this.state.awardData.length);

        // 获取奖品配置
        var awardsConfig = this.state.awardData;

        // 旋转抽奖
        let runDegs = 360 * 8 - awardIndex * (360 / awardsConfig.length);

        // 初始化
        var animationInit = React.api.createAnimation({
            duration: 1
        });

        animationInit.rotate(0).step();
        this.setState({ animationData: animationInit.export(), btnDisabled: 'disabled' });
        // 开始抽奖

        setTimeout(function() {
            var animationRun = React.api.createAnimation({
                duration: 3000,
                timingFunction: 'ease'
            });
            animationRun.rotate(runDegs).step();
            that.setState({ animationData: animationRun.export() });
        }, 300);

        // 中奖提示
        setTimeout(function() {
            React.api.showModal({
                title: '恭喜',
                content: '获得' + awardsConfig[awardIndex].name,
                showCancel: false,
                success: function() {
                    that.props.onOk();
                }
            });
            that.setState({
                btnDisabled: ''
            });
        }, 3300);
    }
Пример #18
0
    takePhoto() {
        const ctx = React.api.createCameraContext();

        ctx.takePhoto({
            quality: 'high',
            success: res => {
                this.setState({
                    src: res.tempImagePath
                });
            },
            error: function(err) {
                // eslint-disable-next-line
                console.log(err);
            }
        });
    }
Пример #19
0
 componentWillMount() {
     var that = this;
     // console.log(this.props.query)
     React.api.request({
         url:
       'http://yapi.demo.qunar.com/mock/17668/wemall/goods/inqGoodsByTypeBrand?brand=' +
       this.props.query.brand +
       '&typeid=' +
       this.props.query.brand,
         method: 'GET',
         data: {},
         header: {
             Accept: 'application/json'
         },
         success: function(res) {
             that.setState({
                 list: res.data
             });
         }
     });
 }
Пример #20
0
 success: function(data) {
     React.api.hideLoading();
     let curData = that.cleanData(data.data);
     that.setState({data: curData});
 }
Пример #21
0
    componentDidMount() {
    // 初始化奖品数据
        let defaultConfig = [
            { index: 0, name: '1元红包' },
            { index: 1, name: '5元话费' },
            { index: 2, name: '6元红包' },
            { index: 3, name: '8元红包' },
            { index: 4, name: '10元话费' },
            { index: 5, name: '10元红包' }
        ];
        let config;
        if (!this.state.awardData.length) {
            config = defaultConfig;
            this.setState({ awardData: defaultConfig });
        } else {
            config = this.state.awardData;
        }

        // 绘制转盘
        var len = config.length,
            rotateDeg = 360 / len / 2 + 90,
            html = [],
            turnNum = 1 / len; // 文字旋转 turn 值

        var ctx = React.api.createContext();
        for (var i = 0; i < len; i++) {
            // 保存当前状态
            ctx.save();
            // 开始一条新路径
            ctx.beginPath();
            // 位移到圆心,下面需要围绕圆心旋转
            ctx.translate(150, 150);
            // 从(0, 0)坐标开始定义一条新的子路径
            ctx.moveTo(0, 0);
            // 旋转弧度,需将角度转换为弧度,使用 degrees * Math.PI/180 公式进行计算。
            ctx.rotate((((360 / len) * i - rotateDeg) * Math.PI) / 180);
            // 绘制圆弧
            ctx.arc(0, 0, 150, 0, (2 * Math.PI) / len, false);

            // 颜色间隔
            if (i % 2 == 0) {
                ctx.setFillStyle('rgba(255,184,32,.1)');
            } else {
                ctx.setFillStyle('rgba(255,203,63,.1)');
            }

            // 填充扇形
            ctx.fill();
            // 绘制边框
            ctx.setLineWidth(0.5);
            ctx.setStrokeStyle('rgba(228,55,14,.1)');
            ctx.stroke();

            // 恢复前一个状态
            ctx.restore();

            // 奖项列表
            html.push({
                turn: i * turnNum + 'turn',
                lineTurn: i * turnNum + turnNum / 2 + 'turn',
                award: config[i].name
            });
        }
        this.setState({
            awardsList: html
        });
    }
Пример #22
0
    toDateSelect() {
        React.api.navigateTo({
            url: '../../demo/calendar/index'
        });

    }
Пример #23
0
 toCitySelect(isStartCity) {
     this.setState({isStartCity});
     React.api.navigateTo({
         url: '../../demo/citySelect/index'
     });
 }
Пример #24
0
 questionDetail() {
     React.api.navigateTo({ url: '../detail/index' });
 }
Пример #25
0
 gotoSome(url) {
     if (url) {
         React.api.navigateTo({ url });
     }
 }
Пример #26
0
 toCitySelect() {
     this.navItemClick(2);
     React.api.navigateTo({ url: '../../citySelect/index' });
 }
Пример #27
0
 copy() {
   console.log('copy')
   React.api.setClipboardData({
     data: this.state.data
   });
 }