<template>
    <view>
        <view class="bt1">
            <scroll-view
                id="listBox"
                style="height: calc(100vh - constant(safe-area-inset-bottom) - 64px); height: calc(100vh - env(safe-area-inset-bottom) - 64px); padding-bottom: 30px"
                :scroll-y="true"
            >
                <view class="p20 pt12 pb10" id="tocanvas">
                    <view class="v-center">
                        <view class="jobTitle">{{ jobDetail.jobName }}</view>
                    </view>
                    <view class="display-flex mt12">
                        <view class="display-flex flex-1">
                            <!-- <view>
          <image class="tImage" wx:if="{{jobDetail.store.logo != null && jobDetail.store.logo != ''}}" mode="aspectFit" src="{{jobDetail.store.logo}}"></image>
          <image class="tImage" wx:else mode="aspectFit" src="https://matripe.oss-cn-beijing.aliyuncs.com/default.png"></image>
          </view>-->
                            <view class="flex-1 vsb">
                                <view class="f14s c045 mb4">
                                    <!-- 深圳丨龙岗区丨16-35岁 -->
                                    {{ citys }}{{ jobDetail.store.distance }}
                                    <!-- {{jobDetail.store.distance}} -->
                                </view>
                                <view class="f14s c045 mb4">
                                    <block>{{ jobDetail.genderRestrict }}</block>
                                    丨{{ jobDetail.age }}
                                </view>
                            </view>
                        </view>
                        <view class="tr">
                            <view class="jobMoney color-f40">
                                <!-- {{jobDetail.combiSalary}} -->
                                <!-- {{jobDetail.hourlyPay || '--'}} -->
                                {{ jobDetail.hourlyPay || '--' }}
                            </view>
                            <view class="f14s c633 mt10 color-f40">
                                <!-- 5200-8400 -->
                                <!-- {{jobDetail.monthlyPay || '--'}} -->
                            </view>
                        </view>
                    </view>
                    <view class="bb1 tabBox pb4 mt4">
                        <!-- <view wx:if="{{jobDetail.rebate != null}}" class='tagsLi spli'>
            返费{{jobDetail.rebate}}
        </view>-->
                        <view class="display-flex" hover-class="none" :hover-stop-propagation="false">
                            <!-- <view class="t-icon t-icon-ziying1" wx:if="{{jobDetail.storeProjectSignType == 1}}"></view> -->
                            <view
                                class="tagsLi"
                                :style="'color:' + labelColor[index % labelColor.length] + ';background-color:' + bgColor[index % bgColor.length] + ';'"
                                v-for="(item1, index) in jobDetail.jobSpecialLabelNames"
                                :key="index"
                            >
                                {{ item1 }}
                            </view>
                        </view>
                        <view class="display-flex" hover-class="none" :hover-stop-propagation="false">
                            <view
                                class="tagsLi"
                                :tyle="'color:' + labelColor[index % labelColor.length] + ';background-color:' + bgColor[index % bgColor.length] + ';'"
                                v-for="(item1, index) in jobDetail.jobRequestLabelNames"
                                :key="index"
                            >
                                {{ item1 }}
                            </view>
                        </view>
                    </view>
                </view>
                <view
                    class="mg020 pb10 bb1 v-center"
                    @tap="parseEventDynamicCode($event, jobDetail.storeAddr != '北京市东城区东华门街道天安门' ? 'toMapChoice' : '')"
                    :data-address="jobDetail"
                >
                    <view>
                        <i class="iconfont icon-dizhi11 f18 mr10 lh1" style="color: var(--color-ysd)"></i>
                    </view>
                    <view class="address c3">{{ jobDetail.storeAddr != '北京市东城区东华门街道天安门' && jobDetail.storeAddr ? jobDetail.storeAddr : '暂无地址信息' }}</view>
                    <view>
                        <i class="iconfont icon-gengduo11 f14 ml18 dib pr c9" style="line-height: 1; top: 1px"></i>
                    </view>
                </view>
                <view style="padding-right: 30px">
                    <scroll-view
                        class="scroll-view_H p016 mt12"
                        v-if="images.length > 0"
                        :scroll-x="true"
                        @scroll="scroll"
                        style="width: 100%; height: 72px; white-space: nowrap; overflow: hidden"
                    >
                        <block v-for="(item, index) in images" :key="index">
                            <image :src="item.url" @tap="showImage" v-if="item.isImg" :data-src="item.url" class="img5" mode />

                            <view
                                class="videoContainer"
                                :data-id="item.id"
                                hover-class="none"
                                @click.stop="showVideo"
                                :hover-stop-propagation="false"
                                v-if="!item.isImg && item.url"
                                style="display: inline-block; position: relative"
                            >
                                <video
                                    class="img5"
                                    :id="item.id"
                                    :data-id="item.id"
                                    :src="item.url"
                                    :show-fullscreen-btn="false"
                                    :show-play-btn="false"
                                    :show-center-play-btn="false"
                                    :enable-play-gesture="true"
                                    @fullscreenchange="fullScreenFun"
                                ></video>
                            </view>
                        </block>
                    </scroll-view>
                </view>

                <view class="p020">
                    <view class="f14">
                        <block v-if="currIndex == '1'">
                            <view>
                                <view class="detailH3">
                                    <view class="fl mr12" style="width: 4px; height: 19px; background: #0dcc91; border-radius: 2px"></view>
                                    职位描述
                                </view>
                                <view class="pri f16" style="line-height: 24px; padding: 3px 0px; border-radius: 4px; color: #777">{{ jobDetail.jobInfo }}</view>
                            </view>

                            <view style="height: 40px"></view>
                        </block>
                        <block v-if="currIndex == '2'">
                            <view class="detailH3">面试</view>
                            <view class="outSp">
                                <view class="display-flex">
                                    <view class="rb1">面试时间</view>
                                    <view class="textb1">{{ jobDetail.interviewDuration }}</view>
                                </view>
                                <!-- <view class="display-flex">
            <view class="rb1">面试地点</view>
            <view class="textb1">{{jobDetail.interviewAddr}}</view>
            </view>-->
                                <!-- <view class="display-flex">
            <view class="rb1">驻场信息</view>
            <view class="textb1">{{jobDetail.onSiteInfo}}</view>
            </view>-->
                                <view class="display-flex">
                                    <view class="rb1">出行方式</view>
                                    <view class="textb1">{{ jobDetail.tripMode }}</view>
                                </view>
                                <!-- <view class="display-flex">
            <view class="rb1">驻场信息1</view>
            <view class="textb1">{{jobDetail.onSiteTransfers}}</view>
            </view>-->
                                <view class="display-flex">
                                    <view class="rb1">面试说明</view>
                                    <view class="textb1">{{ jobDetail.interviewDesp }}</view>
                                </view>
                            </view>
                            <view class="detailH3">入离职</view>
                            <view class="outSp">
                                <!-- <view class="display-flex">
            <view class="rb1">入职时间</view>
            <view class="textb1">{{jobDetail.entryDuration}}</view>
          </view>
          <view class="display-flex">
            <view class="rb1">入职资料</view>
            <view class="textb1">{{jobDetail.entryInformation}}</view>
          </view>
          <view class="display-flex">
            <view class="rb1">入职合同</view>
            <view class="textb1">{{jobDetail.entryContracts}}</view>
            </view>-->
                                <view class="display-flex">
                                    <view class="rb1">入职说明</view>
                                    <view class="textb1">{{ jobDetail.entryDesp }}</view>
                                </view>
                                <view class="display-flex">
                                    <view class="rb1">入职说明</view>
                                    <view class="textb1">{{ jobDetail.leaveRequire }}</view>
                                </view>
                                <view class="display-flex">
                                    <view class="rb1">返厂</view>
                                    <view class="textb1">{{ jobDetail.leaveDesp }}</view>
                                </view>
                            </view>
                            <!-- <view class="detailH3">离职</view>
        <view class="outSp">
          <view class="display-flex">
            <view class="rb1">离职要求</view>
            <view class="textb1">{{jobDetail.leaveRequire}}</view>
          </view>
          <view class="display-flex">
            <view class="rb1">补充说明</view>
            <view class="textb1">{{jobDetail.leaveDesp}}</view>
          </view>
          </view>-->
                        </block>
                        <block v-if="currIndex == '3'">
                            <view class="detailH3">报名须知</view>
                            <view class="pri border1" style="line-height: 24px; padding: 3px 8px; border-radius: 4px; color: #333">{{ jobDetail.agencyStatement }}</view>
                            <!-- <view class="detailH3">温馨提示</view>
        <view class="pri" style="border:1px solid #eee;line-height:24px;padding:3px 8px;border-radius: 4px;color:#ff4400">{{jobDetail.sweetTips}}
          </view>-->
                        </block>
                        <block v-if="currIndex == '4'">
                            <view class="detailH3">财务信息</view>
                            <view v-if="isAgency" class="outSp">
                                <!-- <view class="display-flex" wx:if='{{managerRoleClassify}}'>
            <view class="rb1">伯才利润</view>
            <view class="textb1">{{jobDetail.boCaiProfit}}</view>
            </view>-->
                                <!-- <view class="display-flex">
            <view class="rb1">服务费</view>
            <view class="textb1">{{fuWuFei}}</view>
            </view>-->
                                <!-- <view class="display-flex">
            <view class="rb1">总利润</view>
            <view class="textb1">{{jobDetail.totalProfit}}</view>
            </view>-->
                                <!-- <view class="display-flex">
            <view class="rb1">伯才利润</view>
            <view class="textb1">{{jobDetail.boCaiProfit}}</view>
            </view>-->
                                <!-- <view class="display-flex">
            <view class="rb1">服务费</view>
            <view class="textb1">{{jobDetail.returnFee}}</view>
            </view>-->
                                <!-- <view class="display-flex">
            <view class="rb1">代理利润</view>
            <view class="textb1">{{jobDetail.agencyProfit}}</view>
            </view>-->
                                <view class="display-flex">
                                    <view class="rb1">服务费详情</view>
                                    <view class="textb1">{{ jobDetail.agencyProfit }}</view>
                                </view>
                                <view class="display-flex">
                                    <view class="rb1">扣税说明</view>
                                    <view class="textb1">{{ jobDetail.deductTaxDesp }}</view>
                                </view>
                                <view class="display-flex">
                                    <view class="rb1 vsb">
                                        <view class hover-class="none" :hover-stop-propagation="false">账单日</view>
                                        <view class hover-class="none" :hover-stop-propagation="false">(出名单时间)</view>
                                    </view>
                                    <view class="textb1 fsa" style>{{ jobDetail.outListTime }}</view>
                                </view>
                                <view class="display-flex">
                                    <view class="rb1 vsb">
                                        <view class hover-class="none" :hover-stop-propagation="false">结算日</view>
                                        <view class hover-class="none" :hover-stop-propagation="false">(结算时间)</view>
                                    </view>
                                    <view class="textb1 fsa" style>{{ jobDetail.settlementTime }}</view>
                                </view>
                            </view>
                            <view v-else class @tap="showTobe" hover-class="none" :hover-stop-propagation="false">仅代理可见</view>
                        </block>
                        <block v-if="currIndex == '5'">
                            <view class="pri" style="line-height: 24px; padding: 5px 8px; border-radius: 4px; color: #333">
                                <view :data-content="jobDetail.jobDesp" @click.stop="setCopy">
                                    <!-- <icon class="iconfont icon-fuzhi mr4" style="font-size:16px;float: right;"></icon> -->
                                    <span class="desp-copy">复制</span>
                                </view>
                                <rich-text class hover-class="none" :hover-stop-propagation="false" :nodes="jobDetail.jobDesp1"></rich-text>
                                <view
                                    class="contactInfo"
                                    hover-class="none"
                                    :data-info="
                                        userInfo.agencyStatus == 1
                                            ? userInfo.noticeEndStr
                                                ? userInfo.noticeEndStr
                                                : '详情咨询：' + userInfo.tel
                                            : serviceInfo.userName + ' ' + (serviceInfo.workPhone || '-')
                                    "
                                    :hover-stop-propagation="false"
                                >
                                    {{
                                        userInfo.agencyStatus == 1
                                            ? userInfo.noticeEndStr
                                                ? userInfo.noticeEndStr
                                                : '详情咨询：' + userInfo.tel
                                            : '详情咨询：' + serviceInfo.aliasName + (serviceInfo.workPhone || '-')
                                    }}
                                </view>
                                <view class="f14 tac mt16" v-if="userInfo.agencyStatus == 1" hover-class="none" :hover-stop-propagation="false">
                                    以上联系人，可以
                                    <span class="fw500" @click="changeContact" style="color: #576b95; text-decoration: underline">改成我的</span>
                                </view>
                            </view>
                            <!-- <view class="detailH3">温馨提示</view>
        <view class="pri" style="border:1px solid #eee;line-height:24px;padding:3px 8px;border-radius: 4px;color:#ff4400">{{jobDetail.sweetTips}}
          </view>-->
                        </block>
                    </view>
                    <!-- <view wx:if="{{jobDetail.baseInfo != null && jobDetail.baseInfo != ''}}" class='display-flex pb20 mt20' style="border-bottom:1rpx solid #e2e2e2;">
      <view class='flex-1 f14 c085'>
        <view>利润政策</view>
        <view style="white-space: pre-line;">{{bclr}}</view>
        <view style="white-space: pre-line;margin-top:20px;">{{jobDetail.baseInfo}}</view>
        <view style="margin-top: 20px;">对接信息</view>
        <view style="white-space: pre-line;"> {{djxx}}</view>
      </view>
      </view>-->
                </view>
            </scroll-view>
        </view>
        <view class="bottomBtn" style="height: calc(constant(safe-area-inset-bottom) + 64px); height: calc(env(safe-area-inset-bottom) + 64px)">
            <view class="norecruit" v-if="isMaskShow">该职位暂时停招</view>
            <view class="fsa tc bottomBox">
                <view style="width: 56px; padding-left: 8px" v-if="jobDetail.customServiceUser.tel" @tap="showphone">
                    <view style="position: relative; top: 2px">
                        <i class="iconfont icon-dianhua2 lh1" style="color: #787878; font-size: 18px; position: relative; top: 1px"></i>
                        <view class="btext" style="margin-top: 2px">电话</view>
                    </view>
                </view>
                <view style="width: 56px; padding-right: 10px" v-if="jobDetail.customServiceUser.weChat" @tap="textPaste">
                    <view style="position: relative; top: 2px">
                        <i class="iconfont icon-weixin lh1" style="color: #787878; font-size: 18px"></i>
                        <view class="btext" style="margin-top: 2px">微信</view>
                    </view>
                </view>

                <view class="flex-1 pr16 pl16" v-if="!isMaskShow">
                    <button type class="loginOut" @tap="goNewEnroll" :data-job="jobDetail">立即报名</button>
                    <!-- <button wx:else type="" class="detailBtn" hover-class="button-hover" open-type="getPhoneNumber" catchgetphonenumber="getPhoneNumber" catchtap="emptyMethod">立即报名</button> -->
                </view>
                <view class="flex-1 pr16" v-else>
                    <button class="loginOut" hover-class="none" style="background-color: #ccc" hover-stop-propagation>暂时停招</button>
                </view>
            </view>
        </view>
        <view class="mask" v-if="isMaskShow"></view>
        <bottom-drawer
            :show="recordShow"
            :info="currentInfo"
            drawerType="recordShow"
            :cancerShow="false"
            :touchClose="true"
            @hidedrawer="hidedrawershow"
            class="bottomDrawer"
            height="494px"
            @touchmove.native.stop.prevent="cth"
        ></bottom-drawer>
    </view>
