APP热更新
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
import {getDbDir,toastWithCallback} from "@/util/common.js";
|
||||
import {getConversationContent,conversationSort,prepareConversationState} from "@/util/imCommon";
|
||||
import {PageEvents,UpdateMessageTypes} from "@/constant";
|
||||
import {checkUpgrade} from "@/api/login.js"
|
||||
import checkUpgrade from "@/util/app_update.js"
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
// #ifndef APP
|
||||
|
||||
+2
-1
@@ -21,7 +21,8 @@ const getApiUrl = () => uni.getStorageSync("IMApiUrl") || API_URL;
|
||||
const getWsUrl = () => uni.getStorageSync("IMWsUrl") || WS_URL;
|
||||
|
||||
module.exports = {
|
||||
cdnUrl:"http://"+BASE_DOMAIN,
|
||||
//cdnUrl:"http://"+BASE_DOMAIN,
|
||||
cdnUrl:"https://shunliao.oss-accelerate.aliyuncs.com",
|
||||
version,
|
||||
getRegisterUrl,
|
||||
getApiUrl,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
:show="previewVideoFlag"
|
||||
opacity="1"
|
||||
:custom-style="customMaskStyle">
|
||||
<view @tap.stop
|
||||
<view @tap.stop="quitPlay"
|
||||
class="playBox"
|
||||
style="height:100vh;width:100vw;">
|
||||
<video
|
||||
@@ -18,7 +18,7 @@
|
||||
</video>
|
||||
<view class="quitBox" @click="quitPlay">
|
||||
<u-icon name="close-circle" color="#FFF" size="32"></u-icon>
|
||||
<cover-view class="icon"></cover-view>
|
||||
<!-- <cover-view class="icon"></cover-view> -->
|
||||
</view>
|
||||
</view>
|
||||
</u-overlay>
|
||||
@@ -99,7 +99,7 @@
|
||||
right: 5%;
|
||||
top: 10%;
|
||||
.icon{
|
||||
color: #fff;
|
||||
color: #f00;
|
||||
font-size: 32px;
|
||||
font-family: uicon-iconfont;
|
||||
}
|
||||
|
||||
+2
-1
@@ -300,7 +300,8 @@
|
||||
{
|
||||
"path": "pages/find/friend-circle/friend-circle",
|
||||
"style": {
|
||||
"navigationBarTitleText": ""
|
||||
"navigationBarTitleText": "",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -119,8 +119,8 @@
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
console.log(this.storeCurrentGroup)
|
||||
console.log(this.storeCurrentMemberInGroup)
|
||||
//console.log(this.storeCurrentGroup)
|
||||
//console.log(this.storeCurrentMemberInGroup)
|
||||
this.setKeyboardListener();
|
||||
},
|
||||
beforeDestroy() {
|
||||
|
||||
@@ -117,14 +117,14 @@
|
||||
methods: {
|
||||
async init(){
|
||||
const self = this;
|
||||
//console.log(this.message?.videoElem);
|
||||
console.log(this.message?.videoElem,this.conversationID);
|
||||
const snapshotUrl = this.message?.videoElem?.snapshotUrl;
|
||||
self.coverDownloading = true;
|
||||
//console.log(snapshotUrl);
|
||||
util.cacheFile(snapshotUrl,`${this.conversationID}`).then((fn)=>{
|
||||
self.coverDownloading = false;
|
||||
self.src = fn;
|
||||
console.log(fn);
|
||||
//console.log(fn);
|
||||
});
|
||||
},
|
||||
clickMediaItem() {
|
||||
@@ -138,20 +138,22 @@
|
||||
this.loadingWidth = "auto";
|
||||
},
|
||||
onOverlayClick() {
|
||||
const _this = this;
|
||||
// 点击覆盖层:如果视频已缓存则直接播放,否则开始下载
|
||||
const url = this.message?.videoElem?.videoUrl || this.message?.videoElem?.videoPath;
|
||||
const url = _this.message?.videoElem?.videoUrl;
|
||||
if (!url) {
|
||||
uni.showToast({ title: '无可下载的视频' });
|
||||
return;
|
||||
}
|
||||
this.videoDownloading = true;
|
||||
this.videoDownloadProgress = 0;
|
||||
util.downloadFile(url, `${this.conversationID}`, (prog) => {
|
||||
//this.videoDownloadProgress = prog;
|
||||
_this.videoDownloading = true;
|
||||
_this.videoDownloadProgress = 0;
|
||||
util.cacheFile(url, `${_this.conversationID}`, (prog) => {
|
||||
//console.log(prog);
|
||||
this.videoDownloadProgress = prog;
|
||||
}).then((fn) => {
|
||||
this.videoDownloading = false;
|
||||
this.videoExists = true;
|
||||
this.playVideo(fn);
|
||||
_this.videoDownloading = false;
|
||||
_this.videoExists = true;
|
||||
_this.playVideo(fn);
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
import SelectFooter from "./components/SelectFooter";
|
||||
import {markConversationAsRead} from "@/util/imCommon";
|
||||
import IMSDK, {MessageType,GroupMemberRole} from "openim-uniapp-polyfill";
|
||||
import util from "@/util/index.js"
|
||||
export default {
|
||||
components: {
|
||||
ChatingHeader,
|
||||
@@ -110,7 +111,7 @@
|
||||
return item.serverMsgID != data.serverMsgID;
|
||||
})
|
||||
this.$store.commit('message/SET_HISTORY_MESSAGE_LIST',list);
|
||||
})
|
||||
});
|
||||
},
|
||||
onUnload() {
|
||||
IMSDK.unsubscribe(IMSDK.IMEvents.OnMsgDeleted);
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
<scroll-view class="scroll-view"
|
||||
scroll-y="true"
|
||||
refresher-enabled="true"
|
||||
:refresher-triggered="triggered"
|
||||
:refresher-triggered="refreshing"
|
||||
:scroll-top="scrollTop"
|
||||
:scroll-with-animation="true"
|
||||
@scroll="scroll"
|
||||
@refresherrefresh="onRefresh"
|
||||
@refresherrestore="onRestore"
|
||||
@refresherabort="onRestore"
|
||||
@scrolltolower="scrolltolower">
|
||||
<uni-swipe-action ref="swipe_action">
|
||||
<uni-swipe-action-item
|
||||
@@ -66,7 +67,6 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
triggered: false,
|
||||
refreshing: false,
|
||||
};
|
||||
},
|
||||
@@ -80,17 +80,18 @@
|
||||
},
|
||||
onLoad() {
|
||||
//console.log(this.storeConversationList);
|
||||
this._freshing = false;
|
||||
this.triggered = true;
|
||||
setTimeout(()=>{
|
||||
// uni.switchTab({
|
||||
// url:"/pages/user/index/index"
|
||||
// })
|
||||
// uni.navigateTo({
|
||||
// url:"/pages/user/vip/vip"
|
||||
// });
|
||||
prepareConversationState(this.storeConversationList[0]);
|
||||
},1000)
|
||||
this.freshing = false;
|
||||
if(process.env.NODE_ENV == 'development'){
|
||||
// setTimeout(()=>{
|
||||
// // uni.switchTab({
|
||||
// // url:"/pages/user/index/index"
|
||||
// // })
|
||||
// // uni.navigateTo({
|
||||
// // url:"/pages/user/vip/vip"
|
||||
// // });
|
||||
// //prepareConversationState(this.storeConversationList[1]);
|
||||
// },1000)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
test(){
|
||||
@@ -177,23 +178,23 @@
|
||||
this.old.scrollTop = e.detail.scrollTop;
|
||||
},
|
||||
onRefresh() {
|
||||
if (this._freshing) return;
|
||||
this._freshing = true;
|
||||
if (this.refreshing) return;
|
||||
console.log('onRefresh');
|
||||
this.refreshing = true;
|
||||
this.queryList(true);
|
||||
},
|
||||
onRestore() {
|
||||
this.triggered = "restore";
|
||||
this.refreshing = false;
|
||||
console.log("onRestore");
|
||||
},
|
||||
scrolltolower() {
|
||||
this.queryList();
|
||||
},
|
||||
async queryList(isFirstPage = false) {
|
||||
//console.log(1);
|
||||
console.log(1);
|
||||
await this.$store.dispatch("conversation/getConversationList",isFirstPage);
|
||||
//console.log(2);
|
||||
this.triggered = false;
|
||||
this._freshing = false;
|
||||
console.log(2);
|
||||
this.refreshing = false;
|
||||
},
|
||||
closeAllSwipe() {
|
||||
this.$refs.swipeWrapperRef.closeAll();
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<view class="relavivetime" :id="`comment-${'null'}-${index}`">
|
||||
<view class="time">
|
||||
<view>{{ item.created_at }}</view>
|
||||
<view @click="deleteCircle(item,index)" style="color:#36648b;margin-left: 20rpx;" v-if="item.user_id==selfInfo.userID">删除</view>
|
||||
<view @click="deleteCircle(item,index)" style="color:#36648b;margin-left: 20rpx;" v-if="item.user_id==storeSelfInfo.userID">删除</view>
|
||||
</view>
|
||||
|
||||
<view class="icon-box u-flex u-row-between u-col-center">
|
||||
@@ -80,22 +80,29 @@
|
||||
<!-- 点赞人 评论 -->
|
||||
<view class="msg-box">
|
||||
<view class="thumbinfo u-border-bottom" v-if="item.likes!=null&&item.likes.length">
|
||||
<uni-icons size="30" type="heart" color="#36648b" class="u-m-r-10"></uni-icons>
|
||||
<text class="thumbinfo-name" v-for="(userInfo, pindex) in item.likes" :index="pindex"
|
||||
:key="pindex" @tap="linkToBusinessCard(userInfo.userId)">
|
||||
{{ userInfo.nickame }}{{ pindex != item.likes.length - 1 ? ',' : '' }}
|
||||
<uni-icons size="24" type="heart" color="#36648b" class="u-m-r-10"></uni-icons>
|
||||
<text class="thumbinfo-name" v-for="(ui, pindex) in item.likes" :index="pindex"
|
||||
:key="pindex" @tap="linkToBusinessCard(ui.user_id)">
|
||||
{{ ui.nickname }}{{ pindex != item.likes.length - 1 ? ',' : '' }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="comment" v-if="item.comments!=null&&item.comments.length">
|
||||
<view class="comment-box" v-for="(comment, commentIndex) in item.comments" :index="comment.id"
|
||||
:key="comment.id" hover-class="comment-hover-class"
|
||||
<view
|
||||
class="comment-box"
|
||||
v-for="(comment, commentIndex) in item.comments"
|
||||
:index="comment.id"
|
||||
:key="comment.id"
|
||||
hover-class="comment-hover-class"
|
||||
:id="`comment-${item.id}-${comment.id}`"
|
||||
@tap="handleComment(comment, index)">
|
||||
<text class="comment-box-name">
|
||||
{{ comment.user.nickname }}
|
||||
<text class="callback u-m-l-4 u-m-r-4">回复</text>
|
||||
</text>
|
||||
<text v-if="comment.reply_user_id" class="comment-box-name">{{ comment.user.nickname }}:</text>
|
||||
<text class="callback u-m-l-4 u-m-r-4" v-if="comment.reply_user_id">回复</text>
|
||||
<text v-if="comment.reply_user_id" class="comment-box-name">
|
||||
{{ comment.user.nickname }}
|
||||
</text>
|
||||
<text>:</text>
|
||||
<text class="comment-box-content">{{ comment.body }}</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -106,10 +113,10 @@
|
||||
|
||||
<script>
|
||||
import MyAvatar from "@/components/MyAvatar/index.vue";
|
||||
import videoPlayer from '@/components/videoPlayer.vue';
|
||||
import util from "@/util/index.js";
|
||||
import { mapGetters } from "vuex";
|
||||
export default{
|
||||
components:{videoPlayer ,MyAvatar},
|
||||
components:{MyAvatar},
|
||||
props:{
|
||||
index:{
|
||||
type:Number,
|
||||
@@ -123,12 +130,10 @@
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
selfInfo() {
|
||||
return this.$store.getters.storeSelfInfo;
|
||||
},
|
||||
...mapGetters(["storeSelfInfo"]),
|
||||
},
|
||||
data(){
|
||||
//console.log(this.item);
|
||||
console.log(this.item);
|
||||
return {
|
||||
girdItemCustomStyle:{
|
||||
padding: '0',
|
||||
@@ -138,6 +143,9 @@
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
log(v){
|
||||
console.log(v)
|
||||
},
|
||||
clickThumb(item,index){
|
||||
this.$emit('userEvent',{type:'clickThumb',item,index});
|
||||
},
|
||||
|
||||
@@ -2,53 +2,49 @@
|
||||
<view class="content" id="content">
|
||||
<u-navbar
|
||||
@leftClick="leftClick"
|
||||
bgColor="transparent"
|
||||
:bgColor="scrollTop>bannarHeight?'#f4f4f4':'transparent'"
|
||||
title="朋友圈"
|
||||
title-size="36"
|
||||
leftIconColor="#fff"
|
||||
:titleStyle ="{color:'#fff'}"
|
||||
:leftIconColor="scrollTop>bannarHeight?'#333':'#fff'"
|
||||
:titleStyle ="{color:scrollTop>bannarHeight?'#333':'#fff'}"
|
||||
:title-bold="true"
|
||||
:border-bottom="false">
|
||||
<view slot="right" class="u-margin-right-20" @click="showTypeSheet"
|
||||
@longpress="linkToRelease({releaseType:0})">
|
||||
<u-icon name="camera" color="#fff" size="32"></u-icon>
|
||||
<u-icon name="camera" :color="scrollTop>bannarHeight?'#333':'#fff'" size="32"></u-icon>
|
||||
</view>
|
||||
</u-navbar>
|
||||
<scroll-view :scroll-x="false" :scroll-y="true" class="scrollView"
|
||||
:scroll-with-animation="scrollWithAnimation" :scroll-top="scrollTop" @scroll="scrolling"
|
||||
@scrolltolower="loadMore"
|
||||
:style="'height:'+scrollViewHeight+'px'">
|
||||
<!-- 我的朋友圈基本信息 -->
|
||||
<view class="content-imgbox">
|
||||
<image class="bgimg" v-if="settings.bg" :src="settings.bg" mode="scaleToFill" @tap="showSheet"></image>
|
||||
<view class="bgimg" v-else @tap="showSheet"></view>
|
||||
|
||||
<MyAvatar class="headimg" :src="selfInfo.faceURL" :desc="selfInfo.nickname || selfInfo.remark"
|
||||
:isGroup="Boolean(selfInfo.groupID)" size="66" @tap="linkToBusinessCard(selfInfo.userID)" />
|
||||
<text class="nickname">{{ selfInfo.nickname || selfInfo.remark }}</text>
|
||||
</view>
|
||||
<!-- 个性签名 -->
|
||||
<view class="signature">
|
||||
<view class="">{{ selfInfo.bio }}</view>
|
||||
</view>
|
||||
<!-- 我的朋友圈基本信息 -->
|
||||
<view class="content-imgbox" :class="{top:scrollTop>bannarHeight}">
|
||||
<image class="bgimg" v-if="storeCircleSettings.bg" :src="storeCircleSettings.bg" mode="scaleToFill" @tap="showSheet"></image>
|
||||
<view class="bgimg" v-else @tap="showSheet"></view>
|
||||
|
||||
<view v-if="unreadCount>0" style="display: flex;justify-content: center;">
|
||||
<view @click="clearUnReadCount()"
|
||||
style="width: 300rpx;height:70rpx;line-height:70rpx;background-color: #333333;color: #ffffff;border-radius:10rpx;display: flex;align-items: center;">
|
||||
<view style="width:80rpx;padding:0 10rpx;">
|
||||
<MyAvatar :src="selfInfo.faceURL" class="headimg" desc=" " size="24"/>
|
||||
</view>
|
||||
<view style="flex:1;">
|
||||
{{unreadCount}}条新信息
|
||||
</view>
|
||||
<MyAvatar class="headimg" :src="storeSelfInfo.faceURL" :desc="storeSelfInfo.nickname || storeSelfInfo.remark"
|
||||
:isGroup="Boolean(storeSelfInfo.groupID)" size="66" @tap="linkToBusinessCard(storeSelfInfo.userID)" />
|
||||
<text class="nickname">{{ storeSelfInfo.nickname || storeSelfInfo.remark }}</text>
|
||||
</view>
|
||||
<!-- 个性签名 -->
|
||||
<view class="signature">
|
||||
<view class="">{{ storeSelfInfo.bio }}</view>
|
||||
</view>
|
||||
|
||||
<view v-if="storeCircleUnreadCount>0" style="display: flex;justify-content: center;">
|
||||
<view @click="clearUnReadCount()"
|
||||
style="width: 300rpx;height:70rpx;line-height:70rpx;background-color: #333333;color: #ffffff;border-radius:10rpx;display: flex;align-items: center;">
|
||||
<view style="width:80rpx;padding:0 10rpx;">
|
||||
<MyAvatar :src="storeSelfInfo.faceURL" class="headimg" desc=" " size="24"/>
|
||||
</view>
|
||||
<view style="flex:1;">
|
||||
{{storeCircleUnreadCount}}条新信息
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 朋友圈列表 -->
|
||||
<view class="content-circle">
|
||||
<!-- circleData是vuex变量,不在本页面定义 -->
|
||||
<template v-if="circleData!=null&&circleData.length>0">
|
||||
<template v-for="(item, index) in circleData" >
|
||||
</view>
|
||||
|
||||
<!-- 朋友圈列表 -->
|
||||
<view class="content-circle">
|
||||
<!-- storeCircleData是vuex变量,不在本页面定义 -->
|
||||
<template v-if="storeCircleData!=null&&storeCircleData.length>0">
|
||||
<template v-for="(item, index) in storeCircleData" >
|
||||
<CircleItem :key="index" :index="index" :item="item" @userEvent="onUserEvent"></CircleItem>
|
||||
</template>
|
||||
</template>
|
||||
@@ -58,7 +54,7 @@
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<u-overlay :show="showInput" @click="showInput = false">
|
||||
<view class="input-box" style="height: 100rpx;" @tap.stop>
|
||||
<view class="input-box-flex">
|
||||
@@ -95,41 +91,19 @@
|
||||
import MyAvatar from "@/components/MyAvatar/index.vue";
|
||||
import util from "@/util/index.js";
|
||||
import CircleItem from "./components/circleItem.vue"
|
||||
import { mapGetters } from "vuex";
|
||||
export default {
|
||||
name: 'firendCircle',
|
||||
mixins:[UserBase],
|
||||
components:{videoPlayer ,MyAvatar,CircleItem},
|
||||
computed: {
|
||||
selfInfo() {
|
||||
return this.$store.getters.storeSelfInfo;
|
||||
},
|
||||
circleData() {
|
||||
return this.$store.getters.storeCircleData;
|
||||
},
|
||||
unreadCount() {
|
||||
return this.$store.getters.storeCircleUnreadCount;
|
||||
},
|
||||
last_unread_item() {
|
||||
return this.$store.getters.storeCircleLastUnreadItem;
|
||||
},
|
||||
settings() {
|
||||
return this.$store.getters.storeCircleSettings;
|
||||
},
|
||||
computed:{
|
||||
...mapGetters(["storeSelfInfo",'storeCircleData','storeCircleUnreadCount','storeCircleTopUnreadItems','storeCircleSettings']),
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loadMoreFlag:true,//可以分页加载吗
|
||||
platFrom:'',
|
||||
girdItemCustomStyle:{
|
||||
padding: '0',
|
||||
margin:'0',
|
||||
border:'1rpx solid #f2f6fc'
|
||||
},
|
||||
scrollViewHeight: 0,
|
||||
bannarHeight:202,
|
||||
scrollTop: 0,
|
||||
currentTop: 0,
|
||||
currentScroll: 0,
|
||||
scrollWithAnimation: false,
|
||||
content: '',
|
||||
placeholder: '',
|
||||
showInput: false,
|
||||
@@ -139,7 +113,6 @@
|
||||
currentItem: {},
|
||||
previewVideoFlag:false,
|
||||
previewVideoSrc:'',
|
||||
videoContext:null,
|
||||
page:1,
|
||||
limit:5,
|
||||
//删除对象参数
|
||||
@@ -152,37 +125,33 @@
|
||||
},
|
||||
//vuex变量
|
||||
watch:{
|
||||
circleData:function(val){
|
||||
storeCircleData:function(val){
|
||||
console.log("监听到朋友圈内容有变动",val.length);
|
||||
}
|
||||
},
|
||||
|
||||
onReady() {
|
||||
console.log(this.selfInfo);
|
||||
console.log(this.storeSelfInfo);
|
||||
let that = this;
|
||||
uni.onKeyboardHeightChange(res => {
|
||||
if (res.height == 0) {
|
||||
let windowHeight = this.$u.sys().windowHeight;
|
||||
this.scrollViewHeight = windowHeight - 90;
|
||||
//this.scrollViewHeight = windowHeight - 90;
|
||||
this.showInput = false;
|
||||
this.currentTop = 0;
|
||||
return;
|
||||
} else {
|
||||
this.currentTop = 999;
|
||||
let windowHeight = this.$u.sys().windowHeight;
|
||||
this.scrollViewHeight = (windowHeight - res.height) - 120;
|
||||
//this.scrollViewHeight = (windowHeight - res.height) - 120;
|
||||
}
|
||||
});
|
||||
},
|
||||
onShow: function(option) {
|
||||
let windowHeight = this.$u.sys().windowHeight;
|
||||
this.scrollViewHeight = windowHeight - 90;
|
||||
console.log("onshow",this.page);
|
||||
//let windowHeight = this.$u.sys().windowHeight;
|
||||
//this.scrollViewHeight = windowHeight - 90;
|
||||
//console.log("onshow",this.page);
|
||||
},
|
||||
onLoad:function(){
|
||||
let that=this;
|
||||
this.platFrom= this.$u.os();
|
||||
console.log("onload",this.platFrom);
|
||||
let param={
|
||||
page:1,
|
||||
limit:this.limit,
|
||||
@@ -192,11 +161,11 @@
|
||||
this.getCircleDataList(param);
|
||||
uni.$on("handleFriendCircle", function(friendCircleMessage) {
|
||||
console.log("监听到朋友圈动态有更新",friendCircleMessage);
|
||||
let id= friendCircleMessage.content.id;
|
||||
let newPraise= friendCircleMessage.content.likes;
|
||||
const index = that.circleData.findIndex(i => i.id ==id);
|
||||
that.circleData[index].likes=JSON.parse(newPraise);
|
||||
if(friendCircleMessage.content.is_liked&&friendCircleMessage.userId!=that.selfInfo.userID){
|
||||
//let id= friendCircleMessage.content.id;
|
||||
//let newPraise= friendCircleMessage.content.likes;
|
||||
//const index = that.storeCircleData.findIndex(i => i.id ==id);
|
||||
//that.storeCircleData[index].likes=JSON.parse(newPraise);
|
||||
if(friendCircleMessage.content.is_liked&&friendCircleMessage.userId!=that.storeSelfInfo.userID){
|
||||
that.$store.dispatch('circle/updateUnreadCount',1);
|
||||
}
|
||||
})
|
||||
@@ -229,16 +198,16 @@
|
||||
},
|
||||
|
||||
//滚动事件
|
||||
scrolling: function(event) {
|
||||
scrolling: function(scrollTop) {
|
||||
//console.log("event",event);
|
||||
let that = this;
|
||||
if (that.showInput == true) {
|
||||
return;
|
||||
}
|
||||
let scrollTop = event.detail.scrollTop;
|
||||
setTimeout(function() {
|
||||
that.currentScroll = scrollTop;
|
||||
}, 300);
|
||||
//let scrollTop = event.detail.scrollTop;
|
||||
// setTimeout(function() {
|
||||
// that.currentScroll = scrollTop;
|
||||
// }, 300);
|
||||
},
|
||||
//加载更多
|
||||
loadMore:function(){
|
||||
@@ -295,28 +264,20 @@
|
||||
clickThumb(item,index) {
|
||||
let that=this;
|
||||
let flag=true;
|
||||
item.is_liked = !item.is_liked;
|
||||
if (item.is_liked) {
|
||||
item.likes.push({
|
||||
userId: this.selfInfo.userID,
|
||||
userName: this.selfInfo.nickname
|
||||
});
|
||||
} else {
|
||||
const index = item.likes.findIndex(i => i.userId == this.selfInfo.userID);
|
||||
item.likes.splice(index, 1);
|
||||
flag=false;
|
||||
}
|
||||
console.log("当前动态下标",index);
|
||||
console.log("点赞列表",item);
|
||||
let param={
|
||||
id:item.id,
|
||||
likes:JSON.stringify(item.likes),
|
||||
user_id: this.storeSelfInfo.userID,
|
||||
nickname: this.storeSelfInfo.nickname,
|
||||
avatar: this.storeSelfInfo.avatar,
|
||||
is_liked:flag
|
||||
};
|
||||
this.$store.dispatch('circle/like',param).then(res=>{
|
||||
console.log("点赞更新成功",res.data);
|
||||
item.likes=JSON.parse(res.data.likes);
|
||||
that.circleData[index]=item;
|
||||
}).catch(e=>{
|
||||
item.is_liked = !item.is_liked;
|
||||
console.log("评论失败",e);
|
||||
@@ -324,7 +285,7 @@
|
||||
},
|
||||
//跳转到名片
|
||||
linkToBusinessCard(userId) {
|
||||
if(userId==this.selfInfo.userID){
|
||||
if(userId==this.storeSelfInfo.userID){
|
||||
return;
|
||||
}
|
||||
this.goto('/pages/common/userCard?sourceID='+userId);
|
||||
@@ -348,9 +309,9 @@
|
||||
that.delCircleObj.delCircleModelFlag=false;
|
||||
that.delCircleObj.tempDelCircleId="";
|
||||
that.delCircleObj.tempDelIndex="";
|
||||
let tempData=that.circleData;
|
||||
let tempData=that.storeCircleData;
|
||||
tempData.splice(delIndex,1);
|
||||
this.$u.vuex('circleData', tempData);
|
||||
this.$store.commit('circle/SET_LIST',tempData);
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -365,14 +326,13 @@
|
||||
handleComment(comment, index) {
|
||||
let that = this;
|
||||
this.content = '';
|
||||
that.currentItem = that.circleData[index];
|
||||
that.currentTop = 0;
|
||||
that.currentItem = that.storeCircleData[index];
|
||||
this.id = that.currentItem.id;
|
||||
this.commentInfo = comment || {};
|
||||
this.placeholder = '评论:';
|
||||
if (comment) {
|
||||
//console.log("评论内容",comment);
|
||||
if (comment.comment.user_id == this.selfInfo.userID) {
|
||||
if (comment.comment.user_id == this.storeSelfInfo.userID) {
|
||||
//如果是回复自己
|
||||
this.placeholder = `评论:`;
|
||||
} else {
|
||||
@@ -420,7 +380,6 @@
|
||||
//关闭键盘 关闭输入框
|
||||
closeInputModel() {
|
||||
this.showInput = false;
|
||||
this.currentTop = 0;
|
||||
this.content = '';
|
||||
this.id = '';
|
||||
this.commentInfo = {};
|
||||
@@ -507,6 +466,14 @@
|
||||
},
|
||||
cdn:util.cdn
|
||||
},
|
||||
onReachBottom() {
|
||||
this.loadMore();
|
||||
},
|
||||
onPageScroll({scrollTop}) {
|
||||
this.scrollTop = scrollTop;
|
||||
//console.log(scrollTop)
|
||||
//this.scrolling(scrollTop);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -533,6 +500,9 @@
|
||||
}
|
||||
&-imgbox {
|
||||
position: relative;
|
||||
&.top{
|
||||
background: #f4f4f4;
|
||||
}
|
||||
|
||||
.bgimg {
|
||||
width: 100%;
|
||||
|
||||
+16
-10
@@ -11,9 +11,11 @@
|
||||
:thumbSize="thumbSize"
|
||||
showArrow
|
||||
to="/pages/find/friend-circle/friend-circle">
|
||||
<view slot="footer" v-if="last_unread_item&&last_unread_item.avatar.length>0">
|
||||
<u-avatar :src="last_unread_item.avatar" mode="square" :size="70"></u-avatar>
|
||||
<u-badge :is-dot="true" type="error" :offset="[20,60]"></u-badge>
|
||||
<view slot="footer" v-if="storeCircleTopUnreadItems.length>0">
|
||||
<view class="avatargroup">
|
||||
<MyAvatar :src="item.user.avatar" shape="circle" size="32" v-for="(item,index) in storeCircleTopUnreadItems" :key="index"></MyAvatar>
|
||||
<u-avatar :text="'+'+storeCircleUnreadCount" size="32" bg-color="#353432" shape="circle"></u-avatar>
|
||||
</view>
|
||||
</view>
|
||||
</uni-list-item>
|
||||
</uni-list>
|
||||
@@ -31,21 +33,17 @@
|
||||
|
||||
<script>
|
||||
import { mapGetters } from "vuex";
|
||||
import MyAvatar from "@/components/MyAvatar/index.vue";
|
||||
import util from "@/util";
|
||||
export default {
|
||||
components:{MyAvatar},
|
||||
data() {
|
||||
return {
|
||||
thumbSize:"base"
|
||||
};
|
||||
},
|
||||
computed:{
|
||||
...mapGetters(["config"]),
|
||||
circleUnreadCount() {
|
||||
return this.$store.getters.storeCircleUnreadCount;
|
||||
},
|
||||
last_unread_item() {
|
||||
return this.$store.getters.storeCircleLastUnreadItem;
|
||||
},
|
||||
...mapGetters(["config",'storeCircleUnreadCount','storeCircleTopUnreadItems']),
|
||||
},
|
||||
onShow: function() {
|
||||
let unreadCount= 1;
|
||||
@@ -61,4 +59,12 @@
|
||||
.workbench_page {
|
||||
background-color: #ececec !important;
|
||||
}
|
||||
.avatargroup{
|
||||
display: flex;
|
||||
.u-avatar {
|
||||
position: relative;
|
||||
margin-left: -16px;
|
||||
//border: 1px solid #333;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
import CustomNavBar from "@/components/CustomNavBar/index.vue";
|
||||
import {PageEvents } from "@/constant";
|
||||
import InfoItem from "../selfInfo/InfoItem.vue";
|
||||
import {checkUpgrade} from "@/api/login.js"
|
||||
import { mapGetters } from "vuex";
|
||||
import util from "@/util/index.js"
|
||||
import checkUpgrade from "@/util/app_update.js"
|
||||
export default {
|
||||
components: {
|
||||
CustomNavBar,
|
||||
@@ -111,18 +111,7 @@
|
||||
},
|
||||
// 验证是否升级
|
||||
checkUpdate() {
|
||||
this.loading = true;
|
||||
const _this = this;
|
||||
checkUpgrade().then(res=>{
|
||||
_this.loading = false;
|
||||
}).catch(e=>{
|
||||
console.log(e);
|
||||
if(e === true){
|
||||
uni.showToast({title:'已经是最新版本'})
|
||||
return ;
|
||||
}
|
||||
_this.loading = false;
|
||||
});
|
||||
checkUpgrade(true);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
+1
-1
@@ -24,7 +24,7 @@ export default {
|
||||
storeAuthData: (state) => state.user.authData,
|
||||
storeCircleData: (state) => state.circle.list,
|
||||
storeCircleUnreadCount: (state) => state.circle.unread_count,
|
||||
storeCircleLastUnreadItem: (state) => state.circle.last_unread_item,
|
||||
storeCircleTopUnreadItems: (state) => state.circle.top_unread_items,
|
||||
storeCircleSettings: (state) => state.circle.settings,
|
||||
config: (state) => state.system.config,
|
||||
};
|
||||
+20
-16
@@ -1,7 +1,7 @@
|
||||
const state = {
|
||||
list: [],
|
||||
unread_count: 0,
|
||||
last_unread_item: {"avatar":"","user_id":"","nickname":""},
|
||||
top_unread_items: [],
|
||||
settings: {bg:""}
|
||||
};
|
||||
|
||||
@@ -22,8 +22,8 @@ const mutations = {
|
||||
})
|
||||
}
|
||||
},
|
||||
SET_LAST_UNREAD(state, data) {
|
||||
state.last_unread_item = {...data};
|
||||
SET_TOP_UNREAD_ITEMS(state, data) {
|
||||
state.top_unread_items = [...data];
|
||||
},
|
||||
SET_SETTINGS(state, data) {
|
||||
state.settings = {...data};
|
||||
@@ -41,8 +41,8 @@ const actions = {
|
||||
},
|
||||
async getFriendCircleInfo({ commit, state}) {
|
||||
uni.$u.http.get('/friendcircle/info').then(data=>{
|
||||
commit("SET_UNREAD_COUNT", data.count);
|
||||
commit("SET_LAST_UNREAD", data.last_unread_item);
|
||||
commit("SET_UNREAD_COUNT", data.unread_count);
|
||||
commit("SET_TOP_UNREAD_ITEMS", data.top_unread_items);
|
||||
commit("SET_SETTINGS", data.settings);
|
||||
}).catch(e=>{
|
||||
uni.$u.toast("获取信息失败");
|
||||
@@ -77,19 +77,23 @@ const actions = {
|
||||
return new Promise((resolve,reject)=>{
|
||||
uni.$u.http.post('/friendcircle/like',params).then(data=>{
|
||||
console.log("点赞成功",data);
|
||||
let index = -1;
|
||||
for(let i=0;i<state.list.length;i++){
|
||||
if(state.list[i].id==params.id){
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
console.log("index",index);
|
||||
if(index!=-1){
|
||||
const index = state.list.findIndex(i => i.id ==params.id);
|
||||
|
||||
//console.log("index",index);
|
||||
if(index>=0){
|
||||
if(data.is_liked){
|
||||
state.list[index].likes.push(params.user_id);
|
||||
state.list[index].likes.push({
|
||||
user_id:params.user_id,
|
||||
nickname:params.nickname,
|
||||
avatar:params.avatar
|
||||
});
|
||||
state.list[index].is_liked = params.is_liked;
|
||||
}else{
|
||||
state.list[index].likes.splice(state.list[index].likes.indexOf(params.user_id),1);
|
||||
const likes = state.list[index].likes.filter((item)=>{
|
||||
item.user_id != params.user_id
|
||||
});
|
||||
state.list[index].likes = likes;
|
||||
state.list[index].is_liked = params.is_liked;
|
||||
}
|
||||
resolve(data);
|
||||
}else{
|
||||
|
||||
@@ -0,0 +1,815 @@
|
||||
// #ifdef APP-PLUS
|
||||
const lang = uni.getStorageSync('locale') || 'zh-Hans';
|
||||
const platform = uni.getSystemInfoSync().platform;
|
||||
// 主颜色
|
||||
const $mainColor = "#07c160";
|
||||
// 弹窗图标url
|
||||
const $iconUrl = "/static/images/icon_upgrade.png";
|
||||
|
||||
// 获取当前应用的版本号
|
||||
export const getCurrentNo = function() {
|
||||
return new Promise((resolve,reject)=>{
|
||||
// 获取本地应用资源版本号
|
||||
plus.runtime.getProperty(plus.runtime.appid, function(inf) {
|
||||
resolve({
|
||||
versionCode: inf.versionCode,
|
||||
version: inf.version
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
// 发起ajax请求获取服务端版本号
|
||||
export const getServerNo = function(version,isPrompt = false) {
|
||||
console.log(isPrompt)
|
||||
return new Promise((resolve,reject)=>{
|
||||
let httpData = {
|
||||
platform:platform,
|
||||
version:version.version,
|
||||
version_wgt:version.versionCode,
|
||||
};
|
||||
/****************以下是示例*******************/
|
||||
// 可以用自己项目的请求方法
|
||||
uni.$u?.http.post("/common/checkUpgrade",JSON.stringify(httpData)).then(res => {
|
||||
//console.log(res);
|
||||
/* res的数据说明
|
||||
* | 参数名称 | 一定返回 | 类型 | 描述
|
||||
* | -------------|--------- | --------- | ------------- |
|
||||
* | version | y | int | 版本号 |
|
||||
* | type | y | String | 更新方式 |
|
||||
* | content | y | String | 版本信息 |
|
||||
* | force | y | boolean | 是否强制更新 |
|
||||
* | source | y | String | 版本下载链接(IOS安装包更新请放跳转store应用商店链接,安卓apk和wgt文件放文件下载链接) |
|
||||
*/
|
||||
if (res && res.version) {
|
||||
return resolve({
|
||||
versionCode: parseInt(res.version),
|
||||
versionName: res.version,
|
||||
versionInfo: res.content,
|
||||
forceUpdate: res.force === 1,
|
||||
updateType: res.type,
|
||||
downloadUrl: res.source
|
||||
});
|
||||
} else {
|
||||
if (isPrompt) {
|
||||
uni.showToast({
|
||||
title: "暂无新版本",
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
return reject('暂无新版本');
|
||||
}
|
||||
}).catch(e=>{
|
||||
console.log(e);
|
||||
if (isPrompt) {
|
||||
uni.showToast({
|
||||
title: "暂无新版本",
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
return reject('暂无新版本');
|
||||
});
|
||||
});
|
||||
/****************以上是示例*******************/
|
||||
}
|
||||
// 从服务器下载应用资源包(wgt文件)
|
||||
export const getDownload = function(data) {
|
||||
let popupData = {
|
||||
progress:true,
|
||||
buttonNum: 2
|
||||
};
|
||||
if(data.forceUpdate){
|
||||
popupData.buttonNum = 0;
|
||||
}
|
||||
let dtask;
|
||||
let lastProgressValue = 0;
|
||||
downloadPopup(popupData, function(res) {
|
||||
dtask = plus.downloader.createDownload(data.downloadUrl, {
|
||||
filename: "_doc/update/"
|
||||
}, function(download, status) {
|
||||
if (status == 200) {
|
||||
res.change({
|
||||
progressValue: 100,
|
||||
progressTip: lang=='en' ? 'installing...' : "正在安装文件...",
|
||||
progress: true,
|
||||
buttonNum: 0
|
||||
});
|
||||
plus.runtime.install(download.filename, {}, function() {
|
||||
res.change({
|
||||
contentText: lang=='en' ? 'Application resource update completed' : "应用资源更新完成!",
|
||||
buttonNum: 1,
|
||||
progress: false
|
||||
});
|
||||
}, function(e) {
|
||||
res.cancel();
|
||||
plus.nativeUI.alert(lang=='en' ? 'Installation file failed[' + e.code + ']' + e.message : "安装文件失败[" + e.code + "]:" + e.message);
|
||||
});
|
||||
} else {
|
||||
res.change({
|
||||
contentText: lang=='en' ? 'File download failed' : "文件下载失败...",
|
||||
buttonNum: 1,
|
||||
progress: false
|
||||
});
|
||||
}
|
||||
});
|
||||
dtask.start();
|
||||
dtask.addEventListener("statechanged", function(task, status) {
|
||||
switch (task.state) {
|
||||
case 1: // 开始
|
||||
res.change({
|
||||
progressValue:0,
|
||||
progressTip: lang=='en' ? 'Ready to download...' : "准备下载...",
|
||||
progress: true
|
||||
});
|
||||
break;
|
||||
case 2: // 已连接到服务器
|
||||
res.change({
|
||||
progressValue:0,
|
||||
progressTip: lang=='en' ? 'Start downloading...' : "开始下载...",
|
||||
progress: true
|
||||
});
|
||||
break;
|
||||
case 3:
|
||||
const progress = parseInt(task.downloadedSize / task.totalSize * 100);
|
||||
if(progress - lastProgressValue >= 2){
|
||||
lastProgressValue = progress;
|
||||
res.change({
|
||||
progressValue:progress,
|
||||
progressTip: lang=='en' ? "Downloaded" + progress + "%" : "已下载" + progress + "%",
|
||||
progress: true
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
});
|
||||
},function(){
|
||||
// 取消下载
|
||||
dtask && dtask.abort();
|
||||
uni.showToast({
|
||||
title: lang=='en' ? 'Download cancelled' : "已取消下载",
|
||||
icon:"none"
|
||||
});
|
||||
},
|
||||
function(){
|
||||
// 重启APP
|
||||
plus.runtime.restart();
|
||||
});
|
||||
}
|
||||
// 文字换行
|
||||
function drawtext(text, maxWidth) {
|
||||
let textArr = text.split("");
|
||||
let len = textArr.length;
|
||||
// 上个节点
|
||||
let previousNode = 0;
|
||||
// 记录节点宽度
|
||||
let nodeWidth = 0;
|
||||
// 文本换行数组
|
||||
let rowText = [];
|
||||
// 如果是字母,侧保存长度
|
||||
let letterWidth = 0;
|
||||
// 汉字宽度
|
||||
let chineseWidth = 14;
|
||||
// otherFont宽度
|
||||
let otherWidth = 7;
|
||||
for (let i = 0; i < len; i++) {
|
||||
if (/[\u4e00-\u9fa5]|[\uFE30-\uFFA0]/g.test(textArr[i])) {
|
||||
if(letterWidth > 0){
|
||||
if(nodeWidth + chineseWidth + letterWidth * otherWidth > maxWidth){
|
||||
rowText.push({
|
||||
type: "text",
|
||||
content: text.substring(previousNode, i)
|
||||
});
|
||||
previousNode = i;
|
||||
nodeWidth = chineseWidth;
|
||||
letterWidth = 0;
|
||||
} else {
|
||||
nodeWidth += chineseWidth + letterWidth * otherWidth;
|
||||
letterWidth = 0;
|
||||
}
|
||||
} else {
|
||||
if(nodeWidth + chineseWidth > maxWidth){
|
||||
rowText.push({
|
||||
type: "text",
|
||||
content: text.substring(previousNode, i)
|
||||
});
|
||||
previousNode = i;
|
||||
nodeWidth = chineseWidth;
|
||||
}else{
|
||||
nodeWidth += chineseWidth;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(/\n/g.test(textArr[i])){
|
||||
rowText.push({
|
||||
type: "break",
|
||||
content: text.substring(previousNode, i)
|
||||
});
|
||||
previousNode = i + 1;
|
||||
nodeWidth = 0;
|
||||
letterWidth = 0;
|
||||
}else if(textArr[i] == "\\" && textArr[i + 1] == "n"){
|
||||
rowText.push({
|
||||
type: "break",
|
||||
content: text.substring(previousNode, i)
|
||||
});
|
||||
previousNode = i + 2;
|
||||
nodeWidth = 0;
|
||||
letterWidth = 0;
|
||||
}else if(/[a-zA-Z0-9]/g.test(textArr[i])){
|
||||
letterWidth += 1;
|
||||
if(nodeWidth + letterWidth * otherWidth > maxWidth){
|
||||
rowText.push({
|
||||
type: "text",
|
||||
content: text.substring(previousNode, i + 1 - letterWidth)
|
||||
});
|
||||
previousNode = i + 1 - letterWidth;
|
||||
nodeWidth = letterWidth * otherWidth;
|
||||
letterWidth = 0;
|
||||
}
|
||||
} else{
|
||||
if(nodeWidth + otherWidth > maxWidth){
|
||||
rowText.push({
|
||||
type: "text",
|
||||
content: text.substring(previousNode, i)
|
||||
});
|
||||
previousNode = i;
|
||||
nodeWidth = otherWidth;
|
||||
}else{
|
||||
nodeWidth += otherWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (previousNode < len) {
|
||||
rowText.push({
|
||||
type: "text",
|
||||
content: text.substring(previousNode, len)
|
||||
});
|
||||
}
|
||||
return rowText;
|
||||
}
|
||||
// 是否更新弹窗
|
||||
function updatePopup(data, callback) {
|
||||
// 弹窗遮罩层
|
||||
let maskLayer = new plus.nativeObj.View("maskLayer", { //先创建遮罩层
|
||||
top: '0px',
|
||||
left: '0px',
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
backgroundColor: 'rgba(0,0,0,0.5)'
|
||||
});
|
||||
|
||||
// 以下为计算菜单的nview绘制布局,为固定算法,使用者无关关心
|
||||
const screenWidth = plus.screen.resolutionWidth;
|
||||
const screenHeight = plus.screen.resolutionHeight;
|
||||
//弹窗容器宽度
|
||||
const popupViewWidth = screenWidth * 0.7;
|
||||
// 弹窗容器的Padding
|
||||
const viewContentPadding = 20;
|
||||
// 弹窗容器的宽度
|
||||
const viewContentWidth = parseInt(popupViewWidth - (viewContentPadding * 2));
|
||||
// 描述的列表
|
||||
const descriptionList = drawtext(data.versionInfo, viewContentWidth);
|
||||
// 弹窗容器高度
|
||||
let popupViewHeight = 80 + 20 + 20 + 90 + 10;
|
||||
let popupViewContentList = [{
|
||||
src: $iconUrl,
|
||||
id: "logo",
|
||||
tag: "img",
|
||||
position: {
|
||||
top: "0px",
|
||||
left: (popupViewWidth - 124) / 2 + "px",
|
||||
width: "124px",
|
||||
height: "80px",
|
||||
}
|
||||
},
|
||||
{
|
||||
tag: 'font',
|
||||
id: 'title',
|
||||
text: lang=='en' ? "Discover a new version" + data.versionName : "发现新版本" + data.versionName,
|
||||
textStyles: {
|
||||
size: '18px',
|
||||
color: "#333",
|
||||
weight: "bold",
|
||||
whiteSpace: "normal"
|
||||
},
|
||||
position: {
|
||||
top: '90px',
|
||||
left: viewContentPadding + "px",
|
||||
width: viewContentWidth + "px",
|
||||
height: "30px",
|
||||
}
|
||||
}];
|
||||
const textHeight = 18;
|
||||
let contentTop = 130;
|
||||
descriptionList.forEach((item,index) => {
|
||||
if(index > 0){
|
||||
popupViewHeight += textHeight;
|
||||
contentTop += textHeight;
|
||||
}
|
||||
popupViewContentList.push({
|
||||
tag: 'font',
|
||||
id: 'content' + index + 1,
|
||||
text: item.content,
|
||||
textStyles: {
|
||||
size: '14px',
|
||||
color: "#666",
|
||||
lineSpacing: "50%",
|
||||
align: "left"
|
||||
},
|
||||
position: {
|
||||
top: contentTop + "px",
|
||||
left: viewContentPadding + "px",
|
||||
width: viewContentWidth + "px",
|
||||
height: textHeight + "px",
|
||||
}
|
||||
});
|
||||
if(item.type == "break"){
|
||||
contentTop += 10;
|
||||
popupViewHeight += 10;
|
||||
}
|
||||
});
|
||||
// 弹窗内容
|
||||
let popupView = new plus.nativeObj.View("popupView", { //创建底部图标菜单
|
||||
tag: "rect",
|
||||
top: (screenHeight - popupViewHeight) / 2 + "px",
|
||||
left: '15%',
|
||||
height: popupViewHeight + "px",
|
||||
width: "70%"
|
||||
});
|
||||
// 绘制白色背景
|
||||
popupView.drawRect({
|
||||
color: "#FFFFFF",
|
||||
radius: "8px"
|
||||
}, {
|
||||
top: "40px",
|
||||
height: popupViewHeight - 40 + "px",
|
||||
});
|
||||
// 绘制底边按钮
|
||||
popupView.drawRect({
|
||||
radius: "3px",
|
||||
borderColor: "#f1f1f1",
|
||||
borderWidth: "1px",
|
||||
}, {
|
||||
bottom: viewContentPadding + 'px',
|
||||
left: viewContentPadding + "px",
|
||||
width: (viewContentWidth - viewContentPadding) / 2 + "px",
|
||||
height: "30px",
|
||||
});
|
||||
// 绘制底边按钮
|
||||
popupView.drawRect({
|
||||
radius: "3px",
|
||||
color: $mainColor,
|
||||
}, {
|
||||
bottom: viewContentPadding + 'px',
|
||||
left: ((viewContentWidth - viewContentPadding) / 2 + viewContentPadding * 2) + "px",
|
||||
width: (viewContentWidth - viewContentPadding) / 2 + "px",
|
||||
height: "30px",
|
||||
});
|
||||
popupViewContentList.push({
|
||||
tag: 'font',
|
||||
id: 'cancelText',
|
||||
text: lang=='en' ? 'Not upgrading temporarily' : "暂不升级",
|
||||
textStyles: {
|
||||
size: '14px',
|
||||
color: "#666",
|
||||
lineSpacing: "0%",
|
||||
whiteSpace: "normal"
|
||||
},
|
||||
position: {
|
||||
bottom: viewContentPadding + 'px',
|
||||
left: viewContentPadding + "px",
|
||||
width: (viewContentWidth - viewContentPadding) / 2 + "px",
|
||||
height: "30px",
|
||||
}
|
||||
});
|
||||
popupViewContentList.push({
|
||||
tag: 'font',
|
||||
id: 'confirmText',
|
||||
text: lang=='en' ? 'upgrade now' : "立即升级",
|
||||
textStyles: {
|
||||
size: '14px',
|
||||
color: "#FFF",
|
||||
lineSpacing: "0%",
|
||||
whiteSpace: "normal"
|
||||
},
|
||||
position: {
|
||||
bottom: viewContentPadding + 'px',
|
||||
left: ((viewContentWidth - viewContentPadding) / 2 + viewContentPadding * 2) + "px",
|
||||
width: (viewContentWidth - viewContentPadding) / 2 + "px",
|
||||
height: "30px",
|
||||
}
|
||||
});
|
||||
popupView.draw(popupViewContentList);
|
||||
popupView.addEventListener("click", function(e) {
|
||||
let maxTop = popupViewHeight - viewContentPadding;
|
||||
let maxLeft = popupViewWidth - viewContentPadding;
|
||||
let buttonWidth = (viewContentWidth - viewContentPadding) / 2;
|
||||
if (e.clientY > maxTop - 30 && e.clientY < maxTop) {
|
||||
// 暂不升级
|
||||
if (e.clientX > viewContentPadding && e.clientX < maxLeft - buttonWidth - viewContentPadding) {
|
||||
maskLayer.hide();
|
||||
popupView.hide();
|
||||
} else if (e.clientX > maxLeft - buttonWidth && e.clientX < maxLeft) {
|
||||
// 立即升级
|
||||
maskLayer.hide();
|
||||
popupView.hide();
|
||||
callback && callback();
|
||||
}
|
||||
}
|
||||
});
|
||||
// 点击遮罩层
|
||||
maskLayer.addEventListener("click", function() { //处理遮罩层点击
|
||||
maskLayer.hide();
|
||||
popupView.hide();
|
||||
});
|
||||
// 显示弹窗
|
||||
maskLayer.show();
|
||||
popupView.show();
|
||||
}
|
||||
// 文件下载的弹窗绘图
|
||||
function downloadPopupDrawing(data){
|
||||
// 以下为计算菜单的nview绘制布局,为固定算法,使用者无关关心
|
||||
const screenWidth = plus.screen.resolutionWidth;
|
||||
const screenHeight = plus.screen.resolutionHeight;
|
||||
//弹窗容器宽度
|
||||
const popupViewWidth = screenWidth * 0.7;
|
||||
// 弹窗容器的Padding
|
||||
const viewContentPadding = 20;
|
||||
// 弹窗容器的宽度
|
||||
const viewContentWidth = popupViewWidth - (viewContentPadding * 2);
|
||||
// 弹窗容器高度
|
||||
let popupViewHeight = viewContentPadding * 3 + 60;
|
||||
let progressTip = data.progressTip || lang=='en' ? 'Ready to download' :"准备下载...";
|
||||
let contentText = data.contentText || lang=='en' ? 'We are updating for you, please be patient' :"正在为您更新,请耐心等待";
|
||||
let elementList = [
|
||||
{
|
||||
tag: 'rect', //背景色
|
||||
color: '#FFFFFF',
|
||||
rectStyles:{
|
||||
radius: "8px"
|
||||
}
|
||||
},
|
||||
{
|
||||
tag: 'font',
|
||||
id: 'title',
|
||||
text: lang=='en' ? 'Upgrade APP' : "升级APP",
|
||||
textStyles: {
|
||||
size: '16px',
|
||||
color: "#333",
|
||||
weight: "bold",
|
||||
verticalAlign: "middle",
|
||||
whiteSpace: "normal"
|
||||
},
|
||||
position: {
|
||||
top: viewContentPadding + 'px',
|
||||
height: "30px",
|
||||
}
|
||||
},
|
||||
{
|
||||
tag: 'font',
|
||||
id: 'content',
|
||||
text: contentText,
|
||||
textStyles: {
|
||||
size: '14px',
|
||||
color: "#333",
|
||||
verticalAlign: "middle",
|
||||
whiteSpace: "normal"
|
||||
},
|
||||
position: {
|
||||
top: viewContentPadding * 2 + 30 + 'px',
|
||||
height: "20px",
|
||||
}
|
||||
}
|
||||
];
|
||||
// 是否有进度条
|
||||
if(data.progress){
|
||||
popupViewHeight += viewContentPadding + 40;
|
||||
elementList = elementList.concat([
|
||||
{
|
||||
tag: 'font',
|
||||
id: 'progressValue',
|
||||
text: progressTip,
|
||||
textStyles: {
|
||||
size: '14px',
|
||||
color: $mainColor,
|
||||
whiteSpace: "normal"
|
||||
},
|
||||
position: {
|
||||
top: viewContentPadding * 4 + 20 + 'px',
|
||||
height: "30px"
|
||||
}
|
||||
},
|
||||
{
|
||||
tag: 'rect', //绘制进度条背景
|
||||
id: 'progressBg',
|
||||
rectStyles:{
|
||||
radius: "4px",
|
||||
borderColor: "#f1f1f1",
|
||||
borderWidth: "1px",
|
||||
},
|
||||
position:{
|
||||
top: viewContentPadding * 4 + 60 + 'px',
|
||||
left: viewContentPadding + "px",
|
||||
width: viewContentWidth + "px",
|
||||
height: "8px"
|
||||
}
|
||||
},
|
||||
]);
|
||||
}
|
||||
if (data.buttonNum == 2) {
|
||||
popupViewHeight += viewContentPadding + 30;
|
||||
elementList = elementList.concat([
|
||||
{
|
||||
tag: 'rect', //绘制底边按钮
|
||||
rectStyles:{
|
||||
radius: "3px",
|
||||
borderColor: "#f1f1f1",
|
||||
borderWidth: "1px",
|
||||
},
|
||||
position:{
|
||||
bottom: viewContentPadding + 'px',
|
||||
left: viewContentPadding + "px",
|
||||
width: (viewContentWidth - viewContentPadding) / 2 + "px",
|
||||
height: "30px"
|
||||
}
|
||||
},
|
||||
{
|
||||
tag: 'rect', //绘制底边按钮
|
||||
rectStyles:{
|
||||
radius: "3px",
|
||||
color: $mainColor
|
||||
},
|
||||
position:{
|
||||
bottom: viewContentPadding + 'px',
|
||||
left: ((viewContentWidth - viewContentPadding) / 2 + viewContentPadding * 2) + "px",
|
||||
width: (viewContentWidth - viewContentPadding) / 2 + "px",
|
||||
height: "30px"
|
||||
}
|
||||
},
|
||||
{
|
||||
tag: 'font',
|
||||
id: 'cancelText',
|
||||
text: lang=='en' ? 'Cancel Download' :"取消下载",
|
||||
textStyles: {
|
||||
size: '14px',
|
||||
color: "#666",
|
||||
lineSpacing: "0%",
|
||||
whiteSpace: "normal"
|
||||
},
|
||||
position: {
|
||||
bottom: viewContentPadding + 'px',
|
||||
left: viewContentPadding + "px",
|
||||
width: (viewContentWidth - viewContentPadding) / 2 + "px",
|
||||
height: "30px",
|
||||
}
|
||||
},
|
||||
{
|
||||
tag: 'font',
|
||||
id: 'confirmText',
|
||||
text: lang=='en' ? 'Backend download' :"后台下载",
|
||||
textStyles: {
|
||||
size: '14px',
|
||||
color: "#FFF",
|
||||
lineSpacing: "0%",
|
||||
whiteSpace: "normal"
|
||||
},
|
||||
position: {
|
||||
bottom: viewContentPadding + 'px',
|
||||
left: ((viewContentWidth - viewContentPadding) / 2 + viewContentPadding * 2) + "px",
|
||||
width: (viewContentWidth - viewContentPadding) / 2 + "px",
|
||||
height: "30px",
|
||||
}
|
||||
}
|
||||
]);
|
||||
}
|
||||
if (data.buttonNum == 1) {
|
||||
popupViewHeight += viewContentPadding + 40;
|
||||
elementList = elementList.concat([
|
||||
{
|
||||
tag: 'rect', //绘制底边按钮
|
||||
rectStyles:{
|
||||
radius: "6px",
|
||||
color: $mainColor
|
||||
},
|
||||
position:{
|
||||
bottom: viewContentPadding + 'px',
|
||||
left: viewContentPadding + "px",
|
||||
width: viewContentWidth + "px",
|
||||
height: "40px"
|
||||
}
|
||||
},
|
||||
{
|
||||
tag: 'font',
|
||||
id: 'confirmText',
|
||||
text: lang=='en' ? 'close' :"关闭",
|
||||
textStyles: {
|
||||
size: '14px',
|
||||
color: "#FFF",
|
||||
lineSpacing: "0%",
|
||||
},
|
||||
position: {
|
||||
bottom: viewContentPadding + 'px',
|
||||
left: viewContentPadding + "px",
|
||||
width: viewContentWidth + "px",
|
||||
height: "40px"
|
||||
}
|
||||
}
|
||||
]);
|
||||
}
|
||||
return {
|
||||
popupViewHeight:popupViewHeight,
|
||||
popupViewWidth:popupViewWidth,
|
||||
screenHeight:screenHeight,
|
||||
viewContentWidth:viewContentWidth,
|
||||
viewContentPadding:viewContentPadding,
|
||||
elementList: elementList
|
||||
};
|
||||
}
|
||||
// 文件下载的弹窗
|
||||
function downloadPopup(data, callback, cancelCallback,rebootCallback) {
|
||||
// 弹窗遮罩层
|
||||
let maskLayer = new plus.nativeObj.View("maskLayer", { //先创建遮罩层
|
||||
top: '0px',
|
||||
left: '0px',
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
backgroundColor: 'rgba(0,0,0,0.5)'
|
||||
});
|
||||
let popupViewData = downloadPopupDrawing(data);
|
||||
// 弹窗内容
|
||||
let popupView = new plus.nativeObj.View("popupView", { //创建底部图标菜单
|
||||
tag: "rect",
|
||||
top: (popupViewData.screenHeight - popupViewData.popupViewHeight) / 2 + "px",
|
||||
left: '15%',
|
||||
height: popupViewData.popupViewHeight + "px",
|
||||
width: "70%",
|
||||
});
|
||||
let progressValue = 0;
|
||||
let progressTip = 0;
|
||||
let contentText = 0;
|
||||
let buttonNum = 2;
|
||||
if(data.buttonNum >= 0){
|
||||
buttonNum = data.buttonNum;
|
||||
}
|
||||
popupView.draw(popupViewData.elementList);
|
||||
popupView.addEventListener("click", function(e) {
|
||||
let maxTop = popupViewData.popupViewHeight - popupViewData.viewContentPadding;
|
||||
let maxLeft = popupViewData.popupViewWidth - popupViewData.viewContentPadding;
|
||||
if (e.clientY > maxTop - 40 && e.clientY < maxTop) {
|
||||
if(buttonNum == 1){
|
||||
// 单按钮
|
||||
if (e.clientX > popupViewData.viewContentPadding && e.clientX < maxLeft) {
|
||||
maskLayer.hide();
|
||||
popupView.hide();
|
||||
rebootCallback && rebootCallback();
|
||||
}
|
||||
}else if(buttonNum == 2){
|
||||
// 双按钮
|
||||
let buttonWidth = (popupViewData.viewContentWidth - popupViewData.viewContentPadding) / 2;
|
||||
if (e.clientX > popupViewData.viewContentPadding && e.clientX < maxLeft - buttonWidth - popupViewData.viewContentPadding) {
|
||||
maskLayer.hide();
|
||||
popupView.hide();
|
||||
cancelCallback && cancelCallback();
|
||||
} else if (e.clientX > maxLeft - buttonWidth && e.clientX < maxLeft) {
|
||||
maskLayer.hide();
|
||||
popupView.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// 显示弹窗
|
||||
maskLayer.show();
|
||||
popupView.show();
|
||||
// 改变进度条
|
||||
callback({
|
||||
change: function(res) {
|
||||
let progressElement = [];
|
||||
if(res.progressValue){
|
||||
progressValue = res.progressValue;
|
||||
// 绘制进度条
|
||||
progressElement.push({
|
||||
tag: 'rect', //绘制进度条背景
|
||||
id: 'progressValueBg',
|
||||
rectStyles:{
|
||||
radius: "4px",
|
||||
color: $mainColor
|
||||
},
|
||||
position:{
|
||||
top: popupViewData.viewContentPadding * 4 + 60 + 'px',
|
||||
left: popupViewData.viewContentPadding + "px",
|
||||
width: popupViewData.viewContentWidth * (res.progressValue / 100) + "px",
|
||||
height: "8px"
|
||||
}
|
||||
});
|
||||
}
|
||||
if(res.progressTip){
|
||||
progressTip = res.progressTip;
|
||||
progressElement.push({
|
||||
tag: 'font',
|
||||
id: 'progressValue',
|
||||
text: res.progressTip,
|
||||
textStyles: {
|
||||
size: '14px',
|
||||
color: $mainColor,
|
||||
whiteSpace: "normal"
|
||||
},
|
||||
position: {
|
||||
top: popupViewData.viewContentPadding * 4 + 20 + 'px',
|
||||
height: "30px"
|
||||
}
|
||||
});
|
||||
}
|
||||
if(res.contentText){
|
||||
contentText = res.contentText;
|
||||
progressElement.push({
|
||||
tag: 'font',
|
||||
id: 'content',
|
||||
text: res.contentText,
|
||||
textStyles: {
|
||||
size: '16px',
|
||||
color: "#333",
|
||||
whiteSpace: "normal"
|
||||
},
|
||||
position: {
|
||||
top: popupViewData.viewContentPadding * 2 + 30 + 'px',
|
||||
height: "30px",
|
||||
}
|
||||
});
|
||||
}
|
||||
if(res.buttonNum >= 0 && buttonNum != res.buttonNum){
|
||||
buttonNum = res.buttonNum;
|
||||
popupView.reset();
|
||||
popupViewData = downloadPopupDrawing(Object.assign({
|
||||
progressValue:progressValue,
|
||||
progressTip:progressTip,
|
||||
contentText:contentText,
|
||||
},res));
|
||||
let newElement = [];
|
||||
popupViewData.elementList.map((item,index) => {
|
||||
let have = false;
|
||||
progressElement.forEach((childItem,childIndex) => {
|
||||
if(item.id == childItem.id){
|
||||
have = true;
|
||||
}
|
||||
});
|
||||
if(!have){
|
||||
newElement.push(item);
|
||||
}
|
||||
});
|
||||
progressElement = newElement.concat(progressElement);
|
||||
popupView.setStyle({
|
||||
tag: "rect",
|
||||
top: (popupViewData.screenHeight - popupViewData.popupViewHeight) / 2 + "px",
|
||||
left: '15%',
|
||||
height: popupViewData.popupViewHeight + "px",
|
||||
width: "70%",
|
||||
});
|
||||
popupView.draw(progressElement);
|
||||
}else{
|
||||
popupView.draw(progressElement);
|
||||
}
|
||||
},
|
||||
cancel: function() {
|
||||
maskLayer.hide();
|
||||
popupView.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
function dopdate(res){
|
||||
if(res.updateType === 1){
|
||||
//wgt
|
||||
getDownload(res);
|
||||
|
||||
}else if(res.updateType === 2){
|
||||
//外链下载更新
|
||||
plus.runtime.openURL(res.downloadUrl);
|
||||
}else{
|
||||
//整包更新
|
||||
if (platform == "android") {
|
||||
getDownload(res);
|
||||
} else {
|
||||
plus.runtime.openURL(res.downloadUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
export default function(isPrompt = false) {
|
||||
console.log(isPrompt)
|
||||
getCurrentNo().then((version) => {
|
||||
//console.log('getCurrentNo',version);
|
||||
getServerNo(version,isPrompt).then(res=> {
|
||||
//console.log('getServerNo',res);
|
||||
if (res.forceUpdate) {
|
||||
dopdate(res);
|
||||
} else {
|
||||
updatePopup(res, function() {
|
||||
dopdate(res);
|
||||
});
|
||||
}
|
||||
}).catch(e=>{
|
||||
console.log(e);
|
||||
});
|
||||
});
|
||||
}
|
||||
// #endif
|
||||
Reference in New Issue
Block a user