相亲交友小程序开发源码案例:仿比心交友陪玩APP小程序开发

比心单身小程序为青年男女提供线上相亲服务的小程序,通过“翻牌子”获取联系方式。

以feed流形式查阅陌生人卡片,用户可以通过“翻牌子”的方式获取对方的联系方式;在选择好友的标准中,除了基本信息外,学历成为唯一标准,与市面上注重颜值的陌生社交产品相比,比心单身小程序更加注重“精神匹配”。

在开发的过程中,用户基础信息的字段是比较重要的,今天我们就来给大家列举一下开发过程中所出现的字段。

登录注册01-1-C基础信息填写/登录注册01-1-D详细信息填写
星动派
字段说明属性
登录注册01-1-C基础信息填写昵称文本表单/必填
性别单选/必填
出生年月日日期/必填
星座(自动计算)必填
邀请人ID(扫码自动填入)文本表单/必填
微信绑定的手机号文本表单/选填
手机号码:微信授权,后台可见,前端不显示
登录注册01-1-D详细信息填写字段标题名称:形象展示
头像图片图片/必填
字段标题名称:详细信息
婚姻状况单选/必填
学历单选/必填
身高滚轮选值/必填
体重滚轮选值/选填
属相(自动计算)必填
住房情况单选/必填
购车情况单选/必填
字段标题名称:工作家庭
年薪滚轮选值(MAX-MIN)/必填
单位性质单选/选填
所属行业单选/选填
常住地区省/市/区必填
户籍地省/市/必填
民族单选/必填
家庭成员单选/选填
有没有小孩单选/选填
是否想要孩子单选/选填
字段标题名称:介绍下自己吧
性格特征多选/选填
兴趣爱好多选/选填据选项自动标签,分组
特殊嗜好多选/选填据选项自动标签,分组
内心独白文本表单/选填
字段标题名称:择偶条件
最低年龄要求滚轮选区间值(MAX-MIN)/选填
婚史状况要求单选/选填
最低学历要求单选/选填
身高要求滚轮选区间值(MAX-MIN)/选填
特殊嗜好要求单选/选填
住房要求单选/选填
购车要求单选/选填
体重要求滚轮选区间值(MAX-MIN)/选填
年薪要求滚轮选区间值(MAX-MIN)/选填
常住地区省/市/选填
有没有小孩单选/选填
是否想要孩子单选/选填
兴趣爱好要求多选/选填

 相亲交友小程序开发部分源码分享:

<?php

namespace app\admin\command;

use app\admin\command\Api\library\Builder;
use think\Config;
use think\console\Command;
use think\console\Input;
use think\console\input\Option;
use think\console\Output;
use think\Exception;

class Api extends Command
{
    protected function configure()
    {
        $site = Config::get('site');
        $this
            ->setName('api')
            ->addOption('url', 'u', Option::VALUE_OPTIONAL, 'default api url', '')
            ->addOption('module', 'm', Option::VALUE_OPTIONAL, 'module name(admin/index/api)', 'api')
            ->addOption('output', 'o', Option::VALUE_OPTIONAL, 'output index file name', 'api.html')
            ->addOption('template', 'e', Option::VALUE_OPTIONAL, '', 'index.html')
            ->addOption('force', 'f', Option::VALUE_OPTIONAL, 'force override general file', false)
            ->addOption('title', 't', Option::VALUE_OPTIONAL, 'document title', $site['name'] ?? '')
            ->addOption('class', 'c', Option::VALUE_OPTIONAL | Option::VALUE_IS_ARRAY, 'extend class', null)
            ->addOption('language', 'l', Option::VALUE_OPTIONAL, 'language', 'zh-cn')
            ->addOption('addon', 'a', Option::VALUE_OPTIONAL, 'addon name', null)
            ->addOption('controller', 'r', Option::VALUE_REQUIRED | Option::VALUE_IS_ARRAY, 'controller name', null)
            ->setDescription('Build Api document from controller');
    }

