Compare commits
54 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9baac8ef63 | ||
|
|
26c2e044dc | ||
|
|
7cf5577cb0 | ||
| e33e07178d | |||
|
|
9fac4e8a2e | ||
|
|
e223fd5ff9 | ||
| d7c6625416 | |||
|
|
0a8f2f815d | ||
| 42a08e07ba | |||
| 4e350f4dd0 | |||
|
e946b98abf
|
|||
|
|
2759972de6 | ||
| bee3ab9fba | |||
|
a318ea9f84
|
|||
|
3eaee9009a
|
|||
|
|
2ab2d1c38e | ||
| d8840edb30 | |||
|
|
1d98624753 | ||
|
75a4bbedbe
|
|||
| d4a9b38f99 | |||
|
|
3b9e429c80 | ||
|
|
a9d4708d2c | ||
| 7206d00afc | |||
| 798f499263 | |||
|
|
64da585bd7 | ||
|
|
959afc776a | ||
|
f89803cf9b
|
|||
| 795726bdb8 | |||
|
|
de2b7fe26d | ||
|
|
a0e780d05b | ||
|
|
0b5fa511bf | ||
| a1cba0a7fd | |||
| 1b03d1be7e | |||
|
55695f164b
|
|||
| 084826e144 | |||
| ab4b418c8f | |||
|
56eb7e551c
|
|||
|
0279128637
|
|||
| d78b787967 | |||
| 242f22d2ce | |||
|
427442f50a
|
|||
|
641cb4a4a2
|
|||
|
78d60bd9ac
|
|||
|
217e8b51ed
|
|||
|
74a9778a62
|
|||
| e83b5b1311 | |||
|
ceb2b8084d
|
|||
|
4453742f3c
|
|||
|
93c412a515
|
|||
|
|
71a25fd11d | ||
|
|
6ec2318d0c | ||
|
|
04a4ed523f | ||
|
|
e67e2fe701 | ||
| 7d82d8d156 |
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
.vscode
|
.vscode
|
||||||
node_modules
|
node_modules
|
||||||
unpackage
|
unpackage
|
||||||
|
manifest.json
|
||||||
6
App.vue
@@ -1,6 +1,10 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
|
globalData: {
|
||||||
|
im: {}
|
||||||
|
},
|
||||||
onLaunch: function() {
|
onLaunch: function() {
|
||||||
|
getApp().globalData.im = this.imService
|
||||||
console.log('App Launch');
|
console.log('App Launch');
|
||||||
},
|
},
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
@@ -14,5 +18,7 @@ export default {
|
|||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
/*每个页面公共css */
|
/*每个页面公共css */
|
||||||
|
/* #ifndef APP-PLUS-NVUE */
|
||||||
@import 'uview-ui/index.scss';
|
@import 'uview-ui/index.scss';
|
||||||
|
/* #endif*/
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
7
common/cos-wx-sdk-v5.js
Normal file
@@ -86,8 +86,8 @@ const install = (Vue, vm) => {
|
|||||||
return vm.$u.post("/article/articleInfo",{article_id})
|
return vm.$u.post("/article/articleInfo",{article_id})
|
||||||
},
|
},
|
||||||
// 回复评论
|
// 回复评论
|
||||||
reply({article_id,pid,content}){
|
reply({article_id,pid,content,reply_id}){
|
||||||
return vm.$u.post("/article/articleAddComment",{article_id,pid,content})
|
return vm.$u.post("/article/articleAddComment",{article_id,pid,content,reply_id})
|
||||||
},
|
},
|
||||||
// 达人是否可以直播
|
// 达人是否可以直播
|
||||||
canlive(){
|
canlive(){
|
||||||
|
|||||||
62
components/GoEasyAudioPlayer/GoEasyAudioPlayer.vue
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<template>
|
||||||
|
<div class="goeasy-audio-player" @click="playAudio">
|
||||||
|
<div class="audio-facade" :style="{width:Math.ceil(duration)*7 + 50 + 'px'}">
|
||||||
|
<div class="audio-facade-bg" :class="{'play-icon':play}"> </div>
|
||||||
|
<div>{{Math.ceil(duration) || 0}}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const innerAudioContext = uni.createInnerAudioContext();
|
||||||
|
export default {
|
||||||
|
name: "GoEasyAudioPlayer",
|
||||||
|
props : ['src', 'duration'],
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
play : false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods : {
|
||||||
|
playAudio () {
|
||||||
|
this.play = true;
|
||||||
|
innerAudioContext.src = this.src;
|
||||||
|
innerAudioContext.play();
|
||||||
|
setTimeout(() => {
|
||||||
|
this.play = false;
|
||||||
|
}, this.duration*1000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.goeasy-audio-player{
|
||||||
|
margin-top: 12rpx;
|
||||||
|
-webkit-tap-highlight-color:rgba(0,0,0,0);
|
||||||
|
}
|
||||||
|
.audio-facade{
|
||||||
|
min-width: 20rpx;
|
||||||
|
padding: 6rpx 10rpx;
|
||||||
|
height: 72rpx;
|
||||||
|
line-height: 72rpx;
|
||||||
|
background: #D02129;
|
||||||
|
font-size: 24rpx;
|
||||||
|
border-radius: 14rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.audio-facade-bg{
|
||||||
|
background: url("./images/voice.png") no-repeat center;
|
||||||
|
background-size: 30rpx;
|
||||||
|
width: 40rpx;
|
||||||
|
}
|
||||||
|
.audio-facade-bg.play-icon{
|
||||||
|
background: url("./images/play.gif") no-repeat center;
|
||||||
|
background-size: 30rpx;
|
||||||
|
-moz-transform:rotate(180deg);
|
||||||
|
-webkit-transform:rotate(180deg);
|
||||||
|
-o-transform:rotate(180deg);
|
||||||
|
transform:rotate(180deg);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
BIN
components/GoEasyAudioPlayer/images/play.gif
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
components/GoEasyAudioPlayer/images/voice.png
Normal file
|
After Width: | Height: | Size: 300 B |
55
components/GoEasyVideoPlayer/GoEasyVideoPlayer.vue
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<template>
|
||||||
|
<video
|
||||||
|
v-if="show"
|
||||||
|
class="video-player"
|
||||||
|
controls = ""
|
||||||
|
@play="onPlayStart"
|
||||||
|
id="videoPlayer"
|
||||||
|
autoplay="true"
|
||||||
|
@fullscreenchange="onVideoFullScreenChange"
|
||||||
|
:src="url">
|
||||||
|
</video>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "GoEasyVideoPlayer",
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
show : false,
|
||||||
|
context: null,
|
||||||
|
url: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods : {
|
||||||
|
play (video) {
|
||||||
|
this.show = true;
|
||||||
|
this.url = video.url;
|
||||||
|
this.context = uni.createVideoContext('videoPlayer');
|
||||||
|
},
|
||||||
|
onVideoFullScreenChange (e) {
|
||||||
|
//当退出全屏播放时,隐藏播放器
|
||||||
|
if(this.show && !e.detail.fullScreen){
|
||||||
|
this.show = false;
|
||||||
|
this.context.stop();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onPlayStart () {
|
||||||
|
//播放开始时,立即全屏
|
||||||
|
this.context.requestFullScreen({
|
||||||
|
direction : 0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.video-player{
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
BIN
components/GoEasyVideoPlayer/images/play.png
Normal file
|
After Width: | Height: | Size: 560 B |
@@ -10,14 +10,15 @@
|
|||||||
<view class="status" v-if="info.view_type==1">待处理订单</view>
|
<view class="status" v-if="info.view_type==1">待处理订单</view>
|
||||||
<view class="status" v-else-if="info.view_type==2">已发货订单</view>
|
<view class="status" v-else-if="info.view_type==2">已发货订单</view>
|
||||||
<view class="status" v-else-if="info.view_type==3">已完成订单</view>
|
<view class="status" v-else-if="info.view_type==3">已完成订单</view>
|
||||||
<view class="status" v-else-if="info.view_type==4">申请退款订单</view>
|
<view class="status" v-else-if="info.view_type==4">申请退款</view>
|
||||||
<view class="status" v-else-if="info.view_type==5">已退款订单</view>
|
<view class="status" v-else-if="info.view_type==5">已退款订单</view>
|
||||||
<view class="status" v-else-if="info.view_type==6">拒绝退款订单</view>
|
<view class="status" v-else-if="info.view_type==6">商家同意</view>
|
||||||
|
<view class="status" v-else-if="info.view_type==7">商家拒绝</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="name u-line-1">{{info.extend_order_goods[0].goods_name}}</view>
|
<view class="name u-line-1">{{info.extend_order_goods[0].goods_name}}</view>
|
||||||
<view class="info">
|
<view class="info">
|
||||||
<view class="num">共{{info.extend_order_goods[0].goods_num}}件商品</view>
|
<view class="num">共{{info.count_number}}件商品</view>
|
||||||
<view class="price">实付<span>¥{{info.extend_order_goods[0].goods_pay_price}}</span></view>
|
<view class="price">实付<span>¥{{info.order_amount}}</span></view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -2,14 +2,16 @@
|
|||||||
<view class="item" @click="toDetailsPage">
|
<view class="item" @click="toDetailsPage">
|
||||||
<image :src="info.goods_pic"></image>
|
<image :src="info.goods_pic"></image>
|
||||||
<view class="goods">
|
<view class="goods">
|
||||||
<view class="">
|
<view class="box">
|
||||||
|
<view class="boxid">
|
||||||
|
{{info.goods_try_id}}
|
||||||
|
</view>
|
||||||
<!-- 0:待处理订单 20:同意 40:拒绝此订单 -->
|
<!-- 0:待处理订单 20:同意 40:拒绝此订单 -->
|
||||||
<view class="status" v-if="info.goods_try_order_status==0">待处理订单</view>
|
<view class="status" v-if="info.goods_try_order_status==0">待处理订单</view>
|
||||||
<view class="status" v-if="info.goods_try_order_status==20">已接单订单</view>
|
<view class="status" v-if="info.goods_try_order_status==20">已接单订单</view>
|
||||||
<view class="status" v-if="info.goods_try_order_status==40">已拒绝订单</view>
|
<view class="status" v-if="info.goods_try_order_status==40">已拒绝订单</view>
|
||||||
<view class="status" v-if="info.goods_try_order_status==50">已完成订单</view>
|
<view class="status" v-if="info.goods_try_order_status==50">已完成订单</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="name u-line-1">{{info.goods_name}}</view>
|
<view class="name u-line-1">{{info.goods_name}}</view>
|
||||||
<view class="info">
|
<view class="info">
|
||||||
<view class="num">共{{info.goods_try_num}}件商品</view>
|
<view class="num">共{{info.goods_try_num}}件商品</view>
|
||||||
@@ -67,7 +69,15 @@ export default {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
justify-content: center;
|
justify-content: space-between;
|
||||||
|
.box{
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
font-size: 24rpx;
|
||||||
|
}
|
||||||
|
.boxid{
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
.status {
|
.status {
|
||||||
align-self: flex-end;
|
align-self: flex-end;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
|
|||||||
@@ -18,12 +18,19 @@ export default {
|
|||||||
xuanzhong:false,
|
xuanzhong:false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props:['image','title','price','num','sid'],
|
props:['image','title','price','num','sid','wxuanzhong'],
|
||||||
methods:{
|
methods:{
|
||||||
xuanzhongs(){
|
xuanzhongs(){
|
||||||
this.xuanzhong = !this.xuanzhong
|
this.xuanzhong = !this.xuanzhong
|
||||||
this.$emit("xuanzhong")
|
this.$emit("xuanzhong")
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
watch:{
|
||||||
|
|
||||||
|
},
|
||||||
|
created(){
|
||||||
|
this.xuanzhong = this.wxuanzhong
|
||||||
|
console.log(this.wxuanzhong)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
5
main.js
@@ -1,11 +1,12 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import App from './App'
|
import App from './App'
|
||||||
|
import IMService from './static/imservice.js'
|
||||||
import uView from "uview-ui";
|
import uView from "uview-ui";
|
||||||
Vue.use(uView);
|
Vue.use(uView);
|
||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
|
Vue.prototype.imService = new IMService();
|
||||||
|
Vue.prototype.a = 1;
|
||||||
App.mpType = 'app'
|
App.mpType = 'app'
|
||||||
|
|
||||||
const app = new Vue({
|
const app = new Vue({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "hdemingshangjia",
|
"name" : "德铭阳光商家",
|
||||||
"appid" : "",
|
"appid" : "__UNI__EA895BE",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"versionName" : "1.0.0",
|
"versionName" : "1.0.0",
|
||||||
"versionCode" : "100",
|
"versionCode" : "100",
|
||||||
@@ -17,7 +17,12 @@
|
|||||||
"delay" : 0
|
"delay" : 0
|
||||||
},
|
},
|
||||||
/* 模块配置 */
|
/* 模块配置 */
|
||||||
"modules" : {},
|
"modules" : {
|
||||||
|
"Push" : {},
|
||||||
|
"OAuth" : {},
|
||||||
|
"VideoPlayer" : {},
|
||||||
|
"LivePusher" : {}
|
||||||
|
},
|
||||||
/* 应用发布信息 */
|
/* 应用发布信息 */
|
||||||
"distribute" : {
|
"distribute" : {
|
||||||
/* android打包配置 */
|
/* android打包配置 */
|
||||||
@@ -45,12 +50,56 @@
|
|||||||
"<uses-feature android:name=\"android.hardware.camera\"/>",
|
"<uses-feature android:name=\"android.hardware.camera\"/>",
|
||||||
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
|
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
|
||||||
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
|
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
|
||||||
]
|
],
|
||||||
|
"abiFilters" : [ "armeabi-v7a", "x86" ]
|
||||||
},
|
},
|
||||||
/* ios打包配置 */
|
/* ios打包配置 */
|
||||||
"ios" : {},
|
"ios" : {},
|
||||||
/* SDK配置 */
|
/* SDK配置 */
|
||||||
"sdkConfigs" : {}
|
"sdkConfigs" : {
|
||||||
|
"ad" : {},
|
||||||
|
"push" : {},
|
||||||
|
"oauth" : {},
|
||||||
|
"maps" : {}
|
||||||
|
},
|
||||||
|
"icons" : {
|
||||||
|
"android" : {
|
||||||
|
"hdpi" : "unpackage/res/icons/72x72.png",
|
||||||
|
"xhdpi" : "unpackage/res/icons/96x96.png",
|
||||||
|
"xxhdpi" : "unpackage/res/icons/144x144.png",
|
||||||
|
"xxxhdpi" : "unpackage/res/icons/192x192.png"
|
||||||
|
},
|
||||||
|
"ios" : {
|
||||||
|
"appstore" : "unpackage/res/icons/1024x1024.png",
|
||||||
|
"ipad" : {
|
||||||
|
"app" : "unpackage/res/icons/76x76.png",
|
||||||
|
"app@2x" : "unpackage/res/icons/152x152.png",
|
||||||
|
"notification" : "unpackage/res/icons/20x20.png",
|
||||||
|
"notification@2x" : "unpackage/res/icons/40x40.png",
|
||||||
|
"proapp@2x" : "unpackage/res/icons/167x167.png",
|
||||||
|
"settings" : "unpackage/res/icons/29x29.png",
|
||||||
|
"settings@2x" : "unpackage/res/icons/58x58.png",
|
||||||
|
"spotlight" : "unpackage/res/icons/40x40.png",
|
||||||
|
"spotlight@2x" : "unpackage/res/icons/80x80.png"
|
||||||
|
},
|
||||||
|
"iphone" : {
|
||||||
|
"app@2x" : "unpackage/res/icons/120x120.png",
|
||||||
|
"app@3x" : "unpackage/res/icons/180x180.png",
|
||||||
|
"notification@2x" : "unpackage/res/icons/40x40.png",
|
||||||
|
"notification@3x" : "unpackage/res/icons/60x60.png",
|
||||||
|
"settings@2x" : "unpackage/res/icons/58x58.png",
|
||||||
|
"settings@3x" : "unpackage/res/icons/87x87.png",
|
||||||
|
"spotlight@2x" : "unpackage/res/icons/80x80.png",
|
||||||
|
"spotlight@3x" : "unpackage/res/icons/120x120.png"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"splashscreen" : {
|
||||||
|
"iosStyle" : "storyboard",
|
||||||
|
"ios" : {
|
||||||
|
"storyboard" : "E:/Source-code/deming/static/CustomStoryboard.zip"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/* 快应用特有相关 */
|
/* 快应用特有相关 */
|
||||||
@@ -72,7 +121,7 @@
|
|||||||
"mp-toutiao" : {
|
"mp-toutiao" : {
|
||||||
"usingComponents" : true
|
"usingComponents" : true
|
||||||
},
|
},
|
||||||
"uniStatistics": {
|
"uniStatistics" : {
|
||||||
"enable": false
|
"enable" : false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
24
pages.json
@@ -37,6 +37,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/messages/privateChat",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "uni-app",
|
||||||
|
"app-plus": {
|
||||||
|
"titleNView": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/index/index",
|
"path": "pages/index/index",
|
||||||
"style": {
|
"style": {
|
||||||
@@ -257,29 +266,28 @@
|
|||||||
},
|
},
|
||||||
"tabBar": {
|
"tabBar": {
|
||||||
"color": "#7A7E83",
|
"color": "#7A7E83",
|
||||||
"selectedColor": "#3cc51f",
|
"selectedColor": "#FF780F",
|
||||||
"borderStyle": "black",
|
"borderStyle": "black",
|
||||||
"backgroundColor": "#ffffff",
|
"backgroundColor": "#ffffff",
|
||||||
"height": "50px",
|
"height": "50px",
|
||||||
"fontSize": "10px",
|
|
||||||
"iconWidth": "24px",
|
"iconWidth": "24px",
|
||||||
"spacing": "3px",
|
"spacing": "3px",
|
||||||
"list": [{
|
"list": [{
|
||||||
"pagePath": "pages/index/index",
|
"pagePath": "pages/index/index",
|
||||||
"iconPath": "",
|
"iconPath": "static/image/tabbar/index.png",
|
||||||
"selectedIconPath": "",
|
"selectedIconPath": "static/image/tabbar/indexselect.png",
|
||||||
"text": "首页",
|
"text": "首页",
|
||||||
"selectedColor": "#FBFBFB"
|
"selectedColor": "#FBFBFB"
|
||||||
}, {
|
}, {
|
||||||
"pagePath": "pages/messages/messagesList",
|
"pagePath": "pages/messages/messagesList",
|
||||||
"iconPath": "",
|
"iconPath": "static/image/tabbar/info.png",
|
||||||
"selectedIconPath": "",
|
"selectedIconPath": "static/image/tabbar/infoselect.png",
|
||||||
"text": "消息",
|
"text": "消息",
|
||||||
"selectedColor": "#FBFBFB"
|
"selectedColor": "#FBFBFB"
|
||||||
}, {
|
}, {
|
||||||
"pagePath": "pages/user/index",
|
"pagePath": "pages/user/index",
|
||||||
"iconPath": "",
|
"iconPath": "static/image/tabbar/mine.png",
|
||||||
"selectedIconPath": "",
|
"selectedIconPath": "static/image/tabbar/mineselect.png",
|
||||||
"text": "我的",
|
"text": "我的",
|
||||||
"selectedColor": "#FBFBFB"
|
"selectedColor": "#FBFBFB"
|
||||||
}]
|
}]
|
||||||
|
|||||||
@@ -1,38 +1,45 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="details">
|
<view class="details">
|
||||||
<view class="goods-info">
|
<view class="box" v-if="type<4">
|
||||||
<image :src="info.extend_order_goods[0].goods_image"></image>
|
<view class="goods-info" v-for="list in info.extend_order_goods">
|
||||||
<view class="info-right">
|
<image :src="list.image_480_url"></image>
|
||||||
<view class="name u-line-1">{{ info.extend_order_goods[0].goods_name }}</view>
|
<view class="info-right">
|
||||||
<view class="info">
|
<view class="name u-line-1">{{ list.goods_name }}</view>
|
||||||
<view class="num">共{{ info.extend_order_goods[0].goods_num }}件商品</view>
|
<view class="info">
|
||||||
<view class="price">
|
<view class="num">共{{ list.goods_num }}件商品</view>
|
||||||
实付
|
<view class="price">
|
||||||
<span>¥{{ info.extend_order_goods[0].goods_pay_price }}</span>
|
实付
|
||||||
|
<span>¥{{ list.goods_pay_price }}</span>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="refunds-user" v-if="type == 2 || type == 3 || type == 4 || type == 5 || type == 6">
|
<u-radio-group class="box" v-model="value" v-if="type>3">
|
||||||
<view>
|
<view class="goods-info" v-for="list in info.refund_list">
|
||||||
<image src="/static/image/home/2.png"></image>
|
<image :src="list.goods_image"></image>
|
||||||
<view>{{ info.extend_order_common.reciver_name }}</view>
|
<view class="info-right">
|
||||||
|
<view class="name u-line-1">{{ list.goods_name }}</view>
|
||||||
|
<view class="info">
|
||||||
|
<view class="num">共{{ list.goods_num }}件商品</view>
|
||||||
|
<view class="price">
|
||||||
|
实付
|
||||||
|
<span>¥{{ list.refund_amount }}</span>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<u-radio :name="list.refund_id" v-if="type==4" shape="circle" @change="radioGroupChange">
|
||||||
|
</u-radio >
|
||||||
</view>
|
</view>
|
||||||
<view>
|
</u-radio-group>
|
||||||
<image src="/static/image/home/3.png"></image>
|
<!-- 待处理 -->
|
||||||
<view>{{ info.extend_order_common.reciver_info.mob_phone }}</view>
|
|
||||||
</view>
|
|
||||||
<view>
|
|
||||||
<image src="/static/image/home/4.png"></image>
|
|
||||||
<view class="address u-line-1">{{ info.extend_order_common.reciver_info.address }}</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="user-info" v-if="type == 1">
|
<view class="user-info" v-if="type == 1">
|
||||||
<view class="info-title">收件人信息</view>
|
<view class="info-title">收件人信息</view>
|
||||||
<view class="info-container">
|
<view class="info-container">
|
||||||
<view>
|
<view>
|
||||||
<view class="title">姓名</view>
|
<view class="title">姓名</view>
|
||||||
<view class="value">{{ info.extend_order_common.reciver_name }}</view>
|
<view class="value">{{ info.extend_order_common.reciver_name }}</view>
|
||||||
|
<image src="/static/image/home/chat.png" @click="tochat(info.buyer_id)"></image>
|
||||||
</view>
|
</view>
|
||||||
<view>
|
<view>
|
||||||
<view class="title">手机号</view>
|
<view class="title">手机号</view>
|
||||||
@@ -44,6 +51,24 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- 待处理之后的 -->
|
||||||
|
<view class="refunds-title" v-if="type!=1">收件人信息</view>
|
||||||
|
<view class="refunds-user" v-if="type == 2 || type == 3 || type == 4 || type == 5 || type == 6|| type == 7">
|
||||||
|
<view>
|
||||||
|
<image src="/static/image/home/2.png"></image>
|
||||||
|
<view>{{ info.extend_order_common.reciver_name }}</view>
|
||||||
|
<image src="/static/image/home/chat.png" @click="tochat(info.buyer_id)"></image>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<image src="/static/image/home/3.png"></image>
|
||||||
|
<view>{{ info.extend_order_common.reciver_info.mob_phone }}</view>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<image src="/static/image/home/4.png"></image>
|
||||||
|
<view class="address u-line-1">{{ info.extend_order_common.reciver_info.address }}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- 待处理 -->
|
||||||
<view class="delivery" v-if="type == 1">
|
<view class="delivery" v-if="type == 1">
|
||||||
<view class="title">派送方式</view>
|
<view class="title">派送方式</view>
|
||||||
<view class="methods">
|
<view class="methods">
|
||||||
@@ -52,19 +77,25 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="btn" @click="confirmpushstyle">确认</view>
|
<view class="btn" @click="confirmpushstyle">确认</view>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- 已发货 -->
|
||||||
<view class="pushtimeline" v-if="type == 2">
|
<view class="pushtimeline" v-if="type == 2">
|
||||||
<view class="timelinetitle">物流信息</view>
|
<view class="timelinetitle">物流信息</view>
|
||||||
<view class="timelineid">订单单号:{{ info.order_sn }}</view>
|
<view class="timelineid">订单单号: {{ info.order_sn }}</view>
|
||||||
<view class="timelinebox" v-for="list in info.express_list">
|
<view class="timelinebox" v-for="list in info.express_list">
|
||||||
<view class="timelinecontent">{{list.content}}</view>
|
<view class="timelinecontent">{{list.content}}</view>
|
||||||
<view class="timelinetime">{{list.kd_time}}</view>
|
<view class="timelinetime">{{list.kd_time}}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- 已完成 -->
|
||||||
|
<!-- 退款处理 -->
|
||||||
<view class="refunds-option" v-if="type == 4">
|
<view class="refunds-option" v-if="type == 4">
|
||||||
<view :class="{ active: cur == 0 }" @click="unrefuse">不处理</view>
|
<view :class="{ active: cur == 0 }" @click="unrefuse">不处理</view>
|
||||||
<view :class="{ active: cur == 1 }" @click="refuse">确定处理</view>
|
<view :class="{ active: cur == 1 }" @click="refuse">确定处理</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="refund" v-if="type == 5 || type == 6">退款状态:{{ type == 5 ? '同意退款,请注意查收' : '拒绝退款,请等待客服联系' }}</view>
|
<!-- 同意退款/拒绝退款 -->
|
||||||
|
<view class="refund" v-if="type == 5 ">退款状态:同意退款,请注意查收!</view>
|
||||||
|
<view class="refund" v-if="type == 6 ">退款状态:商家同意退款,等待后台处理!</view>
|
||||||
|
<view class="refund" v-if="type == 7 ">退款状态:商家拒绝退款,请等待客服联系!</view>
|
||||||
<u-popup v-model="showDelivery" mode="center" border-radius="10" class="delivery-popup">
|
<u-popup v-model="showDelivery" mode="center" border-radius="10" class="delivery-popup">
|
||||||
<view class="title">骑手信息</view>
|
<view class="title">骑手信息</view>
|
||||||
<view class="input-info">
|
<view class="input-info">
|
||||||
@@ -74,7 +105,8 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="btn" @click="showDelivery = false">确认</view>
|
<view class="btn" @click="showDelivery = false">确认</view>
|
||||||
</u-popup>
|
</u-popup>
|
||||||
<u-picker mode="selector" v-model="show" :default-selector="[0]" :range="list" range-key="content" @confirm="getselect"></u-picker>
|
<!-- <u-picker mode="selector" v-model="show" :default-selector="[0]" :range="list" range-key="content" @confirm="getselect" confirm-color="#ff780f;"></u-picker> -->
|
||||||
|
<u-select v-model="show" :list="list" @confirm="getselect" confirm-color="#FF780F"></u-select>
|
||||||
<!-- companylist -->
|
<!-- companylist -->
|
||||||
<u-picker
|
<u-picker
|
||||||
mode="selector"
|
mode="selector"
|
||||||
@@ -128,29 +160,84 @@ export default {
|
|||||||
express: '',
|
express: '',
|
||||||
type: '',
|
type: '',
|
||||||
orderid: 0,
|
orderid: 0,
|
||||||
info: {},
|
info: {
|
||||||
|
extend_order_goods:[{}],
|
||||||
|
extend_order_common:{
|
||||||
|
reciver_info:{
|
||||||
|
mob_phone:"",
|
||||||
|
address:""
|
||||||
|
},
|
||||||
|
receive_name:""
|
||||||
|
}
|
||||||
|
},
|
||||||
list: [],
|
list: [],
|
||||||
pushid: null,
|
pushid: null,
|
||||||
pushstate: false, //显示物流单号
|
pushstate: false, //显示物流单号
|
||||||
selctcar: null, //骑手信息
|
selctcar: null, //骑手信息
|
||||||
companyidA: null, //物流派送公司id
|
companyidA: null, //物流派送公司id
|
||||||
companyidB: null //骑手派送公司id
|
companyidB: null, //骑手派送公司id
|
||||||
|
value:"",
|
||||||
|
refundid:null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onLoad(option) {
|
onLoad(option) {
|
||||||
this.type = option.type;
|
this.type = option.type;
|
||||||
|
console.log(this.type)
|
||||||
this.orderid = option.id;
|
this.orderid = option.id;
|
||||||
this.resetinfo();
|
this.resetinfo();
|
||||||
if (this.type == 1) {
|
if (this.type == 1) {
|
||||||
|
// 获取快递公司
|
||||||
this.getcompanyinfo();
|
this.getcompanyinfo();
|
||||||
}
|
}
|
||||||
if (this.type == 2) {
|
if (this.type == 2) {
|
||||||
|
// 获取物流信息
|
||||||
this.getcarinfo();
|
this.getcarinfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 订单状态: 0:全部 1已付款未发货 2已发货 3已完成 4申请退款/退货 5已退款/退货 6拒绝退款/退货
|
// 订单状态: 0:全部 1已付款未发货 2已发货 3已完成 4申请退款/退货 5已退款/退货 6拒绝退款/退货
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 跳转详情页面
|
||||||
|
tochat(ID){
|
||||||
|
function Friend(uuid, name, avatar,time = "", text = "",date = "") {
|
||||||
|
this.uuid = uuid;
|
||||||
|
this.name = name;
|
||||||
|
this.avatar = avatar;
|
||||||
|
this.online = false;
|
||||||
|
this.unReadMessage = 0;
|
||||||
|
this.text = text;
|
||||||
|
this.time = time;
|
||||||
|
this.date = date
|
||||||
|
}
|
||||||
|
console.log(ID)
|
||||||
|
const token = uni.getStorageSync('token');
|
||||||
|
let that = this
|
||||||
|
uni.request({
|
||||||
|
url:"https://dmmall.sdbairui.com/api/Specialci/getAtwillUserInfo",
|
||||||
|
data:{
|
||||||
|
userId: ID
|
||||||
|
},
|
||||||
|
method:"POST",
|
||||||
|
header:{
|
||||||
|
"Authorization" : 'Bearer' + " " + token
|
||||||
|
},
|
||||||
|
success(res){
|
||||||
|
console.log(res)
|
||||||
|
res = res.data
|
||||||
|
let user = new Friend(res.data.member_id,res.data.member_nickname,res.data.member_avatar)
|
||||||
|
that.$u.route({
|
||||||
|
url:"/pages/messages/privateChat",
|
||||||
|
params:{
|
||||||
|
id:JSON.stringify(user)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 退款单选
|
||||||
|
radioGroupChange(e) {
|
||||||
|
this.refundid = e
|
||||||
|
console.log(e);
|
||||||
|
},
|
||||||
// 人工配送
|
// 人工配送
|
||||||
pushstyleA() {
|
pushstyleA() {
|
||||||
this.cur = 0;
|
this.cur = 0;
|
||||||
@@ -181,9 +268,8 @@ export default {
|
|||||||
this.showRefunds = false;
|
this.showRefunds = false;
|
||||||
if (this.cur == 0) {
|
if (this.cur == 0) {
|
||||||
// 确定退款
|
// 确定退款
|
||||||
return;
|
|
||||||
this.$u.api.refund({
|
this.$u.api.refund({
|
||||||
refund_id: this.orderid,
|
refund_id: this.refundid,
|
||||||
seller_state:2,
|
seller_state:2,
|
||||||
seller_message:""
|
seller_message:""
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
@@ -197,14 +283,16 @@ export default {
|
|||||||
title: res.message,
|
title: res.message,
|
||||||
type: 'success'
|
type: 'success'
|
||||||
});
|
});
|
||||||
|
uni.navigateBack({
|
||||||
|
delta: 1
|
||||||
|
});
|
||||||
console.log(res);
|
console.log(res);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// 不进行退款
|
// 不进行退款
|
||||||
return;
|
|
||||||
this.$u.api.refund({
|
this.$u.api.refund({
|
||||||
refund_id: this.orderid,
|
refund_id: this.refundid,
|
||||||
seller_state:3,
|
seller_state:3,
|
||||||
seller_message:""
|
seller_message:""
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
@@ -218,6 +306,9 @@ export default {
|
|||||||
title: res.message,
|
title: res.message,
|
||||||
type: 'success'
|
type: 'success'
|
||||||
});
|
});
|
||||||
|
uni.navigateBack({
|
||||||
|
delta: 1
|
||||||
|
});
|
||||||
console.log(res);
|
console.log(res);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -233,25 +324,6 @@ export default {
|
|||||||
this.cur = 0;
|
this.cur = 0;
|
||||||
this.showRefunds = true;
|
this.showRefunds = true;
|
||||||
},
|
},
|
||||||
// 获取物流信息
|
|
||||||
getcarinfo() {
|
|
||||||
this.$u.api.getpushinfo({
|
|
||||||
order_id: this.orderid
|
|
||||||
}).then(res => {
|
|
||||||
if (res.errCode != 0) {
|
|
||||||
this.$refs.uToast.show({
|
|
||||||
title: res.message,
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.$refs.uToast.show({
|
|
||||||
title: res.message,
|
|
||||||
type: 'success'
|
|
||||||
});
|
|
||||||
console.log(res);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
// 选择快递公司
|
// 选择快递公司
|
||||||
getselectcompany(e) {
|
getselectcompany(e) {
|
||||||
let obj = this.companylist[e[0]];
|
let obj = this.companylist[e[0]];
|
||||||
@@ -298,13 +370,16 @@ export default {
|
|||||||
title: res.message,
|
title: res.message,
|
||||||
type: 'success'
|
type: 'success'
|
||||||
});
|
});
|
||||||
|
uni.navigateBack({
|
||||||
|
delta: 1
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 选择骑手
|
// 选择骑手
|
||||||
getselect(e) {
|
getselect(e) {
|
||||||
this.selctcar = this.list[e[0]];
|
this.selctcar = this.list[e[0].value];
|
||||||
},
|
},
|
||||||
// 获取订单信息
|
// 获取订单信息
|
||||||
resetinfo() {
|
resetinfo() {
|
||||||
@@ -331,7 +406,8 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
let arr = res.data;
|
let arr = res.data;
|
||||||
for (let index in arr) {
|
for (let index in arr) {
|
||||||
arr[index].content = arr[index].company_name + '——' + arr[index].contacts + '——' + arr[index].contact_number;
|
arr[index].value = index;
|
||||||
|
arr[index].label = arr[index].company_name + ' ' + arr[index].contacts + ' ' + arr[index].contact_number;
|
||||||
}
|
}
|
||||||
this.list = arr;
|
this.list = arr;
|
||||||
}
|
}
|
||||||
@@ -348,6 +424,7 @@ export default {
|
|||||||
background-color: #ececec;
|
background-color: #ececec;
|
||||||
.goods-info {
|
.goods-info {
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
|
width: 750rpx;
|
||||||
padding: 30rpx;
|
padding: 30rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -381,6 +458,12 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.refunds-title{
|
||||||
|
padding: 25rpx 30rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #333333;
|
||||||
|
background-color: #ffffff;
|
||||||
|
}
|
||||||
.refunds-user {
|
.refunds-user {
|
||||||
padding: 25rpx 30rpx;
|
padding: 25rpx 30rpx;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
@@ -388,6 +471,7 @@ export default {
|
|||||||
> view {
|
> view {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
margin-bottom: 30rpx;
|
margin-bottom: 30rpx;
|
||||||
@mixin image-class($width, $right) {
|
@mixin image-class($width, $right) {
|
||||||
> image {
|
> image {
|
||||||
@@ -409,6 +493,7 @@ export default {
|
|||||||
@include image-class($width: 36rpx, $right: 22rpx);
|
@include image-class($width: 36rpx, $right: 22rpx);
|
||||||
}
|
}
|
||||||
> view {
|
> view {
|
||||||
|
flex: 1;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
color: rgba(51, 51, 51, 1);
|
color: rgba(51, 51, 51, 1);
|
||||||
}
|
}
|
||||||
@@ -443,6 +528,11 @@ export default {
|
|||||||
}
|
}
|
||||||
.value {
|
.value {
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
image{
|
||||||
|
width: 40rpx;
|
||||||
|
height: 40rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,19 +2,7 @@
|
|||||||
<view class="home">
|
<view class="home">
|
||||||
<view class="image-swiper"><u-swiper :list="imageList" mode="dot" border-radius="20"></u-swiper></view>
|
<view class="image-swiper"><u-swiper :list="imageList" mode="dot" border-radius="20"></u-swiper></view>
|
||||||
<view class="tab-swiper">
|
<view class="tab-swiper">
|
||||||
<u-tabs-swiper
|
<u-tabs :list="list" font-size="26" gutter="10" item-width="130" bar-width="120" active-color="#FF780F" :current="current" @change="tabsChange"></u-tabs>
|
||||||
ref="uTabs"
|
|
||||||
:list="list"
|
|
||||||
:current="current"
|
|
||||||
@change="tabsChange"
|
|
||||||
active-color="#FF780F"
|
|
||||||
inactive-color="#333333"
|
|
||||||
font-size="26"
|
|
||||||
height="98"
|
|
||||||
:show-bar="false"
|
|
||||||
swiperWidth="750"
|
|
||||||
gutter="52"
|
|
||||||
></u-tabs-swiper>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="order-list" v-if="current == 0">
|
<view class="order-list" v-if="current == 0">
|
||||||
<view v-for="(item, index) in allorder" :key="index"><OrderItem :info="item"></OrderItem></view>
|
<view v-for="(item, index) in allorder" :key="index"><OrderItem :info="item"></OrderItem></view>
|
||||||
@@ -34,7 +22,7 @@
|
|||||||
<view class="title">选择订单号</view>
|
<view class="title">选择订单号</view>
|
||||||
<view class="worker" v-if="JSON.stringify(worker) != '{}'">
|
<view class="worker" v-if="JSON.stringify(worker) != '{}'">
|
||||||
<view>{{ worker.name }}</view>
|
<view>{{ worker.name }}</view>
|
||||||
<u-icon name="edit-pen" @click="worker = {}"></u-icon>
|
<u-icon name="arrow-down" @click="worker = {}"></u-icon>
|
||||||
</view>
|
</view>
|
||||||
<view v-else class="select" @click="showSelect = true">
|
<view v-else class="select" @click="showSelect = true">
|
||||||
<view>请选择</view>
|
<view>请选择</view>
|
||||||
@@ -50,10 +38,14 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-else-if="current == 5">
|
<view v-else-if="current == 5">
|
||||||
<view v-for="(item, index) in finshlist" :key="index"><OrderItem :cur="current"></OrderItem></view>
|
<view v-for="(item, index) in finshlist" :key="index">
|
||||||
|
<OrderItem :info="item"></OrderItem>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-else-if="current == 6">
|
<view v-else-if="current == 6">
|
||||||
<view v-for="(item, index) in badlist" :key="index"><OrderItem :cur="current"></OrderItem></view>
|
<view v-for="(item, index) in badlist" :key="index">
|
||||||
|
<OrderItem :info="item"></OrderItem>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="release-btn" @click="publish">
|
<view class="release-btn" @click="publish">
|
||||||
<image src="../../static/image/index/publish.png"></image>
|
<image src="../../static/image/index/publish.png"></image>
|
||||||
@@ -150,14 +142,15 @@ export default {
|
|||||||
this.getswiper();
|
this.getswiper();
|
||||||
// 获取可投诉列表
|
// 获取可投诉列表
|
||||||
this.getcarlist();
|
this.getcarlist();
|
||||||
|
// 所有订单
|
||||||
|
this.getallorder(0);
|
||||||
|
const user = uni.getStorageSync('userinfo');
|
||||||
|
console.log(user)
|
||||||
|
this.imService.login(user.userId,user.member_avatar,"")
|
||||||
|
this.imService.connectIM()
|
||||||
// 订单状态: 0:全部 1已付款未发货 2已发货 3已完成 4申请退款/退货 5已退款/退货 6拒绝退款/退货
|
// 订单状态: 0:全部 1已付款未发货 2已发货 3已完成 4申请退款/退货 5已退款/退货 6拒绝退款/退货
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
this.current=0
|
|
||||||
// 初始化数据
|
|
||||||
this.resetarr()
|
|
||||||
// 所有订单
|
|
||||||
this.getallorder(0);
|
|
||||||
this.publishstate = false;
|
this.publishstate = false;
|
||||||
},
|
},
|
||||||
onReachBottom() {
|
onReachBottom() {
|
||||||
@@ -197,7 +190,7 @@ export default {
|
|||||||
this.getallorder(3);
|
this.getallorder(3);
|
||||||
} else if (current == 6) {
|
} else if (current == 6) {
|
||||||
// 退货订单
|
// 退货订单
|
||||||
this.getallorder(5);
|
this.getallorder(4);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 关闭发布弹窗
|
// 关闭发布弹窗
|
||||||
@@ -353,6 +346,13 @@ export default {
|
|||||||
},
|
},
|
||||||
// 骑手投诉点击确定
|
// 骑手投诉点击确定
|
||||||
setWorker(e) {
|
setWorker(e) {
|
||||||
|
if(e[0].label==null){
|
||||||
|
this.$refs.uToast.show({
|
||||||
|
title: "选择无效",
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
return
|
||||||
|
}
|
||||||
let arr = this.carlist;
|
let arr = this.carlist;
|
||||||
for (let index in arr) {
|
for (let index in arr) {
|
||||||
if (arr[index].takeawayer_id == e[0].value) {
|
if (arr[index].takeawayer_id == e[0].value) {
|
||||||
@@ -370,9 +370,6 @@ export default {
|
|||||||
this.current = index;
|
this.current = index;
|
||||||
this.num = 1;
|
this.num = 1;
|
||||||
this.resetarr();
|
this.resetarr();
|
||||||
if (index == 6) {
|
|
||||||
this.getallorder(4);
|
|
||||||
}
|
|
||||||
this.reset();
|
this.reset();
|
||||||
},
|
},
|
||||||
// 发布内容跳转页面
|
// 发布内容跳转页面
|
||||||
@@ -400,15 +397,15 @@ export default {
|
|||||||
}
|
}
|
||||||
.complaint {
|
.complaint {
|
||||||
margin: 0 30rpx;
|
margin: 0 30rpx;
|
||||||
padding: 75rpx 30rpx;
|
padding: 100rpx 20rpx;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
.select-container {
|
.select-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 60rpx;
|
margin-bottom: 100rpx;
|
||||||
.title {
|
.title {
|
||||||
width: 180rpx;
|
width: 150rpx;
|
||||||
font-size: 30rpx;
|
font-size: 26rpx;
|
||||||
color: rgba(51, 51, 51, 1);
|
color: rgba(51, 51, 51, 1);
|
||||||
margin-right: 20rpx;
|
margin-right: 20rpx;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
@@ -446,8 +443,8 @@ export default {
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
display: flex;
|
display: flex;
|
||||||
.title {
|
.title {
|
||||||
width: 180rpx;
|
width: 150rpx;
|
||||||
font-size: 30rpx;
|
font-size: 26rpx;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
color: rgba(51, 51, 51, 1);
|
color: rgba(51, 51, 51, 1);
|
||||||
margin-right: 20rpx;
|
margin-right: 20rpx;
|
||||||
|
|||||||
@@ -13,21 +13,9 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="refunds-user" v-if="type == 2 || type == 3 || type == 4">
|
|
||||||
<view>
|
<!-- 待处理订单/已发货订单,收货人信息 -->
|
||||||
<image src="/static/image/home/2.png"></image>
|
<view class="user-info">
|
||||||
<view>{{ info.goods_try_member_name }}</view>
|
|
||||||
</view>
|
|
||||||
<view>
|
|
||||||
<image src="/static/image/home/3.png"></image>
|
|
||||||
<view>{{ info.goods_try_member_mobile }}</view>
|
|
||||||
</view>
|
|
||||||
<view>
|
|
||||||
<image src="/static/image/home/4.png"></image>
|
|
||||||
<view class="address u-line-1">{{ info.goods_try_area_info }}</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="user-info" v-if="type == 1">
|
|
||||||
<view class="info-title">收件人信息</view>
|
<view class="info-title">收件人信息</view>
|
||||||
<view class="info-container">
|
<view class="info-container">
|
||||||
<view>
|
<view>
|
||||||
@@ -42,8 +30,29 @@
|
|||||||
<view class="title">收货地址</view>
|
<view class="title">收货地址</view>
|
||||||
<view class="value u-line-1">{{ info.goods_try_area_info }}</view>
|
<view class="value u-line-1">{{ info.goods_try_area_info }}</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view v-if="type==2">
|
||||||
|
<view class="title">派送方式</view>
|
||||||
|
<view class="value u-line-1">{{ info.goods_try_deliver_goods_type==1?"人工送达":"骑手" }}</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- 已拒绝/已完成订单,收货人信息 -->
|
||||||
|
<!-- <view class="refunds-user" v-if="type == 3 || type == 4">
|
||||||
|
<view>
|
||||||
|
<image src="/static/image/home/2.png"></image>
|
||||||
|
<view>{{ info.goods_try_member_name }}</view>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<image src="/static/image/home/3.png"></image>
|
||||||
|
<view>{{ info.goods_try_member_mobile }}</view>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<image src="/static/image/home/4.png"></image>
|
||||||
|
<view class="address u-line-1">{{ info.goods_try_area_info }}</view>
|
||||||
|
</view>
|
||||||
|
</view> -->
|
||||||
|
<!-- 待处理订单 -->
|
||||||
<view class="delivery" v-if="type == 1">
|
<view class="delivery" v-if="type == 1">
|
||||||
<view class="title">派送方式</view>
|
<view class="title">派送方式</view>
|
||||||
<view class="methods">
|
<view class="methods">
|
||||||
@@ -53,35 +62,44 @@
|
|||||||
|
|
||||||
<view class="btn" @click="confirmpushstyle">确认</view>
|
<view class="btn" @click="confirmpushstyle">确认</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- <view class="refunds-option" v-if="type==4">
|
<!-- 已发货 -->
|
||||||
<view :class="{active: cur==0}" @click="cur=0;showRefunds=true">不处理</view>
|
<!-- 人工送达 -->
|
||||||
<view :class="{active: cur==1}" @click="cur=1;showRefunds=true">确定处理</view>
|
<view class="refunds-user" v-if="info.goods_try_deliver_goods_type==1&&type==2">
|
||||||
</view> -->
|
<view>
|
||||||
<!-- <u-popup v-model="showDelivery" mode="center" border-radius="10" class="delivery-popup">
|
<view>人工送达,请等待,货物正在飞速与你接近!</view>
|
||||||
<view class="title">骑手信息</view>
|
|
||||||
<view class="input-info">
|
|
||||||
<input type="text" placeholder="请输入您的姓名" v-model="name" />
|
|
||||||
<input type="text" placeholder="请输入您的手机号" v-model="phone" />
|
|
||||||
<input type="text" placeholder="请输入您的公司名称" v-model="company" />
|
|
||||||
</view>
|
</view>
|
||||||
<view class="btn">确认</view>
|
</view>
|
||||||
</u-popup> -->
|
<!-- 骑手 -->
|
||||||
|
<view class="refunds-title" v-if="type==2">配送信息</view>
|
||||||
|
<view class="refunds-title" v-if="type==3||type==4">提示信息</view>
|
||||||
|
<view class="refunds-user" v-if="info.goods_try_deliver_goods_type==2&&type==2">
|
||||||
|
<view>
|
||||||
|
<image src="/static/image/home/2.png"></image>
|
||||||
|
<view>{{ info.takeawayer_name }}</view>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<image src="/static/image/home/3.png"></image>
|
||||||
|
<view>{{ info.takeawayer_mobile }}</view>
|
||||||
|
</view>
|
||||||
|
<!-- 骑手公司 -->
|
||||||
|
<!-- <view>
|
||||||
|
<image src="/static/image/home/4.png"></image>
|
||||||
|
<view class="address u-line-1">{{ info.goods_try_area_info }}</view>
|
||||||
|
</view> -->
|
||||||
|
</view>
|
||||||
|
<!-- 已经拒绝 -->
|
||||||
|
<view class="refunds-user" v-if="type==3">
|
||||||
|
<view>
|
||||||
|
<view>抱歉,商家正忙无法接单,期待下次为您服务!</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- 已完成订单 -->
|
||||||
|
<view class="refunds-user" v-if="type==4">
|
||||||
|
<view>
|
||||||
|
<view>订单配送完成,期待下次为您服务!</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
<u-picker mode="selector" v-model="show" :default-selector="[0]" :range="list" range-key="content" @confirm="getselect"></u-picker>
|
<u-picker mode="selector" v-model="show" :default-selector="[0]" :range="list" range-key="content" @confirm="getselect"></u-picker>
|
||||||
<!-- <u-popup v-model="showExpress" mode="center" border-radius="10" class="delivery-popup">
|
|
||||||
<view class="title" @click="bindpushid">填写快递单号</view>
|
|
||||||
<view class="input-info">
|
|
||||||
<input type="text" placeholder="请输入快递单号" v-model="express" />
|
|
||||||
</view>
|
|
||||||
<view class="btn">确认</view>
|
|
||||||
</u-popup> -->
|
|
||||||
<!-- <u-popup v-model="showRefunds" mode="center" border-radius="10" class="refunds-popup">
|
|
||||||
<view v-if="cur==1" class="popup-tips">确定处理<br />平台将进行退款</view>
|
|
||||||
<view v-if="cur==0" class="popup-tips">确定不处理<br />平台将进行联系</view>
|
|
||||||
<view class="popup-btn">
|
|
||||||
<view class="cancel" @click="showRefunds=false">取消</view>
|
|
||||||
<view class="determine">确定</view>
|
|
||||||
</view>
|
|
||||||
</u-popup> -->
|
|
||||||
<u-toast ref="uToast" />
|
<u-toast ref="uToast" />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -135,6 +153,13 @@ export default {
|
|||||||
type: 'error'
|
type: 'error'
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
this.$refs.uToast.show({
|
||||||
|
title: res.message,
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
uni.navigateBack({
|
||||||
|
delta: 1
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -150,6 +175,13 @@ export default {
|
|||||||
type: 'error'
|
type: 'error'
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
this.$refs.uToast.show({
|
||||||
|
title: res.message,
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
uni.navigateBack({
|
||||||
|
delta: 1
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -234,6 +266,13 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.refunds-title{
|
||||||
|
padding: 25rpx 30rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #333333;
|
||||||
|
background-color: #ffffff;
|
||||||
|
border-bottom: 2rpx solid #ececec;
|
||||||
|
}
|
||||||
.refunds-user {
|
.refunds-user {
|
||||||
padding: 25rpx 30rpx;
|
padding: 25rpx 30rpx;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
@@ -290,7 +329,7 @@ export default {
|
|||||||
border-bottom: 2rpx solid #ececec;
|
border-bottom: 2rpx solid #ececec;
|
||||||
}
|
}
|
||||||
.title {
|
.title {
|
||||||
width: 150rpx;
|
width: 170rpx;
|
||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
margin-right: 10rpx;
|
margin-right: 10rpx;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<!-- login页面 -->
|
<!-- login页面 -->
|
||||||
<view>
|
<view>
|
||||||
<view class="login">
|
<view class="login">
|
||||||
<image class="images" :src="url"></image>
|
<!-- <image class="images" :src="url"></image> -->
|
||||||
<view class="backes"></view>
|
<view class="backes"></view>
|
||||||
<view class="title_top">德铭阳光在线-商家端</view>
|
<view class="title_top">德铭阳光在线-商家端</view>
|
||||||
<view class="content">
|
<view class="content">
|
||||||
@@ -99,10 +99,11 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 清除本地存储才可以正常登陆(具体原因没有仔细检查)
|
// 清除本地存储才可以正常登陆(具体原因没有仔细检查)
|
||||||
uni.clearStorage();
|
// uni.clearStorage();
|
||||||
// 账号登录1达人0商家
|
// 账号登录1达人0商家
|
||||||
if(this.state==1){
|
if(this.state==1){
|
||||||
this.$u.api.login({ member_name: this.zhanghaoA, member_password: this.mimaA }).then(res => {
|
this.$u.api.login({ member_name: this.zhanghaoA, member_password: this.mimaA }).then(res => {
|
||||||
|
console.log(JSON.stringify(res))
|
||||||
if (res.errCode != 0) {
|
if (res.errCode != 0) {
|
||||||
// 恢复按钮可点击状态
|
// 恢复按钮可点击状态
|
||||||
this.clickstate=false
|
this.clickstate=false
|
||||||
@@ -122,6 +123,7 @@ export default {
|
|||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
this.$u.api.shoplogin({ member_name: this.zhanghao, member_password: this.mima }).then(res => {
|
this.$u.api.shoplogin({ member_name: this.zhanghao, member_password: this.mima }).then(res => {
|
||||||
|
console.log(JSON.stringify(res))
|
||||||
if (res.errCode != 0) {
|
if (res.errCode != 0) {
|
||||||
// 恢复按钮可点击状态
|
// 恢复按钮可点击状态
|
||||||
this.clickstate=false
|
this.clickstate=false
|
||||||
@@ -156,8 +158,20 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
.login:before{
|
||||||
|
background: url(../../static/bg.png) no-repeat;
|
||||||
|
background-size: cover;
|
||||||
|
width: 750rpx;
|
||||||
|
height: 100vh;
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: -1;/*-1 可以当背景*/
|
||||||
|
-webkit-filter: blur(3px);
|
||||||
|
filter: blur(3px);
|
||||||
|
}
|
||||||
.login {
|
.login {
|
||||||
// background: url(../../static/pageA/loginbackground.png) no-repeat!important;
|
|
||||||
.images {
|
.images {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- login页面 -->
|
<!-- login页面 -->
|
||||||
<view>
|
<view :style="{'height':swiperHeight + 'px'}">
|
||||||
<view class="border_serach">
|
<!-- <view class="border_serach">
|
||||||
<view class="u-search">
|
<view class="u-search">
|
||||||
<u-search :show-action="false" input-align="left" shape="round" placeholder="搜索" v-model="keyword"></u-search>
|
<u-search :show-action="false" input-align="left" shape="round" placeholder="搜索" v-model="keyword"></u-search>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view> -->
|
||||||
<!-- 消息列表 -->
|
<!-- 消息列表 -->
|
||||||
<view class="massage_list" v-for="(item,index) in list" :key="index">
|
<u-empty text="并没有什么消息" mode="message" v-if="Object.keys(list).length == 0" style="margin: auto"></u-empty>
|
||||||
|
<view class="massage_list" v-for="(item,index) in list" :key="index" @click="gochat(item)">
|
||||||
<view class="images">
|
<view class="images">
|
||||||
<image :src="item.url" ></image>
|
<image :src="item.avatar" ></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="names">{{item.name}}</view>
|
<view class="names">{{item.name}}</view>
|
||||||
<view class="content">{{item.content}}</view>
|
<view class="content u-line-1">{{item.text}}</view>
|
||||||
<view class="times">{{item.time}}</view>
|
<view class="times">{{item.time}}</view>
|
||||||
|
<view class="tishi" v-if="item.unReadMessage"></view>
|
||||||
</view>
|
</view>
|
||||||
<u-toast ref="uToast" />
|
<u-toast ref="uToast" />
|
||||||
</view>
|
</view>
|
||||||
@@ -23,37 +25,53 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
keyword: '搜索',
|
keyword: '搜索',
|
||||||
list: [{
|
list: [
|
||||||
name: '瘦瘦',
|
|
||||||
content: "木糖少女小紫薯西装领连衣裙夏季新款女装装领连衣裙夏季装领连衣裙夏季装领连衣裙夏季夏收腰格子格纹裙子",
|
|
||||||
url: '../../static/image/tosign/tosigin(5).png',
|
|
||||||
id : '1',
|
|
||||||
time : '10:15'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '瘦瘦',
|
|
||||||
content: "木糖少女小紫薯西装领连衣裙夏季新款女装装领连衣裙夏季装领连衣裙夏季装领连衣裙夏季夏收腰格子格纹裙子",
|
|
||||||
url: '../../static/image/tosign/tosigin(5).png',
|
|
||||||
id : '1',
|
|
||||||
time : '10:15'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '瘦瘦',
|
|
||||||
content: "木糖少女小紫薯西装领连衣裙夏季新款女装装领连衣裙夏季装领连衣裙夏季装领连衣裙夏季夏收腰格子格纹裙子",
|
|
||||||
url: '../../static/image/tosign/tosigin(5).png',
|
|
||||||
id : '1',
|
|
||||||
time : '10:15'
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
gochat(id){
|
||||||
|
console.log(id)
|
||||||
|
this.$u.route({
|
||||||
|
url:"/pages/messages/privateChat",
|
||||||
|
params:{
|
||||||
|
id:JSON.stringify(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onFriendListChange(onlineFriends) {
|
||||||
|
//todo:比较垃圾的处理方式,因为Uniapp的基于MAP的双向绑定在H5端不稳定,H5端偶尔会抽风
|
||||||
|
// 下边这一行删掉,有时候页面可以更新,有时候不行,大家有优雅的方式,也欢迎跟我们沟通
|
||||||
|
console.log(onlineFriends,121212)
|
||||||
|
this.information_dl = onlineFriends;
|
||||||
|
|
||||||
|
this.$forceUpdate();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
onShow(){
|
||||||
|
// this.list = this.imService.friends;
|
||||||
|
this.imService.onFriendListChange=this.onFriendListChange;
|
||||||
|
},
|
||||||
|
onLoad(){
|
||||||
|
const res = uni.getSystemInfoSync();
|
||||||
|
this.swiperHeight = res.windowHeight;
|
||||||
|
this.list = this.imService.friends;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
.tishi{
|
||||||
|
position: absolute;
|
||||||
|
bottom: 30rpx;
|
||||||
|
right: 30rpx;
|
||||||
|
width: 12rpx;
|
||||||
|
height: 12rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: #FF0000;
|
||||||
|
}
|
||||||
.u-search{
|
.u-search{
|
||||||
width: 690rpx;
|
width: 690rpx;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
@@ -67,6 +85,7 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
border-bottom: 1px #ECECEC solid;
|
border-bottom: 1px #ECECEC solid;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
zoom: 1;
|
zoom: 1;
|
||||||
.images{
|
.images{
|
||||||
width: 84rpx;
|
width: 84rpx;
|
||||||
|
|||||||
615
pages/messages/privateChat.vue
Normal file
@@ -0,0 +1,615 @@
|
|||||||
|
<template>
|
||||||
|
<div class="chatInterface">
|
||||||
|
<div class="chat-scroll-container">
|
||||||
|
<scroll-view ref="myScroll" scroll-y="true" class="scroll-view" :scroll-into-view="contentPosition">
|
||||||
|
<div :class="[allHistoryLoaded ? 'top gray' : 'top']" @click="loadMoreHistoryMessage">
|
||||||
|
<span class="description">{{allHistoryLoaded ? '已经没有更多的历史消息' : '点击加载更多历史消息'}}</span>
|
||||||
|
</div>
|
||||||
|
<!--已经收到的消息-->
|
||||||
|
<div v-for="(message, key) in messages || []"
|
||||||
|
:id="'message_' + message.timestamp"
|
||||||
|
:key="message.timestamp"
|
||||||
|
class = "message-item"
|
||||||
|
:class="{'self' : message.senderId == (currentUser && currentUser.uuid)}">
|
||||||
|
<div :class="friend.online ? 'avatar' : 'avatar offline-gray'"
|
||||||
|
v-if="message.senderId != (currentUser && currentUser.uuid)">
|
||||||
|
<image :src="friend.avatar" ></image>
|
||||||
|
</div>
|
||||||
|
<div class="avatar" v-else>
|
||||||
|
<image :src="currentUser.avatar"></image>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<span class="text-content" v-if="message.type =='text'">{{message.payload.text}}</span>
|
||||||
|
<image class="image-content" v-if="message.type == 'image'" :src="message.payload.url" :data-url="message.payload.url" @click="showImageFullScreen" mode="widthFix" @load="scrollToBottom"></image>
|
||||||
|
<div class="video-snapshot" v-if="message.type == 'video'" :data-url="message.payload.video.url" @click="playVideo">
|
||||||
|
<image :src="message.payload.thumbnail.url" mode="aspectFit" @load="scrollToBottom"></image>
|
||||||
|
<div class="video-play-icon"></div>
|
||||||
|
</div>
|
||||||
|
<GoEasyAudioPlayer v-if="message.type =='audio'" :src="message.payload.url" :duration="message.payload.duration" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--发送中的消息-->
|
||||||
|
<div v-for="(message, index) in pendingMessages || []"
|
||||||
|
:key="index"
|
||||||
|
:id="'pendingMessage_' + index"
|
||||||
|
class = "message-item"
|
||||||
|
:class="{'self' : message.senderId == (currentUser && currentUser.uuid)}">
|
||||||
|
<div :class="friend.online ? 'avatar' : 'avatar offline-gray'"
|
||||||
|
v-if="message.senderId != (currentUser && currentUser.uuid)">
|
||||||
|
<image :src="friend.avatar"></image>
|
||||||
|
</div>
|
||||||
|
<div class="avatar" v-else>
|
||||||
|
<image :src="currentUser.avatar"></image>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<b class="pending"></b>
|
||||||
|
<span class="text-content" v-if="message.type =='text'">{{message.payload.text}}</span>
|
||||||
|
<image class="image-content" v-if="message.type == 'image'" :src="message.payload.url" mode="widthFix" @load="scrollToBottom"></image>
|
||||||
|
<div v-if="message.type == 'video'" class="video-snapshot">
|
||||||
|
<image :src="message.payload.thumbnail.url" mode="aspectFit" @load="scrollToBottom"></image>
|
||||||
|
<div class="video-play-icon"></div>
|
||||||
|
</div>
|
||||||
|
<GoEasyAudioPlayer v-if="message.type =='audio'" :src="message.payload.url" :duration="message.payload.duration" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</scroll-view>
|
||||||
|
</div>
|
||||||
|
<div class="action-box" v-if="!video.visible">
|
||||||
|
<div class="action-top">
|
||||||
|
<div :class="[audio.visible ? 'record-icon record-open':'record-icon']" @click="switchAudioKeyboard"></div>
|
||||||
|
<div class="record-input" @longpress="onRecordStart" @touchend="onRecordEnd" v-if="audio.visible" >{{audio.recording ? '松开发送' : '按住录音'}}</div>
|
||||||
|
<div class="message-input" v-else>
|
||||||
|
<input type="text" placeholder="发送消息" v-model="content">
|
||||||
|
</div>
|
||||||
|
<div class="file-icon img-video" @click="sendImage"></div>
|
||||||
|
<div class="file-icon" @click="sendVideo"></div>
|
||||||
|
<span class="send-message-btn" @click="sendMessage">发送</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="record-loading" v-if="audio.recording"></div>
|
||||||
|
<video style="width:100%;height: 100%" :src="video.url" v-if="video.visible" id="videoPlayer" autoplay="true" @fullscreenchange="onVideoFullScreenChange" @play="onVideoPlayStart"></video>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import GoEasyAudioPlayer from "../../components/GoEasyAudioPlayer/GoEasyAudioPlayer";
|
||||||
|
const recorderManager = uni.getRecorderManager();
|
||||||
|
export default {
|
||||||
|
name: "privateChat",
|
||||||
|
components : {
|
||||||
|
GoEasyAudioPlayer,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
//聊天文本框
|
||||||
|
content: '',
|
||||||
|
friend: null,
|
||||||
|
currentUser: null,
|
||||||
|
//已经接收到的消息
|
||||||
|
messages: [],
|
||||||
|
//正在发送中的消息
|
||||||
|
pendingMessages : [],
|
||||||
|
//已经加载完所有历史消息
|
||||||
|
allHistoryLoaded: false,
|
||||||
|
|
||||||
|
contentPosition : '',
|
||||||
|
|
||||||
|
audio : {
|
||||||
|
//语音录音中
|
||||||
|
recording : false,
|
||||||
|
//录音按钮展示
|
||||||
|
visible : false
|
||||||
|
},
|
||||||
|
video : {
|
||||||
|
visible : false,
|
||||||
|
url : '',
|
||||||
|
context : null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch : {
|
||||||
|
//每当新增了发送中的消息,都滑动到底部
|
||||||
|
pendingMessages(){
|
||||||
|
this.scrollToBottom()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onReady () {
|
||||||
|
this.video.context = uni.createVideoContext('videoPlayer');
|
||||||
|
},
|
||||||
|
onLoad(options) {
|
||||||
|
if(!this.imService.currentUser){
|
||||||
|
uni.navigateTo({
|
||||||
|
url : '../login/login'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//对话数据
|
||||||
|
this.friend = JSON.parse(options.id);
|
||||||
|
this.currentUser = this.imService.currentUser;
|
||||||
|
let privateMessages = this.imService.getPrivateMessages(this.friend.uuid);
|
||||||
|
this.messages = privateMessages.sentMessages;
|
||||||
|
this.pendingMessages = privateMessages.pendingMessages;
|
||||||
|
|
||||||
|
uni.setNavigationBarTitle({
|
||||||
|
title : this.friend.name
|
||||||
|
});
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.setNavigationBarColor({
|
||||||
|
backgroundColor : '#FF780F',
|
||||||
|
frontColor : '#333333'
|
||||||
|
});
|
||||||
|
}, 10);
|
||||||
|
|
||||||
|
this.initialListeners();
|
||||||
|
|
||||||
|
//每次进入聊天页面,总是滚动到底部
|
||||||
|
this.scrollToBottom()
|
||||||
|
|
||||||
|
},
|
||||||
|
onUnload() {
|
||||||
|
//退出聊天页面之前,清空页面传入的监听器
|
||||||
|
this.imService.onNewPrivateMessageReceive = (friendId, message)=> {};
|
||||||
|
this.imService.onPrivateHistoryLoad = (friendId, messages) =>{};
|
||||||
|
//将未读消息数清零
|
||||||
|
this.imService.resetFriendUnReadMessage(this.friend);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initialListeners () {
|
||||||
|
//传入监听器,收到一条私聊消息总是滚到到页面底部
|
||||||
|
this.imService.onNewPrivateMessageReceive = (friendId, message)=> {
|
||||||
|
if (friendId == this.friend.uuid) {
|
||||||
|
//收到新消息,是滚动到最底部
|
||||||
|
this.scrollToBottom()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//传入监听器,完成一次私聊历史加载时,如果加载结果为空,显示没有更多消息
|
||||||
|
this.imService.onPrivateHistoryLoad = (friendId, messages) =>{
|
||||||
|
if (messages.length == 0) {
|
||||||
|
//灰色,就不能点击了
|
||||||
|
this.allHistoryLoaded = true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// 录音监听器
|
||||||
|
this.initRecorderListeners();
|
||||||
|
},
|
||||||
|
initRecorderListeners(){
|
||||||
|
var self = this;
|
||||||
|
// 监听录音开始
|
||||||
|
recorderManager.onStart(function(){
|
||||||
|
self.audio.recording = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
//录音结束后,发送
|
||||||
|
recorderManager.onStop(function(res){
|
||||||
|
self.audio.recording = false;
|
||||||
|
self.imService.sendPrivateAudioMessage(self.friend.uuid, res)
|
||||||
|
});
|
||||||
|
|
||||||
|
// 监听录音报错
|
||||||
|
recorderManager.onError(function(res){
|
||||||
|
console.log("录音报错:",res);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
sendMessage() {//发送消息
|
||||||
|
if (this.content.trim() != '') {
|
||||||
|
this.imService.sendPrivateTextMessage(this.friend.uuid, this.content);
|
||||||
|
let that = this
|
||||||
|
setTimeout(function(){
|
||||||
|
that.scrollToBottom();
|
||||||
|
},500)
|
||||||
|
}
|
||||||
|
this.content = "";
|
||||||
|
},
|
||||||
|
loadMoreHistoryMessage() {//历史消息
|
||||||
|
let lastMessageTimeStamp = Date.now();
|
||||||
|
let lastMessage = this.messages[0];
|
||||||
|
if (lastMessage) {
|
||||||
|
lastMessageTimeStamp = lastMessage.timestamp;
|
||||||
|
}
|
||||||
|
this.imService.loadPrivateHistoryMessage(this.friend.uuid, lastMessageTimeStamp);
|
||||||
|
},
|
||||||
|
onRecordStart () {
|
||||||
|
try{
|
||||||
|
recorderManager.start();
|
||||||
|
}catch(e){
|
||||||
|
console.log("e:",e);
|
||||||
|
uni.showModal({
|
||||||
|
title: '录音错误',
|
||||||
|
content : '请在app和小程序端体验录音,Uni官方明确H5不支持getRecorderManager, 详情查看Uni官方文档'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onRecordEnd () {
|
||||||
|
try{
|
||||||
|
recorderManager.stop();
|
||||||
|
}catch(e){
|
||||||
|
console.log("e:",e);
|
||||||
|
uni.showModal({
|
||||||
|
title: '录音错误',
|
||||||
|
content : '请在app和小程序端体验录音,Uni官方明确H5不支持getRecorderManager, 详情查看Uni官方文档'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
sendVideo () {//发送文件
|
||||||
|
uni.chooseVideo({
|
||||||
|
success : (res) => {
|
||||||
|
console.log(res)
|
||||||
|
this.imService.sendPrivateVideoMessage(this.friend.uuid, res)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
sendImage() {
|
||||||
|
uni.chooseImage({
|
||||||
|
count :1,
|
||||||
|
success :(res) => {
|
||||||
|
console.log(res)
|
||||||
|
this.imService.sendPrivateImageMessage(this.friend.uuid,res);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
showImageFullScreen (e) {
|
||||||
|
var imagesUrl = [e.currentTarget.dataset.url];
|
||||||
|
uni.previewImage({
|
||||||
|
urls: imagesUrl
|
||||||
|
});
|
||||||
|
},
|
||||||
|
//语音录制按钮和键盘输入的切换
|
||||||
|
switchAudioKeyboard() {
|
||||||
|
this.audio.visible = !this.audio.visible;
|
||||||
|
},
|
||||||
|
playVideo (e) {
|
||||||
|
this.video.visible = true;
|
||||||
|
this.video.url =e.currentTarget.dataset.url;
|
||||||
|
},
|
||||||
|
onVideoPlayStart () {
|
||||||
|
this.video.context.requestFullScreen({
|
||||||
|
direction : 0
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onVideoFullScreenChange (e) {
|
||||||
|
//当退出全屏播放时,隐藏播放器
|
||||||
|
if(this.video.visible && !e.detail.fullScreen){
|
||||||
|
this.video.visible = false;
|
||||||
|
this.video.context.stop();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scrollToBottom () {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
if(this.messages && this.messages.length !=0){
|
||||||
|
this.contentPosition = 'message_' + (this.messages[this.messages.length-1].timestamp || '');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style >
|
||||||
|
page {
|
||||||
|
height: 100%;;
|
||||||
|
}
|
||||||
|
uni-page-body, uni-page-refresh {
|
||||||
|
height: 100%;;
|
||||||
|
}
|
||||||
|
.chatInterface{
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
.chatInterface .chat-scroll-container{
|
||||||
|
overflow: hidden;
|
||||||
|
padding-left: 20rpx;
|
||||||
|
padding-right: 20rpx;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.chatInterface .scroll-view{
|
||||||
|
flex: 1;
|
||||||
|
overflow: auto;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.chatInterface .top{
|
||||||
|
font-size: 24rpx;
|
||||||
|
height: 90rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
-webkit-tap-highlight-color: transparent;
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
.chatInterface .top .description{
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chatInterface .message-item{
|
||||||
|
/* max-height: 400rpx; */
|
||||||
|
margin-top: 40rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.chatInterface .avatar{
|
||||||
|
width: 80rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
margin-right:20rpx ;
|
||||||
|
}
|
||||||
|
.chatInterface .message-item.self .avatar{
|
||||||
|
margin-left: 20rpx;
|
||||||
|
}
|
||||||
|
.chatInterface .message-item .avatar image{
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chatInterface .content{
|
||||||
|
font-size: 34rpx;
|
||||||
|
line-height: 44rpx;
|
||||||
|
/* max-height: 400rpx; */
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: right;
|
||||||
|
}
|
||||||
|
.chatInterface .content .image-content{
|
||||||
|
padding: 16rpx;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
width: 300rpx;
|
||||||
|
height: 300rpx;
|
||||||
|
}
|
||||||
|
.chatInterface .content .text-content{
|
||||||
|
padding: 16rpx;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
max-width: 520rpx;
|
||||||
|
}
|
||||||
|
.chatInterface .content .pending{
|
||||||
|
background: url("../../static/images/pending.gif") no-repeat center;
|
||||||
|
background-size: 30rpx;
|
||||||
|
width: 30rpx;
|
||||||
|
height: 30rpx;
|
||||||
|
margin-right: 10rpx;
|
||||||
|
flex-grow: 0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chatInterface .action-box{
|
||||||
|
display: flex;
|
||||||
|
height: 80rpx;
|
||||||
|
padding-top: 20rpx;
|
||||||
|
padding-bottom: 20rpx;
|
||||||
|
backdrop-filter: blur(0.27rpx);
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.chatInterface .action-top{
|
||||||
|
display: flex;
|
||||||
|
padding-top: 20rpx;
|
||||||
|
padding-bottom: 20rpx;
|
||||||
|
backdrop-filter: blur(0.27rem);
|
||||||
|
height: 80rpx;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.chatInterface .record-icon{
|
||||||
|
font-size: 32rpx;
|
||||||
|
width: 80rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
line-height: 80rpx;
|
||||||
|
text-align: center;
|
||||||
|
background: url("../../static/images/record-appearance-icon.png") no-repeat center;
|
||||||
|
background-size: 50%;
|
||||||
|
-webkit-tap-highlight-color:rgba(0,0,0,0);
|
||||||
|
}
|
||||||
|
.chatInterface .action-top .file-icon{
|
||||||
|
background: url("../../static/images/vedio.png") no-repeat center;
|
||||||
|
background-size: 70%;
|
||||||
|
color: #9D9D9D;
|
||||||
|
position: relative;
|
||||||
|
width:80rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
line-height: 80rpx;
|
||||||
|
-webkit-tap-highlight-color:rgba(0,0,0,0);
|
||||||
|
}
|
||||||
|
.chatInterface .record-icon.record-open{
|
||||||
|
background: url("../../static/images/jianpan.png") no-repeat center;
|
||||||
|
background-size: 70%;
|
||||||
|
-webkit-tap-highlight-color:rgba(0,0,0,0);
|
||||||
|
}
|
||||||
|
.chatInterface .action-top .img-video{
|
||||||
|
background: url("../../static/images/file.png") no-repeat center;
|
||||||
|
background-size: 74%;
|
||||||
|
}
|
||||||
|
.chatInterface .record-input{
|
||||||
|
width: 480rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
line-height: 80rpx;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
background: #cccccc;
|
||||||
|
color: #ffffff;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.chatInterface .message-input{
|
||||||
|
border-radius: 12rpx;
|
||||||
|
}
|
||||||
|
.chatInterface .message-input input{
|
||||||
|
width: 440rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
line-height: 80rpx;
|
||||||
|
padding-left: 20rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
}
|
||||||
|
.chatInterface .send-message-btn{
|
||||||
|
font-size: 32rpx;
|
||||||
|
width: 80rpx;
|
||||||
|
line-height: 80rpx;
|
||||||
|
}
|
||||||
|
.record-loading{
|
||||||
|
position: absolute;
|
||||||
|
top:50%;
|
||||||
|
left: 50%;
|
||||||
|
width: 300rpx;
|
||||||
|
height: 300rpx;
|
||||||
|
margin: -150rpx -150rpx;
|
||||||
|
background: #262628;
|
||||||
|
background: url("../../static/images/recording-loading.gif") no-repeat center;
|
||||||
|
background-size: 100%;
|
||||||
|
border-radius: 40rpx;
|
||||||
|
}
|
||||||
|
.chatInterface .img-layer{
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background: #000000;
|
||||||
|
z-index: 9999;
|
||||||
|
padding: 6rpx;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.chatInterface .img-layer uni-image {
|
||||||
|
height: 100%!important;
|
||||||
|
}
|
||||||
|
.chatInterface .img-layer {
|
||||||
|
height: 100%!important;
|
||||||
|
width: 100%!important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.chatInterface .content .file-content .file-info{
|
||||||
|
height: 0.5rem;
|
||||||
|
width: 1.5rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 0 0.1rem;
|
||||||
|
}
|
||||||
|
.chatInterface .content .file-content .file-info .title{
|
||||||
|
height: 0.3rem;
|
||||||
|
line-height: 0.3rem;
|
||||||
|
overflow: hidden;
|
||||||
|
font-size: 0.16rem;
|
||||||
|
padding: 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
word-break: break-all;
|
||||||
|
color: #262628;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.chatInterface .content .file-content .file-info .size{
|
||||||
|
font-size: 0.14rem;
|
||||||
|
height: 0.2rem;
|
||||||
|
line-height: 0.2rem;
|
||||||
|
padding: 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
word-break: break-all;
|
||||||
|
color: #999999;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.chatInterface .video-snapshot{
|
||||||
|
position: relative;
|
||||||
|
height: 300rpx;
|
||||||
|
max-width: 400rpx;
|
||||||
|
background: #000000;
|
||||||
|
}
|
||||||
|
.chatInterface .video-snapshot image{
|
||||||
|
max-height: 300rpx;
|
||||||
|
max-width: 400rpx;
|
||||||
|
}
|
||||||
|
.chatInterface .video-snapshot video{
|
||||||
|
max-height: 300rpx;
|
||||||
|
max-width: 400rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-snapshot .video-play-icon{
|
||||||
|
position: absolute;
|
||||||
|
width: 40rpx;
|
||||||
|
height: 40rpx;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
background:url("../../static/images/play.png") no-repeat center;
|
||||||
|
background-size: 100%;
|
||||||
|
top:50%;
|
||||||
|
left: 50%;
|
||||||
|
margin:-20rpx;
|
||||||
|
}
|
||||||
|
.chatInterface .avatar{
|
||||||
|
overflow: hidden;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
.chatInterface .avatar img{
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.chatInterface .content{
|
||||||
|
float: left;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.chatInterface .content span{
|
||||||
|
font-family: Source Han Sans CN;
|
||||||
|
letter-spacing: -0.41px;
|
||||||
|
color: #262628;
|
||||||
|
background: #efefef;
|
||||||
|
display: inline-block;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
.chatInterface .message-item.self{
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
.chatInterface .message-item.self .avatar{
|
||||||
|
margin-right: 0;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
.chatInterface .message-item.self .content{
|
||||||
|
text-align: right;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
.chatInterface .message-item.self .content span{
|
||||||
|
color: #ffffff;
|
||||||
|
background:#FF780F;
|
||||||
|
word-break: break-all;
|
||||||
|
text-align: left;
|
||||||
|
max-width: 520rpx;
|
||||||
|
}
|
||||||
|
.chatInterface .action-box{
|
||||||
|
background: #FAFAFA;
|
||||||
|
display: flex;
|
||||||
|
align-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.chatInterface .message-input{
|
||||||
|
background: #efefef;
|
||||||
|
border: 0;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chatInterface .send-message-btn{
|
||||||
|
flex-grow: 1;
|
||||||
|
text-align: center;
|
||||||
|
color: #95949A;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chatInterface .member-layer{
|
||||||
|
width:100%;
|
||||||
|
height: 100%;
|
||||||
|
background: #FFFFFF;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
.member-layer .member{
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chatInterface .group-icon{
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chatInterface .gray{
|
||||||
|
color: gray!important;
|
||||||
|
text-decoration: none!important;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -32,8 +32,8 @@
|
|||||||
<!-- 标签 -->
|
<!-- 标签 -->
|
||||||
<view>
|
<view>
|
||||||
<view class="titles">标签</view>
|
<view class="titles">标签</view>
|
||||||
<view class="form-view" @click="show_add()">+ 新建标签</view>
|
<view class="form-view active" @click="show_add()">+ 新建标签</view>
|
||||||
<view :class="[item.state == true ? 'active' : '', 'form-view']" v-for="(item, index) in fileListes" :key="index" @click="changeselect(index)">
|
<view :class="['form-view', item.state == true ? 'active' : '']" v-for="(item, index) in fileListes" :key="index" @click="changeselect(index)">
|
||||||
{{ item.name }}
|
{{ item.name }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -49,7 +49,14 @@
|
|||||||
<view class="listes_shoping" v-for="(item, index) in list" :key="index">
|
<view class="listes_shoping" v-for="(item, index) in list" :key="index">
|
||||||
<view>
|
<view>
|
||||||
<u-checkbox-group>
|
<u-checkbox-group>
|
||||||
<u-checkbox @change="checkboxChange" shape="circle" active-color="#FF780F" v-model="item.checked" :name="item.goods_id"></u-checkbox>
|
<u-checkbox
|
||||||
|
shape="circle"
|
||||||
|
size="40"
|
||||||
|
active-color="#FF780F"
|
||||||
|
v-model="item.checked"
|
||||||
|
:name="index"
|
||||||
|
@change="checkboxChange"
|
||||||
|
></u-checkbox>
|
||||||
</u-checkbox-group>
|
</u-checkbox-group>
|
||||||
</view>
|
</view>
|
||||||
<view><image :src="item.goods_image" mode="widthFix"></image></view>
|
<view><image :src="item.goods_image" mode="widthFix"></image></view>
|
||||||
@@ -118,6 +125,8 @@ export default {
|
|||||||
checked: false,
|
checked: false,
|
||||||
list: [],
|
list: [],
|
||||||
List_tosign: [],
|
List_tosign: [],
|
||||||
|
flagA: true,
|
||||||
|
flagB: false,
|
||||||
scrollTop: 0,
|
scrollTop: 0,
|
||||||
imgarr: [], //上传图片数组
|
imgarr: [], //上传图片数组
|
||||||
cover: '', //图文封面
|
cover: '', //图文封面
|
||||||
@@ -137,34 +146,37 @@ export default {
|
|||||||
for (let index in arr) {
|
for (let index in arr) {
|
||||||
newarr.push(arr[index].file_id);
|
newarr.push(arr[index].file_id);
|
||||||
}
|
}
|
||||||
this.$u.api.publishphoto({
|
console.log(this.imgarrA);
|
||||||
article_title: this.form.name,
|
this.$u.api
|
||||||
article_content: this.form.intro,
|
.publishphoto({
|
||||||
article_pic: this.imgarrA[0].file_name,
|
article_title: this.form.name,
|
||||||
file_id: newarr,
|
article_content: this.form.intro,
|
||||||
goods_id_arr: this.arres_list,
|
article_pic: this.imgarrA[0].file_name,
|
||||||
label_arr: this.selectarr
|
file_id: newarr,
|
||||||
}).then(res => {
|
goods_id_arr: this.arres_list,
|
||||||
if (res.errCode != 0) {
|
label_arr: this.selectarr
|
||||||
this.$refs.uToast.show({
|
})
|
||||||
title: res.message,
|
.then(res => {
|
||||||
type: 'error'
|
if (res.errCode != 0) {
|
||||||
});
|
this.$refs.uToast.show({
|
||||||
} else {
|
title: res.message,
|
||||||
this.$refs.uToast.show({
|
type: 'error'
|
||||||
title: res.message,
|
});
|
||||||
type: 'success'
|
} else {
|
||||||
});
|
this.$refs.uToast.show({
|
||||||
setTimeout(function(){
|
title: res.message,
|
||||||
uni.navigateBack({
|
type: 'success'
|
||||||
delta:1
|
});
|
||||||
})
|
setTimeout(function() {
|
||||||
},1000)
|
uni.navigateBack({
|
||||||
}
|
delta: 1
|
||||||
});
|
});
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
// 获取商品数组变化
|
// 获取商品数组变化
|
||||||
getshoplist() {
|
getshoplist(id) {
|
||||||
let arr = this.arres_list;
|
let arr = this.arres_list;
|
||||||
let newarr = this.list;
|
let newarr = this.list;
|
||||||
this.shoplist = [];
|
this.shoplist = [];
|
||||||
@@ -175,6 +187,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log(this.shoplist)
|
||||||
},
|
},
|
||||||
// 改变选中状态
|
// 改变选中状态
|
||||||
changeselect(num) {
|
changeselect(num) {
|
||||||
@@ -207,35 +220,52 @@ export default {
|
|||||||
},
|
},
|
||||||
// 创建标签
|
// 创建标签
|
||||||
addLiveSpec() {
|
addLiveSpec() {
|
||||||
this.$u.api.createLivesp({
|
this.$u.api
|
||||||
spec_name: this.tagcontent
|
.createLivesp({
|
||||||
}).then(res => {
|
spec_name: this.tagcontent
|
||||||
if (res.errCode != 0) {
|
})
|
||||||
this.$refs.uToast.show({
|
.then(res => {
|
||||||
title: res.message,
|
if (res.errCode != 0) {
|
||||||
type: 'error'
|
this.$refs.uToast.show({
|
||||||
});
|
title: res.message,
|
||||||
} else {
|
type: 'error'
|
||||||
this.tagcontent = '';
|
});
|
||||||
this.show = false;
|
} else {
|
||||||
this.$refs.uToast.show({
|
this.tagcontent = '';
|
||||||
title: res.message,
|
this.show = false;
|
||||||
type: 'success'
|
this.$refs.uToast.show({
|
||||||
});
|
title: res.message,
|
||||||
}
|
type: 'success'
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
// 上传封面
|
// 上传封面
|
||||||
uploadcover(data) {
|
uploadcover(data) {
|
||||||
let obj = data.data;
|
console.log(data);
|
||||||
obj.url = obj.file_path;
|
if (data.errCode != 0) {
|
||||||
this.imgarrA.push(obj);
|
this.$refs.uToast.show({
|
||||||
|
title: '上传失败',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
let obj = data.data;
|
||||||
|
obj.url = obj.file_path;
|
||||||
|
this.imgarrA.push(obj);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// 上传图片
|
// 上传图片
|
||||||
uploadphoto(data) {
|
uploadphoto(data) {
|
||||||
let obj = data.data;
|
if (data.errCode != 0) {
|
||||||
obj.url = obj.file_path;
|
this.$refs.uToast.show({
|
||||||
this.imgarrB.push(obj);
|
title: '上传失败',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
let obj = data.data;
|
||||||
|
obj.url = obj.file_path;
|
||||||
|
this.imgarrB.push(obj);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
changes() {
|
changes() {
|
||||||
let that = this;
|
let that = this;
|
||||||
@@ -246,11 +276,14 @@ export default {
|
|||||||
},
|
},
|
||||||
// 选中某个复选框时,由checkbox时触发
|
// 选中某个复选框时,由checkbox时触发
|
||||||
checkboxChange(e) {
|
checkboxChange(e) {
|
||||||
let id = e.name;
|
let that = this;
|
||||||
|
let num =Number(e.name)
|
||||||
if (e.value == true) {
|
if (e.value == true) {
|
||||||
this.pushes(id);
|
that.pushes(that.list[num].goods_id);
|
||||||
|
that.list[num].checked=true
|
||||||
} else {
|
} else {
|
||||||
this.delarr(id);
|
that.delarr(that.list[num].goods_id);
|
||||||
|
that.list[num].checked=false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 删除直播商品
|
// 删除直播商品
|
||||||
@@ -307,7 +340,7 @@ export default {
|
|||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
|
||||||
.form-view {
|
.form-view {
|
||||||
background: rgba(255, 120, 15, 1);
|
background: #cdc7c8;
|
||||||
border-radius: 6rpx;
|
border-radius: 6rpx;
|
||||||
margin-right: 20rpx;
|
margin-right: 20rpx;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
@@ -317,7 +350,7 @@ export default {
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
.active {
|
.active {
|
||||||
background: red;
|
background: #ff780f;
|
||||||
}
|
}
|
||||||
.scroll {
|
.scroll {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
<view class="title">我的商品</view>
|
<view class="title">我的商品</view>
|
||||||
<u-checkbox-group>
|
<u-checkbox-group>
|
||||||
<view class="list">
|
<view class="list">
|
||||||
<shopItem @xuanzhong="xuanzhong" class="items" v-for="(i,j) in list" :key="j" :image="i.goods_image" :title="i.goods_name" :price="i.goods_marketprice" :num="i.goods_salenum" :sid="i.goods_id" ref="shop"></shopItem>
|
<shopItem @xuanzhong="xuanzhong" :wxuanzhong="sele.indexOf(i.goods_id + '') > -1" class="items" v-for="(i,j) in list" :key="j" :image="i.goods_image" :title="i.goods_name" :price="i.goods_marketprice" :num="i.goods_salenum" :sid="i.goods_id" ref="shop"></shopItem>
|
||||||
</view>
|
</view>
|
||||||
</u-checkbox-group>
|
</u-checkbox-group>
|
||||||
<view class="jiaru" @click="jiaru">加入售货袋</view>
|
<view class="jiaru" @click="jiaru" :style="{'background-color': sele.length > 0 ? 'rgba(255, 120, 15, 1' : ''}">加入售货袋</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
@@ -45,6 +45,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(){
|
onLoad(){
|
||||||
|
this.sele = uni.getStorageSync("gouwudai").split(',')
|
||||||
|
if(this.sele[0] == ""){
|
||||||
|
this.sele = []
|
||||||
|
}
|
||||||
|
console.log(this.sele[0])
|
||||||
this.$u.api.getStoreGoodsList().then((res)=>{
|
this.$u.api.getStoreGoodsList().then((res)=>{
|
||||||
this.list = res.data.list
|
this.list = res.data.list
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- tosign页面 -->
|
<!-- tosign页面 -->
|
||||||
<view>
|
<view>
|
||||||
<view class="tosign">
|
<view class="tosign" style="padding-bottom:180rpx">
|
||||||
<image class="images" src="../../static/image/login/login(2).png"></image>
|
<image class="images" src="../../static/image/login/login(2).png"></image>
|
||||||
<view class="backes"></view>
|
<view class="backes"></view>
|
||||||
<!-- z自定义导航卡 -->
|
<!-- z自定义导航卡 -->
|
||||||
<u-navbar title="" class="content" :background="background" :is-back="false" :border-bottom="false">
|
<u-navbar title="" class="content" :background="background" :is-back="false" :border-bottom="false">
|
||||||
<!-- <image src="../../static/image/tosign/tosigin(4).png"></image> -->
|
<!-- <image src="../../static/image/tosign/tosigin(4).png"></image> -->
|
||||||
<image src="../../static/image/tosign/tosigin(1).png"></image>
|
<image src="../../static/image/tosign/tosigin(1).png" @click="fanhui"></image>
|
||||||
</u-navbar>
|
</u-navbar>
|
||||||
|
|
||||||
<view id="content_tosign">
|
<view id="content_tosign">
|
||||||
@@ -21,18 +21,19 @@
|
|||||||
</u-form-item>
|
</u-form-item>
|
||||||
<view class="values"><text>{{20 - form.text.length}}</text>/20</view>
|
<view class="values"><text>{{20 - form.text.length}}</text>/20</view>
|
||||||
<u-form-item label-position="right" >
|
<u-form-item label-position="right" >
|
||||||
<u-input v-model="form.values" placeholder="我的售货袋" @click="navto('selectshop')"/>
|
<u-input :disabled="true" v-model="form.values" placeholder="我的售货袋" @click="navto('selectshop')"/>
|
||||||
<view class="rightes" @click="navto('selectshop')">售货袋</view>
|
<view class="rightes" @click="navto('selectshop')">售货袋</view>
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
</u-form>
|
</u-form>
|
||||||
<!-- 标签的引入 -->
|
<!-- 标签的引入 -->
|
||||||
<tap_tosign :fileListes="fileListes" @chuangjian="chuangjian" @qiehuan="qiehuan"></tap_tosign>
|
<tap_tosign :fileListes="fileListes" @chuangjian="chuangjian" @qiehuan="qiehuan"></tap_tosign>
|
||||||
<view class="titles">直播封面图</view>
|
<view class="titles">直播封面图</view>
|
||||||
<u-upload :form-data="{'name':'article_cover'}" action='https://dmmall.sdbairui.com/storeapi/Upload/uploadFile' name="article_cover" :header="{'Authorization' : 'Bearer' + ' ' + token}" :max-count="1" :show-progress="true" @on-change="tupian" del-color="#ececec" upload-text="上传" del-bg-color="#fff"></u-upload>
|
<u-upload :form-data="{'name':'article_cover'}" action='https://dmmall.sdbairui.com/storeapi/Upload/uploadFile' name="article_cover" :header="{'Authorization' : 'Bearer' + ' ' + token}" :max-count="1" :show-progress="true" @on-change="tupian" @on-success="sccg" del-color="#ececec" upload-text="上传" del-bg-color="#fff" :before-upload="shangchuan"></u-upload>
|
||||||
</view>
|
</view>
|
||||||
<view class="button-uview">
|
<view class="button-uview">
|
||||||
<u-button @click="kaibo">{{relerest}}</u-button>
|
<u-button :hair-line="false" @click="kaibo">{{relerest}}</u-button>
|
||||||
</view>
|
</view>
|
||||||
|
<u-toast ref="uToast" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -61,10 +62,26 @@
|
|||||||
fileListes:[],
|
fileListes:[],
|
||||||
rSelect:[],
|
rSelect:[],
|
||||||
image:"",
|
image:"",
|
||||||
token:""
|
token:"",
|
||||||
|
tiaozhuan:false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
fanhui(){
|
||||||
|
this.$u.route({
|
||||||
|
type:"back",
|
||||||
|
delta:1
|
||||||
|
})
|
||||||
|
},
|
||||||
|
shangchuan(){
|
||||||
|
uni.showLoading({
|
||||||
|
title: '上传中'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
tupian(){
|
||||||
|
uni.hideLoading()
|
||||||
|
},
|
||||||
|
sccg() {},
|
||||||
// 选中某个复选框时,由checkbox时触发
|
// 选中某个复选框时,由checkbox时触发
|
||||||
checkboxChange(e) {
|
checkboxChange(e) {
|
||||||
//console.log(e);
|
//console.log(e);
|
||||||
@@ -91,8 +108,11 @@
|
|||||||
this.init()
|
this.init()
|
||||||
},
|
},
|
||||||
tupian(a){
|
tupian(a){
|
||||||
console.log(JSON.parse(a.data))
|
// console.log(JSON.parse(a.data));
|
||||||
this.image = JSON.parse(a.data).data.file_name
|
let info = JSON.parse(a.data);
|
||||||
|
console.log(info.data.file_path);
|
||||||
|
// console.log(JSON.stringify(a.data))
|
||||||
|
this.image = info.data.file_path;
|
||||||
},
|
},
|
||||||
navto(url){
|
navto(url){
|
||||||
this.$u.route({
|
this.$u.route({
|
||||||
@@ -100,6 +120,10 @@
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
kaibo(){
|
kaibo(){
|
||||||
|
if(this.tiaozhuan){
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
this.tiaozhuan = true
|
||||||
this.$u.api.createChatRoom({
|
this.$u.api.createChatRoom({
|
||||||
chat_name:this.max,
|
chat_name:this.max,
|
||||||
live_desc:this.form.text,
|
live_desc:this.form.text,
|
||||||
@@ -108,6 +132,13 @@
|
|||||||
cover_img:this.image
|
cover_img:this.image
|
||||||
}).then((res)=>{
|
}).then((res)=>{
|
||||||
console.log(res)
|
console.log(res)
|
||||||
|
if(res.errCode == 1){
|
||||||
|
this.$refs.uToast.show({
|
||||||
|
title: res.message,
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
this.tiaozhuan = false
|
||||||
|
}
|
||||||
this.$u.route({
|
this.$u.route({
|
||||||
url:"/pages/release/zhibo",
|
url:"/pages/release/zhibo",
|
||||||
params:{
|
params:{
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
<!-- 标签 -->
|
<!-- 标签 -->
|
||||||
<view>
|
<view>
|
||||||
<view class="titles">标签</view>
|
<view class="titles">标签</view>
|
||||||
<view class="form-view" @click="show_add()">+ 新建标签</view>
|
<view class="form-view active" @click="show_add()">+ 新建标签</view>
|
||||||
<view :class="[item.state == true ? 'active' : '', 'form-view']" v-for="(item, index) in fileListes" :key="index" @click="changeselect(index)">
|
<view :class="['form-view', item.state == true ? 'active' : '']" v-for="(item, index) in fileListes" :key="index" @click="changeselect(index)">
|
||||||
{{ item.name }}
|
{{ item.name }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
<view class="listes_shoping" v-for="(item, index) in list" :key="index">
|
<view class="listes_shoping" v-for="(item, index) in list" :key="index">
|
||||||
<view>
|
<view>
|
||||||
<u-checkbox-group>
|
<u-checkbox-group>
|
||||||
<u-checkbox @change="checkboxChange" shape="circle" active-color="#FF780F" v-model="item.checked" :name="item.goods_id"></u-checkbox>
|
<u-checkbox shape="circle" size="40" active-color="#FF780F" v-model="item.checked" :name="index" @change="checkboxChange"></u-checkbox>
|
||||||
</u-checkbox-group>
|
</u-checkbox-group>
|
||||||
</view>
|
</view>
|
||||||
<view><image :src="item.goods_image" mode="widthFix"></image></view>
|
<view><image :src="item.goods_image" mode="widthFix"></image></view>
|
||||||
@@ -77,6 +77,75 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
let COS = require('../../common/cos-wx-sdk-v5.js');
|
||||||
|
// 上传文件
|
||||||
|
const upload_file_server = (_this, filepath) => {
|
||||||
|
// 腾讯云配置
|
||||||
|
let cosConfig = {
|
||||||
|
Bucket: 'dmmall-1300406074', //replace with yours
|
||||||
|
Region: 'ap-shanghai', //replace with yours
|
||||||
|
SecretId: 'AKIDjDPJhni9gTzEB9iGNWQ3PTVGjv74q7EL', //replace with yours
|
||||||
|
SecretKey: 'ye3SZOvAQO5X5LK3Vy933h6G86h4mqpG' //replace with yours
|
||||||
|
};
|
||||||
|
// 获取本地文件
|
||||||
|
let filePath = filepath;
|
||||||
|
// 自定义文件名以及路径
|
||||||
|
let time = new Date();
|
||||||
|
var y = time.getFullYear();
|
||||||
|
var m = time.getMonth() + 1;
|
||||||
|
m = m < 10 ? '0' + m : m;
|
||||||
|
var d = time.getDate();
|
||||||
|
d = d < 10 ? '0' + d : d;
|
||||||
|
let str = y + m + d;
|
||||||
|
let Key = 'video/' + str + '/' + filePath.substr(filePath.lastIndexOf('/') + 1);
|
||||||
|
// 初始化凭证
|
||||||
|
var cos = new COS({
|
||||||
|
SecretId: cosConfig.SecretId,
|
||||||
|
SecretKey: cosConfig.SecretKey
|
||||||
|
});
|
||||||
|
//上传文件
|
||||||
|
cos.postObject(
|
||||||
|
{
|
||||||
|
Bucket: cosConfig.Bucket,
|
||||||
|
Region: cosConfig.Region,
|
||||||
|
Key: Key,
|
||||||
|
StorgeClass: 'STANDARD', //存储方式
|
||||||
|
FilePath: filePath
|
||||||
|
},
|
||||||
|
(err, data) => {
|
||||||
|
console.log(err, data, 12345);
|
||||||
|
if (err == null) {
|
||||||
|
if (data.statusCode == 200) {
|
||||||
|
_this.videopath = 'https://dmmall-1300406074.cos.ap-shanghai.myqcloud.com/' + Key;
|
||||||
|
uni.hideLoading();
|
||||||
|
_this.videostate = true;
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: '上传失败!',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
// 选择图片(通用)
|
||||||
|
const cImage = _this => {
|
||||||
|
uni.chooseVideo({
|
||||||
|
count: 1,
|
||||||
|
sourceType: ['camera', 'album'],
|
||||||
|
success: function(res) {
|
||||||
|
uni.showLoading({
|
||||||
|
title: '上传中'
|
||||||
|
});
|
||||||
|
const tempFilePaths = res.tempFilePath;
|
||||||
|
console.log(tempFilePaths);
|
||||||
|
upload_file_server(_this, tempFilePaths);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -106,7 +175,8 @@ export default {
|
|||||||
selectarr: [], //选中标签
|
selectarr: [], //选中标签
|
||||||
tagcontent: '', //新建标签名字
|
tagcontent: '', //新建标签名字
|
||||||
selectvideo: '', //视频名字
|
selectvideo: '', //视频名字
|
||||||
videostate: false //视频状态
|
videostate: false, //视频状态
|
||||||
|
progress: 0
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
@@ -150,11 +220,11 @@ export default {
|
|||||||
title: res.message,
|
title: res.message,
|
||||||
type: 'success'
|
type: 'success'
|
||||||
});
|
});
|
||||||
setTimeout(function(){
|
setTimeout(function() {
|
||||||
uni.navigateBack({
|
uni.navigateBack({
|
||||||
delta:1
|
delta: 1
|
||||||
})
|
});
|
||||||
},1000)
|
}, 1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -228,36 +298,7 @@ export default {
|
|||||||
},
|
},
|
||||||
// 上传视频
|
// 上传视频
|
||||||
uploadvideo() {
|
uploadvideo() {
|
||||||
let url = this.action;
|
cImage(this);
|
||||||
let that = this;
|
|
||||||
uni.chooseVideo({
|
|
||||||
count: 1,
|
|
||||||
sourceType: ['camera', 'album'],
|
|
||||||
success: function(res) {
|
|
||||||
self.src = res.tempFilePath;
|
|
||||||
const tempFilePaths = res.tempFilePath;
|
|
||||||
uni.uploadFile({
|
|
||||||
url: url, //仅为示例,非真实的接口地址
|
|
||||||
filePath: tempFilePaths,
|
|
||||||
name: 'article_video',
|
|
||||||
formData: {
|
|
||||||
name: 'article_video'
|
|
||||||
},
|
|
||||||
header: {
|
|
||||||
Authorization: 'Bearer' + ' ' + uni.getStorageSync('token')
|
|
||||||
},
|
|
||||||
success: uploadFileRes => {
|
|
||||||
let obj = JSON.parse(uploadFileRes.data);
|
|
||||||
that.videopath = obj.data.url;
|
|
||||||
that.selectvideo = obj.data.key;
|
|
||||||
that.videostate = true;
|
|
||||||
},
|
|
||||||
fail: function(error) {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
// 新建标签
|
// 新建标签
|
||||||
show_add() {
|
show_add() {
|
||||||
@@ -270,11 +311,14 @@ export default {
|
|||||||
},
|
},
|
||||||
// 选中某个复选框时,由checkbox时触发
|
// 选中某个复选框时,由checkbox时触发
|
||||||
checkboxChange(e) {
|
checkboxChange(e) {
|
||||||
let id = e.name;
|
let that = this;
|
||||||
|
let num = Number(e.name);
|
||||||
if (e.value == true) {
|
if (e.value == true) {
|
||||||
this.pushes(id);
|
that.pushes(that.list[num].goods_id);
|
||||||
|
that.list[num].checked = true;
|
||||||
} else {
|
} else {
|
||||||
this.delarr(id);
|
that.delarr(that.list[num].goods_id);
|
||||||
|
that.list[num].checked = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 删除直播商品
|
// 删除直播商品
|
||||||
@@ -433,7 +477,7 @@ export default {
|
|||||||
-webkit-line-clamp: 2;
|
-webkit-line-clamp: 2;
|
||||||
}
|
}
|
||||||
.form-view {
|
.form-view {
|
||||||
background: rgba(255, 120, 15, 1);
|
background: #cdc7c8;
|
||||||
border-radius: 6rpx;
|
border-radius: 6rpx;
|
||||||
margin-right: 20rpx;
|
margin-right: 20rpx;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
@@ -443,7 +487,7 @@ export default {
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
.active {
|
.active {
|
||||||
background: red;
|
background: #ff780f;
|
||||||
}
|
}
|
||||||
.titles {
|
.titles {
|
||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<live-pusher id='livePusher' ref="livePusher" class="livePusher" :url="url"
|
<live-pusher id='livePusher' ref="livePusher" class="livePusher" :url="url"
|
||||||
mode="SD" :muted="false" :enable-camera="true" :auto-focus="true" :beauty="meiyan + 1" whiteness="2"
|
mode="FHD" :muted="false" :enable-camera="true" :auto-focus="true" :beauty="meiyan + 1" whiteness="0"
|
||||||
aspect="9:16" @statechange="statechange" @netstatus="netstatus" @error = "error"
|
aspect="9:16" @statechange="statechange" @netstatus="netstatus" @error = "error"
|
||||||
:style="{'height':height + 'px'}"
|
:style="{'height':height + 'px'}"
|
||||||
></live-pusher>
|
></live-pusher>
|
||||||
<div class="bottom" :style="{'height':height + 'px'}" v-if="show" @click="show = false">
|
<div class="bottom" :style="{'height':height }" v-if="show" @click="show = false">
|
||||||
<div class="tanchuceng" @click="zuzhi">
|
<div class="tanchuceng" @click="zuzhi">
|
||||||
<div class="head">
|
<div class="head">
|
||||||
<div style="flex-direction: row;align-items:center">
|
<div style="flex-direction: row;align-items:center">
|
||||||
@@ -231,6 +231,8 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
width: 750rpx;
|
||||||
|
height: 335rpx;
|
||||||
}
|
}
|
||||||
.menutitle{
|
.menutitle{
|
||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
@@ -290,22 +292,61 @@
|
|||||||
chatRoomService:{},
|
chatRoomService:{},
|
||||||
danmulist:[]
|
danmulist:[]
|
||||||
},
|
},
|
||||||
onReady() {
|
onLaunch: function() {
|
||||||
// 注意:需要在onReady中 或 onLoad 延时
|
console.log('App Launch');
|
||||||
this.context = uni.createLivePusherContext("livePusher", this);
|
},
|
||||||
|
onShow: function() {
|
||||||
|
this.stop()
|
||||||
this.startPreview()
|
this.startPreview()
|
||||||
let that = this
|
this.start()
|
||||||
uni.getSystemInfo({
|
},
|
||||||
success(a){
|
onHide: function() {
|
||||||
console.log(a.windowHeight)
|
console.log('App Hide');
|
||||||
that.height = a.windowHeight
|
},
|
||||||
// that.start()
|
//模拟onshow生命周期
|
||||||
|
created() {
|
||||||
}
|
//监听当前窗口显示
|
||||||
|
currentWebview.addEventListener('show',e=>{
|
||||||
|
console.log('search show');
|
||||||
|
this.startPreview()
|
||||||
|
this.start()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
//摧毁之前的声明周期
|
||||||
|
beforeDestroy() {
|
||||||
|
//移除监听事件
|
||||||
|
console.log(123)
|
||||||
|
currentWebview.removeEventListener('show',e=>{})
|
||||||
|
},
|
||||||
|
onReady() {
|
||||||
|
// 注意:需要在onReady中 或 onLoad 延时
|
||||||
|
let that = this
|
||||||
|
setTimeout(()=>{
|
||||||
|
uni.getSystemInfo({
|
||||||
|
success(a){
|
||||||
|
console.log(a.windowHeight,1212)
|
||||||
|
that.height = a.windowHeight
|
||||||
|
// that.start()
|
||||||
|
setTimeout(()=>{
|
||||||
|
that.context = uni.createLivePusherContext("livePusher", that);
|
||||||
|
that.startPreview()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
},500)
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
},500)
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
onLoad(a){
|
onLoad(a){
|
||||||
|
console.log(getApp().globalData.im)
|
||||||
|
|
||||||
this.url = a.url.replace("*","&")
|
this.url = a.url.replace("*","&")
|
||||||
let that = this
|
let that = this
|
||||||
const token = uni.getStorageSync('token');
|
const token = uni.getStorageSync('token');
|
||||||
@@ -336,7 +377,7 @@
|
|||||||
console.log(uni.getStorageSync('userinfo'),123)
|
console.log(uni.getStorageSync('userinfo'),123)
|
||||||
//当前用户
|
//当前用户
|
||||||
var currentUser = {
|
var currentUser = {
|
||||||
id : res.data.data.memberInfo.member_id + "",
|
id : Date.parse(new Date()) + "",
|
||||||
nickname : res.data.data.memberInfo.member_nickname + "",
|
nickname : res.data.data.memberInfo.member_nickname + "",
|
||||||
avatar: res.data.data.memberInfo.member_avatar
|
avatar: res.data.data.memberInfo.member_avatar
|
||||||
};
|
};
|
||||||
@@ -345,11 +386,11 @@
|
|||||||
id : a.id + "",
|
id : a.id + "",
|
||||||
name : a.id + ""
|
name : a.id + ""
|
||||||
};
|
};
|
||||||
console.log(room)
|
that.chatRoomService = getApp().globalData.im
|
||||||
|
console.log(room,currentUser)
|
||||||
//构造chatRoomService
|
//构造chatRoomService
|
||||||
that.chatRoomService = new ChatRoomService(room, currentUser);
|
that.chatRoomService.subscribeRoomMessage(room,currentUser)
|
||||||
that.chatRoomService.initialWhenNewMessage(that.whenNewMessage);
|
that.chatRoomService.initialWhenNewMessage(that.whenNewMessage);
|
||||||
that.chatRoomService.connectGoEasyIM();
|
|
||||||
//获取当前聊天室数据
|
//获取当前聊天室数据
|
||||||
that.room = that.chatRoomService.room;
|
that.room = that.chatRoomService.room;
|
||||||
}
|
}
|
||||||
@@ -490,6 +531,7 @@
|
|||||||
},
|
},
|
||||||
statechange(e) {
|
statechange(e) {
|
||||||
console.log("statechange:" + JSON.stringify(e));
|
console.log("statechange:" + JSON.stringify(e));
|
||||||
|
console.log(e)
|
||||||
},
|
},
|
||||||
netstatus(e) {
|
netstatus(e) {
|
||||||
// console.log("netstatus:" + JSON.stringify(e));
|
// console.log("netstatus:" + JSON.stringify(e));
|
||||||
@@ -498,6 +540,7 @@
|
|||||||
console.log("error:" + JSON.stringify(e));
|
console.log("error:" + JSON.stringify(e));
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
|
console.log("开始")
|
||||||
console.log(this.url)
|
console.log(this.url)
|
||||||
this.context.start({
|
this.context.start({
|
||||||
success: (a) => {
|
success: (a) => {
|
||||||
|
|||||||
@@ -31,12 +31,12 @@
|
|||||||
<view class="comment-list">
|
<view class="comment-list">
|
||||||
<view class="item" v-for="(item, index) in info.articlecomment" :key="index">
|
<view class="item" v-for="(item, index) in info.articlecomment" :key="index">
|
||||||
<view class="info">
|
<view class="info">
|
||||||
<image></image>
|
<image :src="item.member_avatar"></image>
|
||||||
<view class="center">
|
<view class="center">
|
||||||
<view class="name">{{item.member_nickname}}</view>
|
<view class="name">{{item.member_nickname}}{{item.reply_member_nickname==null?"评论了文章":" 回复了 "+item.reply_member_nickname}}</view>
|
||||||
<view class="time">{{item.create_time}}</view>
|
<view class="time">{{item.create_time}}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="btn" @click="showreply(item.id)">回复</view>
|
<view class="btn" @click="showreply(item.id,item.member_id)">回复</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="content u-line-1">{{item.content}}</view>
|
<view class="content u-line-1">{{item.content}}</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -63,7 +63,8 @@ export default {
|
|||||||
},
|
},
|
||||||
type:1,
|
type:1,
|
||||||
content:"",
|
content:"",
|
||||||
pid:null
|
pid:null,
|
||||||
|
replyid:null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onLoad(option) {
|
onLoad(option) {
|
||||||
@@ -74,9 +75,10 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 展示回复弹框
|
// 展示回复弹框
|
||||||
showreply(id){
|
showreply(id,replyid){
|
||||||
this.showChat = true
|
this.showChat = true
|
||||||
this.pid = id
|
this.pid = id
|
||||||
|
this.replyid = replyid
|
||||||
},
|
},
|
||||||
// 回复评论
|
// 回复评论
|
||||||
reply(){
|
reply(){
|
||||||
@@ -91,7 +93,8 @@ export default {
|
|||||||
this.$u.api.reply({
|
this.$u.api.reply({
|
||||||
pid:that.pid,
|
pid:that.pid,
|
||||||
content:that.content,
|
content:that.content,
|
||||||
article_id: that.id
|
article_id: that.id,
|
||||||
|
reply_id:that.replyid
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.errCode != 0) {
|
if (res.errCode != 0) {
|
||||||
this.$refs.uToast.show({
|
this.$refs.uToast.show({
|
||||||
@@ -101,6 +104,8 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
this.pid = "";
|
this.pid = "";
|
||||||
this.content = "";
|
this.content = "";
|
||||||
|
this.getdetail();
|
||||||
|
this.showChat = false
|
||||||
this.$refs.uToast.show({
|
this.$refs.uToast.show({
|
||||||
title: res.message,
|
title: res.message,
|
||||||
type: 'success'
|
type: 'success'
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="user">
|
<view class="user">
|
||||||
<view class="head" @click="toOthersPage('info')">
|
<view class="head" @click="toOthersPage('info')">
|
||||||
<view class="info">
|
<view class="info" :key="num">
|
||||||
<image :src="info.member_avatar"></image>
|
<image :src="info.member_avatar+'?'+new Date().getTime()"></image>
|
||||||
<view class="name">
|
<view class="name">
|
||||||
<text>{{info.member_nickname==null?"新用户":info.member_nickname}}</text>
|
<text>{{info.member_nickname==null?"新用户":info.member_nickname}}</text>
|
||||||
<text>账号:{{info.member_name}}</text>
|
<text>账号:{{info.member_name}}</text>
|
||||||
@@ -23,6 +23,10 @@
|
|||||||
<text>骑手投诉</text>
|
<text>骑手投诉</text>
|
||||||
<image src="/static/image/user/1.png"></image>
|
<image src="/static/image/user/1.png"></image>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="nav" @click="loginout()">
|
||||||
|
<text>退出登录</text>
|
||||||
|
<image src="/static/image/user/1.png"></image>
|
||||||
|
</view>
|
||||||
<u-toast ref="uToast" />
|
<u-toast ref="uToast" />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -31,13 +35,27 @@ export default {
|
|||||||
name:"user",
|
name:"user",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
info:{}
|
info:{},
|
||||||
|
num:0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
|
},
|
||||||
|
onShow() {
|
||||||
this.getmyinfo()
|
this.getmyinfo()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 退出登陆
|
||||||
|
loginout(){
|
||||||
|
uni.clearStorage();
|
||||||
|
this.$refs.uToast.show({
|
||||||
|
title: "退出登陆成功!",
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
uni.reLaunch({
|
||||||
|
url:"../login/login"
|
||||||
|
})
|
||||||
|
},
|
||||||
// 获取个人信息
|
// 获取个人信息
|
||||||
getmyinfo(){
|
getmyinfo(){
|
||||||
let that = this;
|
let that = this;
|
||||||
@@ -50,6 +68,7 @@ export default {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.info = res.data.memberInfo
|
this.info = res.data.memberInfo
|
||||||
|
this.num++
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="info">
|
<view class="info">
|
||||||
<view class="head" @click="chooseImage">
|
<view class="head" @click="chooseImage">
|
||||||
<image :src="fileurl" :key="num"></image>
|
<image :src="fileurl+'?'+new Date().getTime()"></image>
|
||||||
<text>更换头像</text>
|
<text>更换头像</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="item">
|
<view class="item">
|
||||||
@@ -35,6 +35,12 @@ export default {
|
|||||||
},
|
},
|
||||||
onNavigationBarButtonTap() {
|
onNavigationBarButtonTap() {
|
||||||
let that = this;
|
let that = this;
|
||||||
|
let obj ={
|
||||||
|
nickname:that.info.member_nickname,
|
||||||
|
avatar:that.filename,
|
||||||
|
signature:that.info.signature
|
||||||
|
}
|
||||||
|
console.log(obj)
|
||||||
this.$u.api.changeinfo({
|
this.$u.api.changeinfo({
|
||||||
nickname:that.info.member_nickname,
|
nickname:that.info.member_nickname,
|
||||||
avatar:that.filename,
|
avatar:that.filename,
|
||||||
@@ -51,6 +57,9 @@ export default {
|
|||||||
title: res.message,
|
title: res.message,
|
||||||
type: 'success'
|
type: 'success'
|
||||||
});
|
});
|
||||||
|
uni.navigateBack({
|
||||||
|
delta:1
|
||||||
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -81,7 +90,6 @@ export default {
|
|||||||
success: function(res) {
|
success: function(res) {
|
||||||
console.log(JSON.stringify(res.tempFilePaths));
|
console.log(JSON.stringify(res.tempFilePaths));
|
||||||
const tempFilePaths = res.tempFilePaths;
|
const tempFilePaths = res.tempFilePaths;
|
||||||
that.fileurl = tempFilePaths[0]
|
|
||||||
uni.uploadFile({
|
uni.uploadFile({
|
||||||
url: 'https://dmmall.sdbairui.com/storeapi/Upload/uploadFile',
|
url: 'https://dmmall.sdbairui.com/storeapi/Upload/uploadFile',
|
||||||
filePath: tempFilePaths[0],
|
filePath: tempFilePaths[0],
|
||||||
|
|||||||
BIN
static/bg.png
Normal file
|
After Width: | Height: | Size: 908 KiB |
BIN
static/image/home/chat.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 2.9 KiB |
BIN
static/image/tabbar/index.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
static/image/tabbar/indexselect.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
static/image/tabbar/info.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
static/image/tabbar/infoselect.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
static/image/tabbar/mine.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
static/image/tabbar/mineselect.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
static/images/Arrow-Left.png
Normal file
|
After Width: | Height: | Size: 222 B |
BIN
static/images/Avatar-1.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
static/images/Avatar-2.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
static/images/Avatar-3.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
static/images/Avatar-4.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
static/images/GoEasyDemo-Vue-IM-Chat-gif.gif
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
static/images/Vector.png
Normal file
|
After Width: | Height: | Size: 714 B |
BIN
static/images/file-content.png
Normal file
|
After Width: | Height: | Size: 808 B |
BIN
static/images/file-icon.png
Normal file
|
After Width: | Height: | Size: 372 B |
BIN
static/images/file.png
Normal file
|
After Width: | Height: | Size: 463 B |
BIN
static/images/green-dot.png
Normal file
|
After Width: | Height: | Size: 373 B |
BIN
static/images/group-icon.png
Normal file
|
After Width: | Height: | Size: 502 B |
BIN
static/images/group.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
static/images/im.gif
Normal file
|
After Width: | Height: | Size: 758 KiB |
BIN
static/images/jianpan.png
Normal file
|
After Width: | Height: | Size: 932 B |
BIN
static/images/loading.gif
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
static/images/logo.png
Normal file
|
After Width: | Height: | Size: 6.7 KiB |
BIN
static/images/pending.gif
Normal file
|
After Width: | Height: | Size: 771 B |
BIN
static/images/play.png
Normal file
|
After Width: | Height: | Size: 560 B |
BIN
static/images/record-appearance-icon.png
Normal file
|
After Width: | Height: | Size: 620 B |
BIN
static/images/recording-loading.gif
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
static/images/vedio.png
Normal file
|
After Width: | Height: | Size: 472 B |
931
static/imservice.js
Normal file
@@ -0,0 +1,931 @@
|
|||||||
|
/*
|
||||||
|
* @Author: jack.lu
|
||||||
|
* @Date: 2020-4-21 10:10:20
|
||||||
|
* @Last Modified by: jack.lu
|
||||||
|
* @Last Modified time: 2020-4-21 15:01:41
|
||||||
|
*/
|
||||||
|
|
||||||
|
import GoEasyIM from './goeasy-im-1.0.9';
|
||||||
|
import restApi from './restapi';
|
||||||
|
|
||||||
|
function Friend(uuid, name, avatar,time = "", text = "",date = "",unReadMessage = 0) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
this.name = name;
|
||||||
|
this.avatar = avatar;
|
||||||
|
this.online = false;
|
||||||
|
this.unReadMessage = parseInt(unReadMessage);
|
||||||
|
this.text = text;
|
||||||
|
this.time = time;
|
||||||
|
this.date = date
|
||||||
|
}
|
||||||
|
|
||||||
|
function Group(uuid, name, avatar) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
this.name = name;
|
||||||
|
this.avatar = avatar;
|
||||||
|
this.unReadMessage = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function CurrentUser(uuid, name, avatar) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
this.name = name;
|
||||||
|
this.avatar = avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
function IMService() {
|
||||||
|
this.im = GoEasyIM.getInstance({
|
||||||
|
host:'hangzhou.goeasy.io',//qos=1
|
||||||
|
appkey:'BC-453aa755c4ea48148abefc55a86df283'
|
||||||
|
});
|
||||||
|
//当前“我”
|
||||||
|
this.currentUser = null;
|
||||||
|
//我的好友
|
||||||
|
this.friends = {};
|
||||||
|
this.friendsarr = [];
|
||||||
|
//我的群
|
||||||
|
this.groups = {};
|
||||||
|
//私聊消息记录,map格式,每个好友对应一个数组
|
||||||
|
this.privateMessages = {};
|
||||||
|
|
||||||
|
//群聊消息记录,map格式,每个群对应一个数组
|
||||||
|
this.groupMessages = {};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 监听器们
|
||||||
|
*
|
||||||
|
* 可以在页面里,根据需求,重写以下监听器,
|
||||||
|
* 便于当各种事件触发时,页面能够执行对应的响应
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//收到一条私聊消息
|
||||||
|
this.onNewPrivateMessageReceive = function (friendId, message) {};
|
||||||
|
//完成一次私聊历史加载
|
||||||
|
this.onPrivateHistoryLoad = function (friendId, messages) {};
|
||||||
|
//收到一条群聊消息
|
||||||
|
this.onNewGroupMessageReceive = function (groupId, message) {};
|
||||||
|
//完成一次群聊历史加载
|
||||||
|
this.onGroupHistoryLoad = function (groupId, messages) {};
|
||||||
|
//好友列表发生改变
|
||||||
|
this.onFriendListChange = function (friends) {};
|
||||||
|
//群列表发生改变
|
||||||
|
this.onGroupListChange = function (groups) {};
|
||||||
|
|
||||||
|
this.whenNewMessage = function () {
|
||||||
|
|
||||||
|
};
|
||||||
|
this.whenOnlineUserChange = function () {
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//登录
|
||||||
|
IMService.prototype.login = function (uuid, name, avatar) {
|
||||||
|
//初始化当前用户
|
||||||
|
this.currentUser = new CurrentUser(uuid, name, avatar);
|
||||||
|
//初始化联系人信息,包括群
|
||||||
|
this.initialContacts();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//初始化联系人信息
|
||||||
|
IMService.prototype.initialContacts = function (friendList) {
|
||||||
|
//查询并初始化好友信息
|
||||||
|
// let friendList = restApi.findFriends(this.currentUser);
|
||||||
|
let value = uni.getStorageSync('imlist');
|
||||||
|
console.log(value)
|
||||||
|
if(value != undefined && !value){
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
value = JSON.parse(value)
|
||||||
|
let that = this
|
||||||
|
console.log(value)
|
||||||
|
for(let i of value){
|
||||||
|
const token = uni.getStorageSync('token');
|
||||||
|
console.log(token)
|
||||||
|
uni.request({
|
||||||
|
url:"https://dmmall.sdbairui.com/api/Specialci/getAtwillUserInfo",
|
||||||
|
data:{
|
||||||
|
userId:i[0]
|
||||||
|
},
|
||||||
|
method:"POST",
|
||||||
|
header:{
|
||||||
|
"Authorization" : 'Bearer' + " " + token
|
||||||
|
},
|
||||||
|
success(res){
|
||||||
|
console.log(res)
|
||||||
|
that.friends[i[0]] = new Friend(res.data.data.member_id, res.data.data.member_nickname, res.data.data.member_avatar,i[1],i[2],i[3]);
|
||||||
|
console.log(that.friends)
|
||||||
|
let sorts = function (friends){
|
||||||
|
let paixu = function (a,b){
|
||||||
|
if(a.date > b.date){
|
||||||
|
return 0;
|
||||||
|
}else{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
friends.sort(paixu)
|
||||||
|
|
||||||
|
}
|
||||||
|
that.friendsarr = []
|
||||||
|
for(let i in that.friends){
|
||||||
|
console.log(i)
|
||||||
|
that.friendsarr.push(that.friends[i])
|
||||||
|
}
|
||||||
|
sorts(that.friendsarr)
|
||||||
|
console.log("历史记录")
|
||||||
|
that.onFriendListChange(that.friends);
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//将用户列表初始化为一个map,便于后续根据friendId得到friend
|
||||||
|
// friendList.map(friend => {
|
||||||
|
// this.friends[friend.uuid] = new Friend(friend.uuid, friend.name, friend.avatar);
|
||||||
|
// });
|
||||||
|
|
||||||
|
//查询并初始化与自己相关的群信息
|
||||||
|
// let groupList = restApi.findGroups(this.currentUser);
|
||||||
|
|
||||||
|
// //将群列表初始化为一个map,方便后续根据groupId索引
|
||||||
|
// groupList.map(group => {
|
||||||
|
// this.groups[group.uuid] = new Group(group.uuid, group.name, group.avatar);
|
||||||
|
// });
|
||||||
|
};
|
||||||
|
|
||||||
|
//获取群成员
|
||||||
|
IMService.prototype.getGroupMembers = function (groupId) {
|
||||||
|
let members = restApi.findGroupMembers(groupId);
|
||||||
|
let membersMap = {};
|
||||||
|
members.map(item => {
|
||||||
|
membersMap[item.uuid] = item
|
||||||
|
});
|
||||||
|
return membersMap;
|
||||||
|
};
|
||||||
|
|
||||||
|
IMService.prototype.getGroupMessages = function (groupId) {
|
||||||
|
if (!this.groupMessages[groupId]) {
|
||||||
|
this.groupMessages[groupId] = {
|
||||||
|
sentMessages:[],
|
||||||
|
pendingMessages:[]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return this.groupMessages[groupId]
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
IMService.prototype.getPrivateMessages = function (friendId) {
|
||||||
|
if (!this.privateMessages[friendId]) {
|
||||||
|
this.privateMessages[friendId] = {
|
||||||
|
sentMessages:[],
|
||||||
|
pendingMessages:[]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return this.privateMessages[friendId]
|
||||||
|
};
|
||||||
|
|
||||||
|
//重置群聊未读消息
|
||||||
|
IMService.prototype.resetGroupUnReadMessage = function (group) {
|
||||||
|
this.groups[group.uuid].unReadMessage = 0;
|
||||||
|
this.onGroupListChange(this.groups);
|
||||||
|
};
|
||||||
|
|
||||||
|
//将好友的未读消息数字清零
|
||||||
|
IMService.prototype.resetFriendUnReadMessage = function (friend) {
|
||||||
|
if(friend && friend.uuid){
|
||||||
|
this.friends[friend.uuid].unReadMessage = 0;
|
||||||
|
}
|
||||||
|
this.onFriendListChange(this.friends);
|
||||||
|
};
|
||||||
|
|
||||||
|
//连接GoEasy
|
||||||
|
IMService.prototype.connectIM = function () {
|
||||||
|
//初始化IM相关的监听器
|
||||||
|
try {
|
||||||
|
this.initialIMListeners();
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.log(123)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
this.im.connect({
|
||||||
|
id: this.currentUser.uuid,
|
||||||
|
data: {
|
||||||
|
avatar: this.currentUser.avatar,
|
||||||
|
name: this.currentUser.name
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
console.log('连接成功')
|
||||||
|
//订阅与自己相关的群信息
|
||||||
|
this.subscribeGroupMessage();
|
||||||
|
//初始化好友们的在线状态
|
||||||
|
this.initialFriendOnlineStatus();
|
||||||
|
//订阅我的好友们的上下线信息
|
||||||
|
this.subscribeFriendsPresence();
|
||||||
|
}).catch(error => {
|
||||||
|
console.log('连接失败,请确保网络正常,appkey和host正确,code:' + error.code + " content:" + error.content);
|
||||||
|
this.connectIM()
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log(12323)
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//IM监听
|
||||||
|
IMService.prototype.initialIMListeners = function () {
|
||||||
|
this.im.on(GoEasyIM.EVENT.CONNECTED, () => {
|
||||||
|
console.log('连接成功.')
|
||||||
|
});
|
||||||
|
|
||||||
|
this.im.on(GoEasyIM.EVENT.DISCONNECTED, () => {
|
||||||
|
console.log('连接断开.')
|
||||||
|
});
|
||||||
|
|
||||||
|
//监听好友上下线
|
||||||
|
this.im.on(GoEasyIM.EVENT.USER_PRESENCE, (user) => {
|
||||||
|
console.log(user)
|
||||||
|
//更新好友在线状态
|
||||||
|
let onlineStatus = user.action == 'online' ? true : false;
|
||||||
|
let friend = this.friends[user.userId];
|
||||||
|
friend.online = onlineStatus;
|
||||||
|
|
||||||
|
//如果页面传入了相应的listener,执行listener
|
||||||
|
this.onFriendListChange(this.friends);
|
||||||
|
});
|
||||||
|
|
||||||
|
//监听私聊消息
|
||||||
|
this.im.on(GoEasyIM.EVENT.PRIVATE_MESSAGE_RECEIVED, (message) => {
|
||||||
|
console.log(message)
|
||||||
|
//如果不是自己发的,朋友未读消息数 +1
|
||||||
|
if (message.senderId != this.currentUser.uuid) {
|
||||||
|
let friend = this.friends[message.senderId];
|
||||||
|
console.log(friend)
|
||||||
|
// return ;
|
||||||
|
let sorts = function (friends){
|
||||||
|
let paixu = function (a,b){
|
||||||
|
if(a.date > b.date){
|
||||||
|
return 0;
|
||||||
|
}else{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
friends.sort(paixu)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
let that = this
|
||||||
|
if(!friend && friend == undefined){
|
||||||
|
const token = uni.getStorageSync('token');
|
||||||
|
console.log(token)
|
||||||
|
uni.request({
|
||||||
|
url:"https://dmmall.sdbairui.com/api/Specialci/getAtwillUserInfo",
|
||||||
|
data:{
|
||||||
|
userId:message.senderId
|
||||||
|
},
|
||||||
|
method:"POST",
|
||||||
|
header:{
|
||||||
|
"Authorization" : 'Bearer' + " " + token
|
||||||
|
},
|
||||||
|
success(res){
|
||||||
|
console.log(res)
|
||||||
|
that.friends[message.senderId] = new Friend(res.data.data.member_id, res.data.data.member_nickname, res.data.data.member_avatar);
|
||||||
|
friend = that.friends[message.senderId];
|
||||||
|
console.log(friend)
|
||||||
|
friend.unReadMessage++;
|
||||||
|
friend.text = message.type != "text" ? "其他消息" : message.payload.text
|
||||||
|
let time = new Date(message.timestamp)
|
||||||
|
friend.date = message.timestamp
|
||||||
|
friend.time = time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds()
|
||||||
|
console.log(that.friends)
|
||||||
|
that.friendsarr = []
|
||||||
|
for(let i in that.friends){
|
||||||
|
console.log(i)
|
||||||
|
that.friendsarr.push(that.friends[i])
|
||||||
|
}
|
||||||
|
sorts(that.friendsarr)
|
||||||
|
let arr = []
|
||||||
|
for(let i in that.friends){
|
||||||
|
arr.push([that.friends[i].uuid,that.friends[i].time,that.friends[i].text,that.friends[i].date,that.friends[i].unReadMessage])
|
||||||
|
}
|
||||||
|
console.log(arr)
|
||||||
|
uni.setStorageSync('imlist',JSON.stringify(arr))
|
||||||
|
let value = uni.getStorageSync('imlist');
|
||||||
|
console.log(value)
|
||||||
|
that.onFriendListChange(that.friends);
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
console.log(friend)
|
||||||
|
friend.unReadMessage++;
|
||||||
|
friend.text = message.type != "text" ? "其他消息" : message.payload.text
|
||||||
|
let time = new Date(message.timestamp)
|
||||||
|
friend.date = message.timestamp
|
||||||
|
friend.time = time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds()
|
||||||
|
console.log(this.friends)
|
||||||
|
that.friendsarr = []
|
||||||
|
for(let i in this.friends){
|
||||||
|
that.friendsarr.push(this.friends[i])
|
||||||
|
}
|
||||||
|
sorts(that.friendsarr)
|
||||||
|
let arr = []
|
||||||
|
for(let i in that.friends){
|
||||||
|
arr.push([that.friends[i].uuid,that.friends[i].time,that.friends[i].text,that.friends[i].date,that.friends[i].unReadMessage])
|
||||||
|
}
|
||||||
|
console.log(arr)
|
||||||
|
uni.setStorageSync('imlist',JSON.stringify(arr))
|
||||||
|
let value = uni.getStorageSync('imlist');
|
||||||
|
console.log(value)
|
||||||
|
this.onFriendListChange(this.friends);
|
||||||
|
|
||||||
|
}
|
||||||
|
// let value = uni.getStorageSync('imlist');
|
||||||
|
// value = JSON.parse(value)
|
||||||
|
// if(value.indexOf(message.senderId) == -1){
|
||||||
|
// value.unshift(message.senderId)
|
||||||
|
// }
|
||||||
|
// uni.setStorageSync('imlist',JSON.stringify(value))
|
||||||
|
|
||||||
|
}
|
||||||
|
//更新私聊消息记录
|
||||||
|
let friendId;
|
||||||
|
if (this.currentUser.uuid == message.senderId) {
|
||||||
|
friendId = message.receiverId;
|
||||||
|
} else {
|
||||||
|
friendId = message.senderId;
|
||||||
|
}
|
||||||
|
removePrivatePendingMessage(this, friendId, message);
|
||||||
|
|
||||||
|
let friendMessages = this.getPrivateMessages(friendId);
|
||||||
|
friendMessages.sentMessages.push(message);
|
||||||
|
|
||||||
|
//如果页面传入了相应的listener,执行listener
|
||||||
|
this.onNewPrivateMessageReceive(friendId, message);
|
||||||
|
});
|
||||||
|
|
||||||
|
// //监听群聊消息
|
||||||
|
// this.im.on(GoEasyIM.EVENT.GROUP_MESSAGE_RECEIVED, (message) => {
|
||||||
|
// let groupId = message.groupId;
|
||||||
|
// //群未读消息+1
|
||||||
|
// let group = this.groups[groupId];
|
||||||
|
// group.unReadMessage++;
|
||||||
|
// removeGroupPendingMessage(this, groupId, message);
|
||||||
|
// //如果页面传入了相应的listener,执行listener
|
||||||
|
// this.onGroupListChange(this.groups);
|
||||||
|
|
||||||
|
// //更新群聊消息记录
|
||||||
|
// let groupMessages = this.getGroupMessages(groupId);
|
||||||
|
// let sentMessages = groupMessages.sentMessages;
|
||||||
|
// sentMessages.push(message);
|
||||||
|
// //如果页面传入了相应的listener,执行listener
|
||||||
|
// this.onNewGroupMessageReceive(groupId, message);
|
||||||
|
// })
|
||||||
|
};
|
||||||
|
|
||||||
|
IMService.prototype.sendMessagesSetStorage = function (friendId,message){
|
||||||
|
let friend = this.friends[friendId];
|
||||||
|
console.log(friend)
|
||||||
|
// return ;
|
||||||
|
let sorts = function (friends){
|
||||||
|
let paixu = function (a,b){
|
||||||
|
if(a.date > b.date){
|
||||||
|
return 0;
|
||||||
|
}else{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
friends.sort(paixu)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
let that = this
|
||||||
|
if(!friend && friend == undefined){
|
||||||
|
const token = uni.getStorageSync('token');
|
||||||
|
console.log(token)
|
||||||
|
uni.request({
|
||||||
|
url:"https://dmmall.sdbairui.com/api/Specialci/getAtwillUserInfo",
|
||||||
|
data:{
|
||||||
|
userId:friendId
|
||||||
|
},
|
||||||
|
method:"POST",
|
||||||
|
header:{
|
||||||
|
"Authorization" : 'Bearer' + " " + token
|
||||||
|
},
|
||||||
|
success(res){
|
||||||
|
console.log(res)
|
||||||
|
that.friends[friendId] = new Friend(res.data.data.member_id, res.data.data.member_nickname, res.data.data.member_avatar);
|
||||||
|
friend = that.friends[friendId];
|
||||||
|
console.log(friend)
|
||||||
|
friend.text = message
|
||||||
|
let time = new Date()
|
||||||
|
friend.date = time.getTime()
|
||||||
|
friend.time = time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds()
|
||||||
|
console.log(that.friends)
|
||||||
|
that.friendsarr = []
|
||||||
|
for(let i in that.friends){
|
||||||
|
console.log(i)
|
||||||
|
that.friendsarr.push(that.friends[i])
|
||||||
|
}
|
||||||
|
sorts(that.friendsarr)
|
||||||
|
let arr = []
|
||||||
|
for(let i in that.friends){
|
||||||
|
arr.push([that.friends[i].uuid,that.friends[i].time,that.friends[i].text,that.friends[i].date,0])
|
||||||
|
}
|
||||||
|
console.log(arr)
|
||||||
|
uni.setStorageSync('imlist',JSON.stringify(arr))
|
||||||
|
|
||||||
|
that.onFriendListChange(that.friends);
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
console.log(friend)
|
||||||
|
friend.text = message
|
||||||
|
let time = new Date()
|
||||||
|
friend.date = time.getTime()
|
||||||
|
friend.time = time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds()
|
||||||
|
console.log(this.friends)
|
||||||
|
that.friendsarr = []
|
||||||
|
for(let i in this.friends){
|
||||||
|
that.friendsarr.push(this.friends[i])
|
||||||
|
}
|
||||||
|
sorts(that.friendsarr)
|
||||||
|
let arr = []
|
||||||
|
for(let i in that.friends){
|
||||||
|
arr.push([that.friends[i].uuid,that.friends[i].time,that.friends[i].text,that.friends[i].date,0])
|
||||||
|
}
|
||||||
|
console.log(arr)
|
||||||
|
uni.setStorageSync('imlist',JSON.stringify(arr))
|
||||||
|
this.onFriendListChange(this.friends);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//订阅群消息
|
||||||
|
IMService.prototype.subscribeGroupMessage = function (id) {
|
||||||
|
this.im.subscribeGroup([id])
|
||||||
|
.then(() => {
|
||||||
|
console.log('订阅群消息成功')
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log('订阅群消息失败')
|
||||||
|
console.log(error)
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
//初始化好友在线状态
|
||||||
|
IMService.prototype.initialFriendOnlineStatus = function () {
|
||||||
|
let friendIds = Object.keys(this.friends);
|
||||||
|
this.im.hereNow({
|
||||||
|
userIds: friendIds
|
||||||
|
}).then(result => {
|
||||||
|
let onlineFriends = result.content;
|
||||||
|
onlineFriends.map(user => {
|
||||||
|
let friend = this.friends[user.userId];
|
||||||
|
friend.online = true;
|
||||||
|
});
|
||||||
|
this.onFriendListChange(this.friends);
|
||||||
|
}).catch(error => {
|
||||||
|
console.log(error)
|
||||||
|
if (error.code == 401) {
|
||||||
|
console.log("获取在线用户失败,您尚未开通用户在线状态,请登录GoEasy,查看应用详情里自助启用.");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
//监听所有好友上下线
|
||||||
|
IMService.prototype.subscribeFriendsPresence = function () {
|
||||||
|
let friendIds = Object.keys(this.friends);
|
||||||
|
this.im.subscribeUserPresence(friendIds)
|
||||||
|
.then(() => {
|
||||||
|
console.log('监听好友上下线成功')
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
if (error.code == 401) {
|
||||||
|
console.log("监听好友上下线失败,您尚未开通用户状态提醒,请登录GoEasy,查看应用详情里自助启用.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
//加载单聊历史消息
|
||||||
|
IMService.prototype.loadPrivateHistoryMessage = function (friendId, timeStamp) {
|
||||||
|
this.im.history({
|
||||||
|
friendId: friendId,
|
||||||
|
lastTimestamp: timeStamp
|
||||||
|
}).then(result => {
|
||||||
|
let history = result.content;
|
||||||
|
let privateMessages = this.getPrivateMessages(friendId);
|
||||||
|
let friendMessages = privateMessages.sentMessages;
|
||||||
|
for (let i = history.length - 1; i >=0; i--) {
|
||||||
|
friendMessages.unshift(history[i])
|
||||||
|
}
|
||||||
|
//如果页面传入了相应的listener,执行listener
|
||||||
|
this.onPrivateHistoryLoad(friendId, history);
|
||||||
|
}).catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
if (error.code == 401) {
|
||||||
|
console.log("您尚未开通历史消息,请登录GoEasy,查看应用详情里自助启用.");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
//发送私聊消息
|
||||||
|
IMService.prototype.sendPrivateTextMessage = function (friendId, text) {
|
||||||
|
let textMessage = this.im.createTextMessage({
|
||||||
|
text: text
|
||||||
|
});
|
||||||
|
this.sendPrivateMessage(friendId, textMessage);
|
||||||
|
this.sendMessagesSetStorage(friendId, text)
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//私聊图片消息
|
||||||
|
IMService.prototype.sendPrivateImageMessage = function (friendId, imageFile) {
|
||||||
|
let imageMessage = this.im.createImageMessage({
|
||||||
|
file: imageFile,
|
||||||
|
onProgress :function (progress) {
|
||||||
|
console.log(progress)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.sendPrivateMessage(friendId, imageMessage);
|
||||||
|
this.sendMessagesSetStorage(friendId, '其他消息')
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//私聊视频消息
|
||||||
|
IMService.prototype.sendPrivateVideoMessage = function (friendId, videoFile) {
|
||||||
|
let videoMessage = this.im.createVideoMessage({
|
||||||
|
file: videoFile,
|
||||||
|
onProgress :function (progress) {
|
||||||
|
console.log(progress)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.sendPrivateMessage(friendId, videoMessage);
|
||||||
|
this.sendMessagesSetStorage(friendId, '其他消息')
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
IMService.prototype.sendPrivateAudioMessage = function (friendId, audiofile) {
|
||||||
|
let audioMessage = this.im.createAudioMessage({
|
||||||
|
file: audiofile,
|
||||||
|
onProgress :function (progress) {
|
||||||
|
console.log(progress)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.sendPrivateMessage(friendId, audioMessage);
|
||||||
|
this.sendMessagesSetStorage(friendId, '其他消息')
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//发送私聊消息
|
||||||
|
IMService.prototype.sendPrivateMessage = function (friendId, message) {
|
||||||
|
|
||||||
|
//加入pendingMessage列表,成功后将会被挪除
|
||||||
|
let privateMessages = this.getPrivateMessages(friendId);
|
||||||
|
privateMessages.pendingMessages.push(message);
|
||||||
|
|
||||||
|
//发送
|
||||||
|
this.im.sendPrivateMessage(friendId, message)
|
||||||
|
.then((res) => {
|
||||||
|
console.log(res)
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
console.log(e)
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
//发送群聊消息
|
||||||
|
IMService.prototype.sendGroupTextMessage = function (groupId, message) {
|
||||||
|
let textMessage = this.im.createTextMessage({
|
||||||
|
text:message
|
||||||
|
});
|
||||||
|
this.sendGroupMessage(groupId, textMessage);
|
||||||
|
};
|
||||||
|
//私聊图片消息
|
||||||
|
IMService.prototype.sendGroupImageMessage = function (groupId, imageFile) {
|
||||||
|
let imageMessage = this.im.createImageMessage({
|
||||||
|
file: imageFile,
|
||||||
|
onProgress :function (progress) {
|
||||||
|
console.log(progress)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.sendGroupMessage(groupId, imageMessage);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//私聊视频消息
|
||||||
|
IMService.prototype.sendGroupVideoMessage = function (groupId, videoFile) {
|
||||||
|
let videoMessage = this.im.createVideoMessage({
|
||||||
|
file: videoFile,
|
||||||
|
onProgress :function (progress) {
|
||||||
|
console.log(progress)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.sendGroupMessage(groupId, videoMessage);
|
||||||
|
};
|
||||||
|
|
||||||
|
IMService.prototype.sendGroupAudioMessage = function (groupId, audioFile) {
|
||||||
|
let audioMessage = this.im.createAudioMessage({
|
||||||
|
file: audioFile,
|
||||||
|
onProgress :function (progress) {
|
||||||
|
console.log(progress)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.sendGroupMessage(groupId, audioMessage);
|
||||||
|
};
|
||||||
|
|
||||||
|
IMService.prototype.sendGroupMessage =function(groupId, groupMessage) {
|
||||||
|
//先放入Pending列表,待成功后挪除
|
||||||
|
let groupMessages = this.getGroupMessages(groupId);
|
||||||
|
let pendingMessages = groupMessages.pendingMessages;
|
||||||
|
pendingMessages.push(groupMessage)
|
||||||
|
|
||||||
|
this.im.sendGroupMessage(groupId, groupMessage)
|
||||||
|
.then((res) => {
|
||||||
|
console.log(res)
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
console.log(e)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//群聊历史消息
|
||||||
|
IMService.prototype.loadGroupHistoryMessage = function (groupId, timeStamp) {
|
||||||
|
this.im.history({
|
||||||
|
groupId: groupId,
|
||||||
|
lastTimestamp: timeStamp
|
||||||
|
}).then(result => {
|
||||||
|
let history = result.content;
|
||||||
|
let groupMessages = this.getGroupMessages(groupId);
|
||||||
|
let sentGroupMessages = groupMessages.sentMessages;
|
||||||
|
for (let i = history.length - 1; i >= 0; i--) {
|
||||||
|
sentGroupMessages.unshift(history[i]);
|
||||||
|
}
|
||||||
|
this.onGroupHistoryLoad(groupId, history);
|
||||||
|
}).catch(error => {
|
||||||
|
console.log(error)
|
||||||
|
if (error.code == 401) {
|
||||||
|
console.log("您尚未开通历史消息,请登录GoEasy,查看应用详情里自助启用.");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
IMService.prototype.disconnect = function () {
|
||||||
|
this.im.disconnect()
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function removePrivatePendingMessage(imService,friendId, message){
|
||||||
|
let privateMessages = imService.getPrivateMessages(friendId);
|
||||||
|
let pendingMessages = privateMessages.pendingMessages;
|
||||||
|
let pendingMessageIndex = pendingMessages.findIndex(item => item.messageId == message.messageId);
|
||||||
|
if(pendingMessageIndex > -1) {
|
||||||
|
pendingMessages.splice(pendingMessageIndex,1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function removeGroupPendingMessage(imService,groupId, message){
|
||||||
|
let groupMessages = imService.getGroupMessages(groupId);
|
||||||
|
let pendingMessages = groupMessages.pendingMessages;
|
||||||
|
let pendingMessageIndex = pendingMessages.findIndex(item => item.messageId == message.messageId);
|
||||||
|
if(pendingMessageIndex > -1) {
|
||||||
|
pendingMessages.splice(pendingMessageIndex,1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//下面是合并的
|
||||||
|
|
||||||
|
|
||||||
|
//用户
|
||||||
|
function User(id, nickname, avatar) {
|
||||||
|
this.id = id;
|
||||||
|
this.nickname = nickname;
|
||||||
|
this.avatar = avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
//消息
|
||||||
|
function Message(senderUserId, senderNickname, content, type) {
|
||||||
|
this.senderNickname = senderNickname;
|
||||||
|
this.senderUserId = senderUserId;
|
||||||
|
this.content = content;
|
||||||
|
this.type = type
|
||||||
|
}
|
||||||
|
|
||||||
|
//聊天室
|
||||||
|
function Room(id, name, currentUser) {
|
||||||
|
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.currentUser = currentUser;
|
||||||
|
|
||||||
|
this.onlineUsers = {
|
||||||
|
count: 0,
|
||||||
|
users: []
|
||||||
|
};
|
||||||
|
|
||||||
|
this.messages = [];
|
||||||
|
|
||||||
|
this.MessageType = {
|
||||||
|
CHAT: 0,//文字聊天
|
||||||
|
PROP: 1//道具
|
||||||
|
};
|
||||||
|
|
||||||
|
this.Prop = {
|
||||||
|
HEART: 0,//桃心
|
||||||
|
ROCKET: 1//火箭
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
IMService.prototype.initialWhenNewMessage = function (whenNewMessage) {
|
||||||
|
this.whenNewMessage = whenNewMessage;
|
||||||
|
};
|
||||||
|
|
||||||
|
IMService.prototype.initialWhenOnlineUserChange = function (whenOnlineUserChange) {
|
||||||
|
this.whenOnlineUserChange = whenOnlineUserChange;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//监听新消息
|
||||||
|
IMService.prototype.listenerNewMessage = function () {
|
||||||
|
|
||||||
|
this.im.on(GoEasyIM.EVENT.GROUP_MESSAGE_RECEIVED, (message) => {
|
||||||
|
var content = JSON.parse(message.payload.text);
|
||||||
|
this.addNewMessage(message);
|
||||||
|
this.whenNewMessage(content);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
IMService.prototype.addNewMessage = function (message) {
|
||||||
|
var content = JSON.parse(message.payload.text);
|
||||||
|
let messageContent = "";
|
||||||
|
//聊天消息
|
||||||
|
if (content.type == this.room.MessageType.CHAT) {
|
||||||
|
messageContent = content.content;
|
||||||
|
}
|
||||||
|
//道具消息
|
||||||
|
if (content.type == this.room.MessageType.PROP) {
|
||||||
|
if (content.content == this.room.Prop.ROCKET) {
|
||||||
|
messageContent = "送出了一枚大火箭";
|
||||||
|
}
|
||||||
|
if (content.content == this.room.Prop.HEART) {
|
||||||
|
messageContent = "送出了一个大大的比心";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//添加消息
|
||||||
|
let newMessage = new Message(message.senderId, content.senderNickname, messageContent);
|
||||||
|
this.room.messages.push(newMessage);
|
||||||
|
};
|
||||||
|
|
||||||
|
//监听用户上下线
|
||||||
|
IMService.prototype.listenerGroupPresence = function () {
|
||||||
|
this.im.on(GoEasyIM.EVENT.GROUP_PRESENCE, (event) => {
|
||||||
|
//更新在线用户数
|
||||||
|
this.room.onlineUsers.count = event.groupOnlineCount;
|
||||||
|
|
||||||
|
if (event.action == 'join' || event.action == 'online') {
|
||||||
|
let userData = JSON.parse(event.userData);
|
||||||
|
//添加新用户
|
||||||
|
let user = new User(event.userId, userData.nickname, userData.avatar);
|
||||||
|
|
||||||
|
//添加在线用户,避免用户重复
|
||||||
|
if (!this.room.onlineUsers.users.find(item => item.id == event.userId)) {
|
||||||
|
this.room.onlineUsers.users.push(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加进入房间的消息
|
||||||
|
let message = new Message(event.userId, userData.nickname, " 进入房间", this.room.MessageType.CHAT);
|
||||||
|
this.room.messages.push(message);
|
||||||
|
} else {
|
||||||
|
let offlineUserIndex = this.room.onlineUsers.users.findIndex(item => item.id == event.userId);
|
||||||
|
if (offlineUserIndex > -1) {
|
||||||
|
//将离开的用户从onlineUsers中删掉
|
||||||
|
let offlineUser = Object.assign(this.room.onlineUsers.users[offlineUserIndex]);
|
||||||
|
this.room.onlineUsers.users.splice(offlineUserIndex, 1);
|
||||||
|
//添加离开消息
|
||||||
|
let message = new Message(offlineUser.id, offlineUser.nickname, " 离开房间", this.room.MessageType.CHAT)
|
||||||
|
this.room.messages.push(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.whenOnlineUserChange(this.room.onlineUsers);
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
//查询和初始化在线用户列表和在线用户数
|
||||||
|
IMService.prototype.initialOnlineUsers = function (roomId) {
|
||||||
|
let self = this;
|
||||||
|
|
||||||
|
//查询最新上线的用户列表
|
||||||
|
this.im.groupHereNow(roomId)
|
||||||
|
.then(result => {
|
||||||
|
if (result.code == 200) {
|
||||||
|
let users = [];
|
||||||
|
result.content && result.content.map(function (onlineUser) {
|
||||||
|
let userData = JSON.parse(onlineUser.userData);
|
||||||
|
let user = new User(onlineUser.userId, userData.nickname, userData.avatar);
|
||||||
|
users.push(user);
|
||||||
|
});
|
||||||
|
self.room.onlineUsers = {
|
||||||
|
users: users
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}).catch(e => {
|
||||||
|
if (e.code == 401) {
|
||||||
|
console.log("您还没有开通用户在线状态提醒,登录goeasy->我的应用->查看详情->高级功能,自助开通.");
|
||||||
|
} else {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//获取聊天室在线用户数
|
||||||
|
this.im.groupOnlineCount(roomId)
|
||||||
|
.then(result => {
|
||||||
|
this.room.onlineUsers.count = result.content.onlineCount;
|
||||||
|
}).catch(e => {
|
||||||
|
console.log(e)
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
//订阅聊天室成员上下线
|
||||||
|
IMService.prototype.subscribePresence = function (roomId) {
|
||||||
|
this.im.subscribeGroupPresence([roomId])
|
||||||
|
.then(() => {
|
||||||
|
console.log('成员上下线订阅成功')
|
||||||
|
}).catch(e => {
|
||||||
|
console.log(e)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//订阅聊天室消息
|
||||||
|
IMService.prototype.subscribeRoomMessage = function (room, user) {
|
||||||
|
this.room = new Room(room.id, room.name, user);
|
||||||
|
|
||||||
|
|
||||||
|
//监听上下线提醒
|
||||||
|
this.listenerGroupPresence();
|
||||||
|
|
||||||
|
//监听新消息
|
||||||
|
this.listenerNewMessage();
|
||||||
|
//订阅用户上下线事件
|
||||||
|
this.subscribePresence(this.room.id);
|
||||||
|
//订阅聊天室消息
|
||||||
|
// this.subscribeRoomMessage(this.room.id);
|
||||||
|
this.im.subscribeGroup([this.room.id])
|
||||||
|
.then(result => {
|
||||||
|
console.log('消息订阅成功')
|
||||||
|
}).catch(e => {
|
||||||
|
console.log(e,'失败')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//历史消息
|
||||||
|
IMService.prototype.initialChatHistory = function (roomId) {
|
||||||
|
var self = this;
|
||||||
|
this.im.history({
|
||||||
|
groupId: roomId
|
||||||
|
}).then(res => {
|
||||||
|
res.content.forEach(function (message) {
|
||||||
|
self.addNewMessage(message);
|
||||||
|
})
|
||||||
|
}).catch(function (error) {
|
||||||
|
if (error.code == 401) {
|
||||||
|
console.log("您还没有开通历史消息的权限,登录goeasy->我的应用->查看详情->高级功能,自助开通.");
|
||||||
|
} else {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
//发送消息
|
||||||
|
IMService.prototype.sendMessages = function (roomId, content) {
|
||||||
|
var contentMessage = {
|
||||||
|
text: JSON.stringify(content)
|
||||||
|
};
|
||||||
|
let message = this.im.createTextMessage(contentMessage);
|
||||||
|
this.im.sendGroupMessage(roomId, message)
|
||||||
|
.then(() => {
|
||||||
|
console.log('消息发送成功')
|
||||||
|
}).catch(e => {
|
||||||
|
console.log(e);
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
//退出聊天室
|
||||||
|
IMService.prototype.quitRoom = function (roomId) {
|
||||||
|
this.im.disconnect()
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export default IMService;
|
||||||
79
static/restapi.js
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
//用户数据示例
|
||||||
|
let users = [
|
||||||
|
{
|
||||||
|
"uuid": "08c0a6ec-a42b-47b2-bb1e-15e0f5f9a19a",
|
||||||
|
"name": "Mattie",
|
||||||
|
"password": "123",
|
||||||
|
"avatar": '../../static/images/Avatar-1.png'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"uuid": "3bb179af-bcc5-4fe0-9dac-c05688484649",
|
||||||
|
"name": "Wallace",
|
||||||
|
"password": "123",
|
||||||
|
"avatar": '../../static/images/Avatar-2.png'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"uuid": "fdee46b0-4b01-4590-bdba-6586d7617f95",
|
||||||
|
"name": "Tracy",
|
||||||
|
"password": "123",
|
||||||
|
"avatar": '../../static/images/Avatar-3.png'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"uuid": "33c3693b-dbb0-4bc9-99c6-fa77b9eb763f",
|
||||||
|
"name": "Juanita",
|
||||||
|
"password": "123",
|
||||||
|
"avatar": '../../static/images/Avatar-4.png'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
//群数据示例
|
||||||
|
let groups = [
|
||||||
|
{
|
||||||
|
"uuid": "group-a42b-47b2-bb1e-15e0f5f9a19a",
|
||||||
|
"name": "群1",
|
||||||
|
"userList": ['08c0a6ec-a42b-47b2-bb1e-15e0f5f9a19a', '3bb179af-bcc5-4fe0-9dac-c05688484649', 'fdee46b0-4b01-4590-bdba-6586d7617f95', '33c3693b-dbb0-4bc9-99c6-fa77b9eb763f']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"uuid": "group-4b01-4590-bdba-6586d7617f95",
|
||||||
|
"name": "群2",
|
||||||
|
"userList": ['08c0a6ec-a42b-47b2-bb1e-15e0f5f9a19a', 'fdee46b0-4b01-4590-bdba-6586d7617f95', '33c3693b-dbb0-4bc9-99c6-fa77b9eb763f']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"uuid": "group-dbb0-4bc9-99c6-fa77b9eb763f",
|
||||||
|
"name": "群3",
|
||||||
|
"userList": ['08c0a6ec-a42b-47b2-bb1e-15e0f5f9a19a', '3bb179af-bcc5-4fe0-9dac-c05688484649']
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
function RestApi() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
RestApi.prototype.findFriends = function (user) {
|
||||||
|
var friendList = users.filter(v => v.uuid != user.uuid);
|
||||||
|
return friendList;
|
||||||
|
}
|
||||||
|
|
||||||
|
RestApi.prototype.findGroups = function (user) {
|
||||||
|
var groupList = groups.filter(v => v.userList.find(id => id == user.uuid));
|
||||||
|
return groupList;
|
||||||
|
}
|
||||||
|
|
||||||
|
RestApi.prototype.findUser = function (username, password) {
|
||||||
|
var user = users.find(user => (user.name == username && user.password == password))
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
RestApi.prototype.findGroupMembers = function (groupId) {
|
||||||
|
let members = [];
|
||||||
|
let group = groups.find(v => v.uuid == groupId);
|
||||||
|
users.map(user => {
|
||||||
|
if (group.userList.find(v => v == user.uuid)) {
|
||||||
|
members.push(user)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return members;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new RestApi();
|
||||||