lalala 6 лет назад
Родитель
Сommit
571d35c001

+ 2 - 2
mobile-code/src/admin/order/fill-form.vue

@@ -3,10 +3,10 @@
 		<form @submit="formSubmit">
 			<app-delivery-module ref="appDelivery" />
 			<!-- 匿名派送 -->
-			<div class="none-name-delivery flex-center">
+			<!-- <div class="none-name-delivery flex-center">
 				<checkbox class="ljd-checkbox" @change="anonymityChange"></checkbox>
 				<span class="none-name-text">匿名派送</span>
-			</div>
+			</div> -->
 			<!-- 按钮 -->
 			<div class="app-footer">
 				<button class="admin-button-com blue middle" formType="submit">提交</button>

+ 1 - 1
mobile-code/src/components/app-delivery.vue

@@ -111,7 +111,7 @@
 		props: {
 			anonymous: {
 				type: Boolean,
-				default: false
+				default: true
 			}
 		},
 		data() {

+ 1 - 1
mobile-code/src/pages.json

@@ -73,7 +73,7 @@
 				{
 					"path": "index",
 					"style": {
-						"navigationBarTitleText": "支付"
+						"navigationBarTitleText": ""
 					}
 				}
 			]

+ 68 - 40
mobile-code/src/pages/chat/index.vue

@@ -9,7 +9,7 @@
 						<div class="list-attr" v-if="index == 2">
 							<img :src="`${constant.imgUrl}/retail/user/attr-default.png`" alt />
 						</div>
-						<div class="list-content" v-if="index == 2">哇哈哈哈~ 苏伟强是个大骗子, 苏伟强是个大骗子,拉~</div>
+						<div class="list-content" v-if="index == 2">哇哈哈哈~ 拉~</div>
 						<div class="list-content list-img" v-else>
 							<div class="list-content-img">
 								<img :src="`${constant.imgUrl}/retail/extension.png`" alt mode="center" />
@@ -52,32 +52,60 @@
 </template>
 
 <script>
-import AppSearchModule from '@/components/module/app-search'
-import ModalModule from '@/components/plugin/modal'
-export default {
-	name: 'chat-index',
-	components: {
-		AppSearchModule,
-		ModalModule
-	},
-	data() {
-		return {
-			constant: this.$constant,
-			linkShow: false
-		}
-	},
-	onLoad(option) {},
-	computed: {
-		scrollHei() {
-			return uni.upx2px(1334 - 170) + 'px'
-		}
-	},
-	methods: {
-		modalCancel() {
-			this.linkShow = false
+	import AppSearchModule from '@/components/module/app-search'
+	import ModalModule from '@/components/plugin/modal'
+	import chat from '@/utils/chat'
+	export default {
+		name: 'chat-index',
+		components: {
+			AppSearchModule,
+			ModalModule
+		},
+		data() {
+			return {
+				constant: this.$constant,
+				linkShow: false,
+				// === chat
+				messagehandler: null
+			}
+		},
+		onLoad(option) {},
+		destroyed() {
+			this.messagehandler && this.messagehandler.destroy()
+		},
+		computed: {
+			scrollHei() {
+				return uni.upx2px(1334 - 170) + 'px'
+			}
+		},
+		methods: {
+			init() {
+				console.log('chat', chat)
+				//建立messagesocket连接
+				this.messagehandler = chat()
+				this.messagehandler.watch(this.messagehandler.MESSAGE_TYPE.CART, (type, data, source, target) => {
+					// let message
+					// if (type === 1) {
+					// 	message = this._socketDataToMessageAdapter(data)
+					// }
+					// if (message == null) return
+					// let self = this
+					// this.messages.unshift(message)
+					// this.$notify.info({
+					// 	title: '提示',
+					// 	message: message.ms_content,
+					// 	onClick() {
+					// 		self.checkMessage(message)
+					// 	},
+					// 	duration: 3000
+					// })
+				})
+			},
+			modalCancel() {
+				this.linkShow = false
+			}
 		}
 	}
-}
 </script>
 
 <style lang="scss" scoped>
@@ -201,20 +229,20 @@ export default {
 					font-size: 32px;
 				}
 			}
-        }
+		}
+	}
+	// 发链接弹窗
+	.link-modal-wrap {
+		.link-tit {
+			text-align: center;
+			font-size: 40px;
+			margin-bottom: 40px;
+		}
+		.btn-wrap {
+			.button-com {
+				display: block;
+				margin-bottom: 20px;
+			}
+		}
 	}
-        // 发链接弹窗
-        .link-modal-wrap {
-            .link-tit {
-                text-align: center;
-                font-size: 40px;
-                margin-bottom: 40px;
-            }
-            .btn-wrap {
-                .button-com {
-                    display: block;
-                    margin-bottom: 20px;
-                }
-            }
-        }
 </style>

