uni-app 190扫一扫加入群聊功能(二)

简介: uni-app 190扫一扫加入群聊功能(二)

/pages/chat/scan-add/scan-add.nvue

<template>
  <view class="page">
    <!-- 导航栏 -->
    <free-nav-bar title="加入群聊" showBack :showRight="false"></free-nav-bar>
    
    <view class="p-5">
      <view class="bg-white rounded p-4">
        <view class="flex align-center">
          <free-avatar :src="detail.avatar || '/static/images/demo/demo6.jpg'"></free-avatar>
          <view class="pl-4 flex flex-column">
            <text class="font-md">{{detail.name}}</text>
            <text class="font-sm text-muted" >群成员数:{{detail.users_count}}</text>
          </view>
        </view>
        <view class="flex flex-column align-center justify-center">
          <image :src="src" mode="" style="width: 550rpx;height: 550rpx;" class="bg-secondary mb-4"></image>
          <text class="font text-light-muted">扫一扫上面的二维码,加我的微信</text>
        </view>
      </view>
      
      <view class="py-3 flex align-center justify-center main-bg-color" hover-class="main-bg-hover-color" @click="join"> 
        <text class="font-md text-white">加入群聊</text>
      </view>
      
    </view>
  </view>
</template>
<script>
  import freeNavBar from '@/components/free-ui/free-nav-bar.vue';
  import freeAvatar from '@/components/free-ui/free-avatar.vue';
  import {mapState} from 'vuex';
  import $C from '@/common/free-lib/config.js';
  export default {
    components:{
      freeNavBar,
      freeAvatar
    },
    computed:{
      ...mapState({
        user:state=>state.user.user
      })
    },
    data() {
      return {
        detail:{
          id:0,
          name:"",
          avatar:'',
          users_count:0
        }
      }
    },
    onLoad(e) {
      if(e.params){
        
        this.detail = JSON.parse(decodeURIComponent(e.params));
        
      }
    },
    methods: {
      join(){
        
      }
    }
  }
</script>
<style>
</style>

/components/free-ui/free-nav-bar.vue

<template>
  <view>
    <view :class="getClass">
      <!-- 状态栏 -->
      <view :style="'height:'+statusBarHeight+'px'"></view>
      <!-- 导航 -->
      <view class="w-100 flex align-center justify-between" style="height: 90rpx;">
        <!-- 左边 -->
        <view class="flex align-center">
          <!-- 返回按钮 -->
          <!-- #ifndef MP -->
          <free-icon-button v-if="showBack" @click="back"><text class="iconfont font-md">&#xe60d;</text></free-icon-button>
          <!-- #endif -->
          <!-- 标题 -->
          <slot>
            <text v-if="title" class="font-md ml-3">{{getTitle}}</text>
          </slot>
        </view>
        <!-- 右边 -->
        <view class="flex align-center" v-if="showRight">
          <slot name="right">
            <free-icon-button @click="search"><text class="iconfont font-md">&#xe6e3;</text></free-icon-button>
            <free-icon-button @click="openExtend"><text class="iconfont font-md">&#xe682;</text></free-icon-button>
          </slot>
        </view>
      </view>
    </view>
    <!-- 占位 -->
    <view v-if="fixed" :style="fixedStyle"></view>
    
    <!-- 扩展菜单 -->
    <free-popup v-if="showRight" ref="extend" :bodyWidth="320" :bodyHeight="525"
    bodyBgColor="bg-dark" transformOrigin="right top">
      <view class="flex flex-column" 
      style="width: 320rpx;height: 525rpx;">
        <view class="flex-1 flex align-center" 
        hover-class="bg-hover-dark"
        v-for="(item,index) in menus"
        :key="index"
        @click="clickEvent(item)">
          <text class="iconfont pl-3 pr-2 font-md text-white">{{item.icon}}</text>
          <text class="font-md text-white">{{item.name}}</text>
        </view>
      </view>
    </free-popup>
    
    
  </view>
</template>
<script>
  import freeIconButton from "./free-icon-button.vue"
  import freePopup from "./free-popup.vue"
  export default {
    props: {
      showBack:{
        type:Boolean,
        default:false
      },
      backEvent:{
        type:Boolean,
        default:true
      },
      title: {
        type: [String,Boolean],
        default:false 
      },
      fixed:{
        type:Boolean,
        default:true
      },
      noreadnum:{
        type:[Number,String],
        default:0
      },
      bgColor:{
        type:String,
        default:"bg-light"
      },
      showRight:{
        type:Boolean,
        default:true
      }
    },
    components:{
      freeIconButton,
      freePopup
    },
    data() {
      return {
        statusBarHeight:0,
        navBarHeight:0,
        menus:[
          {
            name:"发起群聊",
            event:"navigateTo",
            path:"/pages/mail/mail/mail?type=createGroup",
            icon:"\ue633"
          },
          {
            name:"添加好友",
            event:"navigateTo",
            path:"/pages/common/search/search",
            icon:"\ue65d"
          },
          // #ifndef H5
          {
            name:"扫一扫",
            event:"scan",
            icon:"\ue614"
          },
          // #endif
          {
            name:"收付款",
            event:"",
            icon:"\ue66c"
          },
          {
            name:"帮助与反馈",
            event:"",
            icon:"\ue66c"
          }
        ],
      }
    },
    mounted() {
      // #ifdef APP-PLUS-NVUE
      this.statusBarHeight = plus.navigator.getStatusbarHeight()
      // #endif
      this.navBarHeight = this.statusBarHeight + uni.upx2px(90)
    },
    computed: {
      fixedStyle() {
        return `height:${this.navBarHeight}px`
      },
      getTitle(){
        let noreadnum = this.noreadnum > 0 ? '('+this.noreadnum+')' : ''
        return this.title + noreadnum
      },
      getClass(){
        let fixed = this.fixed?'fixed-top':''
        return `${fixed} ${this.bgColor}` 
      }
    },
    methods: {
      openExtend() {
        this.$refs.extend.show(uni.upx2px(415),uni.upx2px(150))
      },
      // 返回
      back(){
        if(this.backEvent){
          return uni.navigateBack({
            delta: 1
          });
        }
        this.$emit('back')
      },
      search(){
        uni.navigateTo({
          url: '/pages/common/search/search'
        });
      },
      clickEvent(item){
        this.$refs.extend.hide()
        switch (item.event){
          case 'navigateTo':
          uni.navigateTo({
            url: item.path,
          });
            break;
            case 'scan':
          uni.scanCode({
            success:(res)=>{
              if(res.scanType === 'QR_CODE'){
                let result = JSON.parse(res.result);
                switch(result.type){
                  case 'group':
                  $H.post('/group/checkrelation',{
                    id:parseInt(result.id)
                  }).then(res2=>{
                    if(res2.status){
                      // 已经在群内
                    }else{
                      // 加入群聊
                      uni.navigateTo({
                        url:'/pages/chat/scan-add/scan-add?params='+encodeURIComponent(JSON.stringify(res2.group))
                      });
                    }
                  })
                  break;
                  default:
                  uni.showToast({
                    title: '靓仔,自己发挥',
                    icon: 'none'
                  });
                  break;
                }
              }
            }
          })
          break;
          default:
          uni.showToast({
            title: '靓仔,自己发挥',
            icon: 'none'
          });
            break;
        }
      }
    },
  }