</template>

<script>
import bottomDrawer from '../../components/bottom-drawer/index';
const app = getApp();
const commonUtil = require('../../utils/commonUtil');
const { wxml, style } = require('./demo.js');
var QQMapWX = require('../../utils/qqmap-wx-jssdk.min.js');
var qqmapsdk;
export default {
    components: {
        bottomDrawer
    },
    data() {
        return {
            recordShow: false,
            images: [],
            isLogin: false,
            statusBarHeight: uni.getStorageSync('statusBarHeight'),

            // 状态栏高度

            navigationBarHeight: uni.getStorageSync('navigationBarHeight'),

            // 导航栏高度

            menuButtonHeight: uni.getStorageSync('menuButtonHeight'),

            // 胶囊按钮高度

            menuButton: uni.getStorageSync('menuButtonInfo'),

            // 胶囊信息
            backHeight: uni.getMenuButtonBoundingClientRect().top + uni.getMenuButtonBoundingClientRect().height / 2 + 'px',

            storeJobId: '',
            iosDialog: false,

            //职位ID
            searchForm: {
                storeJobId: '',
                lng: '',
                lat: ''
            },

            fullScreen: false,
            bclr: '',
            djxx: '',
            currIndex: '1',

            jobDetail: {
                jobName: '',
                genderRestrict: '',
                jobSpecialLabelNames: [],
                jobRequestLabelNames: [],
                storeAddr: '',
                jobInfo: '',
                interviewDuration: '',
                tripMode: '',
                interviewDesp: '',
                entryDesp: '',
                leaveRequire: '',
                leaveDesp: '',
                agencyStatement: '',
                agencyProfit: '',
                deductTaxDesp: '',
                outListTime: '',
                settlementTime: '',
                jobDesp: '',
                jobDesp1: '',

                customServiceUser: {
                    tel: '',
                    weChat: ''
                }
            },

            //详情
            wxCode: '',

            pbtm: 0,
            shareTitle: '',
            isCollect: false,
            src: '',
            word: 'woca',
            phoneDialog: false,
            isImg: true,
            labelColor: ['#c41d7f', '#096dd9', '#531dab', '#d46b08', '#389e0d', '#08979c', '#cf1322'],
            bgColor: ['#fff0f6', '#e6f7ff', '#f9f0ff', '#fff7e6', '#f6ffed', '#e6fffb', '#fff1f0'],

            wxml: {
                text: '啊啊按'
            },

            addressNew: '',
            citys: '',
            showSexAgeText: '',
            fuWuFei: '',
            isServicePriceShow: true,
            isAgency: true,
            isShareShow: false,
            managerRoleClassify: false,

            // 管理员权限
            serviceInfo: app.globalData.serviceInfo,

            isMaskShow: false,
            onSiteRemark: '',
            img: 'https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/bg.png',
            canvasImg: '',
            isLoading: true,
            iosDialogTobe: false,

            // 成为代理弹窗显示
            userInfo: {
                agencyStatus: 0,
                noticeEndStr: false,
                tel: ''
            },

            shareListImg: 'https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/detail830-1.png',
            shareDetailImg: 'https://matripe-cms.oss-cn-beijing.aliyuncs.com/1shoudan/posterbg1.1.png',
            posterImg: '',
            safeBottom: uni.getWindowInfo().screenHeight - uni.getWindowInfo().safeArea.height + 'px',
            swiperHeight: 0,
            bottomLift: 0,
            showfixToast: false,
            current: 0,
            corpUserFlag: '',
            posterShow: false,
            currentInfo: ''
        };
    },
    onShow() {
        var that = this;
        uni.getSystemInfo({
            success: (res) => {
                that.bottomLift = res.screenHeight - res.safeArea.bottom + 60;
            },
            fail(err) {
                console.log(err);
            }
        });
        console.log(that.bottomLift);
        this.setData({
            bottomLift: that.bottomLift,
            isLogin: app.globalData.isLogin,
            // backHeight:wx.getMenuButtonBoundingClientRect().top,
            isLoading: true
            // userInfo:{...app.globalData.loginUserInfo,  agencyStatus:0},
        });
        if (app.globalData.isLogin) {
            that.setData({
                // agencyStatus: app.globalData.agencyStatus,
                userInfo: app.globalData.loginUserInfo
            });
        } else {
            this.wxLogin();
        }
    },
    onLoad(query) {
        var that = this;
        console.log(app.globalData.loginUserInfo);
        qqmapsdk = new QQMapWX({
            key: '5PTBZ-YI7C6-MZGS3-ES7QN-4T5O2-EJFVR'
        });
        that.setData({
            isAgency: app.globalData.loginUserInfo.agencyStatus == 1 ? true : false,
            corpUserFlag: app.globalData.loginUserInfo.corpUserFlag,
            managerRoleClassify: app.globalData.loginUserInfo.managerRoleClassify,
            userInfo: app.globalData.loginUserInfo
        });
        that.widget = that.zpSelectComponent('.widget');
        uni.getSystemInfo({
            success: (res) => {
                console.log('手机信息res' + res.model);
                let modelmes = res.model;
                console.log(modelmes.search('iPhone X'));
                if (
                    modelmes.search('iPhone 12 Pro') != -1 ||
                    modelmes.search('iPhone X') != -1 ||
                    modelmes.search('iPhone XR') != -1 ||
                    modelmes.search('iPhone XS max') != -1 ||
                    modelmes.search('iPhone 11') != -1
                ) {
                    that.setData({
                        pbtm: 40
                    });
                } else {
                }
            }
        });
        console.log(query);
        console.log('HHHHHHHHHHHHH' + query.storeJobId);
        if (app.globalData.isNotEmptyCheck(query.storeJobId)) {
            console.log('HHHHHHHHHHHHH');
            this.searchForm.storeJobId = query.storeJobId;
        } else if (app.globalData.isNotEmptyCheck(query.scene)) {
            console.log('XXXXXXXXXXXX');
            //扫小程序码携带参数
            var sceneStr = decodeURIComponent(query.scene);
            var sceneJson = commonUtil.sceneToJson(sceneStr);
            console.log('sceneJson===', sceneJson);
            this.searchForm.storeJobId = sceneJson.storeJobId;
        }

        // this.data.wxCode = query.wxCode;
        // this.getLocation();
        this.getStoreJobDetailById();
        // that.setData({
        //     wxCode: that.data.wxCode
        // })
        uni.setStorageSync({
            key: 'storeJobId',
            data: query.storeJobId
        });
        let agencyUserId = query.agencyUserId;
        if (agencyUserId) {
            uni.setStorageSync('storageSyncAgencyUserId', agencyUserId);
            console.log('agencyUserId', agencyUserId);
            app.globalData.isCommission = 1;
        }
    },
    onShareAppMessage() {},
    methods: {
        cth() {
            return false;
        },

        showVideo(e) {
            console.log(e.target.dataset.id);
            console.log(uni.getSystemInfo());
            var that = this;
            that.videoContext = uni.createVideoContext(`${e.target.dataset.id}`, that);
            console.log(that.videoContext);
            console.log('=========================');
            that.videoContext.requestFullScreen();
            that.videoContext.hideStatusBar();
            that.videoContext.play();
            // setTimeout(() => {
            //   that.setData({
            //     isShareShow: true,
            //   });
            // }, 500);
        },

        fullScreenFun() {
            if (!e.detail.fullScreen) {
                this.setData({
                    isShareShow: false
                });
                this.videoContext.stop();
            }
        },

        doNothing() {},

        closeFix() {
            this.setData({
                showfixToast: false
            });
        },

        bindchange(e) {
            console.log(e.detail.current);
            this.setData({
                current: e.detail.current
            });
        },

        showFix(e) {
            var that = this;
            console.log(e.currentTarget.dataset.id);
            var id = e.currentTarget.dataset.id;
            var profiles = that.jobDetail.storeImage;
            var currentProfileIndex = (profiles || []).findIndex((profile) => profile.id === id);
            console.log(currentProfileIndex);
            this.setData({
                current: currentProfileIndex,
                showfixToast: true
            });
        },

        showdialog() {
            this.setData({
                iosDialog: true
            });
        },

        closeDialog() {
            this.setData({
                iosDialog: false
            });
        },

        showphone: function () {
            var that = this;
            // console.log( that.data.serviceInfo.workPhone);
            uni.makePhoneCall({
                // number: that.data.jobDetail.assistantUserTel + ""
                phoneNumber: that.jobDetail.customServiceUser.tel || '0371-6611 3723'
            });
        },

        close: function () {
            this.setData({
                phoneDialog: false
            });
        },

        wxLogin() {
            var that = this;
            uni.login({
                success(res) {
                    if (res.code) {
                        that.setData({
                            wxCode: res.code
                        });
                    } else {
                        console.log('获取code失败！' + res.errMsg);
                    }
                }
            });
        },

        showImage(e) {
            let resImg = e.currentTarget.dataset.src;
            var imgArr = [];
            this.images.forEach((item) => {
                // let regs = /\.(jpg|jpeg|png)(\?.*)?$/;
                //   item.isImg = regs.test(item.url.toLowerCase());
                if (item.isImg) {
                    imgArr.push(item.url);
                }
            });
            uni.previewImage({
                current: e.currentTarget.dataset.src,
                // 当前显示图片的http链接
                urls: imgArr
            });
        },

        renderToCanvas() {
            const p1 = this.widget.renderToCanvas({
                wxml: wxml(that.data.wxml),
                style
            });
            p1.then((res) => {
                console.log('container', res.layoutBox);
                this.container = res;
                console.log(res);
            });
        },

        extraImage() {
            var that = this;
            // return new Promise(function (resolve, reject) {
            that.widget
                .renderToCanvas({
                    wxml: wxml(that.wxml),
                    style
                })
                .then((res1) => {
                    const p2 = that.widget.canvasToTempFilePath();
                    p2.then((res) => {
                        console.log(res);
                        that.setData({
                            src: res.tempFilePath
                        });
                    });
                });
            // });
        },

        searchAnimate() {
            let that = this;
            uni.createSelectorQuery()
                .in(uni)
                .select('#listBox')
                .fields(
                    {
                        scrollOffset: true,
                        size: true
                    },
                    (res) => {
                        // #ifdef MP-WEIXIN
                        this.$scope.animate(
                            '.navigatorBar',
                            [
                                {
                                    opacity: 0
                                },
                                {
                                    opacity: 1
                                }
                            ],
                            800,
                            {
                                scrollSource: '#listBox',
                                timeRange: 1000,
                                startScrollOffset: 0,
                                endScrollOffset: that.swiperHeight - 34
                            }
                        );
                        // #endif
                        // #ifndef MP-WEIXIN
                        this.animate(
                            '.navigatorBar',
                            [
                                {
                                    opacity: 0
                                },
                                {
                                    opacity: 1
                                }
                            ],
                            800,
                            {
                                scrollSource: '#listBox',
                                timeRange: 1000,
                                startScrollOffset: 0,
                                endScrollOffset: that.swiperHeight - 34
                            }
                        );
                        // #endif
                        // #ifdef MP-WEIXIN
                        this.$scope.animate(
                            '.noBack',
                            [
                                {
                                    opacity: 1
                                },
                                {
                                    opacity: 0
                                }
                            ],
                            800,
                            {
                                scrollSource: '#listBox',
                                timeRange: 1000,
                                startScrollOffset: 0,
                                endScrollOffset: 1
                            }
                        );
                        // #endif
                        // #ifndef MP-WEIXIN
                        this.animate(
                            '.noBack',
                            [
                                {
                                    opacity: 1
                                },
                                {
                                    opacity: 0
                                }
                            ],
                            800,
                            {
                                scrollSource: '#listBox',
                                timeRange: 1000,
                                startScrollOffset: 0,
                                endScrollOffset: 1
                            }
                        );
                        // #endif
                    }
                )
                .exec();
        },

        // onReady() {
        // 	let that = this;
        // 	var query = wx.createSelectorQuery();
        // 	query.select(".page-section").boundingClientRect();
        // 	query.exec(function (res) {
        // 		//res就是 所有标签为v1的元素的信息 的数组
        // 		console.log(res);
        // 		//取高度
        // 		console.log(res[0].height);
        // 		that.setData({
        // 			swiperHeight: res[0].height,
        // 		});
        // 	});
        // },

        getAgencyInfo(job) {
            var that = this;
            console.log(job);
            console.log('打印基本信息');
            let objAgency = {
                returnFeeDesp: job.returnFeeDesp,
                returnFeeType: job.returnFeeType,
                transferFee: job.transferFee,
                returnFee: job.returnFee != null ? new Number(job.returnFee).toFixed(2) : null
            };
            let agencyStr = '';
            if (app.globalData.isNotEmptyCheck(job.transferFee)) {
                agencyStr = '伯才利润：' + job.transferFee + ';';
            }
            if (job.returnFeeType == 0) {
                agencyStr += `\n服务费：xxx元/时`;
            } else if (job.returnFeeType == 1) {
                agencyStr += `\n服务费：xxx元/天`;
            } else if (job.returnFeeType == 2) {
                agencyStr += `\n服务费：xxx元/月`;
            } else if (job.returnFeeType == 3) {
                agencyStr += `\n服务费：xxx元/次`;
            }
            if (objAgency.returnFee > 0) {
                agencyStr = agencyStr.replace('xxx', objAgency.returnFee);
            } else if (app.globalData.isNotEmptyCheck(job.transferFee)) {
                agencyStr = '伯才利润：' + job.transferFee + ';';
            } else {
                agencyStr = '-';
            }
            if (app.globalData.isEmptyCheck(objAgency.returnFeeDesp)) {
                // return agencyStr
                that.setData({
                    bclr: agencyStr
                });
            } else {
                that.setData({
                    bclr: agencyStr + '\n' + objAgency.returnFeeDesp
                });
                // return agencyStr + '\n' + objAgency.returnFeeDesp;
            }
        },

        toMapChoice(e) {
            var that = this;
            console.log(e.currentTarget.dataset.address);
            var address = e.currentTarget.dataset.address;
            uni.openLocation({
                latitude: Number(address.storeLat),
                longitude: Number(address.storeLng),
                name: address.storeName,
                address: address.storeAddr,
                scale: 15,
                success(res) {
                    console.log(res);
                },
                fail(res) {
                    console.log(res);
                }
            });
            // wx.getLocation({
            //   type: 'gcj02', //返回可以用于wx.openLocation的经纬度
            //   success (res) {
            //     console.log(res)
            //     wx.openLocation({
            //       latitude: Number(address.storeLat),
            //       longitude:  Number(address.storeLng),
            //       name: address.storeName,
            //       address: address.storeAddr,
            //       scale: 15,
            //       success (res) {
            //         console.log(res)
            //       },
            //       fail (res) {
            //         console.log(res)
            //       }
            //     });
            //   },
            //   fail(res){
            //     console.log(res);
            //   }
            // })
            // console.log(e);
            // try {
            // 	wx.setStorageSync("onSiteRemark", that.data.onSiteRemark);
            // 	wx.setStorageSync("addressList", e.currentTarget.dataset.address);
            // } catch (error) {
            // 	console.log(error);
            // }
            // wx.navigateTo({
            // 	url: "../mine/addressPage/index",
            // });
        },

        // openMap(e) {
        // 	wx.showLoading({
        // 		title: "加载中",
        // 	});
        // 	console.log(e);
        // 	let address = e.currentTarget.dataset.address;
        // 	let lat = e.currentTarget.dataset.lat;
        // 	var formatted_addresses = "";
        // 	qqmapsdk.reverseGeocoder({
        // 		location: `${e.currentTarget.dataset.lat},${e.currentTarget.dataset.lng}`,
        // 		success: function (res) {
        // 			console.log(res);
        // 			formatted_addresses = res.result.formatted_addresses.recommend;
        // 		},
        // 	});
        // 	console.log(formatted_addresses);
        // 	console.log(lat);
        // 	wx.getLocation({
        // 		type: "gcj02", //返回可以用于wx.openLocation的经纬度
        // 		success(res) {
        // 			wx.openLocation({
        // 				latitude: e.currentTarget.dataset.lat - 0,
        // 				longitude: e.currentTarget.dataset.lng - 0,
        // 				name: formatted_addresses,
        // 				address: address,
        // 				scale: 8,
        // 			});
        // 		},
        // 		complete(res) {
        // 			wx.hideLoading();
        // 			console.log(1123213);
        // 		},
        // 	});
        // },
        changeMenu(e) {
            let currentIndex = parseInt(e.currentTarget.dataset.id);
            this.setData({
                currIndex: e.currentTarget.dataset.id
            });
        },

        getLocation() {
            var that = this;
            uni.getSetting({
                success: (res) => {
                    console.log(res); // res.authSetting.location

                    if (res.authSetting.location) {
                        uni.getLocation({
                            success(res1) {
                                console.log('获取位置');
                                console.log(res1);
                                if (app.globalData.isNotEmptyCheck(res1.latitude) && app.globalData.isNotEmptyCheck(res1.longitude)) {
                                    that.searchForm.lat = res1.latitude;
                                    that.searchForm.lng = res1.longitude;
                                }
                                that.getStoreJobDetailById();
                            },
                            fail() {
                                that.getStoreJobDetailById();
                            }
                        });
                    } else {
                        that.getStoreJobDetailById();
                    }
                }
            }); // my.getLocation({
            //     success(res) {
            //         my.hideLoading();
            //         console.log(res)
            //         that.data.searchForm.lng = res.longitude;
            //         that.data.searchForm.lat = res.latitude;
            //         that.getStoreJobDetailById();
            //     },
            //     fail() {
            //         my.hideLoading();
            //         that.getStoreJobDetailById();
            //     },
            // })
        },

        // onShareAppMessage1: function () {
        // 	var path = commonUtil.getCurrentPageUrlWithArgs();
        // 	if (app.globalData.isLogin && app.globalData.agencyStatus - 0 != 0) {
        // 		//当前用户是代理人
        // 		path += "&agencyUserId=" + app.globalData.loginUserInfo.id;
        // 	}
        // 	var that = this;
        // 	// const promise = new Promise(resolve => {
        // 	//     that.widget.renderToCanvas({ wxml:wxml(that.data.jobDetail), style }).then(res1 => {
        // 	//         const p2 = that.widget.canvasToTempFilePath()
        // 	//         p2.then(res => {
        // 	//             console.log(res);
        // 	//             resolve({
        // 	//                 title:that.data.shareTitle,
        // 	//                 imageUrl: res.tempFilePath,
        // 	//             })

        // 	//         })

        // 	//     });
        // 	// });
        //   return this.getCanvas().then(()=>{
        //     	return {
        // 		title: that.data.shareTitle,
        // 		imageUrl: that.data.canvasImg,
        // 		path: path,
        // 		// promise
        // 	};
        //   })

        // },
        getCanvas() {
            const that = this;
            return new Promise((resolve) => {
                var mycenter = 0; //文字左右居中显示
                var myheight = 0; //文字高度
                const query = uni.createSelectorQuery();
                query
                    .select('#canvasId')
                    .fields({
                        node: true,
                        size: true
                    })
                    .exec((res) => {
                        console.log(res);
                        const canvas = res[0].node;
                        const ctx = canvas.getContext('2d');
                        new Promise(function (resolve) {
                            // 绘制背景图片
                            uni.getImageInfo({
                                src: that.img,
                                //网络图片,如果不行请换一个
                                success(res) {
                                    console.log(res);
                                    var width = res.width;
                                    var height = res.height;
                                    mycenter = width / 2;
                                    myheight = height;
                                    canvas.width = width;
                                    canvas.height = height;
                                    const img = canvas.createImage();
                                    console.log(ctx);
                                    img.src = res.path;
                                    img.onload = () => {
                                        ctx.drawImage(img, 0, 0, width, height);
                                        resolve(true);
                                    };
                                }
                            });
                        })
                            .then(() => {
                                ctx.font = '500 70px Arial';
                                ctx.textAlign = 'left';
                                // ctx.fillStyle = "#333";
                                ctx.fillStyle = '#fff';
                                // console.log(that.data.factoryBill.totalSalary.toString().length);
                                // let steNumber = that.data.factoryBill.totalSalary.toString().length
                                // ctx.fillRect(40, 168, steNumber * 30, 72);
                                ctx.fillText('职位详情', 40, 210);
                            })
                            .then(function () {
                                uni.canvasToTempFilePath({
                                    canvas: canvas,
                                    success(res) {
                                        console.log(res);
                                        that.setData({
                                            canvasImg: res.tempFilePath
                                            // base64: canvas.toDataURL(),
                                        });
                                        resolve();
                                        // console.log(that.data.canvasImg);
                                    }
                                });
                            })
                            .catch((err) => {});
                    });
            });
        },

        // onShareTimeline: function () {
        // 	return {
        // 		title: this.data.shareTitle,
        // 		query: "?storeJobId=" + this.data.storeJobId,
        // 	};
        // },
        getCanvas() {
            const that = this;
            return new Promise((resolve) => {
                var mycenter = 0; //文字左右居中显示
                var myheight = 0; //文字高度
                const query = uni.createSelectorQuery();
                query
                    .select('#canvasId')
                    .fields({
                        node: true,
                        size: true
                    })
                    .exec((res) => {
                        console.log(res);
                        const canvas = res[0].node;
                        const ctx = canvas.getContext('2d');
                        new Promise(function (resolve) {
                            // 绘制背景图片
                            uni.getImageInfo({
                                src: that.shareDetailImg,
                                //网络图片,如果不行请换一个
                                success(res) {
                                    console.log(res);
                                    var width = res.width;
                                    var height = res.height;
                                    mycenter = width / 2;
                                    myheight = height;
                                    canvas.width = width;
                                    canvas.height = height;
                                    const img = canvas.createImage();
                                    console.log(ctx);
                                    img.src = res.path;
                                    img.onload = () => {
                                        ctx.drawImage(img, 0, 0, width, height);
                                        resolve(true);
                                    };
                                }
                            });
                        }).then(() => {
                            console.log(530);
                            const fillTextLineBreak = (ctx, text, x, y, lw, lh, color = '#333', font = '32', weight = '500') => {
                                var i = 0;
                                var n = 0;
                                var r = -1;
                                var initHeight = 0;
                                ctx.font = weight + ' ' + font + 'px Arial'; //字体大小
                                ctx.fillStyle = color; //字体颜色
                                while (i < text.length) {
                                    while (ctx.measureText(text.substring(n, i)).width < lw && i < text.length) {
                                        i++;
                                    }
                                    r++;
                                    ctx.fillText(text.substring(n, i), x, y + lh * r);
                                    n = i;
                                }
                                initHeight = lh * r;
                                // wx.setStorageSync("initHeight", initHeight);
                            };
                            const roundRect = (ctx, img, bg_x, bg_y, bg_w, bg_h, bg_r) => {
                                // 开始绘制
                                ctx.save();
                                ctx.beginPath();
                                ctx.arc(bg_x + bg_r, bg_y + bg_r, bg_r, Math.PI, Math.PI * 1.5);
                                ctx.arc(bg_x + bg_w - bg_r, bg_y + bg_r, bg_r, Math.PI * 1.5, Math.PI * 2);
                                ctx.arc(bg_x + bg_w - bg_r, bg_y + bg_h - bg_r, bg_r, 0, Math.PI * 0.5);
                                ctx.arc(bg_x + bg_r, bg_y + bg_h - bg_r, bg_r, Math.PI * 0.5, Math.PI);
                                ctx.clip();
                                ctx.drawImage(img, bg_x, bg_y, bg_w, bg_h);
                                // 恢复之前保存的绘图上下文
                                ctx.restore();
                            };
                            const roundRect_yuan = (ctx, x, y, size) => {
                                // 开始绘制
                                ctx.save(); // 保存
                                ctx.beginPath(); // 开始绘制
                                // ctx.arc(100, 75, 50, 0, 2 * Math.PI)
                                ctx.arc(size / 2 + x, size / 2 + y, size / 2, 0, Math.PI * 2, false);
                                ctx.clip();
                                // 恢复之前保存的绘图上下文
                                ctx.restore();
                            };
                            function roundRect1(ctx, x, y, w, h, r, color) {
                                //绘制圆角矩形(无填充色))
                                ctx.save();
                                ctx.fillStyle = color;
                                ctx.strokeStyle = color;
                                ctx.lineJoin = 'round'; //交点设置成圆角
                                ctx.lineWidth = r;
                                ctx.strokeRect(x + r / 2, y + r / 2, w - r, h - r);
                                ctx.fillRect(x + r, y + r, w - r * 2, h - r * 2);
                                ctx.stroke();
                                ctx.closePath();
                            }
                            //使用：
                            new Promise((imgres) => {
                                // that.data.checkedList.forEach((item, index) => {
                                console.log(587);
                                let labelLeft = 0;
                                // ctx.arcTo()
                                let baseTop;
                                let logoLeft;
                                let logoSize;
                                let titleSize;
                                let ageTop;
                                let salaryClassifyValueLeft;
                                let salaryClassifyValueTop;
                                let monthlyPaySize;
                                let position;
                                let markTop;
                                let roundRectHeight;
                                logoLeft = 112;
                                // if (that.data.checkedList.length == 1) {
                                baseTop = 740;
                                logoSize = 192;
                                titleSize = 72;
                                roundRectHeight = 520;
                                ageTop = 220;
                                salaryClassifyValueLeft = 352;
                                salaryClassifyValueTop = 108;
                                monthlyPaySize = 56;
                                markTop = 290;
                                console.log(603);

                                // }
                                //  else {
                                // 	baseTop = 2 * 294;
                                // 	logoSize = 2 * 80;
                                // 	titleSize = 2 * 32;
                                // 	roundRectHeight = 2 * 226;
                                // 	ageTop = 2 * 88;
                                // 	salaryClassifyValueLeft = 2 * 156;
                                // 	salaryClassifyValueTop = 2 * 48;
                                // 	monthlyPaySize = 2 * 24;
                                // 	markTop = 2 * 115;
                                // }
                                roundRect1(ctx, 48, baseTop - 100, 1104, roundRectHeight, 32, '#fff');
                                console.log(that.jobDetail.store);
                                that.jobDetail.jobSpecialLabelNames.forEach((item1, index) => {
                                    // console.log(item1);
                                    // console.log(ctx.measureText(item1).width);
                                    if (index <= 2) {
                                        fillTextLineBreak(ctx, item1, 120 + labelLeft, baseTop + markTop + 60, 800, 20, '#333', monthlyPaySize); // 标签字符
                                        roundRect1(ctx, 104 + labelLeft, baseTop + markTop, ctx.measureText(item1).width + 32, 80, 64, '#00000008');
                                        labelLeft += ctx.measureText(item1).width + 64;
                                    }
                                });
                                console.log(that.jobDetail.store);
                                console.log(that.jobDetail);
                                fillTextLineBreak(ctx, that.jobDetail.store.aliasName, logoLeft, baseTop, 1000, 20, '#333', titleSize, '600'); // 岗位标题
                                console.log(630);
                                fillTextLineBreak(ctx, that.jobDetail.hourlyPay, salaryClassifyValueLeft, baseTop + salaryClassifyValueTop, 800, 20, '#ff4400', titleSize, '600'); // 时薪
                                fillTextLineBreak(
                                    ctx,
                                    that.jobDetail.monthlyPay,
                                    salaryClassifyValueLeft + ctx.measureText(that.jobDetail.monthlyPay).width,
                                    baseTop + salaryClassifyValueTop,
                                    800,
                                    20,
                                    '#ff4400',
                                    monthlyPaySize,
                                    '400'
                                ); // 月工资
                                fillTextLineBreak(ctx, that.jobDetail.store.districtStr + '丨', salaryClassifyValueLeft, baseTop + ageTop, 600, 20, '#333', monthlyPaySize); // 省市年龄
                                fillTextLineBreak(
                                    ctx,
                                    that.jobDetail.age,
                                    salaryClassifyValueLeft + ctx.measureText(that.jobDetail.store.districtStr + '丨').width,
                                    baseTop + ageTop,
                                    600,
                                    20,
                                    '#333',
                                    monthlyPaySize
                                ); // 省市年龄
                                // let src
                                // src =  that.data.jobDetail.store.logo.indexOf("https") > -1 ? that.data.jobDetail.store.logo : that.data.jobDetail.store.logo.replace("http", "https")
                                console.log(that.jobDetail.store.logo);
                                uni.downloadFile({
                                    url: that.jobDetail.store.logo,
                                    //网络图片,如果不行请换一个
                                    success(res) {
                                        console.log(res);
                                        const img = canvas.createImage();
                                        img.src = res.tempFilePath;
                                        img.onload = () => {
                                            roundRect(ctx, img, logoLeft, baseTop + 40, logoSize, logoSize, 8);
                                            // if (index == that.data.checkedList.length - 1) {
                                            setTimeout(() => {
                                                imgres();
                                            }, 200);
                                            // }
                                        };
                                    },
                                    fail(err) {
                                        console.log(err);
                                    }
                                });
                                // });
                                // setTimeout(() => {
                                // },500);
                            })
                                .then(function () {
                                    uni.canvasToTempFilePath({
                                        canvas: canvas,
                                        success(res) {
                                            console.log(res);
                                            that.setData({
                                                canvasImg: res.tempFilePath
                                            });
                                            resolve(res);
                                        },
                                        fail(res) {
                                            uni.hideLoading();
                                            uni.showToast({
                                                title: res.errMsg,
                                                icon: 'error'
                                            });
                                        }
                                    });
                                })
                                .catch((err) => {
                                    console.log(err);
                                });
                        });
                    });
            });
        },

        /**
         * 分享海报生成海报图并转发
         *
         *
         */
        sharePoster() {
            uni.showLoading({
                title: '生成中...'
            });
            this.getCanvas().then((res) => {
                console.log(res);
                uni.hideLoading();
                this.setData({
                    posterImg: res.tempFilePath,
                    posterShow: true
                });
            });
            // this.setData({
            // });
        },

        hidePoster() {
            this.setData({
                posterShow: false
            });
        },

        saveToalbum() {
            let that = this;
            uni.saveImageToPhotosAlbum({
                filePath: that.posterImg,
                success(res) {
                    console.log(res);
                    if (res.errMsg == 'saveImageToPhotosAlbum:ok') {
                        uni.showToast({
                            title: '图片已保存',
                            icon: 'none',
                            duration: 1500
                        });
                    }
                },
                fail(res) {
                    console.log(res);
                    uni.showToast({
                        title: '图片保存失败',
                        icon: 'none',
                        duration: 1500
                    });
                }
            });
        },

        goBack() {
            uni.navigateBack({
                delta: -1
            });
        },

        getStoreJobDetailById() {
            var that = this;
            uni.showLoading({
                title: '加载中...'
            });
            uni.request({
                // url: app.globalData.ip + "/store/job/getStoreJobDetailById?storeJobId=" + that.data.searchForm.storeJobId,
                url: app.globalData.ip + '/yishoudan/custom/job/detailApp/' + that.searchForm.storeJobId,
                method: 'get',
                header: app.globalData.headers,
                success: function (res) {
                    console.log(res);
                    if (res.data.status == 200) {
                        var result = {};
                        result = res.data.data.record;
                        var title = result.jobName;
                        // var title1 = result.store.aliasName;
                        // that.data.logo2
                        // wx.setStorageSync({
                        //   key: "onSiteRemark",
                        //   data: result.onSiteRemark,
                        // })
                        let regs = /\.(jpg|jpeg|png)(\?.*)?$/;
                        res.data.data.images.forEach((item) => {
                            item.isImg = regs.test(item.url.toLowerCase());
                        });
                        result.genderRestrict = commonUtil.getGenderByMinAge(result);
                        that.setData({
                            shareTitle: title,
                            images: res.data.data.images,
                            onSiteRemark: result.onSiteRemark
                        });
                        if (app.globalData.isNotEmptyCheck(title)) {
                            title = result.jobName;
                        } else {
                            title = result.store.aliasName;
                        }
                        uni.setNavigationBarTitle({
                            title
                        });
                        result.workType = commonUtil.getWorkTypeById(result.workTypeMulti);
                        if (app.globalData.isNotEmptyCheck(result.calculationSalaryType)) {
                            result.calculationSalaryType = result.calculationSalaryType.split('#')[0];
                        }
                        if (app.globalData.isNotEmptyCheck(result.jobDesp)) {
                            result.jobDesp = result.jobDesp.replaceAll('*****', '').split('————————')[0];
                            result['jobDesp1'] = result.jobDesp.replace(
                                '⚠',
                                "<i class='t-icon t-icon-zhuyi' style='margin-bottom:-2px;width:17px;height:17px;background-repeat:no-repeat;background-size:100% 100%'></i>"
                            );
                            result['jobDesp1'] = result.jobDesp1.replace(
                                '[红包]',
                                "<i class='t-icon t-icon-hongbao' style='margin-bottom:-2px;width:17px;height:17px;background-repeat:no-repeat;background-size:100% 100%'></i>"
                            );
                        }
                        if (app.globalData.isNotEmptyCheck(result.paymentSalaryType)) {
                            result.paymentSalaryType = result.paymentSalaryType.split('，');
                        }
                        if (app.globalData.isNotEmptyCheck(result.salaryDesp)) {
                            result.salaryDesp = result.salaryDesp.split('；');
                        }
                        if (app.globalData.isNotEmptyCheck(result.workDurationDesp)) {
                            result.workDurationDesp = result.workDurationDesp.split('；');
                        }
                        if (app.globalData.isNotEmptyCheck(result.probationDesp)) {
                            result.probationDesp = result.probationDesp.split('；');
                        }
                        if (app.globalData.isNotEmptyCheck(result.workingLunchDesp)) {
                            result.workingLunchDesp = result.workingLunchDesp.split('；');
                        }
                        if (app.globalData.isNotEmptyCheck(result.dormitoryDesp)) {
                            result.dormitoryDesp = result.dormitoryDesp.split('；');
                        }
                        if (app.globalData.isNotEmptyCheck(result.foregift)) {
                            result.foregift = result.foregift.split('；');
                            var arrTemp = [];
                            result.foregift.forEach((item) => {
                                var arr = item.split('，');
                                if (app.globalData.length > 0) {
                                    arrTemp.push({
                                        item0: arr[0].split('#')[0],
                                        item1: arr[1].split('#')[0]
                                    });
                                }
                            });
                            result.foregift = arrTemp;
                        } else {
                            result.foregift = '无押金';
                        }

                        // result.store.distance = commonUtil.getDistanceName(result.store.distance);
                        // if (app.isNotEmptyCheck(result.store.distance)) {
                        // 	result.store.distance = "丨" + result.store.distance;
                        // }

                        /*if (app.isNotEmptyCheck(result.store.district)) {
                           var tempArr = result.store.district.split(",");
                              if (tempArr.length == 1) {
                               result.store.district = tempArr[0];
                           } else if (tempArr.length == 2) {
                               result.store.district = tempArr[0] + "" + tempArr[1];
                           } else if (tempArr.length > 2) {
                               result.store.district = tempArr[1] + "" + tempArr[2];
                           }
                       }*/
                        // getStoreAddress

                        that.disposeJobListData(result);
                        // if (app.isNotEmptyCheck(result.store.logo)) {
                        // 	result["logo2"] = result.store.logo.replace("http:", "https:");
                        //   result.store.logo.indexOf("https") > -1 ? result.store.logo : result.store.logo.replace("http", "https")
                        // } else {
                        // 	result["logo2"] = "";
                        // }
                        // console.log(commonUtil.getReturnFeeTypeName1ById(result.returnFeeType, result.returnFee));
                        console.log('isout');
                        if (app.globalData.isNotEmptyCheck(result.returnFeeType) || result.returnFeeType == '0' || result.returnFee == '0') {
                            that.setData({
                                fuWuFei: commonUtil.getReturnFeeTypeName1ById(result.returnFeeType, result.returnFee)
                            });
                        }
                        //  else if (result.returnFeeType == 7) {
                        //   that.setData({
                        //     fuWuFei: commonUtil.getReturnFeeTypeNameById(result.returnFeeType),
                        //   });
                        // }
                        else {
                            that.setData({
                                fuWuFei: '-'
                            });
                        }
                        console.log(result);
                        console.log(commonUtil);
                        let citys = commonUtil.setJobInfoPosition(result.storeDistrict);
                        // result.storeImage.splice(0,1)

                        that.jobDetail['storeName'] = result.storeName;
                        that.jobDetail['notes'] = result.jobInfo;
                        that.setData({
                            jobDetail: result,
                            isMaskShow: !(result.recruitment == '1'),
                            citys: citys || '-'
                            // addressNew: result.store.district.replace(/,/g, "") + result.store.detailPosition,
                        });
                        that.showSexAge();

                        // that.getAgencyInfo(res.data.data.storeJob);

                        // if (app.isEmptyCheck(res.data.data.storeJob.handoverInfo)) {
                        // 	that.setData({
                        // 		djxx: "暂无对接信息",
                        // 	});
                        // } else {
                        // 	that.setData({
                        // 		djxx: res.data.data.storeJob.handoverInfo,
                        // 	});
                        // }
                        console.log(that.jobDetail);
                    }
                    uni.hideLoading();
                }
            });
        },

        showSexAge() {
            var that = this;
            var manStr = '';
            var womanStr = '';
            if (app.globalData.isNotEmptyCheck(that.jobDetail.minAgeMan) || app.globalData.isNotEmptyCheck(that.jobDetail.maxAgeMan)) {
                manStr = '男 ';
            }
            if (app.globalData.isNotEmptyCheck(that.jobDetail.minAgeMan)) {
                manStr = manStr + that.jobDetail.minAgeMan;
            }
            if (app.globalData.isNotEmptyCheck(that.jobDetail.maxAgeMan)) {
                manStr = manStr + '-' + that.jobDetail.maxAgeMan;
            }
            if (app.globalData.isNotEmptyCheck(that.jobDetail.minAgeWoman) || app.globalData.isNotEmptyCheck(that.jobDetail.maxAgeWoman)) {
                womanStr = '女 ';
            }
            if (app.globalData.isNotEmptyCheck(that.jobDetail.minAgeWoman)) {
                womanStr = womanStr + that.jobDetail.minAgeWoman;
            }
            if (app.globalData.isNotEmptyCheck(that.jobDetail.maxAgeWoman)) {
                womanStr = womanStr + '-' + that.jobDetail.maxAgeWoman;
            }
            if (womanStr != '') {
                manStr = manStr + `${manStr == '' ? '' : '；'}` + womanStr;
            }
            that.setData({
                showSexAgeText: manStr
            });
        },

        /**
         * 处理后台返回的职位列表
         */
        disposeJobListData(jobDetail) {
            var that = this;
            console.log(jobDetail);
            // item["workType"] = commonUtil.getWorkTypeById(
            //     item.workTypeMulti
            // );

            // if (app.isNotEmptyCheck(item.distance)) {
            //     item["distanceKm"] = commonUtil.getDistanceName(
            //         item.distance
            //     );
            // }
            //年龄
            var ageStr = '';
            if (app.globalData.isNotEmptyCheck(jobDetail.minAge) && app.globalData.isNotEmptyCheck(jobDetail.maxAge)) {
                ageStr = jobDetail.minAge + '-' + jobDetail.maxAge + '岁';
            } else if (app.globalData.isNotEmptyCheck(jobDetail.minAge)) {
                ageStr = jobDetail.minAge + '岁以上';
            } else if (app.globalData.isNotEmptyCheck(jobDetail.maxAge)) {
                ageStr = jobDetail.maxAge + '岁以下';
            }
            jobDetail['age'] = ageStr;
            //时薪
            // var hourlyPayStr = "";
            var hasHourlyPay = true;
            // console.log(jobDetail);
            // if (app.isNotEmptyCheck(jobDetail.hourlyPay)) {
            // 	hourlyPayStr = jobDetail.hourlyPay + "元/小时";
            // 	hasHourlyPay = true;
            // } else if (app.isNotEmptyCheck(jobDetail.dayPay)) {
            // 	hourlyPayStr = jobDetail.dayPay + "元/日";
            // 	hasHourlyPay = true;
            // } else {
            // 	if (app.isNotEmptyCheck(jobDetail.minMonthlyPay) && app.isNotEmptyCheck(jobDetail.maxMonthlyPay)) {
            // 		if (jobDetail.minMonthlyPay == jobDetail.maxMonthlyPay) {
            // 			hourlyPayStr = jobDetail.minMonthlyPay;
            // 		} else {
            // 			hourlyPayStr = jobDetail.minMonthlyPay + "-" + jobDetail.maxMonthlyPay;
            // 		}
            // 	} else if (app.isNotEmptyCheck(jobDetail.minMonthlyPay)) {
            // 		hourlyPayStr = jobDetail.minMonthlyPay;
            // 	} else if (app.isNotEmptyCheck(jobDetail.maxMonthlyPay)) {
            // 		hourlyPayStr = jobDetail.maxMonthlyPay;
            // 	}
            // }
            // if (app.isNotEmptyCheck(jobDetail.dayPay)){

            // }
            // if (app.isNotEmptyCheck(jobDetail.salaryClassify) && app.isNotEmptyCheck(jobDetail.salaryClassifyValue)) {

            // }
            //月薪
            var monthlyPayStr = '';
            if (hasHourlyPay) {
                if (app.globalData.isNotEmptyCheck(jobDetail.minMonthlyPay) && app.globalData.isNotEmptyCheck(jobDetail.maxMonthlyPay)) {
                    if (jobDetail.minMonthlyPay == jobDetail.maxMonthlyPay) {
                        monthlyPayStr = jobDetail.minMonthlyPay / 100;
                    } else {
                        monthlyPayStr = jobDetail.minMonthlyPay / 100 + '-' + jobDetail.maxMonthlyPay / 100;
                    }
                } else if (app.globalData.isNotEmptyCheck(jobDetail.minMonthlyPay)) {
                    monthlyPayStr = jobDetail.minMonthlyPay / 100;
                } else if (app.globalData.isNotEmptyCheck(jobDetail.maxMonthlyPay)) {
                    monthlyPayStr = jobDetail.maxMonthlyPay / 100;
                }
            }
            jobDetail['monthlyPay'] = monthlyPayStr;
            jobDetail['hourlyPay'] = commonUtil.getSalaryClassifyValue(jobDetail.salaryClassify, jobDetail.salaryClassifyValue, monthlyPayStr);

            //地址深圳丨龙岗区丨
            // var districtStr = "";
            // if (app.isNotEmptyCheck(jobDetail.store.district)) {
            // 	var districtArr = jobDetail.store.district.split(",");
            // 	if (districtArr.length < 3) {
            // 		districtStr = districtArr[districtArr.length - 1];
            // 	} else {
            // 		districtStr = districtArr[1] + "丨" + districtArr[2];
            // 	}
            // }
            // jobDetail.store["districtStr"] = districtStr;
            // jobDetail["districtDetail"] = commonUtil.getStoreAddress(jobDetail.district, jobDetail.detailPosition);
            //职位特色
            if (app.globalData.isNotEmptyCheck(jobDetail.jobSpecialLabelNames)) {
                jobDetail['jobSpecialLabelNames'] = that.getJobSpecialLabelNamesArray(jobDetail.jobSpecialLabelNames);
            }
            if (app.globalData.isNotEmptyCheck(jobDetail.jobRequestLabelNames)) {
                jobDetail['jobRequestLabelNames'] = that.getJobRequestLabelNamesArray(jobDetail.jobRequestLabelNames);
            }
        },

        getJobSpecialLabelNamesArray(jobSpecialLabelNames) {
            if (app.globalData.isNotEmptyCheck(jobSpecialLabelNames)) {
                return jobSpecialLabelNames.split(', ');
            }
            return [];
        },

        getJobRequestLabelNamesArray(jobRequestLabelNames) {
            console.log(jobRequestLabelNames);
            if (app.globalData.isNotEmptyCheck(jobRequestLabelNames)) {
                return jobRequestLabelNames.split(', ');
            }
            return [];
        },

        goSimilar() {
            var that = this;
            console.log(that.jobDetail);
            console.log(that.jobDetail.jobLabelId);
            uni.navigateTo({
                url: '../similar/index?brandId=' + that.jobDetail.store.brandId + '&jobLabelId=' + that.jobDetail.jobLabelId + '&classify=99'
            });
        },

        makePhoneCall() {
            console.log(1);
            var that = this;
            uni.makePhoneCall({
                // number: that.data.jobDetail.assistantUserTel + ""
                phoneNumber: that.jobDetail.customServiceUser.tel || '0371-6611 3723'
            });
            // var that = this;

            // let res = wx.getStorageSync({
            //     key: "assistantUserTel"
            // });

            // console.log(res);
            // console.log("缓存获取电话号：" + res.data);

            // if (app.isNotEmptyCheck(res.data)) {
            //     wx.makePhoneCall({
            //         number: res.data
            //     });
            // } else {
            //     wx.request({
            //         url: app.globalData.ip + "/store/job/getOneAssistantUser",
            //         method: "POST",
            //         header: app.globalData.headers,
            //         data: {},
            //         success: function (res) {
            //             console.log(res.data.data.tel);

            //             wx.setStorageSync({
            //                 key: "assistantUserTel",
            //                 data: res.data.data.tel
            //             });

            //             wx.makePhoneCall({
            //                 number: res.data.data.tel + ""
            //             });
            //         }
            //     });
            // }
        },

        textPaste() {
            var that = this;
            console.log('jobDetail', that.jobDetail);
            uni.setClipboardData({
                // data: that.data.jobDetail.assistantUserWechat,
                data: that.jobDetail.customServiceUser.weChat,
                success: function (res) {
                    console.log(res);
                    uni.getClipboardData({
                        success: function (res) {
                            uni.showToast({
                                icon: 'none',
                                title: '复制成功请去微信添加您的专属客服',
                                duration: 0
                            });
                            uni.showModal({
                                title: '已复制微信号',
                                content: '复制成功请去微信添加您的专属客服',
                                showCancel: false,
                                success(res) {
                                    if (res.confirm) {
                                        console.log('用户点击确定');
                                    } else if (res.cancel) {
                                        console.log('用户点击取消');
                                    }
                                }
                            });
                            console.log(res.data); // data
                        }
                    });
                },
                fail: function (err) {
                    console.log(err);
                }
            });
        },

        /*collectPaste() {
         var txt;
         var that = this;
         if(!this.data.isCollect){
             that.setData({
                 isCollect: true
             })
             txt = '收藏成功'
         }else{
             that.setData({
                 isCollect: false
             })
             txt = '取消收藏'
         }
         wx.showToast({
             icon: "none",
             title: txt,
         })
        
     },*/

        goNewEnroll(e) {
            let that = this;
            console.log(e.currentTarget.dataset.job);
            this.setData({
                recordShow: true,
                currentInfo: e.currentTarget.dataset.job
            });
            console.log(this.recordShow);
            uni.hideTabBar({
                animation: false,
                success: (result) => {},
                fail: () => {},
                complete: () => {}
            });
            return;
            let argument;
            argument = JSON.stringify(that.jobDetail).replace(/\=|\&/g, '3D');
            if (!this.isLogin) {
                uni.setStorageSync('comeFromPage', 'detailBaoming');
                uni.setStorageSync('baomingDetail', argument);
                uni.navigateTo({
                    url: '/pages/login/index'
                });
                return;
            }
            uni.navigateTo({
                url: `../newEnroll/enroll/index?applyType=1&info=${argument}`
            });
            // wx.navigateTo({
            // 	url: `../newEnroll/enroll/index?applyType=1&info=${argument}`,
            // });
        },

        emptyMethod() {},

        wxLogin() {
            var that = this;
            uni.login({
                success(res) {
                    if (res.code) {
                        that.setData({
                            wxCode: res.code
                        });
                    } else {
                        console.log('获取code失败！' + res.errMsg);
                    }
                }
            });
        },

        getPhoneNumber(e) {
            var that = this;
            console.log(e);
            console.log(e.detail.errMsg);
            console.log(that.jobDetail);
            /*wx.setStorageSync({
              key: "jobDetailStorage",
              data: that.data.jobDetail,
          });*/
            uni.setStorageSync('jobDetailStorage', that.jobDetail);
            // console.log(e);
            // console.log(e.detail.errMsg)
            console.log(e.detail.iv);
            // console.log(e.detail.encryptedData)
            if ('getPhoneNumber:ok' == e.detail.errMsg) {
                //同意
                var iv = e.detail.iv;
                var encryptedData = e.detail.encryptedData;
                uni.checkSession({
                    success() {
                        //session_key 未过期，并且在本生命周期一直有效
                        uni.request({
                            url: app.globalData.ip + '/getWechatTel',
                            data: {
                                code: that.wxCode,
                                iv: iv,
                                encryptedData: encryptedData,
                                type: 'yishoudan',
                                appId: app.globalData.appId
                            },
                            success: function (res) {
                                console.log(res);
                                app.globalData.openId = res.data.data.openId;
                                let promise = app.globalData.setLoginUserTokenInfo(res.data.data.phoneNumber, null);
                                var collected = e.currentTarget.dataset.collected;
                                console.log(that.isAgency);
                                if (collected) {
                                    promise.then((res) => {
                                        that.setData({
                                            isLogin: app.globalData.isLogin
                                        });
                                        that.doCollected(collected, e.currentTarget.dataset.jobid);
                                    });
                                } else {
                                    /*wx.navigateTo({
                                        url: "../enroll/index?applyType=1&tel=" + res.data.data.phoneNumber
                                    });*/
                                    promise.then((res) => {
                                        let argument;
                                        argument = JSON.stringify(that.jobDetail).replace(/\=|\&/g, '3D');
                                        uni.navigateTo({
                                            url: `../newEnroll/enroll/index?applyType=1&info=${argument}`
                                        });
                                    });
                                }
                                promise.then(() => {
                                    console.log(app.globalData.loginUserInfo.agencyStatus);
                                    that.setData({
                                        isAgency: app.globalData.loginUserInfo.agencyStatus == 1 ? true : false
                                    });
                                });
                                // wx.navigateTo({
                                //     url: "../enroll/index?applyType=1&tel=" + res.data.data.phoneNumber
                                // });
                            },
                            fail: function (res) {
                                console.log('获取用户手机号错误');
                            }
                        });
                    },
                    fail() {
                        // session_key 已经失效，需要重新执行登录流程
                        uni.login({
                            success(res) {
                                if (res.code) {
                                    console.log(res.code);
                                    //发起网络请求
                                    uni.request({
                                        url: app.globalData.ip + '/getWechatTel',
                                        data: {
                                            code: res.code,
                                            iv: iv,
                                            encryptedData: encryptedData,
                                            type: 'yishoudan',
                                            appId: app.globalData.appId
                                        },
                                        success: function (res) {
                                            console.log(res);
                                            let promise = app.globalData.setLoginUserTokenInfo(res.data.data.phoneNumber, null);
                                            var collected = e.currentTarget.dataset.collected;
                                            if (collected) {
                                                promise.then((res) => {
                                                    that.setData({
                                                        isLogin: app.globalData.isLogin
                                                    });
                                                    that.doCollected(collected, e.currentTarget.dataset.jobid);
                                                });
                                            } else {
                                                promise.then((res) => {
                                                    let argument;
                                                    argument = JSON.stringify(that.jobDetail).replace(/\=|\&/g, '3D');
                                                    uni.navigateTo({
                                                        url: `../newEnroll/enroll/index?applyType=1&info=${argument}`
                                                    });
                                                });
                                            }
                                            promise.then(() => {
                                                console.log(app.globalData.loginUserInfo.agencyStatus);
                                                that.setData({
                                                    isAgency: app.globalData.loginUserInfo.agencyStatus == 1 ? true : false
                                                });
                                            });
                                        },
                                        fail: function (res) {
                                            console.log('获取用户手机号错误');
                                        }
                                    });
                                } else {
                                    console.log('获取手机号失败！' + res.errMsg);
                                }
                            }
                        });
                    }
                });
            } else {
                //拒绝
                var collected = e.currentTarget.dataset.collected;
                if (collected) {
                    try {
                        uni.setStorageSync('comeFromPage', 'detail');
                        uni.setStorageSync('comeFromPageParam', {
                            storeJobId: that.searchForm.storeJobId
                        });
                    } catch (e) {
                        console.log('CatchClause', e);
                        console.log('CatchClause', e);
                        console.log('detail-页面跳转，设置参数错误：', e);
                    }
                    uni.navigateTo({
                        url: '/pages/login/index'
                    });
                } else {
                    uni.navigateTo({
                        //url: "../enroll/index?applyType=1&tel=" + res.data.data.phoneNumber
                        url: '../enroll/index?applyType=1'
                    });
                }
            }
            return false;
        },

        setCopy(e) {
            var that = this;
            var contentInfo;
            const query = uni.createSelectorQuery().in(this);
            query
                .select('.contactInfo')
                .boundingClientRect(function (res) {
                    contentInfo = res.dataset.info;
                    uni.setClipboardData({
                        data: e.currentTarget.dataset.content + contentInfo,
                        success(res) {
                            uni.getClipboardData({
                                success(res) {
                                    console.log(res.data); // data
                                    uni.showToast({
                                        title: '内容已复制',
                                        icon: 'none',
                                        duration: 1500
                                    });
                                }
                            });
                        }
                    });
                })
                .exec();
        },

        changeContact() {
            console.log(2123);
            uni.navigateTo({
                url: `/pages/configAnnunciate/index`
            });
        },

        collectPaste(e) {
            var txt;
            var that = this;
            if (!this.isLogin) {
                uni.setStorageSync('comeFromPage', 'detail');
                uni.navigateTo({
                    url: '/pages/login/index'
                });
                return;
            }
            var collected = e.currentTarget.dataset.collected;
            var storeJobId = e.currentTarget.dataset.jobid;
            that.doCollected(collected, storeJobId);
            // console.log(collected);
            // if(!this.data.isCollect){
            //     that.setData({
            //         isCollect: true,
            //         collectTxt:'已收藏'
            //     })
            //     txt = '收藏成功'
            // }else{
            //     that.setData({
            //         isCollect: false,
            //         collectTxt:'收藏'
            //     })
            // }
        },

        doCollected(collected, storeJobId) {
            var that = this;
            var url = '/user/collect/job/add';
            if (collected - 1 == 0) {
                url = '/user/collect/job/remove';
            }
            // console.log(app.globalData.headers);
            //发起网络请求
            uni.request({
                url: app.globalData.ip + url,
                data: {
                    storeJobId: storeJobId
                },
                header: app.globalData.headers,
                method: 'GET',
                success: function (res) {
                    var txt;
                    if (collected - 1 == 0) {
                        //取消收藏
                        that.jobDetail.collected = 2;
                        txt = '取消收藏';
                    } else {
                        //收藏
                        that.jobDetail.collected = 1;
                        txt = '收藏成功';
                    }
                    that.setData({
                        jobDetail: that.jobDetail,
                        isLogin: app.globalData.isLogin
                    });
                    console.log(that.jobDetail);
                    uni.showToast({
                        icon: 'none',
                        title: txt
                    });
                },
                fail: function (res) {
                    console.log('操作失败');
                }
            });
        },

        toggleprice(type) {
            console.log(type);
            if (type.target.dataset.index == 1) {
                this.setData({
                    isServicePriceShow: false
                });
            } else {
                this.setData({
                    isServicePriceShow: true
                });
            }
        },

        imageLoad() {
            this.setData({
                isLoading: false
            });
        },

        /**
         * 阻止滑动穿透
         *
         *
         */
        modalMove() {
            return false;
        },

        showTobe() {
            this.setData({
                iosDialogTobe: true
            });
        },

        closeTobe() {
            this.setData({
                iosDialogTobe: false
            });
        },

        hidedrawershow(e) {
            console.log(e);
            this.setData({
                [e.detail.type]: false
            });
            uni.showTabBar({
                animation: false,
                success: (result) => {},
                fail: () => {},
                complete: () => {}
            });
        },

        scroll() {
            console.log('占位：函数 scroll 未声明');
        }
    }
};
</script>
<style>
@import './index.css';
</style>