+ 4 - 0
mobile-code/src/pages/home/shop.vue

@@ -98,6 +98,10 @@ export default {
 			})
 		},
 		goNavBtn() {
+			if (!this.shop.shopLat || !this.shop.shopLong) {
+				this.$msg('暂无地址!')
+				return false
+			}
 			uni.openLocation({
 				latitude: parseFloat(this.shop.shopLat),
 				longitude: parseFloat(this.shop.shopLong),

+ 74 - 67
mobile-code/src/pages/interest/invite.vue

@@ -47,32 +47,37 @@
 					</div>
 				</div>
 				<div class="invite-list-wrap">
-					<div class="invite-list flex-center-between" v-for="(item, index) in list" :key="index">
-						<div class="list-left flex-center-start">
-							<div class="list-img">
-								<img :src="`${constant.imgUrl}/retail/user/attr-default.png`" alt mode="widthFix" />
-							</div>
-							<div class>
-								<div class="app-size-30">{{ item.userName }}</div>
-								<div class="app-color-3 invite-list-status">
-									<block v-if="item.status == 0">
-										<span>{{ item.addTime | formatTime }}</span>
-										<span>领券</span>
-									</block>
-									<block v-else-if="item.status == 1">
-										<span>{{ item.orderTime | formatTime }}</span>
-										<span>下单</span>
-										<span class="app-price">¥{{ item.amount }}</span>
-									</block>
-									<block v-else-if="item.status == 2">
-										<span>{{ item.giveTime | formatTime }}</span>
-										<span>兑奖</span>
-									</block>
+					<block v-if="!$util.isEmpty(list)">
+						<div class="invite-list flex-center-between" v-for="(item, index) in list" :key="index">
+							<div class="list-left flex-center-start">
+								<div class="list-img">
+									<img :src="`${constant.imgUrl}/retail/user/attr-default.png`" alt mode="widthFix" />
+								</div>
+								<div class>
+									<div class="app-size-30">{{ item.userName }}</div>
+									<div class="app-color-3 invite-list-status">
+										<block v-if="item.status == 0">
+											<span>{{ item.addTime | formatTime }}</span>
+											<span>领券</span>
+										</block>
+										<block v-else-if="item.status == 1">
+											<span>{{ item.orderTime | formatTime }}</span>
+											<span>下单</span>
+											<span class="app-price">¥{{ item.amount }}</span>
+										</block>
+										<block v-else-if="item.status == 2">
+											<span>{{ item.giveTime | formatTime }}</span>
+											<span>兑奖</span>
+										</block>
+									</div>
 								</div>
 							</div>
+							<div class="app-size-26">{{ item.status | constantfilter('INVITE_STATUS') }}</div>
 						</div>
-						<div class="app-size-26">{{ item.status | constantfilter('INVITE_STATUS') }}</div>
-					</div>
+					</block>
+					<block v-else>
+						<app-wrapper-empty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
+					</block>
 					<!-- <div class="load-more flex-center-center app-color-3">加载更多...</div> -->
 				</div>
 			</div>
@@ -94,55 +99,57 @@
 </template>
 
 <script>
-import AlertModule from '@/components/plugin/alert'
-import AppShareMask from '@/components/module/app-share-mask'
-// api
-import { getList, getProfile } from '@/api/invite'
-export default {
-	name: 'invite',
-	components: {
-		AlertModule,
-		AppShareMask
-	},
-	data() {
-		return {
-			data: {
-				constant: this.$constant,
-				stat: {},
-				asset: {}
-			},
-			list: [],
-			showAlert: false,
-			showShare: false
-		}
-	},
-	onLoad() {
-		// this.init()
-	},
-	methods: {
-		init() {
-			this._getProfile()
-			this._getList()
-		},
-		_getProfile() {
-			getProfile().then(res => {
-				this.data = res.data
-			})
+	import AppWrapperEmpty from '@/components/app-wrapper-empty'
+	import AlertModule from '@/components/plugin/alert'
+	import AppShareMask from '@/components/module/app-share-mask'
+	// api
+	import { getList, getProfile } from '@/api/invite'
+	export default {
+		name: 'invite',
+		components: {
+			AlertModule,
+			AppShareMask,
+			AppWrapperEmpty
 		},
-		_getList() {
-			return getList().then(res => {
-				if (this.$util.isEmpty(res.data.list)) return false
-				this.list = res.data.list
-			})
+		data() {
+			return {
+				data: {
+					constant: this.$constant,
+					stat: {},
+					asset: {}
+				},
+				list: [],
+				showAlert: false,
+				showShare: false
+			}
 		},
-		hideAlert() {
-			this.showAlert = false
+		onLoad() {
+			// this.init()
 		},
-		hideShare() {
-			this.showShare = false
+		methods: {
+			init() {
+				this._getProfile()
+				this._getList()
+			},
+			_getProfile() {
+				getProfile().then(res => {
+					this.data = res.data
+				})
+			},
+			_getList() {
+				return getList().then(res => {
+					if (this.$util.isEmpty(res.data.list)) return false
+					this.list = res.data.list
+				})
+			},
+			hideAlert() {
+				this.showAlert = false
+			},
+			hideShare() {
+				this.showShare = false
+			}
 		}
 	}
-}
 </script>
 
 <style lang="scss" scoped>

+ 2 - 2
mobile-code/src/pages/order/buy.vue

@@ -42,10 +42,10 @@
 			</div>
 
 			<!-- 匿名派送 -->
-			<div class="none-name-delivery flex-center">
+			<!-- <div class="none-name-delivery flex-center">
 				<checkbox class="ljd-checkbox" @change="anonymityChange"></checkbox>
 				<span class="none-name-text">匿名派送</span>
-			</div>
+			</div> -->
 
 			<app-trademark />
 			<!-- 按钮 -->

+ 132 - 0
mobile-code/src/utils/chat.js

@@ -0,0 +1,132 @@
+// import { url } from '@src/utils/axios'
+const DEFAULT_ADDRESS = process.env.NODE_ENV === 'production' ? 'ws://saas.api.beiface.com:1313' : 'http://api.m.huaml.com/chat/begin'
+
+const TYPE = {
+	CART: 1
+}
+Object.freeze(TYPE)
+
+const init = (address = DEFAULT_ADDRESS) => {
+	let ws = new WebSocket(address)
+	// 当socket连接打开时
+	ws.onopen = function (e) {
+		console.log('websocket握手成功')
+		// onMessage(e)
+	}
+	// 当有消息时根据消息类型显示不同信息
+	ws.onmessage = function (e) {
+		let data
+		try {
+			data = JSON.parse(e.data)
+		} catch (e) {
+			data = e.data
+		}
+		let collection = Watcher.collection || {}
+		Object.keys(collection).forEach(watcherId => {
+			let watcher = collection[watcherId]
+			if (watcher == null) return
+			watcher.receive(data)
+		})
+	}
+
+	ws.onclose = function () {
+		console.log('连接关闭,定时重连')
+		// init(address)
+	}
+	ws.onerror = function () {
+		console.log('出现错误')
+	}
+
+	return ws
+}
+
+let watcherId = 1000
+
+const isValidType = type => {
+	// return type == null || type == '' || _.isString(type)
+	if (type == null || type == '') return true
+	let i = -1
+	Object.keys(TYPE).forEach((key, index) => {
+		if (TYPE[key] === type) return (i = index)
+	})
+
+	return i === -1 ? false : true
+}
+
+class Watcher {
+	constructor(types, cb, filter) {
+		this.cb = cb
+		this.filter = filter
+		this._id = watcherId++
+		this.types = []
+		this._isVaildTypes(types)
+
+		this._register()
+	}
+	_isVaildTypes(types) {
+		if (_.isArray(types)) {
+			types.forEach(type => {
+				this._isVaildTypes(type)
+			})
+		} else {
+			let valid = isValidType(types)
+			if (!valid) throw new Error(`types item is invalid (null  or String), current type is ${type}`)
+		}
+		if (types != null && types != '') this.types.push(types)
+	}
+
+	_register() {
+		Watcher.collection[this._id] = this
+	}
+
+	_destroy() {
+		let collection = Watcher.collection
+		collection[this._id] = null
+	}
+	_isNeedReceiveMessage(type, data, source, target) {
+		if (this.types.length == 0) return true
+		let index = this.types.findIndex(_type => {
+			return _type == type
+		})
+		if (index == -1) return false
+		if (!_.isFunction(this.filter)) {
+			return true
+		}
+		try {
+			return this.filter.call(null, type, data, source, target)
+		} catch (e) {
+			throw new Error(e)
+		}
+	}
+	receive({ type, data, source, target } = {}) {
+		let _need = this._isNeedReceiveMessage(type, data, source, target)
+		if (!_need) {
+			return
+		}
+		this.cb.call(null, type, data, source, target)
+	}
+}
+
+//收集器
+Watcher.collection = {}
+
+const handler = () => {
+	let watcher
+	let ws
+	return {
+		MESSAGE_TYPE: TYPE,
+		watch(types, cb, filter) {
+			ws = init()
+			watcher = new Watcher(types, cb, filter)
+			return watcher
+		},
+		destroy() {
+			watcher._destroy()
+			ws.close()
+			watcher = null
+			ws = null
+		}
+	}
+}
+
+export default handler