</script>
<style>
</style>

感谢大家观看,我们下次见

目录
相关文章
|
2天前
|
移动开发 Android开发 数据安全/隐私保护
移动应用与系统的技术演进:从开发到操作系统的全景解析随着智能手机和平板电脑的普及,移动应用(App)已成为人们日常生活中不可或缺的一部分。无论是社交、娱乐、购物还是办公,移动应用都扮演着重要的角色。而支撑这些应用运行的,正是功能强大且复杂的移动操作系统。本文将深入探讨移动应用的开发过程及其背后的操作系统机制,揭示这一领域的技术演进。
本文旨在提供关于移动应用与系统技术的全面概述,涵盖移动应用的开发生命周期、主要移动操作系统的特点以及它们之间的竞争关系。我们将探讨如何高效地开发移动应用,并分析iOS和Android两大主流操作系统的技术优势与局限。同时,本文还将讨论跨平台解决方案的兴起及其对移动开发领域的影响。通过这篇技术性文章,读者将获得对移动应用开发及操作系统深层理解的钥匙。
|
2月前
|
Java PHP
【应用服务 App Service】 App Service Rewrite 实例 - 反向代理转发功能
【应用服务 App Service】 App Service Rewrite 实例 - 反向代理转发功能
【应用服务 App Service】 App Service Rewrite 实例 - 反向代理转发功能
|
2月前
|
Python
【Azure 应用服务】App Service的运行状况检查功能失效,一直提示"实例运行不正常"
【Azure 应用服务】App Service的运行状况检查功能失效,一直提示"实例运行不正常"
|
4月前
|
开发框架 移动开发 JavaScript
SpringCloud微服务实战——搭建企业级开发框架(四十七):【移动开发】整合uni-app搭建移动端快速开发框架-添加Axios并实现登录功能
在uni-app中,使用axios实现网络请求和登录功能涉及以下几个关键步骤: 1. **安装axios和axios-auth-refresh**: 在项目的`package.json`中添加axios和axios-auth-refresh依赖,可以通过HBuilderX的终端窗口运行`yarn add axios axios-auth-refresh`命令来安装。 2. **配置自定义常量**: 创建`project.config.js`文件,配置全局常量,如API基础URL、TenantId、APP_CLIENT_ID和APP_CLIENT_SECRET等。
206 60
|
2月前
|
测试技术
一款功能完善的智能匹配1V1视频聊天App应该通过的测试CASE
文章列举了一系列针对1V1视频聊天App的测试用例,包括UI样式、权限请求、登录流程、匹配逻辑、消息处理、充值功能等多个方面的测试点,并标注了每个测试用例的执行状态,如通过(PASS)、失败(FAIL)或需要进一步处理(延期修改、待定、方案再定等)。
38 0
|
2月前
|
Linux C++ Docker
【Azure 应用服务】App Service for Linux 中实现 WebSocket 功能 (Python SocketIO)
【Azure 应用服务】App Service for Linux 中实现 WebSocket 功能 (Python SocketIO)
|
2月前
|
监控 安全 前端开发
【Azure 应用服务】App Service 运行状况健康检查功能简介 (Health check)
【Azure 应用服务】App Service 运行状况健康检查功能简介 (Health check)
|
3月前
|
存储 前端开发 测试技术
同城交友APP系统开发运营版/案例详细/功能步骤/逻辑方案
开发一款同城交友APP系统需要经过以下大致流程:
|
3月前
|
JavaScript Java 测试技术
基于SpringBoot+Vue+uniapp的多功能智能手机阅读APP的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue+uniapp的多功能智能手机阅读APP的详细设计和实现(源码+lw+部署文档+讲解等)
|
3月前
|
小程序 安全 数据挖掘
陪玩语聊APP小程序定制开发模块功能
随着电竞行业的规范化,游戏陪玩软件兴起,提供专业陪玩服务。核心功能包括:多样化注册登录、用户资料展示、智能匹配筛选陪玩、语音互动(多人/私聊)、订单交易管理、陪玩入驻审核、数据分析、客服系统及社交功能。旨在融合游戏、语音聊天与社交,构建综合娱乐平台。