my_information.html 6.3 KB
<!DOCTYPE html>
<html lang="en">

{include file="public/head"/}
<link rel="stylesheet" href="__CDN__/assets/advertising/css/personalMsg.css">
<link rel="stylesheet" href="__CDN__/assets/advertising/mui/mui.picker.min.css">

<body>
    <!-- 顶部 -->
    <div class="personal_msg_top">
        <!-- 头像 -->
        <div class="per_msg_header layout align_center justify flex_row">
            <div class="">头像</div>
            <div class="header_img">
                <img src="{$user.avatar}" alt="">
            </div>
        </div>
        <div class="per_msg_nick layout align_center justify flex_row">
            <div class="">昵称</div>
            <div class="">
                <input type="text" value="{$user.nickname}" placeholder="请输入微信昵称">
            </div>
        </div>
    </div>
    <!-- 底部 -->
    <div class="personal_msg_bottom">
        <div class="per_msg_single layout align_center justify flex_row" id="sexPicker">
            <div class="">性别</div>
            <div class="layout align_center justify flex_row">
                <input type="text" placeholder="请选择性别" disabled class="sex_input" value="{$user.gender}">
                <img src="__CDN__/assets/advertising/img/right.png" alt="">
            </div>
        </div>
        <div class="per_msg_single layout align_center justify flex_row" id="agePicker">
            <div class="">年龄</div>
            <div class="layout align_center justify flex_row">
                <input type="text" placeholder="请选择年份" disabled class="age_input" value="{:date('Y',$user['birthday'])}">
                <img src="__CDN__/assets/advertising/img/right.png" alt="">
            </div>
        </div>
        <div class="per_msg_single layout align_center justify flex_row" id="datePicker">
            <div class="">生日</div>
            <div class="layout align_center justify flex_row">
                <input type="text" placeholder="请选择出生日期" disabled class="date_input" value="{:date('m-d',$user['birthday'])}">
                <img src="__CDN__/assets/advertising/img/right.png" alt="">
            </div>
        </div>
        <div class="per_msg_single layout align_center justify flex_row">
            <div class="">所在城市</div>
            <div class="city_name"></div>
        </div>
        <div class="btn">保存</div>
    </div>
    <!-- 提示 -->
    <div class="personal_msg_tips layout justify flex_row">
        <div class="personal_tips_icon">
            <img src="__CDN__/assets/advertising/img/sun_34@2x.png" alt="">
        </div>
        <div>
            <p>如实填写信息将有助于获取更多、更有用的信息!</p>
            <p> 性别,年龄,生日填写后无法修改,如填写错误请联系客 服进行处理。</p>
        </div>
    </div>
    {include file="public/js" /}
    <script src="__CDN__/assets/advertising/mui/mui.min.js"></script>
    <script src="__CDN__/assets/advertising/mui/mui.picker.min.js"></script>
    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
    <script>
        var picker = new mui.PopPicker();
        picker.setData([{
            value: '1',
            text: '男'
        }, {
            value: '2',
            text: '女'
        }]);
        $("#sexPicker").click(function() {
            var sex = $(".sex_input").val();
            if (!sex) {
                picker.show(function(selectItems) {
                    $(".sex_input").val(selectItems[0].text)
                })
            }

        });

        // 年
        var dtPicker = new mui.DtPicker({
            type: "year",
            beginDate: new Date(1815, 04, 25), //设置开始日期 
            endDate: new Date(2119, 04, 25), //设置结束日期
        });
        $("#agePicker").click(function() {
            var year = $(".age_input").val();
            if (!year) {
                dtPicker.show(function(e) {
                    $(".age_input").val(e.y.text);
                });
            }

        });

        // 月日
        var dtPicker1 = new mui.DtPicker({
            type: "day",
        });
        $("#datePicker").click(function() {
            var date = $(".date_input").val();
            if (!date) {
                dtPicker1.show(function(e) {
                    $(".date_input").val(e.value)
                })
            }
        });

        wx.config(
            {$jssdk}
        );
        wx.ready(function () {
            wx.getLocation({
                success: function (res) {
                    success(res);
                },
                cancel: function (res) {
                    alert('必须同意授权获取地理位置才能获得奖励哦');
                }
            });
        });
        function success(data) {
            lat = data.latitude; //经度
            lng = data.longitude; //纬度
            //保存到用户表
            $.ajax({
                url:"{:url('home/user/location')}",
                type:"POST",
                data:{'user_id':user_id,'longitude':lng,'latitude':lat},
                success:function(res){
                    if(res.code == 1){
                        toast('定位成功');
                    }else{
                        toast('定位失败');
                    }
                },
                error:function(res){
                    toast('与服务器断开连接')
                }
            });
            //判断商户条件是否满足
            $.ajax({
                url:"{:url('home/index/distance_where')}",
                type:"POST",
                data:{'user_id':user_id,'longitude':lng,'latitude':lat,'goods_id':goods_id},
                success:function(res){
                    if(res.code == 1){
                        is_where_satisfy = res.data.is_where_satisfy;
                        if (is_satisfy == '1' && is_where_satisfy == '1') {
                            init();
                        }else{
                            $(".quest_condition").show();
                        }
                    }else{
                        toast('与服务器断开连接')
                    }
                },
                error:function(){
                    toast('与服务器断开连接');
                }
            });
        }
    </script>
</body>

</html>