hwq 3 yıl önce
ebeveyn
işleme
877081d40d

+ 201 - 185
common/_mixins.js

@@ -4,8 +4,7 @@ import _onSocket from './_onSocket';
 /**
  * socket 发送用到的一个函数
  */
-function stringSource(s)
-{
+function stringSource(s) {
 	let i = 0;
 	return () => {
 		return i < s.length ? s.charCodeAt(i++) : null;
@@ -13,22 +12,22 @@ function stringSource(s)
 
 }
 
-let params  = {
+let params = {
 	timeout: 18000,
 	timeout2: 22000,
 	timeoutObj: null,
 	serverTimeoutObj: null,
-	lockReconnect : false,
-	tt:false,
-	maxConnect:3,
-	status:false,
-	lockSend:false
+	lockReconnect: false,
+	tt: false,
+	maxConnect: 3,
+	status: false,
+	lockSend: false
 }
 
 export default {
 	/** 添加方法时,方法name前加$以避免与页面方法冲突 */
 	methods: {
-	
+
 		/**
 		 *  http 请求
 		 *  config object
@@ -42,32 +41,35 @@ export default {
 		 * 		check: false 是否验证登陆默认不验证
 		 *	}
 		 */
-		getCurPage(){
+		getCurPage() {
 			let pages = getCurrentPages();
-			let curPage = pages[pages.length-1];
+			let curPage = pages[pages.length - 1];
 			return curPage
 		},
-		$reconnect(cb,sendData){
-			if(params.lockReconnect  || params.maxConnect <= 0 || _data.data("socket_state") > 0){
+		$reconnect(cb, sendData) {
+			if (params.lockReconnect || params.maxConnect <= 0 || _data.data("socket_state") > 0) {
 				return false;
 			}
-			_data.data('socket_state',0);
+			_data.data('socket_state', 0);
 			clearTimeout(params.timeoutObj);
 			clearTimeout(params.serverTimeoutObj);
 			uni.closeSocket();
 			params.lockReconnect = true;
 			params.status = false;
-			params.maxConnect --;
-			if(sendData != undefined){
-				this.$socketSend(sendData,cb);
-			}else {
+			params.maxConnect--;
+			if (sendData != undefined) {
+				this.$socketSend(sendData, cb);
+			} else {
 				this.$sendWithPingToken(cb);
 			}
 		},
-		$sendWithPingToken(cb){
-			this.$socketSend({'action':'ping','data':_data.localData('token')},cb);
+		$sendWithPingToken(cb) {
+			this.$socketSend({
+				'action': 'ping',
+				'data': _data.localData('token')
+			}, cb);
 		},
-		$reset(){
+		$reset() {
 			params.status = false;
 			params.lockReconnect = false;
 			params.maxConnect = 3;
@@ -76,43 +78,47 @@ export default {
 			clearTimeout(params.serverTimeoutObj);
 			return this;
 		},
-		$sendWithToken(cb){
-			if(params.lockSend){
+		$sendWithToken(cb) {
+			if (params.lockSend) {
 				return false;
 			}
 			params.lockSend = true;
 			this.$socketSend({
 				action: 'checkToken',
 				data: _data.localData('token'),
-			},cb);
+			}, cb);
 		},
-		$start(){
-			if(params.status){
+		$start() {
+			if (params.status) {
 				return false;
 			}
 			params.status = true;
 			let self = this;
 			clearTimeout(params.serverTimeoutObj);
 			clearTimeout(params.timeoutObj);
-			params.timeoutObj = setTimeout(function () {
+			params.timeoutObj = setTimeout(function() {
 				//这里发送一个心跳,后端收到后,返回一个心跳消息,
 				//onmessage拿到返回的心跳就说明连接正常
 				self.$sendWithPingToken();
-				params.serverTimeoutObj = setTimeout(function () { // 如果超过一定时间还没重置,说明后端主动断开了
-					uni.closeSocket();;//如果onclose会执行reconnect,我们执行 websocket.close()就行了.如果直接执行 reconnect 会触发onclose导致重连两次
+				params.serverTimeoutObj = setTimeout(function() { // 如果超过一定时间还没重置,说明后端主动断开了
+					uni
+				.closeSocket();; //如果onclose会执行reconnect,我们执行 websocket.close()就行了.如果直接执行 reconnect 会触发onclose导致重连两次
 				}, params.timeout2)
 			}, params.timeout)
 		},
-		$requestSend(config){
+		$requestSend(config) {
 			let header = {
 				/** 这里设置为简单跨域,只会请求一次 */
 				'Content-Type': 'application/x-www-form-urlencoded',
 			};
 			let send_data = ('data' in config ? config.data : {}),
-			url = _data.data('http_url') + config.path;
+				url = _data.data('http_url') + config.path;
 			send_data['_token'] = _data.localData('token');
 			send_data['_agent_id'] = _data.data('agent_id');
 			let _this = this;
+			uni.showModal({
+				title: '开始请求',
+			});
 			uni.request({
 				url: url,
 				data: send_data,
@@ -120,35 +126,38 @@ export default {
 				header: header,
 				dataType: 'json',
 				success(res) {
-					if(res.statusCode == 200){
-						if(('success_action' in config) && config.success_action ){
+					uni.showModal({
+						title: '请求成功',
+						content: JSON.stringify(res),
+					});
+					if (res.statusCode == 200) {
+						if (('success_action' in config) && config.success_action) {
 							config.success(res.data);
-						}
-						else {
-							if(res.data.err){
+						} else {
+							if (res.data.err) {
 								/** 不显示未登录提示 */
-								console.log( config.path);
-								if(send_data['_token'] || config.path.indexOf('/in/') > -1 ||  config.path.indexOf('/App/') > -1){
+								console.log(config.path);
+								if (send_data['_token'] || config.path.indexOf('/in/') > -1 || config.path
+									.indexOf('/App/') > -1) {
 									//执行错误回调
 									console.log(JSON.stringify(res));
-									if(('fail_callback' in config) &&  config.fail_callback){
+									if (('fail_callback' in config) && config.fail_callback) {
 										config.fail_callback(res.data);
 										uni.showToast({
 											title: res.data.msg,
 											duration: 2000,
-											icon:"none"
+											icon: "none"
 										});
-									}else {
+									} else {
 										uni.showToast({
 											title: res.data.msg,
 											duration: 1000,
-											icon:"none"
+											icon: "none"
 										});
 									}
 								}
-							}
-							else {
-								if('success' in config){
+							} else {
+								if ('success' in config) {
 									config.success(res.data.data);
 								}
 							}
@@ -158,7 +167,7 @@ export default {
 						uni.showToast({
 							title: '您的网络好像出了点状况哦',
 							duration: 1000,
-							icon:"none"
+							icon: "none"
 						});
 						// uni.showModal({
 						// 	content: 'server error:' + JSON.stringify(res.data),
@@ -166,22 +175,27 @@ export default {
 					}
 				},
 				fail(err) {
-					if('fail' in config){
+					if ('fail' in config) {
 						config.fail(err);
-					}else{
-						return;
+					} else {
 						uni.showModal({
 							content: JSON.stringify(err),
 						});
+						return;
 					}
 				}
 			});
 		},
-		$httpSend(config){
+		$httpSend(config) {
 			let _this = this;
-			_this.$requestSend(config);
+			uni.showModal({
+				title: '开启时请求',
+				success: res => {
+					_this.$requestSend(config);
+				},
+			});
 		},
-		
+
 		/**
 		 * 通过 websocket 发送数据,
 		 * 如果还没有连接 websocket 就先连接websocket,过两秒等websocket连接上了发送本次的数据,如果两秒后还是没有连接上,则舍弃这次发送数据,
@@ -192,128 +206,130 @@ export default {
 		 *		data: {}
 		 *	}
 		 */
-		$socketSend(send_data,cb){
+		$socketSend(send_data, cb) {
 			let self = this;
 			/** callback1是连接,callback2是发送 */
-			((callback1,callback2) => {
-				if(send_data && _data.data('socket_state')){
-						callback2(send_data);
-				}else{
-					callback1(callback2,send_data);
+			((callback1, callback2) => {
+				if (send_data && _data.data('socket_state')) {
+					callback2(send_data);
+				} else {
+					callback1(callback2, send_data);
 				}
-			})((callback,send_data) => {
-				uni.connectSocket({
-					url: _data.data('socket_url'),
-					header: {
-						'content-type': 'application/json',
-					},
-					// protocols: [ 'protocol1' ],
-					method: 'GET',
-					success(){
-						_data.data('socket_state',1);
-					},
-					fail(err){
-						self.$reset().$reconnect();
-					}
-				});
-				uni.onSocketOpen((res) => {
-					self.$reset().$start();
-					/** 绑定服务器消息事件 */
-					uni.onSocketMessage((res) => {
+			})((callback, send_data) => {
+					uni.connectSocket({
+						url: _data.data('socket_url'),
+						header: {
+							'content-type': 'application/json',
+						},
+						// protocols: [ 'protocol1' ],
+						method: 'GET',
+						success() {
+							_data.data('socket_state', 1);
+						},
+						fail(err) {
+							self.$reset().$reconnect();
+						}
+					});
+					uni.onSocketOpen((res) => {
 						self.$reset().$start();
-						res = JSON.parse(res.data);
-						if(!(res.action in _onSocket)){
-							if(res.action != 'ping' && res.type != 'ping' ){
-								uni.showModal({
-									content: '接受到无效的消息',
-								});
+						/** 绑定服务器消息事件 */
+						uni.onSocketMessage((res) => {
+							self.$reset().$start();
+							res = JSON.parse(res.data);
+							if (!(res.action in _onSocket)) {
+								if (res.action != 'ping' && res.type != 'ping') {
+									uni.showModal({
+										content: '接受到无效的消息',
+									});
+								}
+							} else {
+								console.log("接收到消息:", res.action)
+								_onSocket[res.action](res.data);
 							}
-						} else {
-							console.log("接收到消息:",res.action)
-							_onSocket[res.action](res.data);
-						}
 
-						return;
-						/** 下面的写法二进制接收数据不兼容APP */
-						
-						if (res.data instanceof Blob) {
-							/** js中的blob没有没有直接读出其数据的方法,通过FileReader来读取相关数据 */
-							let reader = new FileReader();
-							reader.readAsDataURL(res.data);							
-						    /** 当读取操作成功完成时调用. */
-							reader.onload = function(evt){								
-								let data = JSON.parse(((str) => {
-									/**  base64编码解析 */
-									if(str.indexOf(',') > -1){
-										str = str.split(',')[1];
-									}
-									return decodeURIComponent(atob(str).split('').map((c) => {
-									    return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
-									}).join(''));
-								})(evt.target.result));
-								if(!(data.action in _onSocket)){
-									if(data.action != 'ping'){
+							return;
+							/** 下面的写法二进制接收数据不兼容APP */
+
+							if (res.data instanceof Blob) {
+								/** js中的blob没有没有直接读出其数据的方法,通过FileReader来读取相关数据 */
+								let reader = new FileReader();
+								reader.readAsDataURL(res.data);
+								/** 当读取操作成功完成时调用. */
+								reader.onload = function(evt) {
+									let data = JSON.parse(((str) => {
+										/**  base64编码解析 */
+										if (str.indexOf(',') > -1) {
+											str = str.split(',')[1];
+										}
+										return decodeURIComponent(atob(str).split('')
+											.map((c) => {
+												return '%' + ('00' + c
+													.charCodeAt(0).toString(
+														16)).slice(-2);
+											}).join(''));
+									})(evt.target.result));
+									if (!(data.action in _onSocket)) {
+										if (data.action != 'ping') {}
+										return;
 									}
-									return;
+									_onSocket[data.action](data.data);
 								}
-								_onSocket[data.action](data.data);
+							}
+						});
+
+						/** 这里发送token到服务器验证 */
+						callback({
+							action: 'checkToken',
+							data: _data.localData('token'),
+						});
+
+						/** 这里如果有需要发送的数据,就等待2s再进行发送,如果2s后,token验证还是不合法,就舍弃这次的发送 */
+						if (send_data) {
+							if (_data.localData('token')) {
+								callback(send_data);
+							} else {
+								callback({
+									action: 'checkToken',
+									data: _data.localData('token'),
+								});
 							}
 						}
+
 					});
-					
-					/** 这里发送token到服务器验证 */						
-					callback({
-						action: 'checkToken',
-						data: _data.localData('token'),
+
+					uni.onSocketClose((err) => {
+						_data.data('socket_state', 0);
+						params.lockReconnect = false;
+						self.$reconnect();
+					});
+
+					uni.onSocketError((err) => {
+						_data.data('socket_state', 0);
+						params.lockReconnect = false;
+						self.$reconnect();
 					});
-					
-					/** 这里如果有需要发送的数据,就等待2s再进行发送,如果2s后,token验证还是不合法,就舍弃这次的发送 */
-					if(send_data) {
-						if(_data.localData('token')){
-							callback(send_data);
-						}else {
-							callback({
-								action: 'checkToken',
-								data: _data.localData('token'),
+				},
+				(send_data) => {
+
+					uni.sendSocketMessage({
+						data: JSON.stringify(send_data),
+						fail(err) {
+							return;
+							uni.showModal({
+								content: JSON.stringify(err) + '---发送消息失败',
 							});
+						},
+						success(res) {
+							if (cb != undefined) {
+								cb();
+							}
 						}
-					}
-					
-				});
-				
-				uni.onSocketClose((err) => {
-					_data.data('socket_state',0);
-					params.lockReconnect = false;
-					self.$reconnect();
-				});
-				
-				uni.onSocketError((err) => {
-					_data.data('socket_state',0);
-					params.lockReconnect = false;
-					self.$reconnect();
-				});
-			},
-			(send_data) => {
-				
-				uni.sendSocketMessage({
-					data: JSON.stringify(send_data),
-					fail(err){
-						return;
-						uni.showModal({
-							content: JSON.stringify(err) + '---发送消息失败',
-						});
-					},
-					success(res) {
-						if(cb !=undefined ){
-							cb();
-						}
-					}
+					});
+
+					return true;
 				});
-				
-				return true;
-			});	
 		},
-		
+
 		/** 
 		 * http发送文件(图片、文件、语音)
 		 * @param json obj 
@@ -326,34 +342,34 @@ export default {
 			onProgressUpdate: function 上传进度监听
 		   }
 		 */
-		$httpSendFile(config){
-			if(!config){
+		$httpSendFile(config) {
+			if (!config) {
 				config = {};
 			}
 			let send_data = ('data' in config ? config.data : {});
 			send_data['_token'] = _data.localData('token');
-			
+
 			((callback) => {
-				switch (config.type){
+				switch (config.type) {
 					/** 对话上传文件 */
 					case 0:
-						callback(config.local_url,'/im/upload/chat');
+						callback(config.local_url, '/im/upload/chat');
 						break;
-					/** 上传头像 */
+						/** 上传头像 */
 					case 1:
-						callback(config.local_url,'/im/upload/photo');
+						callback(config.local_url, '/im/upload/photo');
 						break;
-					/** 朋友圈上传文件 */
+						/** 朋友圈上传文件 */
 					case 2:
-						callback(config.local_url,'/im/upload/circle');
+						callback(config.local_url, '/im/upload/circle');
 						break;
-					/** 朋友圈背景图片上传 */
+						/** 朋友圈背景图片上传 */
 					case 3:
-						callback(config.local_url,'/im/upload/circleImg');
+						callback(config.local_url, '/im/upload/circleImg');
 						break;
-					/** 群头像上传 */
+						/** 群头像上传 */
 					case 4:
-						callback(config.local_url,'/im/upload/groupPhoto');
+						callback(config.local_url, '/im/upload/groupPhoto');
 						break;
 					default:
 						uni.showModal({
@@ -361,8 +377,8 @@ export default {
 						});
 						break;
 				}
-			})((local_url,action_path) => {
-				console.log("local_url",local_url)
+			})((local_url, action_path) => {
+				console.log("local_url", local_url)
 				let uploadTask = uni.uploadFile({
 					url: (_data.data('static_url') + action_path),
 					filePath: local_url,
@@ -370,26 +386,26 @@ export default {
 					/** formData必须要有值,否则会上传失败 */
 					formData: send_data,
 					success: (res) => {
-						if(res.statusCode == 200){
-							if('success' in config){
+						if (res.statusCode == 200) {
+							if ('success' in config) {
 								console.log(res.data);
 								res.data = JSON.parse(res.data);
-								if(res.data.err){
-									if('fail' in config){
+								if (res.data.err) {
+									if ('fail' in config) {
 										config.fail(err);
 									} else {
 										uni.showModal({
 											content: res.data.msg,
 										});
 									}
-								}else{
+								} else {
 									config.success(res.data.data);
 								}
 							}
 						}
 					},
-					fail(err){
-						if('fail' in config){
+					fail(err) {
+						if ('fail' in config) {
 							config.fail(err);
 						} else {
 							uni.showModal({
@@ -399,15 +415,15 @@ export default {
 					}
 				});
 				uploadTask.onProgressUpdate((res) => {
-					
-					if('onProgressUpdate' in config){
+
+					if ('onProgressUpdate' in config) {
 						config.onProgressUpdate();
 					}
-					
+
 					return;
 				});
 			});
 		},
-		
+
 	}
-}
+}

+ 2 - 0
common/common.js

@@ -202,6 +202,8 @@ const pushLocalMsg = (data)=>{
 }
 const scanCode=()=>{
         uni.scanCode({
+			scanType:['qrCode'],
+			onlyFromCamera:true,
             success: function (res) {
 				let result = res.result;
 				let params = {};

+ 2 - 2
manifest.json

@@ -2,8 +2,8 @@
     "name" : "优哈",
     "appid" : "__UNI__A063051",
     "description" : "优哈",
-    "versionName" : "1.0.7",
-    "versionCode" : 107,
+    "versionName" : "1.0.9",
+    "versionCode" : 109,
     "transformPx" : false,
     "networkTimeout" : {
         "request" : 6000,

+ 1 - 1
pages/contract/privacy.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="box">
-		<view class="title">“正一线上商城”隐私政策</view>
+		<view class="title">“优哈”隐私政策</view>
 		  <view class="pb10">公司名称:浙江六牛科技有限公司</view>
 		  <view class="pb10">注册地址:浙江省台州市椒江区市府大道西段618号
 </view>

+ 127 - 1
pages/details/index.vue

@@ -146,6 +146,25 @@
                 </view>
             </view>
         </view>
+		<view class="uni-list" style="margin-top: 20upx;" >
+			<view class="uni-list-cell" hover-class="none">
+				<view class="uni-list-cell-navigate" @tap="goDelete">
+					<view class="tool">
+						删除好友
+					</view>
+				</view>
+			</view>
+		</view>
+		<view class="uni-list" style="margin-top: 20upx;" >
+			<view class="uni-list-cell" hover-class="none">
+				<view class="uni-list-cell-navigate" @tap="goPing">
+					<view class="tool">
+						屏蔽好友
+					</view>
+				</view>
+			</view>
+		</view>
+		
         <view class="uni-card">
             <view class="uni-list">
 
@@ -160,7 +179,8 @@
                                 发消息
                             </view>
                         </view>
-
+						
+						
                     </view>
                     <view class="uni-list-cell" hover-class="none" v-if="0">
                         <view class="uni-list-cell-navigate">
@@ -240,6 +260,112 @@
             },
         },
         methods: {
+			goDelete(){
+				let _this = this;
+				uni.showModal({
+					title: '重要提示',
+					content: '删除好友及相关的会话数据并且不能恢复,确认删除吗?',
+					success: function (res) {
+						if (res.confirm) {
+							_this.$httpSend({
+								path: '/im/remove/friend',
+								data: { user_id: _this.user_id },
+								success(list_id) {
+									uni.showToast({
+										title: '操作成功',
+										duration: 1500
+									});
+									
+									/** 删除会话列表数据 **/
+									for(let i = 0,local_chat_list = _data.localData('chat_list'),j = local_chat_list.length;i < j;i ++){
+										if(local_chat_list[i].list_id == list_id){											
+											local_chat_list.splice(i,1);											
+											_data.localData('chat_list',local_chat_list);
+											uni.$emit('data_chat_list',local_chat_list);
+											break;
+										}
+									}
+									
+									/** 删除对话数据 */
+									_data.localData(list_id,null);
+									
+									/** 从我的好友列表里删除 */
+									for(let i = 0,v = _data.localData('friend_list'),j = v.length;i < j;i ++){
+										for(let k = 0,o = v[i].data,l = o.length;k < l;k ++){
+											if(o[k].user_id == _this.user_id){
+												v[i].data.splice(k,1);
+												_data.localData('friend_list',v);
+												uni.$emit('data_friend_list',v);
+												break;
+											}
+										}
+									}
+									
+									setTimeout(() => {
+										uni.switchTab({
+											url: '../friend/index',
+										});
+									},1600);
+								}
+								
+							});
+						}
+					}
+				});
+			},
+			goPing(){
+				let _this = this;
+				uni.showModal({
+					title: '重要提示',
+					content: '是否要屏蔽好友?',
+					success: function (res) {
+						if (res.confirm) {
+							_this.$httpSend({
+								path: '/im/remove/friend',
+								data: { user_id: _this.user_id },
+								success(list_id) {
+									uni.showToast({
+										title: '操作成功',
+										duration: 1500
+									});
+									
+									/** 删除会话列表数据 **/
+									for(let i = 0,local_chat_list = _data.localData('chat_list'),j = local_chat_list.length;i < j;i ++){
+										if(local_chat_list[i].list_id == list_id){											
+											local_chat_list.splice(i,1);											
+											_data.localData('chat_list',local_chat_list);
+											uni.$emit('data_chat_list',local_chat_list);
+											break;
+										}
+									}
+									
+									/** 删除对话数据 */
+									_data.localData(list_id,null);
+									
+									/** 从我的好友列表里删除 */
+									for(let i = 0,v = _data.localData('friend_list'),j = v.length;i < j;i ++){
+										for(let k = 0,o = v[i].data,l = o.length;k < l;k ++){
+											if(o[k].user_id == _this.user_id){
+												v[i].data.splice(k,1);
+												_data.localData('friend_list',v);
+												uni.$emit('data_friend_list',v);
+												break;
+											}
+										}
+									}
+									
+									setTimeout(() => {
+										uni.switchTab({
+											url: '../friend/index',
+										});
+									},1600);
+								}
+								
+							});
+						}
+					}
+				});
+			},
             goKefu(){
                 uni.navigateTo({'url':'/pages/chat/message?list_id='+_data.data('kefu_list_id')})
             },

+ 2 - 2
pages/in/login.vue

@@ -7,8 +7,8 @@
 			<input class="zai-input" v-model="form.username" placeholder="请输入用户名" />
 			<input class="zai-input" v-model="form.password" :class="['landing', checkIn ? 'landing_true' : 'landing_false']" type="password" placeholder="请输入密码" />
 			<view class="zai-label" style="padding: 20upx 0;"></view>
-			<label class="two">
-				<checkbox @click="checkboxChange" style="transform:scale(0.7)" color="#6EAB4E" :checked="istype" />
+			<label class="two" @click="checkboxChange">
+				<checkbox style="transform:scale(0.7)" color="#6EAB4E" :checked="istype" />
 				我已阅读并同意
 				<text @click="navTo('/pages/contract/agreement')">《用户协议》</text>
 				&nbsp

+ 18 - 10
pages/in/reg.vue

@@ -139,17 +139,25 @@
 					});
 					return false;
 				}
-				_get.getSms({mobile:this.form.username,type:'REGISTER'},function (res) {
-                    console.log(22222)
-					_this.cutDown();
-				},function (res) {
-				    console.log(1111)
-					uni.showToast({
-						title: res.msg,
-						duration:2000,
-						icon:'none'
+				try{
+					_get.getSms({mobile:this.form.username,type:'REGISTER'},function (res) {
+						console.log(22222)
+						_this.cutDown();
+					},function (res) {
+						console.log(1111)
+						uni.showToast({
+							title: res.msg,
+							duration:2000,
+							icon:'none'
+						});
+					})
+				}catch(e){
+					uni.showModal({
+						title: '请求错误',
+						content: e.message,
 					});
-				})
+					//TODO handle the exception
+				}
 			},
 			cutDown(val){//倒计时
 				//获取验证码

+ 2 - 2
unpackage/cache/certdataios

@@ -1,3 +1,3 @@
-iosProfile=C:/Users/Administrator/Desktop/红包/ios/ts.mobileprovision
-ioscertFile=C:/Users/Administrator/Desktop/红包/ios/youha.p12
+iosProfile=C:/Users/Administrator/Desktop/红包/证书/ts.mobileprovision
+ioscertFile=C:/Users/Administrator/Desktop/红包/证书/youha.p12
 ioscertPassword=7IwuiYJfyRjKKTfhI7sjzw==