    protected function execute(Input $input, Output $output)
    {
        $apiDir = __DIR__ . DS . 'Api' . DS;

        $force = $input->getOption('force');
        $url = $input->getOption('url');
        $language = $input->getOption('language');
        $template = $input->getOption('template');
        if (!preg_match("/^([a-z0-9]+)\.html\$/i", $template)) {
            throw new Exception('template file not correct');
        }
        $language = $language ? $language : 'zh-cn';
        $langFile = $apiDir . 'lang' . DS . $language . '.php';
        if (!is_file($langFile)) {
            throw new Exception('language file not found');
        }
        $lang = include_once $langFile;
        // 目标目录
        $output_dir = ROOT_PATH . 'public' . DS;
        $output_file = $output_dir . $input->getOption('output');
        if (is_file($output_file) && !$force) {
            throw new Exception("api index file already exists!\nIf you need to rebuild again, use the parameter --force=true ");
        }
        // 模板文件
        $template_dir = $apiDir . 'template' . DS;
        $template_file = $template_dir . $template;
        if (!is_file($template_file)) {
            throw new Exception('template file not found');
        }
        // 额外的类
        $classes = $input->getOption('class');
        // 标题
        $title = $input->getOption('title');
        // 模块
        $module = $input->getOption('module');
        // 插件
        $addon = $input->getOption('addon');

        $moduleDir = $addonDir = '';
        if ($addon) {
            $addonInfo = get_addon_info($addon);
            if (!$addonInfo) {
                throw new Exception('addon not found');
            }
            $moduleDir = ADDON_PATH . $addon . DS;
        } else {
            $moduleDir = APP_PATH . $module . DS;
        }
        if (!is_dir($moduleDir)) {
            throw new Exception('module not found');
        }

        if (version_compare(PHP_VERSION, '7.0.0', '<')) {
            throw new Exception("Requires PHP version 7.0 or newer");
        }

        //控制器名
        $controller = $input->getOption('controller') ?: [];
        if (!$controller) {
            $controllerDir = $moduleDir . Config::get('url_controller_layer') . DS;
            $files = new \RecursiveIteratorIterator(
                new \RecursiveDirectoryIterator($controllerDir),
                \RecursiveIteratorIterator::LEAVES_ONLY
            );

            foreach ($files as $name => $file) {
                if (!$file->isDir() && $file->getExtension() == 'php') {
                    $filePath = $file->getRealPath();
                    $classes[] = $this->get_class_from_file($filePath);
                }
            }
        } else {
            foreach ($controller as $index => $item) {
                $filePath = $moduleDir . Config::get('url_controller_layer') . DS . $item . '.php';
                $classes[] = $this->get_class_from_file($filePath);
            }
        }

        $classes = array_unique(array_filter($classes));

        $config = [
            'sitename'    => config('site.name'),
            'title'       => $title,
            'author'      => config('site.name'),
            'description' => '',
            'apiurl'      => $url,
            'language'    => $language,
        ];

        $builder = new Builder($classes);
        $content = $builder->render($template_file, ['config' => $config, 'lang' => $lang]);

        if (!file_put_contents($output_file, $content)) {
            throw new Exception('Cannot save the content to ' . $output_file);
        }
        $output->info("Build Successed!");
    }

    /**
     * get full qualified class name
     *
     * @param string $path_to_file
     * @return string
     * @author JBYRNE http://jarretbyrne.com/2015/06/197/
     */
    protected function get_class_from_file($path_to_file)
    {
        //Grab the contents of the file
        $contents = file_get_contents($path_to_file);

        //Start with a blank namespace and class
        $namespace = $class = "";

        //Set helper values to know that we have found the namespace/class token and need to collect the string values after them
        $getting_namespace = $getting_class = false;

        //Go through each token and evaluate it as necessary
        foreach (token_get_all($contents) as $token) {

            //If this token is the namespace declaring, then flag that the next tokens will be the namespace name
            if (is_array($token) && $token[0] == T_NAMESPACE) {
                $getting_namespace = true;
            }

            //If this token is the class declaring, then flag that the next tokens will be the class name
            if (is_array($token) && $token[0] == T_CLASS) {
                $getting_class = true;
            }

            //While we're grabbing the namespace name...
            if ($getting_namespace === true) {

                //If the token is a string or the namespace separator...
                if (is_array($token) && in_array($token[0], [T_STRING, T_NS_SEPARATOR])) {

                    //Append the token's value to the name of the namespace
                    $namespace .= $token[1];
                } elseif ($token === ';') {

                    //If the token is the semicolon, then we're done with the namespace declaration
                    $getting_namespace = false;
                }
            }

            //While we're grabbing the class name...
            if ($getting_class === true) {

                //If the token is a string, it's the name of the class
                if (is_array($token) && $token[0] == T_STRING) {

                    //Store the token's value as the class name
                    $class = $token[1];

                    //Got what we need, stope here
                    break;
                }
            }
        }

        //Build the fully-qualified class name and return it
        return $namespace ? $namespace . '\\' . $class : $class;
    }
}

  • 8
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值