Browse Source

wx小程序兼容优化

master
xsx 1 year ago
parent
commit
3f59d79d17
  1. 4
      im-uniapp/common/emotion.js
  2. 3
      im-uniapp/components/chat-message-item/chat-message-item.vue
  3. 33
      im-uniapp/im.scss
  4. 39
      im-uniapp/pages/friend/friend-add.vue
  5. 6
      im-uniapp/pages/group/group-info.vue
  6. 6
      im-uniapp/pages/login/login.vue
  7. 7
      im-uniapp/pages/mine/mine.vue
  8. 6
      im-uniapp/pages/register/register.vue

4
im-uniapp/common/emotion.js

@ -21,10 +21,6 @@ let textToImg = (emoText) => {
return emoText; return emoText;
} }
let path = textToPath(emoText); let path = textToPath(emoText);
// #ifdef MP
// 微信小程序不能有前面的'/'
path = path.slice(1);
// #endif
let img = `<img src="${path}" style="with:30px;height:30px; let img = `<img src="${path}" style="with:30px;height:30px;
margin: 0 -2px;vertical-align:bottom;"/>`; margin: 0 -2px;vertical-align:bottom;"/>`;
return img; return img;

3
im-uniapp/components/chat-message-item/chat-message-item.vue

@ -23,7 +23,7 @@
<view class="chat-msg-image" v-if="msgInfo.type == $enums.MESSAGE_TYPE.IMAGE"> <view class="chat-msg-image" v-if="msgInfo.type == $enums.MESSAGE_TYPE.IMAGE">
<long-press-menu :items="menuItems" @select="onSelectMenu"> <long-press-menu :items="menuItems" @select="onSelectMenu">
<view class="img-load-box"> <view class="img-load-box">
<image class="send-image" mode="widthFix" :src="JSON.parse(msgInfo.content).thumbUrl" <image class="send-image" mode="heightFix" :src="JSON.parse(msgInfo.content).thumbUrl"
lazy-load="true" @click.stop="onShowFullImage()"> lazy-load="true" @click.stop="onShowFullImage()">
</image> </image>
<loading v-if="loading"></loading> <loading v-if="loading"></loading>
@ -306,6 +306,7 @@ export default {
.send-image { .send-image {
min-width: 200rpx; min-width: 200rpx;
max-width: 420rpx; max-width: 420rpx;
height: 350rpx;
cursor: pointer; cursor: pointer;
border-radius: 4px; border-radius: 4px;
} }

33
im-uniapp/im.scss

@ -28,6 +28,39 @@ uni-button[size='mini'] {
font-size: $im-font-size-smaller !important; font-size: $im-font-size-smaller !important;
} }
// #ifdef MP-WEIXIN
// wx小程序只有button,没有uni-botton
button {
font-size: $im-font-size !important;
}
button[type='primary'] {
color: #fff !important;
background-color: $im-color-primary !important;
}
button[type='primary'][plain] {
color: $im-color-primary !important;
border: 1px solid $im-color-primary;
background-color: transparent;
}
button[type='warn'] {
color: #fff !important;
background-color: $im-color-danger !important;
}
button[type='warn'][plain] {
color: $im-color-danger !important;
border: 1px solid $im-color-danger !important;
background-color: transparent !important;
}
button[size='mini'] {
font-size: $im-font-size-smaller !important;
}
// #endif
.button-hover[type='primary'] { .button-hover[type='primary'] {
color: #fff !important; color: #fff !important;
background-color: $im-color-primary-dark-1 !important; background-color: $im-color-primary-dark-1 !important;

39
im-uniapp/pages/friend/friend-add.vue

@ -13,7 +13,13 @@
<view class="user-item"> <view class="user-item">
<head-image :id="user.id" :name="user.nickName" :online="user.online" <head-image :id="user.id" :name="user.nickName" :online="user.online"
:url="user.headImage"></head-image> :url="user.headImage"></head-image>
<view class="user-name">{{ user.nickName }}</view> <view class="user-info">
<view class="user-name">
<view>{{ user.userName }}</view>
<uni-tag v-if="user.status == 1" circle type="error" text="已注销" size="small"></uni-tag>
</view>
<view class="nick-name">{{ `昵称:${user.nickName}`}}</view>
</view>
<view class="user-btns"> <view class="user-btns">
<button type="primary" v-show="!isFriend(user.id)" size="mini" <button type="primary" v-show="!isFriend(user.id)" size="mini"
@click.stop="onAddFriend(user)">加为好友</button> @click.stop="onAddFriend(user)">加为好友</button>
@ -90,22 +96,45 @@ export default {
overflow: hidden; overflow: hidden;
.user-item { .user-item {
height: 120rpx; height: 100rpx;
display: flex; display: flex;
margin-bottom: 1rpx; margin-bottom: 1rpx;
position: relative; position: relative;
padding: 0 30rpx; padding: 18rpx 20rpx;
align-items: center; align-items: center;
background-color: white; background-color: white;
white-space: nowrap; white-space: nowrap;
.user-name { .user-info {
flex: 1; flex: 1;
display: flex;
flex-direction: column;
padding-left: 20rpx; padding-left: 20rpx;
font-size: $im-font-size; font-size: $im-font-size;
line-height: 60rpx;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
.user-name {
display: flex;
flex: 1;
font-size: $im-font-size-large;
white-space: nowrap;
overflow: hidden;
align-items: center;
.uni-tag {
text-align: center;
margin-left: 5rpx;
padding: 1px 5px;
}
}
.nick-name {
display: flex;
font-size: $im-font-size-smaller;
color: $im-text-color-lighter;
padding-top: 8rpx;
}
} }
} }

6
im-uniapp/pages/group/group-info.vue

@ -46,9 +46,9 @@
<view v-if="!group.quit" class="group-edit" @click="onEditGroup()">修改群聊资料 > </view> <view v-if="!group.quit" class="group-edit" @click="onEditGroup()">修改群聊资料 > </view>
</view> </view>
<bar-group v-if="!group.quit"> <bar-group v-if="!group.quit">
<btn-bar type="primary" title="发送消息" @click="onSendMessage()"></btn-bar> <btn-bar type="primary" title="发送消息" @tap="onSendMessage()"></btn-bar>
<btn-bar v-if="!isOwner" type="danger" title="退出群聊" @click="onQuitGroup()"></btn-bar> <btn-bar v-if="!isOwner" type="danger" title="退出群聊" @tap="onQuitGroup()"></btn-bar>
<btn-bar v-if="isOwner" type="danger" title="解散群聊" @click="onDissolveGroup()"></btn-bar> <btn-bar v-if="isOwner" type="danger" title="解散群聊" @tap="onDissolveGroup()"></btn-bar>
</bar-group> </bar-group>
</view> </view>
</template> </template>

6
im-uniapp/pages/login/login.vue

@ -1,7 +1,7 @@
<template> <template>
<view class="login"> <view class="login">
<view class="title">欢迎登录</view> <view class="title">欢迎登录</view>
<uni-forms class="form" :modelValue="loginForm" :rules="rules" validate-trigger="bind"> <uni-forms :modelValue="loginForm" :rules="rules" validate-trigger="bind">
<uni-forms-item name="userName"> <uni-forms-item name="userName">
<uni-easyinput type="text" v-model="loginForm.userName" prefix-icon="person" placeholder="用户名" /> <uni-easyinput type="text" v-model="loginForm.userName" prefix-icon="person" placeholder="用户名" />
</uni-forms-item> </uni-forms-item>
@ -69,7 +69,7 @@ export default {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss">
.login { .login {
.title { .title {
padding-top: 150rpx; padding-top: 150rpx;
@ -80,7 +80,7 @@ export default {
font-weight: bold; font-weight: bold;
} }
.form { .uni-forms {
padding: 50rpx; padding: 50rpx;
.btn-submit { .btn-submit {

7
im-uniapp/pages/mine/mine.vue

@ -31,16 +31,13 @@
</view> </view>
</view> </view>
</view> </view>
<view class="info-arrow">
</view>
</view> </view>
</uni-card> </uni-card>
<bar-group> <bar-group>
<arrow-bar title="修改密码" @click="onModifyPassword()"></arrow-bar> <arrow-bar title="修改密码" @tap="onModifyPassword()"></arrow-bar>
</bar-group> </bar-group>
<bar-group> <bar-group>
<btn-bar title="退出登录" type="danger" @click="onQuit()"></btn-bar> <btn-bar title="退出登录" type="danger" @tap="onQuit()"></btn-bar>
</bar-group> </bar-group>
</view> </view>
</template> </template>

6
im-uniapp/pages/register/register.vue

@ -1,7 +1,7 @@
<template> <template>
<view class="register"> <view class="register">
<view class="title">欢迎注册</view> <view class="title">欢迎注册</view>
<uni-forms class="form" ref="form" :modelValue="dataForm" :rules="rules" validate-trigger="bind" label-width="80px"> <uni-forms ref="form" :modelValue="dataForm" :rules="rules" validate-trigger="bind" label-width="80px">
<uni-forms-item name="userName" label="用户名"> <uni-forms-item name="userName" label="用户名">
<uni-easyinput type="text" v-model="dataForm.userName" placeholder="用户名" /> <uni-easyinput type="text" v-model="dataForm.userName" placeholder="用户名" />
</uni-forms-item> </uni-forms-item>
@ -111,7 +111,7 @@ export default {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss">
.register { .register {
.title { .title {
padding-top: 150rpx; padding-top: 150rpx;
@ -122,7 +122,7 @@ export default {
font-weight: 600; font-weight: 600;
} }
.form { .uni-forms {
padding: 50rpx; padding: 50rpx;
.btn-submit { .btn-submit {

Loading…
Cancel
Save