<?php

function code_mbvue3($post) {
    $schema = get('schema');
    $tabname = get('table');
    $maindb = $post->get('_bcod_maindb', '', 'all');
    $verifyfunc = $post->get('_bcod_verifyfunc', '', 'all');
    $titname = $post->get('_bcod_titname', '', 'all');
    $logtype = $post->get('_bcod_logtype', '', 'all');
    $uploadpat = $post->get('_bcod_uploadpat', '', 'all');
    $liiddict = str_replace('，',',', $post->get('_bcod_liiddict', '', 'all'));
    $tabdict = $post->get('_bcod_tabdict', '', 'all');
    $uniquedata = $post->get('_bcod_uniquedata', '', 'all');
    $chk_in = $post->get('_bcod_chk_in') == 'yes';
    $chk_out = $post->get('_bcod_chk_out') == 'yes';
    $chk_inedit = $post->get('_bcod_chk_inedit') == 'yes';
    $chk_audit = $post->get('_bcod_chk_audit') == 'yes';
    $chk_getupdate = $post->get('_bcod_chk_getupdate') == 'yes';
    $btntop_newline = $post->get('_bcod_btntop_newline', '', 'all');
    $btnlist_line = $post->get('_bcod_btnlist_line', '', 'all');
    $btntop_multibtn = $post->get('_bcod_btntop_multibtn', '', 'all');

    $funcpre = str_replace($maindb.'_','',$tabname);
    $liiddicts = array();
    if(strpos($liiddict, ',') !== false){
        $liiddicts = explode(',', $liiddict);
        $liiddict = '';
    }
    $dbnm = 't';
    if ($maindb != 'mydata')
        $dbnm = $maindb;
    $flds = calfld($post);
    $codex = <<<codexdata
<template>
    <view>
        <view v-if="lst.code == -1">
            <view class="vnavi" @click="openadd()">新增{$titname}</view>
            <view class="vnavi" @click="getlist()">查看{$titname}</view>
            <view class="vnavi" @click="btn_gourl" data-url="/help?id=3">操作指南</view>
        </view>
        <view v-else-if="lst.code == 0" class="vload">
            <view>正在加载...</view>
        </view>
        <view v-else-if="lst.code != 1" class="vload">
            <view>
                {{lst.errmsg}}<br /><br />
                <navigator open-type="navigateBack"><button type="default" size="mini">返回</button></navigator>
            </view>
        </view>
        <view v-else>
            <view class="vtop">
                <view class="vli" v-if="lis.length > 0">
                    <ul>
                        <li :class="{active:liid==index}" v-for="(item,index) in lis" :key="index" @tap="changeli" :data-index="index">
                            <a>{{item.name}}</a>
                        </li>
                    </ul>
                </view>
                <ciy-query ref="query" @queryonceload="queryonceload">
                    <form @submit="querysubmit" @reset="queryreset" class="char4">
                        <view style="max-height:60vh;overflow: auto;">
                            <view class="form-group" v-for="(item,index) in once.querys" :key="index">
                                <label>{{item.name}}</label>
                                <view v-if="item.type == 'input'">
                                    <ciy-input :name="index" type="text"></ciy-input>
                                </view>
                                <view v-if="item.type == 'select'">
                                    <ciy-picker :name="index" :range="item.select"></ciy-picker>
                                </view>
                                <view v-if="item.type == 'num'">
                                    <ciy-input :name="index + '_1'" type="digit" style="width:4em;" textalign="right"></ciy-input>~
                                    <ciy-input :name="index + '_2'" type="digit" style="width:4em;" textalign="right"></ciy-input>
                                </view>
                                <view v-if="item.type == 'daterange'">
                                    <ciy-daterange :name="index"></ciy-daterange>
                                </view>
                            </view>
                        </view>
                        <view style="margin:1em 0;text-align: center;">
                            <button form-type="submit" type="primary" style="margin:0 1em;display:inline-block;">筛选查询</button>
                            <button form-type="reset" type="default" style="margin:0 1em;display:inline-block;">显示全部</button>
                        </view>
                    </form>
                </ciy-query>
            </view>
            <view class="vctop" style="padding-top:6em;">
                <view class="ciy-list" v-for="(item,index) in lst.list" :key="item.id" @click="showmenu(index)">
                    <view class="l0">No: {{item.id}}</view>

codexdata;
    $isrt = false;
    $isrb = false;
    $hasloc = false;
    $hasphone = false;
    $mdconv = '';
    foreach ($flds as $fld) {
        if($fld['cate'] == 'LOC')
            $hasloc = true;
        if(strpos($fld['name'], '联系方式') !== false)
            $hasphone = true;
        if(strpos($fld['name'], '电话') !== false)
            $hasphone = true;
        if(strpos($fld['name'], '手机') !== false)
            $hasphone = true;
        if(isset($fld['set']['cpt']) && $fld['set']['cpt'] == 'mdhtml')
            $mdconv = "this.edat.{$fld['col']} = markdown.convert(json.data.{$fld['col']}, this.g.cdnurl[this.srv]);";
        if($fld['col'] == 'id' || $fld['col'] == 'orgid' || $fld['col'] == 'lat')
            continue;
        if($fld['col'] == 'name')
        $codex .= "                    <view class=\"l1\">{{item.name}}</view>\n";
        else if($fld['cate'] == 'CATA' || $fld['cate'] == 'ID'){
            if($isrt)
                $codex .= "                    <view class=\"l2\">{$fld['name']} {{c.ccode(once.{$fld['data']} || lst.{$fld['data']} || g.{$fld['data']}, item.{$fld['col']})}}</view>\n";
            else{
                $isrt = true;
                if($fld['data2'] == 'bg')
                    $codex .= "                    <view class=\"rt\"><kbd :style=\"{background:c.ccode(g.{$fld['data']},item.{$fld['col']},'extdata')}\">{{c.ccode(g.{$fld['data']},item.{$fld['col']})}}</kbd></view>\n";
                else
                    $codex .= "                    <view class=\"rt\"><kbd>{{c.ccode(once.{$fld['data']} || lst.{$fld['data']} || g.{$fld['data']}, item.{$fld['col']})}}</kbd></view>\n";
            }
        } else if ($fld['cate'] == 'CATM'){
            $codex .= "                    <view class=\"l2\">{$fld['name']} {{c.multicode(g.{$fld['data']}, item.{$fld['col']},' . ')}}</view>\n";
        } else if ($fld['cate'] == 'CNY'){
            $codex .= "                    <view class=\"l2\">{$fld['name']} {{c.tomoney(item.{$fld['col']})}}</view>\n";
        } else if ($fld['cate'] == 'WCNY'){
            $codex .= "                    <view class=\"l2\">{$fld['name']} {{c.tomoney(item.{$fld['col']}/10000)}}万元</view>\n";
        } else if ($fld['cate'] == 'LOC'){
            $codex .= "                    <view class=\"l2\">{$fld['name']} <text style=\"padding-left:1em;text-decoration: underline;\" @click.stop=\"goloc(item.lat, item.lng)\">查看位置</text></view>\n";
        } else if ($fld['cate'] == 'IMG' || $fld['cate'] == 'IMG1'){
            $codex .= "                    <ciy-showimgs label=\"{$fld['name']}\" :pics=\"item.{$fld['col']}\" :cdnurl=\"g.cdnurl[srv]\"></ciy-showimgs>\n";
        } else if ($fld['cate'] == 'DATE'){
            $ext = '';
            if($fld['data'] == 'Y-m-d')
                $ext = ', \'d\'';
            if($isrb){
                $codex .= "                    <view class=\"l2\">{$fld['name']} {{c.todate(item.{$fld['col']}{$ext})}}</view>\n";
            }else{
                $isrb = true;
                $codex .= "                    <view class=\"rb\">{$fld['name']} {{c.todate(item.{$fld['col']}{$ext})}}</view>\n";
            }
        } else if(isset($fld['set']['cpt']) && $fld['set']['cpt'] == 'textarea'){
            $codex .= "                    <view class=\"l3\" v-html=\"c.br('{$fld['name']}: ' + item.{$fld['col']})\"></view>\n";
        } else if(isset($fld['set']['cpt']) && $fld['set']['cpt'] == 'mdhtml'){
            $codex .= "                    <!--<view v-html=\"item.{$fld['col']}\"></view>-->\n";
        } else {
            $codex .= "                    <view class=\"l2\">{$fld['name']} {{item.{$fld['col']}}}</view>\n";
        }
    }

    $codex .= <<<codexdata
                </view>
                <view v-if="!lst.list">
                    <view style="text-align:center;padding-top:2em;">数据加载失败</view>
                </view>
                <view v-else-if="lst.list.length==0">
                    <view style="text-align:center;">
                        <image :src="g.cdnurl[srv] + '/img/none.png'" mode="widthFix" /><br />
                        无记录
                    </view>
                </view>
                <view class="vlistend" v-else-if="pageno < 0">———— ● ————</view>
            </view>
            <view class="vadd" @click="openadd()"></view>
        </view>
        <ciy-dialog ref="dialog_update">
            <form @submit="submit_update" class="char4">
                <input type="hidden" name="id" :value="edat.id" style="display:none;" />

codexdata;
    foreach ($flds as $fld) {
        if($fld['col'] == 'id' || $fld['col'] == 'orgid' || $fld['col'] == 'lat' || $fld['col'] == 'addtimes' || $fld['col'] == 'ip')
            continue;
        if(isset($fld['set']['noup']))
            continue;

        $codex .= "                <view class=\"form-group\">\n";
        if(isset($fld['set']['cpt']) && $fld['set']['cpt'] == 'mdhtml'){
            $codex .= "                    <view style=\"padding-left: 0.5em;\">\n";
        }else{
            if($fld['bimp'])
                $codex .= "                    <label class=\"imp\">{$fld['name']}</label>\n";
            else
                $codex .= "                    <label>{$fld['name']}</label>\n";
            $codex .= "                    <view>\n";
        }
            
        if($fld['cate'] == 'CATA' || $fld['cate'] == 'ID'){
            $codex .= "                        <ciy-picker name=\"{$fld['col']}\" v-model=\"edat.{$fld['col']}\" :range=\"once.{$fld['data']} || lst.{$fld['data']} || g.{$fld['data']}\"></ciy-picker>\n";
        } else if ($fld['cate'] == 'CATM'){
            $codex .= "                        <ciy-picker2 name=\"{$fld['col']}\" v-model=\"edat.{$fld['col']}\" :range=\"g.{$fld['data']}\"></ciy-picker2>\n";
        } else if ($fld['cate'] == 'CNY'){
            $codex .= "                        <ciy-unit-num name=\"{$fld['col']}\" v-model=\"edat.{$fld['col']}\" units=\"元,100\"></ciy-unit-num>\n";
        } else if ($fld['cate'] == 'WCNY'){
            $codex .= "                        <ciy-unit-num name=\"{$fld['col']}\" v-model=\"edat.{$fld['col']}\" units=\"万元,1000000\"></ciy-unit-num>\n";
        } else if ($fld['cate'] == 'LOC'){
            $codex .= "                        <ciy-map name=\"{$fld['col']}\" :value=\"edat.lng + ',' + edat.lat\"></ciy-map>\n";
        } else if ($fld['cate'] == 'IMG' || $fld['cate'] == 'IMG1'){
            $codex .= "                        <ciy-selectimgs name=\"{$fld['col']}\" v-model=\"edat.{$fld['col']}\" imgact=\"cp|1920|80\" :cdnurl=\"g.cdnurl[srv]\" :uploadurl=\"g.jsnurl[srv] + '?json=true&func=boi_upload'\"></ciy-selectimgs>\n";
        } else if ($fld['cate'] == 'DATE'){
            if($fld['data'] == 'Y-m-d')
                $codex .= "                        <ciy-pickerdt name=\"{$fld['col']}\" v-model=\"edat.{$fld['col']}\"></ciy-pickerdt>\n";
            else
                $codex .= "                        <ciy-pickerdt name=\"{$fld['col']}\" v-model=\"edat.{$fld['col']}\" btime></ciy-pickerdt>\n";
        } else if(isset($fld['set']['cpt']) && $fld['set']['cpt'] == 'textarea'){
            $codex .= "                        <ciy-textarea name=\"{$fld['col']}\" v-model=\"edat.{$fld['col']}\"></ciy-textarea>\n";
        } else if(isset($fld['set']['cpt']) && $fld['set']['cpt'] == 'mdhtml'){
            $codex .= "                        <ciy-mdedit name=\"{$fld['col']}\" v-model=\"edat.{$fld['col']}\" imgact=\"cp|1280|80\" :cdnurl=\"g.cdnurl[srv]\" :uploadurl=\"g.jsnurl[srv] + '?json=true&func=boi_upload'\"></ciy-mdedit>\n";
        } else{
                $codex .= "                        <ciy-input name=\"{$fld['col']}\" v-model=\"edat.{$fld['col']}\"></ciy-input>\n";
        }
        $codex .= "                    </view>\n";
        $codex .= "                </view>\n";
    }
    $codex .= <<<codexdata
                <view class="form-group">
                    <button type="primary" form-type="submit" class="btnmain">提交</button>
                </view>
            </form>
        </ciy-dialog>
        <ciy-dialog ref="dialog_view">

codexdata;


    foreach ($flds as $fld) {
        if($fld['col'] == 'id' || $fld['col'] == 'orgid' || $fld['col'] == 'lat')
            continue;
        if(!$fld['bviw'])
            continue;
        $viewprop = '';
        $viewright = '';
        $viewext = '';
        if($fld['cate'] == 'CATA' || $fld['cate'] == 'ID'){
            if($fld['data2'] == 'bg')
                $viewright = "<kbd :style=\"{background:c.ccode(g.{$fld['data']},edat.{$fld['col']},'extdata')}\">{{c.ccode(g.{$fld['data']},edat.{$fld['col']})}}</kbd>";
            else
                $viewright = "{{c.ccode(once.{$fld['data']} || lst.{$fld['data']} || g.{$fld['data']}, edat.{$fld['col']})}}";
        } else if ($fld['cate'] == 'CATM'){
            $viewright = "{{c.multicode(g.{$fld['data']}, edat.{$fld['col']},' . ')}}";
        } else if ($fld['cate'] == 'CNY'){
            $viewright = "{{c.tomoney(edat.{$fld['col']})}}元";
        } else if ($fld['cate'] == 'WCNY'){
            $viewright = "{{c.tomoney(edat.{$fld['col']}/10000)}}万元";
        } else if ($fld['cate'] == 'LOC'){
            $viewprop = ' @click.stop="goloc(edat.lat, edat.lng)"';
            $viewright = "查看定位";
            $viewext = 'more';
        } else if ($fld['cate'] == 'IMG' || $fld['cate'] == 'IMG1'){
            $viewright = "<view style=\"margin: -0.5em -0.5em -1em 0;line-height: 1em;\"><ciy-showimgs width=\"3em\" height=\"3em\" :pics=\"edat.{$fld['col']}\" :cdnurl=\"g.cdnurl[srv]\"></ciy-showimgs></view>";
        } else if ($fld['cate'] == 'DATE'){
            if($fld['data'] == 'Y-m-d')
                $viewright = "{{c.todate(edat.{$fld['col']}, 'd')}}";
            else
                $viewright = "{{c.todate(edat.{$fld['col']})}}";
        } else if(isset($fld['set']['cpt']) && $fld['set']['cpt'] == 'textarea'){
            $viewright = "<view v-html=\"c.br(edat.{$fld['col']})\"></view>";
        } else if(isset($fld['set']['cpt']) && $fld['set']['cpt'] == 'mdhtml'){
            $viewright = "";
            $viewext = "            <view v-html=\"edat.{$fld['col']}\" style=\"min-height:6em;background:#fdfdfd;\"></view>\n";
        }else{
            if(strpos($fld['name'], '联系方式') !== false || strpos($fld['name'], '电话') !== false || strpos($fld['name'], '手机') !== false){
                $viewprop = " @click.stop=\"callphone(edat.{$fld['col']})\"";
                $viewext = 'more';
            }
            $viewright = "{{edat.{$fld['col']}}}";
        }
        $codex .= "            <view class=\"vlinegroup\"{$viewprop}>\n";
        $codex .= "                <view class=\"tit\">{$fld['name']}</view>\n";
        $codex .= "                <view class=\"right\">{$viewright}</view>\n";
        if($viewext == 'more')
            $codex .= "                <view class=\"more\"></view>\n";
        $codex .= "            </view>\n";
        if(substr(trim($viewext),0,1) == '<')
            $codex .= $viewext;
    }

    $codex .= <<<codexdata
        </ciy-dialog>
    </view>
</template>

<style>
</style>

<script module="c" lang="wxs" src="@/wxs.wxs"></script>
<script>
    import c from '@/wxs.wxs';

codexdata;
    if(!empty($mdconv))
        $codex .= "    import markdown from '@/untils/markdown.js';\n";
    if($hasloc)
        $codex .= "    import markdown from '@/untils/gcoord.js';\n";
    $listr = '';
    if(count($liiddicts) > 0){
        $liid = 0;
        $listr = "\n                    {id: 0, name: '全部'},\n";
        foreach($liiddicts as $liidname){
            if(empty($liidname))
                continue;
            $liid++;
            $listr .= "                    {id: {$liid}, name: '{$liidname}'},\n";
        }
        $listr = substr($listr, 0, -2);
    }

    $codex .= <<<codexdata
    var app = getApp();
    export default {
        data() {
            return {
                g: {}
                , srv: '{$dbnm}'
                , pageno: 0
                , liid: 0
                , lis: [{$listr}]
                , lst: {
                    code: -1 //-1导航页，1列表页已加载，else列表页加载中
                    , list: []
                }
                , once: {}
                , edat: {id: 0}
            }
        }
        , onLoad(opn) {
            this.opn = opn;
            app.customlayout(this);
            uni.setNavigationBarTitle({
                title: '{$titname}'
            });

codexdata;
    foreach ($flds as $fld) {
        if($fld['cate'] == 'CATA' || $fld['cate'] == 'CATM'){
            if(substr($fld['data'], 0, 2) == 'X_') {
                $codex .= "            app.loadjsarray({\n";
                $codex .= "                url: app.globalData.cdnurl['t'] + '/static/".strtolower($fld['data']).".js'\n";
                $codex .= "                , success: (json) => {\n";
                $codex .= "                    this.\$set(this.g, '{$fld['data']}', json);\n";
                $codex .= "                }\n";
                $codex .= "            });\n";
            }
        }
    }
    $codex .= <<<codexdata
            if(this.opn.add){
                this.openadd();
            }
            else if (!this.opn.selt) {
                this.getlist();
            }
        }
        , methods: {
            getlist(successcb) {
                if (this.pageno < 0)
                    return;
                if (this.lst.code == -1)
                    this.lst.code = 0;
                this.pageno++;
                if (!this.querys)
                    this.querys = this.opn;
                this.querys.act = 'list';
                this.querys._noquery = !this.once.querys;
                this.querys._dats = this.once._dats;
                this.querys._pageno = this.pageno;
                this.querys._liid = this.lis[this.liid] ? this.lis[this.liid].id : 0;
                app.callajax({
                    func: '{$funcpre}_get'
                    , srv: this.srv
                    , data: this.querys
                    , success: (json) => {
                        if (json.once) {

codexdata;

    if (!empty($liiddict)) {
        $codex .= "                            this.lis = app.objclone(this.g.{$liiddict});\n";
        $codex .= "                            this.lis.unshift({id: 0, name: '全部'});\n";
    }
    $codex .= <<<codexdata
                            if (json.once.querys) {
                                json.once = app.convonce(this, json.once, 'query');
                            }
                            this.once = app.arrconcat(this.once, json.once);
                        }
                        if (this.pageno == 1)
                            this.lst = json;
                        else
                            this.lst = app.arrconcat(this.lst, json);
                        if (json.list.length < json.pagecount)
                            this.pageno = -1;
                        if (typeof(successcb) == 'function')
                            successcb();
                    }
                    , fail: (err) => {
                        this.lst.code = 3;
                        this.lst.errmsg = err.errmsg;
                    }
                });
            }
            , onReachBottom(b) {
                if (this.lst.code == -1)
                    return;
                this.getlist();
            }
            , onPullDownRefresh(b) {
                if (this.lst.code == -1)
                    return uni.stopPullDownRefresh();
                this.pageno = 0;
                this.getlist(() => {
                    uni.stopPullDownRefresh();
                });
            }
            , changeli(b) {
                this.pageno = 0;
                this.liid = c.getint(b.currentTarget.dataset.index);
                this.getlist();
            }
            , queryonceload(b) {
                this.getdats(0, ()=>{
                    b.show = !b.show;
                });
            }
            , querysubmit(e) {
                this.querysearch(e.detail.value);
            }
            , queryreset(e) {
                this.querysearch({});
            }
            , querysearch(query) {
                app.getrefs(this, 'query', ref => {
                    ref.setitem(this.once.querys, query);
                });
                this.querys = query;
                this.pageno = 0;
                this.getlist();
            }
            , getdats(id, cb){
                var querys = {};
                querys._dats = this.once._dats;
                if(id > 0){
                    querys.act = 'data';
                    querys.id = id;
                }
                if(id > 0 || c.getint(this.once._dats) < 2){
                    app.callajax({
                        func: '{$funcpre}_get'
                        , srv: this.srv
                        , data: querys
                        , success: (json) => {
                            if(json.once){
                                var tmpdata = app.objclone(app.arrconcat(this.once, json.once));
                                //this.\$delete(this, 'once');
                                this.\$set(this, 'once', tmpdata);
                            }
                            cb(json);
                        }
                    });
                }else{
                    cb({});
                }
            }
            , openadd() {
                this.edat = {id: 0};
                this.edatidx = -1;
                this.getdats(0, ()=>{
                    app.getrefs(this, 'dialog_update', ref => {
                        ref.open({title:'新建',cb:act=>{
                            if(this.opn.add)
                                uni.navigateBack();
                        }});
                    });
                });
            }
            , submit_update(e) {

codexdata;
    foreach ($flds as $fld) {
        if($fld['bimp']){
            $codex .= "                if (e.detail.value.{$fld['col']} == '')\n";
            $codex .= "                    return app.showtoast('请填写{$fld['name']}');\n";
        }
    }
    $codex .= <<<codexdata
                app.callajax({
                    func: '{$funcpre}_update'
                    , srv: this.srv
                    , data: e.detail.value
                    , success: json => {
                        if(this.edatidx == -1)
                            this.lst.list.unshift(json.data);
                        else
                            this.\$set(this.lst.list, this.edatidx, json.data);
                        this.\$refs.dialog_update.close();
                    }
                });
            }
            , showmenu(idx) {
                var menus = [];
                var dat = this.lst.list[idx];

codexdata;

    if (!empty($btnlist_line)) {
        $strs = explode(',', $btnlist_line); //导入,引导图
        $btns = array();
        for ($i = 0; $i < count($strs); $i++) {
            $ind = strpos($strs[$i],'|');
            if ($ind === false) {
                $btns[] = $strs[$i];
            } else {
                $subs = explode('|', $strs[$i]);//操作|成果|方法|-修改|删除
                for ($j = 1; $j < count($subs); $j++) {
                    $btns[] = $subs[$j];
                }
            }
        }
        foreach($btns as $btn){
            $url = "'./{$funcpre}?_xxxid=' + dat.id";
            if($btn == '查看')
                $url = "'view'";
            if($btn == '修改')
                $url = "'update'";
            if($btn == '删除')
                $url = "'del'";
            $codex .= "                menus.push({\n";
            $codex .= "                    name: '{$btn}'\n";
            $codex .= "                    , url: {$url}\n";
            $codex .= "                });\n";
        }
    }
    $codex .= <<<codexdata
                uni.showActionSheet({
                    itemList: menus.map(item => item.name)
                    , success: res => {
                        var menu = menus[res.tapIndex];
                        if (menu.url == 'del') {
                            app.askmsg('确认删除?', () => {
                                app.callajax({
                                    func: '{$funcpre}_del'
                                    , srv: this.srv
                                    , data: {
                                        id: dat.id
                                    }
                                    , success: (json) => {
                                        this.lst.list.splice(idx, 1);
                                    }
                                });
                            });
                        } else if (menu.url == 'update') {
                            this.edat = app.objclone(this.lst.list[idx]);
                            this.edatidx = idx;
                            this.getdats(dat.id, json=>{
                                if(json.data)
                                    this.edat = json.data;
                                app.getrefs(this, 'dialog_update', ref => {
                                    ref.open('修改');
                                });
                            });
                        } else if (menu.url == 'view') {
                            this.edat = app.objclone(this.lst.list[idx]);
                            this.getdats(dat.id, json=>{
                                if(json.data)
                                    this.edat = json.data;
                                {$mdconv}
                                app.getrefs(this, 'dialog_view', ref => {
                                    ref.open('详情');
                                });
                            });
                        } else {
                            app.globalData.wform = dat;
                            app.globalData.wform.index = idx;
                            uni.navigateTo({
                                url: menu.url
                            });
                        }
                    }
                });
            }

codexdata;
    if($hasloc){
        $codex .= <<<codexdata
            , goloc(lat, lng) {
                if (c.isfloat0(lat))
                    return app.showtoast('没有定位数据');
                var result = gcoord.transform([lng, lat], gcoord.WGS84, gcoord.GCJ02);
                uni.openLocation({
                    latitude: result[1]
                    , longitude: result[0]
                });
            }

codexdata;
    }
    if($hasphone){
        $codex .= <<<codexdata
            , callphone(phone){
                uni.makePhoneCall({
                    phoneNumber: phone
                });
            }

codexdata;
    }
$codex .= <<<codexdata
        }
    }
</script>

codexdata;
    return $codex;
}
