diff --git a/littleApp_child/.gitignore b/littleApp_child/.gitignore new file mode 100644 index 0000000..14ea590 --- /dev/null +++ b/littleApp_child/.gitignore @@ -0,0 +1,14 @@ +# Windows +[Dd]esktop.ini +Thumbs.db +$RECYCLE.BIN/ + +# macOS +.DS_Store +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes + +# Node.js +node_modules/ diff --git a/littleApp_child/app.js b/littleApp_child/app.js index 0b14dfb..046d434 100644 --- a/littleApp_child/app.js +++ b/littleApp_child/app.js @@ -1,6 +1,18 @@ //app.js +//聊天控件 +let WebIM = wx.WebIM = require("./utils/WebIM.js").default; +let disp = require("./utils/broadcast"); + App({ - + getRoomPage: function () { + return this.getPage("pages/consulting/consulting") + }, + getPage: function (pageName) { + var pages = getCurrentPages() + return pages.find(function (page) { + return page.__route__ == pageName + }) + }, onLaunch: function (option) { var that = this //调用API从本地缓存中获取数据 @@ -32,7 +44,7 @@ App({ wx.login({ success: function (res) { // success - that.globalData.openInfo.code = res.code + that.globalData.openInfo.childCode = res.code }, fail: function (res) { // fail @@ -42,6 +54,220 @@ App({ } }) + //聊天 + WebIM.conn.listen({ + onOpened: function (message) { + console.log("登录成功") + wx.setStorageSync('isHxOpend', true) + // WebIM.conn.setPresence() + // WebIM.conn.getRoster(rosters) + }, + onPresence: function (message) { + console.log('onPresence', message) + var pages = getCurrentPages() + if (message.type == "unsubscribe") { + pages[0].moveFriend(message) + } + if (message.type === "subscribe") { + //console.log('MMMMMMMMMMMMMM',message.status) + if (message.status === '[resp:true]') { + return + } else { + /*同意添加好友操作的实现方法*/ + WebIM.conn.subscribed({ + to: message.from + }); + } + } + }, + onRoster: function (message) { + // console.log('onRoster', message) + // var pages = getCurrentPages() + // if (pages[0]) { + // pages[0].onShow() + // } + }, + onTextMessage(message){ + console.log("onTextMessage", message); + var page = that.getRoomPage(); + if(message){ + if(onMessageError(message)){ + if (page && page.data != null && page.data.yourhxname && message.from == page.data.yourhxname) { + page.receiveMsg(message, 'txt') + }else{ + var value = WebIM.parseEmoji(message.data.replace(/\n/mg, '')) + var time = WebIM.time() + var msgData = { + info: { + from: message.from, + to: message.to + }, + username: '', + yourname: message.from, + serviceId: message.ext.serviceId, + msg: { + type: 'txt', + data: value, + url: message.url + }, + style: '', + time: time, + mid: 'txt' + message.id + } + wx.vibrateLong({ + success:function() { + console.log('震动调取成功') + }, + }) + that.globalData.unrederMsg.push(msgData); + } + } + } + }, + onEmojiMessage: function (message) { + console.log("onEmojiMessage", message); + if(message){ + if(onMessageError(message)){ + msgStorage.saveReceiveMsg(message, msgType.EMOJI); + } + calcUnReadSpot(message); + //ack(message); + } + }, + onPictureMessage(message){ + console.log("onPictureMessage", message); + var page = that.getRoomPage() + if(message){ + if(onMessageError(message)){ + if (page && page.data != null && page.data.yourhxname && message.from == page.data.yourhxname) { + page.receiveMsg(message, 'img') + }else{ + var time = WebIM.time() + var msgData = { + info: { + from: message.from, + to: message.to + }, + username: '', + yourname: message.from, + msg: { + type: 'img', + data: message.url, + url: message.url + }, + style: '', + time: time, + mid: 'img' + message.id + } + wx.vibrateLong({ + success:function() { + console.log('震动调取成功') + }, + }) + that.globalData.unrederMsg.push(msgData); + } + } + calcUnReadSpot(message); + //ack(message); + } + }, + onAudioMessage: function ( message ) { + console.log("onAudioMessage", message); + var page = that.getRoomPage() + if(message){ + if(onMessageError(message)){ + if (page && page.data != null && page.data.yourhxname && message.from == page.data.yourhxname) { + page.receiveMsg(message, 'audio') + }else{ + var time = WebIM.time() + var msgData = { + info: { + from: message.from, + to: message.to + }, + username: '', + yourname: message.from, + msg: { + type: 'audio', + data: message.url, + url: message.url, + length : message.length, + token : message.accessToken + }, + style: '', + time: time, + mid: 'audio' + message.id + } + wx.vibrateLong({ + success:function() { + console.log('震动调取成功') + }, + }) + that.globalData.unrederMsg.push(msgData); + } + } + calcUnReadSpot(message); + //ack(message); + } + }, + // 各种异常 + onError(error){ + console.log(error) + // 16: server-side close the websocket connection + if(error.type == WebIM.statusCode.WEBIM_CONNCTION_DISCONNECTED && !logout){ + if(WebIM.conn.autoReconnectNumTotal < WebIM.conn.autoReconnectNumMax){ + return; + } + wx.showToast({ + title: "server-side close the websocket connection", + duration: 1000 + }); + wx.redirectTo({ + url: "../login/login" + }); + logout = true + return; + } + // 8: offline by multi login + if(error.type == WebIM.statusCode.WEBIM_CONNCTION_SERVER_ERROR){ + wx.showToast({ + title: "offline by multi login", + duration: 1000 + }); + wx.redirectTo({ + url: "../login/login" + }); + } + if(error.type == WebIM.statusCode.WEBIM_CONNCTION_OPEN_ERROR){ + wx.hideLoading() + disp.fire("em.xmpp.error.passwordErr"); + // wx.showModal({ + // title: "用户名或密码错误", + // confirmText: "OK", + // showCancel: false + // }); + } + if (error.type == WebIM.statusCode.WEBIM_CONNCTION_AUTH_ERROR) { + wx.hideLoading() + disp.fire("em.xmpp.error.tokenErr"); + } + if (error.type == 'socket_error') {///sendMsgError + console.log('socket_errorsocket_error', error) + wx.showToast({ + title: "网络已断开", + icon: 'none', + duration: 2000 + }); + disp.fire("em.xmpp.error.sendMsgErr", error); + } + }, + onOffline: function () { + console.log("onOffline:") + }, + onOnline: function () { + console.log("onOnline:") + } + }) }, getUserInfo: function (cb) { var that = this @@ -69,7 +295,51 @@ App({ artList:[], days:0, currentId:'', - tourist:false + tourist:false, + unrederMsg:[] }, +}) +function calcUnReadSpot(message){ + let myName = wx.getStorageSync("myUsername"); + let members = wx.getStorageSync("member") || []; //好友 + var listGroups = wx.getStorageSync('listGroup')|| []; //群组 + let allMembers = members.concat(listGroups) + let count = allMembers.reduce(function(result, curMember, idx){ + let chatMsgs; + if (curMember.groupid) { + chatMsgs = wx.getStorageSync(curMember.groupid + myName.toLowerCase()) || []; + }else{ + chatMsgs = wx.getStorageSync(curMember.name.toLowerCase() + myName.toLowerCase()) || []; + } + return result + chatMsgs.length; + }, 0); + getApp().globalData.unReadMessageNum = count; + disp.fire("em.xmpp.unreadspot", message); +} + +function ack(receiveMsg){ + // 处理未读消息回执 + var bodyId = receiveMsg.id; // 需要发送已读回执的消息id + var ackMsg = new WebIM.message("read", WebIM.conn.getUniqueId()); + ackMsg.set({ + id: bodyId, + to: receiveMsg.from + }); + WebIM.conn.send(ackMsg.body); +} + +function onMessageError(err){ + if(err.type === "error"){ + wx.showToast({ + title: err.errorText + }); + return false; + } + return true; +} -}) \ No newline at end of file +function getCurrentRoute(){ + let pages = getCurrentPages(); + let currentPage = pages[pages.length - 1]; + return currentPage.route; +} \ No newline at end of file diff --git a/littleApp_child/app.json b/littleApp_child/app.json index b38f584..e33840b 100644 --- a/littleApp_child/app.json +++ b/littleApp_child/app.json @@ -28,7 +28,18 @@ "pages/Register/Register", "pages/Guide/guide", "pages/checkupInput/checkupInput", - "pages/inspect/inspectList" + "pages/inspect/inspectList", + "pages/diet/measuret", + "pages/inforBind/inforBind", + "pages/QRCodePage/QRCodePage", + "pages/DiseaseGuide/DiseaseGuide", + "pages/quickMeasurement/quickMeasurement", + "pages/doctorLists/doctorLists", + "pages/payFail/payFail", + "pages/paySuccess/paySuccess", + "pages/consulting/consulting", + "pages/consultationRecord/consultationRecord", + "pages/chatHis/chatHis" ], "window": { "backgroundTextStyle": "light", @@ -36,5 +47,6 @@ "navigationBarTitleText": "孕婴助手", "navigationBarTextStyle": "black" }, - "sitemapLocation": "sitemap.json" + "sitemapLocation": "sitemap.json", + "useExtendedLib":{"weui":true} } \ No newline at end of file diff --git a/littleApp_child/app.wxss b/littleApp_child/app.wxss index dcc7ca4..0d7c112 100644 --- a/littleApp_child/app.wxss +++ b/littleApp_child/app.wxss @@ -26,7 +26,6 @@ } page { - height:100%; background: rgb(244, 244, 244); } diff --git a/littleApp_child/components/multiple/image/page17_icon_triangle_n@3x.png b/littleApp_child/components/multiple/image/page17_icon_triangle_n@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..9f62f0becab38e58e7f5938e9fd2cef004d658fb GIT binary patch literal 244 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k3?#4J%UA`ZbOU@sTzxVNZ`{6e=FFKJw=Q45 zefj_YRX1*5KKJC@jhk1l-@bAkD0u724IsJ=Le|zTZ-E;5N`m}?88)##_{hAJd;i4z zi!XjJSn}i`P$t9E#WAGf*4uNIVhsucEEgR^WVZd54`-^7ExEv!7WI+;)W3T=@k^)d zSoM3=`6!QRyLBS2tgv<5z0)l(dV=?C-le?SW=n3I=?j+7NL+A3gOzzH?`rLhjZK1F oZBw(2izF7F2-q3c{?o~PN4&&zFZGiTfOax?y85}Sb4q9e07MpV3IG5A literal 0 HcmV?d00001 diff --git a/littleApp_child/components/multiple/multiple.js b/littleApp_child/components/multiple/multiple.js new file mode 100644 index 0000000..a05d6ee --- /dev/null +++ b/littleApp_child/components/multiple/multiple.js @@ -0,0 +1,80 @@ +/** + * Kulus.Liang + * 2020/09/30 + * @title String 控件名 + * @placeholder String 默认提醒 + * @riderCommentList Array 下拉框内容 + * @modal Array 绑定数据keyname + * **/ + +Component({ + properties: { + title:{ + type:String, + title:'' + }, + placeholder:{ + type:String, + title:'' + }, + riderCommentList:{ + type:Array, + optionalTypes:[] + }, + modal:{ + type:Array, + optionalTypes:[], + observer: function() { + let detailValue = this.data.modal.filter(it => it).map(it => it.value) + this.setData({ + selectedValue:detailValue + }) + } + }, + disabled:{ + type:Boolean, + title:false + } + }, + data: { + selectedValue:'', + buttons: [ + { + type: 'default', + className: '', + text: '取消', + value: 0 + }, + { + type: 'primary', + className: '', + text: '确认', + value: 1 + } + ], + show:false + }, + methods: { + checkboxChange(e){ + let string = "riderCommentList["+e.target.dataset.index+"].selected" + this.setData({ + [string]: !this.data.riderCommentList[e.target.dataset.index].selected + }) + let detailData = this.data.riderCommentList.filter(it => it.selected).map(it => it) + let detailValue = this.data.riderCommentList.filter(it => it.selected).map(it => it.value) + console.log(detailValue) + this.setData({ + modal:detailData, + selectedValue:detailValue + }) + this.triggerEvent('getModel', {data:detailData}, {}) + }, + openhalfScreenDialog(e) { + if(this.data.disabled==false){ + this.setData({ + show: !this.data.show + }) + } + }, + } +}) \ No newline at end of file diff --git a/littleApp_child/components/multiple/multiple.json b/littleApp_child/components/multiple/multiple.json new file mode 100644 index 0000000..6c5970e --- /dev/null +++ b/littleApp_child/components/multiple/multiple.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "mp-halfScreenDialog": "/miniprogram_npm/weui-miniprogram/half-screen-dialog/half-screen-dialog" + } +} \ No newline at end of file diff --git a/littleApp_child/components/multiple/multiple.wxml b/littleApp_child/components/multiple/multiple.wxml new file mode 100644 index 0000000..a81578c --- /dev/null +++ b/littleApp_child/components/multiple/multiple.wxml @@ -0,0 +1,25 @@ + + {{title}} + + + {{selectedValue}} + {{placeholder}} + + + + + + + + + \ No newline at end of file diff --git a/littleApp_child/components/multiple/multiple.wxss b/littleApp_child/components/multiple/multiple.wxss new file mode 100644 index 0000000..b027ed6 --- /dev/null +++ b/littleApp_child/components/multiple/multiple.wxss @@ -0,0 +1,72 @@ +.multiple_picker_view { + background: #fff; + border-radius: 3px; + display: flex; + height: 44px; +} +.multiple_before_text,.symptom_before_text { + font-size: 13px; + color: #48C17B; + margin-left: 8px; + line-height: 44px; + width: 56px; +} +.multiple_name_box{ + display: flex; + width: calc(100% - 62px); + margin: 0 4px; + padding-left: 4px; + align-self: center; + height: 44px +} +.multiple_name_text_color_placeholder{ + color: #999; +} +.multiple_name_text_color{ + color: #333; +} +.multiple_name_text { + font-size: 14px; + line-height: 44px; + line-height: 44px; + padding-right: 12px; + width: calc(100% - 24px); + display: -webkit-box; + overflow: hidden; + white-space: normal; + text-overflow: ellipsis; + word-wrap: break-word; + -webkit-line-clamp:1; + -webkit-box-orient: vertical; +} +.chooce_multiple_image { + width: 12px; + height: 12px; + margin-right: 12px; + margin-top: 15px; +} +.down_drop{ + height: 100%; + z-index: 100; + position: fixed; + background: #fff; +} +.comment-btn{ + display: flex; + height: 152px; + flex-wrap: wrap; +} +.btn{ + width: 150rpx; + height: 70rpx; + font-size: 24rpx; + padding: 0; + border: 1px solid #dcdcdc; + background: #fff; + border-radius: 4px; + margin: 15rpx 10rpx; + text-align: center; +} +.btn-selected{ + border: 1px solid #48C17B; +} \ No newline at end of file diff --git a/littleApp_child/pages/DiseaseGuide/DiseaseGuide.js b/littleApp_child/pages/DiseaseGuide/DiseaseGuide.js new file mode 100644 index 0000000..0b93210 --- /dev/null +++ b/littleApp_child/pages/DiseaseGuide/DiseaseGuide.js @@ -0,0 +1,114 @@ +// pages/DiseaseGuide/DiseaseGuide.js + +// 网络请求工具类 +var networkUtil = require('../../utils/network_util.js') +var api = require('../../utils/apiFile.js') + +// 获取应用实例 +var app = getApp() + +Page({ + + /** + * 页面的初始数据 + */ + data: { + list: [], + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var self = this; + networkUtil._get(api.etArticles, {}, function(res) { + console.log('获取文章信息', res.data.list) + self.setData({ + list: res.data.list + }) + if(self.data.list.length == 0){ + wx.showModal({ + title: '提醒', + content: '暂无疾病指导,请稍后重试!', + showCancel: false, + success: function(res) { + wx.navigateTo({ + url: '../home/home', + }) + } + + }); + } + }, function(res) { + wx.showModal({ + title: '网络异常', + content: res.data.errormsg, + showCancel: false + }); + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + getArticleInfo(days) { + var self = this + // 文章列表 + networkUtil._get(api.homeArtList, { + page: 0, + limit: 100, + days: days + }, function(res) { + console.log('获取文章信息', res.data.list) + artCache[self.data.babyIndex] = res.data.list + self.setArtInfo(res.data.list) + }, function(res) { + wx.stopPullDownRefresh() + }) + }, +}) \ No newline at end of file diff --git a/littleApp_child/pages/DiseaseGuide/DiseaseGuide.json b/littleApp_child/pages/DiseaseGuide/DiseaseGuide.json new file mode 100644 index 0000000..d3afd04 --- /dev/null +++ b/littleApp_child/pages/DiseaseGuide/DiseaseGuide.json @@ -0,0 +1,6 @@ +{ + "navigationBarBackgroundColor": "#48C17B", + "navigationBarTitleText": "疾病指导", + "navigationBarTextStyle": "white", + "backgroundColor": "#d8dbd4" +} \ No newline at end of file diff --git a/littleApp_child/pages/DiseaseGuide/DiseaseGuide.wxml b/littleApp_child/pages/DiseaseGuide/DiseaseGuide.wxml new file mode 100644 index 0000000..7f26392 --- /dev/null +++ b/littleApp_child/pages/DiseaseGuide/DiseaseGuide.wxml @@ -0,0 +1,28 @@ + + + + + + + {{item.title}} + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/littleApp_child/pages/DiseaseGuide/DiseaseGuide.wxss b/littleApp_child/pages/DiseaseGuide/DiseaseGuide.wxss new file mode 100644 index 0000000..6d4a6f1 --- /dev/null +++ b/littleApp_child/pages/DiseaseGuide/DiseaseGuide.wxss @@ -0,0 +1,120 @@ +.article_list_bg { + width: 100%; + background: #F4F4F4; +} + +.article_list { + background: #F4F4F4; + margin-left: 5px; + margin-right: 5px; + margin-top: 11px; +} +.article_bg { + margin-bottom: 10px; + border-radius: 4px; + background: white +} +/* 栏目标题前面图 */ +.article_title_image { + width: 2px; + height: 14px; + margin-left: 15px; + transform: translateY(2px); + background: #48C17B +} +/* 栏目标题文字 */ +.article_title { + height: 34px; + display: inline-block; + line-height: 34px; + font-size: 14px; + color: #979797; + margin-left: 5px; +} +/* 箭头 */ +.article_title_indicator { + width: 12px; + height: 14px; + position: absolute; + right: 15px; + transform: translateY(11px); +} +/* 文章ne内容背景 */ +.article_content { + height: 134px; + position: relative; + width: 100%; +} +/* 内容标题 */ +.article_content_title { + font-size: 14px; + color: #222222; + margin-left: 15px; + margin-right: 85px; + margin-top: 0px; + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 1; +} +/* 内容文字 */ +.article_content_text { + font-size: 12px; + color: #888888; + line-height: 18px; + margin-left: 15px; + margin-right: 109px; + margin-top: 5px; + height: 54px; + display: inline-block; + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 3; +} +/* 内容图 */ +.article_content_image { + position: absolute; + right: 11px; + width: 74px; + height: 74px; + top: 11px; +} +/* 点赞 */ +.article_content_bottomBar { + height: 38px; + width: 100%; + margin-top: 10px; +} + +.article_content_bottomBar_labels { + position: absolute; + right: 0px; + /* height: 100%; */ +} + +.article_content_bottomBar_likes { + float: left; + width: 100px; + margin-left: 10px; +} + +.article_content_bottomBar_likes_icon { + height: 25px; + width: 25px; + margin-right: 4px; +} + +/* 点赞文字 */ +.article_content_bottomBar_likes_text { + font-size: 10px; + color: #C8C6C6; + transform: translateY(-8px) translateX(-5px); + display: inline-block; +} + +.navigator_class { + width: 100%; +} \ No newline at end of file diff --git a/littleApp_child/pages/QRCodePage/QRCodePage.js b/littleApp_child/pages/QRCodePage/QRCodePage.js new file mode 100644 index 0000000..7b40c48 --- /dev/null +++ b/littleApp_child/pages/QRCodePage/QRCodePage.js @@ -0,0 +1,78 @@ +// pages/QRCodePage/QRCodePage.js + +// 获取应用实例 +var app = getApp() +import { toBarcode, toQrcode } from '../../utils/code.js'; + +//存贮尺寸 +Page({ + + /** + * 页面的初始数据 + */ + data: { + encoded:"" + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var encoded = options.encoded; + this.setData({ + encoded:encoded + }) + //self.createQeCode(encoded,'babyQc',size.width,size.height) + var self = this + toBarcode('barcode', encoded , 300, 120); + toQrcode('qrcode', encoded, 300, 300); + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/littleApp_child/pages/QRCodePage/QRCodePage.json b/littleApp_child/pages/QRCodePage/QRCodePage.json new file mode 100644 index 0000000..fbd8439 --- /dev/null +++ b/littleApp_child/pages/QRCodePage/QRCodePage.json @@ -0,0 +1,6 @@ +{ + "navigationBarBackgroundColor": "#48C17B", + "navigationBarTitleText": "查看二维码", + "navigationBarTextStyle": "white", + "backgroundColor": "#d8dbd4" +} \ No newline at end of file diff --git a/littleApp_child/pages/QRCodePage/QRCodePage.wxml b/littleApp_child/pages/QRCodePage/QRCodePage.wxml new file mode 100644 index 0000000..3b2df31 --- /dev/null +++ b/littleApp_child/pages/QRCodePage/QRCodePage.wxml @@ -0,0 +1,8 @@ + + + + {{encoded}} + + + + diff --git a/littleApp_child/pages/QRCodePage/QRCodePage.wxss b/littleApp_child/pages/QRCodePage/QRCodePage.wxss new file mode 100644 index 0000000..6b94011 --- /dev/null +++ b/littleApp_child/pages/QRCodePage/QRCodePage.wxss @@ -0,0 +1,24 @@ +/* pages/QRCodePage/QRCodePage.wxss */ +.container{ + height: 100%; + padding:0; + background: #48C17B; +} +.code{ + padding: 32rpx; + position: relative; + background: #fff; + margin-top: 84rpx; + border-radius: 10rpx; +} +.barCanvas { + width: 300px; + height: 120px; +} +.barView { + text-align: center +} +.qrCanvas { + width: 300px; + height: 300px; +} \ No newline at end of file diff --git a/littleApp_child/pages/Register/Register.js b/littleApp_child/pages/Register/Register.js index b1b7a07..22fd648 100644 --- a/littleApp_child/pages/Register/Register.js +++ b/littleApp_child/pages/Register/Register.js @@ -96,8 +96,8 @@ Page({ param.gzopenid = getApp().globalData.openInfo.mpid console.log('绑定mpid', param) } - if (getApp().globalData.openInfo.code) { - param.jscode = getApp().globalData.openInfo.code + if (getApp().globalData.openInfo.childCode) { + param.jscode = getApp().globalData.openInfo.childCode console.log('绑定code', param) } networkUtil._get(api.verifyCode, param, function (res) { diff --git a/littleApp_child/pages/Setting/Setting.js b/littleApp_child/pages/Setting/Setting.js index 8f888c1..731b256 100644 --- a/littleApp_child/pages/Setting/Setting.js +++ b/littleApp_child/pages/Setting/Setting.js @@ -1,5 +1,6 @@ //hospitalDetail.js 医院详情介绍 - +//聊天控件 +let WebIM = wx.WebIM = require("../../utils/WebIM.js").default; // 网络请求工具类 var networkUtil = require('../../utils/network_util.js') var api = require('../../utils/apiFile.js') @@ -9,6 +10,7 @@ var app = getApp() Page({ data: { setList: [ + { icon: '../../source/set_dangan.png', text: '信息绑定', right_text: '', margin: 0 }, { icon: '../../source/feedback_icon.png', text: '用户反馈', right_text: '', margin: 0 }, { icon: '../../source/clear_cach.png', text: '清除缓存', right_text: '', margin:10} ], isShowOne: false, @@ -94,29 +96,28 @@ Page({ var url = '' switch(index){ case 0: - url = '../feedback/feedback' + url = '../inforBind/inforBind' break case 1: - wx.showToast({ - title: '清除成功', - }) - // url = '../PersonalInfo/PersonalInfo' - break - case 2: - url = '../system_notifacations/system_notifacations' - break - case 3: - url = '../PersonalInfo/PersonalInfo' - break - case 4: - url = '../mySaved/mySaved' - break - case 5: url = '../feedback/feedback' break - case 6: + case 2: + wx.showToast({ + title: '清除成功', + }) + break + // case 3: + // url = '../PersonalInfo/PersonalInfo' + // break + // case 4: + // url = '../mySaved/mySaved' + // break + // case 5: + // url = '../feedback/feedback' + // break + // case 6: - break + // break } wx.navigateTo({ url: url @@ -130,9 +131,13 @@ Page({ if (res.tapIndex == 0) { wx.setStorageSync('userToken', '') wx.setStorageSync('userId', '') + wx.setStorageSync('access_token', '') + wx.setStorageSync('hxName', '') + wx.setStorageSync('hxPassWord', '') getApp().globalData.token = '' getApp().globalData.userId = '' wx.navigateBack({}) + WebIM.conn.close() } }, fail: function (res) { diff --git a/littleApp_child/pages/chatHis/audio/audio.js b/littleApp_child/pages/chatHis/audio/audio.js new file mode 100644 index 0000000..d8a4ce7 --- /dev/null +++ b/littleApp_child/pages/chatHis/audio/audio.js @@ -0,0 +1,161 @@ +let audioCtxFc = require("audioCtxFactory"); +let playStatus = require("playStatus"); + +if (wx.setInnerAudioOption) { + wx.setInnerAudioOption({ + obeyMuteSwitch: false, + autoplay: true + }) +} +Component({ + properties: { + msg: { + type: Object, + val: {} + }, + }, + data: { + playStatus: playStatus, + curStatus: playStatus.STOP, + time: "0'", + opcity: 1, + __comps__: { + audioCtx: null, + } + }, + methods: { + audioPlay(){ + wx.inter && clearInterval(wx.inter) + let audioCtx = this.data.__comps__.audioCtx; + var curl = '' + wx.downloadFile({ + url: this.data.msg.msg.url, + header: { + "X-Requested-With": "XMLHttpRequest", + Accept: "audio/mp3", + Authorization: "Bearer " + this.data.msg.msg.token + }, + success(res){ + curl = res.tempFilePath; + console.log('音频本地',audioCtx) + //renderableMsg.msg.url = res.tempFilePath; + audioCtx.src = curl; + audioCtx.play(); + + }, + fail(e){ + console.log("downloadFile failed", e); + wx.showToast({ + title: "下载失败,请检查网络状态", + duration: 1000 + }); + } + }); + + }, + + audioPause(auCtx){ + //let audioCtx = this.data.__comps__.audioCtx; + let audioCtx = this.data.__comps__.audioCtx = audioCtxFc.getCtx(this.data.msg.mid) || auCtx + audioCtx&&audioCtx.pause(); + }, + + addEvent(){ + let audioCtx = this.data.__comps__.audioCtx; + audioCtx.onPlay(this.onPlaying); + audioCtx.onPause(this.onPause); + audioCtx.onWaiting(this.onPause); + audioCtx.onStop(this.onDone); + audioCtx.onEnded(this.onDone); + audioCtx.onError(this.onDone); + audioCtx.onWaiting(this.onWait) + + //audioCtx.onTimeUpdate(this.onTimeUpdate); + }, + + delEvent(){ + let audioCtx = this.data.__comps__.audioCtx; + audioCtx.offPlay(this.onPlaying); + audioCtx.offPause(this.onPause); + audioCtx.offWaiting(this.onPause); + audioCtx.offStop(this.onDone); + audioCtx.offEnded(this.onDone); + audioCtx.offError(this.onDone); + audioCtx.offWaiting(this.onWait) + // 多次播放会丢失这个回调,所以不用卸载 + // audioCtx.offTimeUpdate(this.onTimeUpdate); + }, + }, + + // lifetimes + created(){}, + attached(){ + console.log(this.properties.msg.msg) + this.setData({ + time: this.properties.msg.msg.length + "''", + style: this.properties.msg.style + }) + }, + moved(){}, + detached(){ + + let audioCtx = this.data.__comps__.audioCtx = audioCtxFc.getCtx(this.data.msg.mid); + this.audioPause(audioCtx); + this.delEvent(); + //audioCtx.destroy(); + }, + ready(){ + let self = this + let curl = '' + let audioCtx = this.data.__comps__.audioCtx = audioCtxFc.getCtx(this.data.msg.mid); + + audioCtx.autoplay = false; + audioCtx.loop = false; + // + this.onPlaying = () => { + //console.log("onPlaying", JSON.stringify(this.data)); + this.setData({ + curStatus: playStatus.PLAYING, + }); + wx.inter && clearInterval(wx.inter) + wx.inter = setInterval(() => { + let opcity = this.data.opcity; + this.setData({ + opcity: opcity == 1 ? 0.4 : 1 + }) + }, 500) + }; + this.onPause = () => { + // console.log("onPause", JSON.stringify(this.data)); + // 第二次播放会立即抛出一个异常的 onPause + if(parseInt(this.data.time, 10) < 1){ + return; + } + this.setData({ + curStatus: playStatus.PAUSE, + opcity: 1 + //time: "0'", + }); + }; + this.onDone = () => { + // console.log("onDone", JSON.stringify(this.data)); + this.setData({ + curStatus: playStatus.STOP, + opcity: 1 + //time: "0'", + }); + clearInterval(wx.inter) + }; + // 多次播放会丢失这个回调 + this.onTimeUpdate = () => { + this.setData({ + time: (audioCtx.currentTime >> 0) + "'" + }); + }; + this.onWait = () => { + + } + this.addEvent(); + }, +}); + diff --git a/littleApp_child/pages/chatHis/audio/audio.json b/littleApp_child/pages/chatHis/audio/audio.json new file mode 100644 index 0000000..6a1b9ce --- /dev/null +++ b/littleApp_child/pages/chatHis/audio/audio.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/littleApp_child/pages/chatHis/audio/audio.wxml b/littleApp_child/pages/chatHis/audio/audio.wxml new file mode 100644 index 0000000..6606512 --- /dev/null +++ b/littleApp_child/pages/chatHis/audio/audio.wxml @@ -0,0 +1,15 @@ + + 语音消息 {{ time }} + + + + + diff --git a/littleApp_child/pages/chatHis/audio/audio.wxss b/littleApp_child/pages/chatHis/audio/audio.wxss new file mode 100644 index 0000000..283b86b --- /dev/null +++ b/littleApp_child/pages/chatHis/audio/audio.wxss @@ -0,0 +1,24 @@ +.audio-player { + position: relative; + display: flex; + transition: opacity .5s; +} + +.audio-player .controls { + height:40rpx; + align-items:center; + display:flex; +} + +.audio-player .controls image { + height: 48rpx; + width: 30rpx; + margin: 0 8rpx 0 20rpx; +} + +.audio-player .time { + font-size: 34rpx; + line-height: 40rpx; + flex: 1; + text-align: left; +} diff --git a/littleApp_child/pages/chatHis/audio/audioCtxFactory.js b/littleApp_child/pages/chatHis/audio/audioCtxFactory.js new file mode 100644 index 0000000..8953d98 --- /dev/null +++ b/littleApp_child/pages/chatHis/audio/audioCtxFactory.js @@ -0,0 +1,50 @@ +// 每一个音频消息都有自己的 ctx。 +// 可以有多个 ctx,每次播放都能知道是哪个 ctx 在调用,从而让其他的 ctx pause。 +// 消息销毁,记得处理 ctx。 +// 主要是同步跨 ctx 的操作,保证只有一个 ctx 播放 +let allCtx = {}; +let inUseCtx = null; +let allComm = {} +function proxier(ctx){ + let __play__ = ctx.play; + let __pause__ = ctx.pause; + ctx.play = playProxier; + ctx.pause = pauseProxier; + function playProxier(){ + // 如果正在播放的不是自己,暂停 + if(inUseCtx && inUseCtx != this){ + inUseCtx.pause(); + } + __play__.call(this); + inUseCtx = this; + } + function pauseProxier(){ + // 只有是自己才 pause + if(inUseCtx == this){ + __pause__.call(this); + } + } +} + +module.exports = { + getCtx(mid){ + let returnCtx = allCtx[mid]; + if(!returnCtx){ + returnCtx = wx.createInnerAudioContext(); + allCtx[mid] = returnCtx; + proxier(returnCtx); + } + return returnCtx; + }, + getAllCtx(){ + wx.setStorageSync("allCtx", JSON.stringify(Object.keys(allCtx))); + return allCtx + }, + getCommponet(mid,comm){ + let curComm = allComm[mid] + if (!curComm) { + allComm[mid] = comm + } + return allComm + } +}; diff --git a/littleApp_child/pages/chatHis/audio/playStatus.js b/littleApp_child/pages/chatHis/audio/playStatus.js new file mode 100644 index 0000000..76281a9 --- /dev/null +++ b/littleApp_child/pages/chatHis/audio/playStatus.js @@ -0,0 +1,5 @@ +module.exports = { + PLAYING: "playing", + PAUSE: "pause", + STOP: "stop", +}; diff --git a/littleApp_child/pages/chatHis/audio/record_status.js b/littleApp_child/pages/chatHis/audio/record_status.js new file mode 100644 index 0000000..a8d37eb --- /dev/null +++ b/littleApp_child/pages/chatHis/audio/record_status.js @@ -0,0 +1,14 @@ +module.exports = { + RecordDesc: { + 0: "长按开始录音", + 2: "向上滑动取消", + 3: "松开手取消", + }, + RecordStatus: { + SHOW: 0, + HIDE: 1, + HOLD: 2, + SWIPE: 3, + RELEASE: 4 + } +}; diff --git a/littleApp_child/pages/chatHis/chatHis.js b/littleApp_child/pages/chatHis/chatHis.js new file mode 100644 index 0000000..b87a6cf --- /dev/null +++ b/littleApp_child/pages/chatHis/chatHis.js @@ -0,0 +1,131 @@ +// pages/chatHis/chatHis.js +// 网络请求工具类 +var networkUtil = require('../../utils/network_util.js') +var api = require('../../utils/apiFile.js') + +// 获取应用实例 +var app = getApp(); + +Page({ + + /** + * 页面的初始数据 + */ + data: { + chatMsg:[] + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + console.log(options) + let me = this; + this.setData({ + illnessList:{ title:'疾病类型', + data:[{id:'1',value:'咳嗽'},{id:'2',value:'发热'},{id:'3',value:'贫血'},{id:'4',value:'腹泻'},{id:'5',value:'肺炎'}, + {id:'6',value:'手足口病'},{id:'7',value:'鹅口疮'},{id:'8',value:'湿疹'},{id:'9',value:'肠炎'},{id:'10',value:'便秘'}], + placeholder:'请选择疾病类型' + }, + serviceId:options.serviceId, + }) + //获取用药记录 + networkUtil._get(api.getBabyDisease,{serviceId:options.serviceId},function(res){ + var illnessId = res.data.data.diseaseId; + var illnessData = me.data.illnessList.data; + var illness = []; + var disabled = false; + var type = 2; + if(illnessId){ + illnessId = illnessId.split(',') + } + if(illnessId&&illnessId.length > 1){ + disabled = true; + type = 1; + illnessId.forEach(function(item){ + illness = illness.concat(illnessData.filter(it => it.id == item).map(it => it)) + }) + } + if(illnessId&&illnessId.length == 1){ + disabled = true; + type = 1; + illness = illnessData.filter(it => it.id == illnessId).map(it => it); + } + me.setData({ + symptomStr:res.data.data.diseaseDesc, + drugsStr:res.data.data.diseaseDrug, + illness:illness, + disabled:disabled, + type:type + }) + + },function(res){ + + }) + + var myName = wx.getStorageSync('hxName'); + var hislist = wx.getStorageSync("rendered_"+options.doctorName + myName + options.serviceId) || []; + var satrDate = new Date(options.createDate); + var endDate = new Date(options.endDate); + var list = []; + + hislist.forEach(item => { + var catetime = new Date(item.time); + if(catetime>=satrDate&&catetime<=endDate){ + list.push(item) + } + }); + this.setData({ + chatMsg:list + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/littleApp_child/pages/chatHis/chatHis.json b/littleApp_child/pages/chatHis/chatHis.json new file mode 100644 index 0000000..f92bb97 --- /dev/null +++ b/littleApp_child/pages/chatHis/chatHis.json @@ -0,0 +1,7 @@ +{ + "navigationBarTitleText": "咨询历史记录", + "usingComponents": { + "audio-msg": "audio/audio", + "multipe":"/components/multiple/multiple" + } +} \ No newline at end of file diff --git a/littleApp_child/pages/chatHis/chatHis.wxml b/littleApp_child/pages/chatHis/chatHis.wxml new file mode 100644 index 0000000..3218f5f --- /dev/null +++ b/littleApp_child/pages/chatHis/chatHis.wxml @@ -0,0 +1,69 @@ + + + + + + + + 症状描述 + + + + + + 用药情况 + + + + + + + + + + + + {{item.time}} + + + + + + + + + +