diff --git a/components/chat/submit.vue b/components/chat/submit.vue index 39e31f4..b39b386 100644 --- a/components/chat/submit.vue +++ b/components/chat/submit.vue @@ -227,16 +227,7 @@ // 可以使用 res.tempFilePath 获取视频的本地路径 const filePath = res.tempFilePath; console.log(filePath); - if(that.checkImageSize(filePath)){ - that.send(filePath, 'video'); - } - else{ - that.$refs.uToast.show({ - title: "视频大小不能超过20M...", - type: "error", - duration: 2000, - }); - } + that.checkImageSize(filePath,2); }, fail: function (err) { console.error('选择视频失败:', err); @@ -245,6 +236,7 @@ }, //图片发送 sendImg(e) { + var that =this; let count = 9; if (e == 'album') { count = 9; @@ -260,40 +252,66 @@ console.log(JSON.stringify(res.tempFilePaths)); const filePaths = res.tempFilePaths; for (let i = 0; i < filePaths.length; i++) { - if(this.checkImageSize(filePath)){ - this.send(filePaths[i], 'image') - } - else{ - this.$refs.uToast.show({ - title: "图片大小不能超过20M...", - type: "error", - duration: 2000, - }); - } + that.checkImageSize(filePaths[i],1); } } }); }, - checkImageSize(filePath) { - var ifsize= 0; + checkImageSize(filePath,type) { + var that = this; uni.getFileInfo({ filePath: filePath, success: function (res) { console.log('文件大小(字节):', res.size); - if (res.size > 20*1024 * 1024) { // 例如,这里检查文件大小是否超过20MB - console.log('文件过大'); - // 可以根据需要处理文件过大的情况,比如提示用户 - ifsize=0; - } else { - console.log('文件大小合适'); - // 处理正常的文件大小情况 - ifsize=1; - } - return ifsize; + if(type==1){ + // 图片 + if (res.size > 2*1024*1024) { // 例如,这里检查文件大小是否超过20MB + console.log('文件过大'); + // 可以根据需要处理文件过大的情况,比如提示用户 + that.$refs.uToast.show({ + title: "图片大小不能超过2M...", + type: "error", + duration: 2000, + }); + } else { + console.log('文件大小合适'); + // 处理正常的文件大小情况 + that.send(filePath, 'image'); + } + } + else if(type==2){ + // 视频 + if (res.size > 10*1024*1024) { // 例如,这里检查文件大小是否超过20MB + console.log('文件过大'); + // 可以根据需要处理文件过大的情况,比如提示用户 + that.$refs.uToast.show({ + title: "视频大小不能超过10M...", + type: "error", + duration: 2000, + }); + } else { + console.log('文件大小合适'); + // 处理正常的文件大小情况 + that.send(filePath, 'video'); + } + } }, fail: function (err) { console.error('获取文件信息失败:', err); - return ifsize; + if(type==1){ + that.$refs.uToast.show({ + title: "图片大小不能超过2M...", + type: "error", + duration: 2000, + }); + } + else if(type==1){ + that.$refs.uToast.show({ + title: "视频大小不能超过10M...", + type: "error", + duration: 2000, + }); + } } }); }, @@ -377,6 +395,7 @@ }, //发送 send(msg, type) { + console.log("send") console.log(msg, type) let date = { message: msg, diff --git a/manifest.json b/manifest.json index 876047e..56bb6ad 100644 --- a/manifest.json +++ b/manifest.json @@ -2,8 +2,8 @@ "name" : "瑜伽汇", "appid" : "__UNI__B6E0086", "description" : "瑜伽汇", - "versionName" : "1.0.0", - "versionCode" : 100, + "versionName" : "1.0.9", + "versionCode" : 109, "transformPx" : false, "app-plus" : { "flexible" : true, @@ -151,7 +151,47 @@ } } }, - "nativePlugins" : {} + "nativePlugins" : { + "JG-JCore" : { + "JPUSH_APPKEY_ANDROID" : "d5edb270e4b1cc29616e1dd5", + "JPUSH_APPKEY_IOS" : "", + "JPUSH_CHANNEL_ANDROID" : "", + "JPUSH_CHANNEL_IOS" : "", + "__plugin_info__" : { + "name" : "极光推送 JCore 官方 SDK", + "description" : "极光推送 JCore 官方 SDK HBuilder 插件版本", + "platforms" : "Android,iOS", + "url" : "https://ext.dcloud.net.cn/plugin?id=4028", + "android_package_name" : "com.sdlyoga.app", + "ios_bundle_id" : "", + "isCloud" : true, + "bought" : 1, + "pid" : "4028", + "parameters" : { + "JPUSH_APPKEY_ANDROID" : { + "des" : "[Android]极光portal配置应用信息时分配的AppKey", + "key" : "JPUSH_APPKEY", + "value" : "" + }, + "JPUSH_APPKEY_IOS" : { + "des" : "[iOS]极光portal配置应用信息时分配的AppKey", + "key" : "JCore:APP_KEY", + "value" : "" + }, + "JPUSH_CHANNEL_ANDROID" : { + "des" : "[Android]用于统计分发渠道,不需要可填默认值developer-default", + "key" : "JPUSH_CHANNEL", + "value" : "" + }, + "JPUSH_CHANNEL_IOS" : { + "des" : "[iOS]用于统计分发渠道,不需要可填默认值developer-default", + "key" : "JCore:CHANNEL", + "value" : "" + } + } + } + } + } }, "quickapp" : {}, "mp-weixin" : { diff --git a/pages.json b/pages.json index e17cbb5..5d48652 100644 --- a/pages.json +++ b/pages.json @@ -161,10 +161,10 @@ } }, { - "path" : "pages/teacher/chat", + "path" : "pages/chat/chat", "style" : { - "navigationBarTitleText": "咨询", + "navigationBarTitleText": "教练咨询", "enablePullDownRefresh": false } }, @@ -214,11 +214,25 @@ } }, { - "path" : "pages/product/service", + "path" : "pages/chat/groupchat", "style" : { "navigationBarTitleText": "客服", - "enablePullDownRefresh": false + "enablePullDownRefresh": false, + "app-plus": { + "titleNView": { + "buttons": [ + { + "fontSrc": "/static/qlfont.ttf", + "text": "\ue68e", + "fontSize": "28", + "color": "#ffffff", + "float": "right", + "background": "rgba(0,0,0,0)" + } + ] + } + } } }, { @@ -367,6 +381,14 @@ "enablePullDownRefresh": false } }, + { + "path": "pages/book/bookshop", + "style" : + { + "navigationBarTitleText": "预约学员", + "enablePullDownRefresh": false + } + }, { "path": "pages/book/book", "style" : diff --git a/pages/book/book.vue b/pages/book/book.vue index aef5add..9aa3b16 100644 --- a/pages/book/book.vue +++ b/pages/book/book.vue @@ -21,9 +21,15 @@ - {{item.claName}} - {{item.claName}} - + + + {{item.claName}} + + + {{item.courseTypeName}} + + @@ -60,7 +66,8 @@ - + + @@ -95,7 +102,7 @@ @@ -264,130 +407,6 @@ line-height: 60rpx; z-index: 9999; } - .submitcon{ - position: fixed; - display: flex; - bottom: 0; - left: 0; - width: 100%; - height: 140rpx; - background-color: #FFFFFF; - .pcon{ - margin-left: 20rpx; - margin-top: 28rpx; - height: 50rpx; - display: flex; - flex:1; - justify-content: flex-start; - align-items: baseline; - .hj{ - font-size: 30rpx; - } - .rmb{ - font-size: 30rpx; - font-family: smallYuan; - color:#00a89b ; - margin-left: 10rpx; - } - .zs{ - font-size: 48rpx; - font-weight: 600; - font-family: smallYuan; - color:#00a89b ; - } - .xs{ - font-size: 28rpx; - font-weight: 600; - font-family: smallYuan; - color:#00a89b ; - } - } - .btn{ - background-color: #00a89b !important; - margin: 30rpx 20rpx 0 0; - border-radius: 50rpx; - height: 60rpx; - line-height: 60rpx; - width: 180rpx; - font-size: 26rpx; - } - .btn::after{ - border:0 !important; - } - .gzbtn{ - background-color: #4A4AFF !important; - margin: 30rpx 20rpx 0 0; - border-radius: 50rpx; - height: 60rpx; - line-height: 60rpx; - width: 180rpx; - font-size: 26rpx; - } - .gzbtn::after{ - border:0 !important; - } - .cancelbtn{ - background-color: #FFFFFF !important; - margin: 30rpx 20rpx 0 0; - border-radius: 50rpx; - height: 60rpx; - line-height: 60rpx; - width:180rpx; - font-size: 26rpx; - color:#333; - border:1rpx solid #dddddd; - } - .cancelbtn::after{ - border:0 !important; - } - .returnbtn{ - background-color: #ff3d0e !important; - margin: 30rpx 20rpx 0 0; - border-radius: 50rpx; - height: 60rpx; - line-height: 60rpx; - width:180rpx; - font-size: 26rpx; - border:1rpx solid #ff3d0e; - color:#FFF; - } - .returnbtn::after{ - border:0 !important; - } - .pjbtn{ - background-color: #FFFFFF !important; - margin: 30rpx 20rpx 0 0; - border-radius: 50rpx; - height: 60rpx; - line-height: 60rpx; - width:170rpx; - font-size: 26rpx; - border:1rpx solid #f5aa00; - color:#f5aa00; - } - .pjbtn::after{ - border:0 !important; - } - .wlbtn{ - background-color: #FFFFFF !important; - margin: 30rpx 20rpx 0 0; - border-radius: 50rpx; - height: 60rpx; - line-height: 60rpx; - width:170rpx; - font-size: 26rpx; - border:1rpx solid #00a89b; - color:#00a89b; - } - .wlbtn::after{ - border:0 !important; - } - } - .signimg{ - width: 150rpx; - height: 180rpx; - border-radius: 10rpx; - } .oscon{ margin:0; background-color: #f3fafa; @@ -408,13 +427,23 @@ justify-content: flex-start; margin-left: 20rpx; } - .osname{ - line-height: 48rpx; - font-size:32rpx; - font-weight: 600; - color:#009999; - padding-bottom: 15rpx; + .ostop{ + display: flex; + flex-direction: row; border-bottom: 1rpx dotted #74defb; + padding-bottom: 15rpx; + .osname{ + line-height: 48rpx; + font-size:32rpx; + font-weight: 600; + color:#009999; + display: flex; + flex:1; + } + .qrimg{ + width: 50rpx; + height: 50rpx; + } } .oscell{ display: flex; @@ -425,21 +454,111 @@ border-bottom: 1rpx dotted #74defb; .txt{ display: flex; flex: 1; + } + } + .oscellqr{ + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + margin: 20rpx 20rpx 10rpx 20rpx; + .ordtip{ + font-size: 28rpx; + color:#000; + margin-bottom: 10rpx; + } + .ordqr{ + display: flex; + justify-content: center; + align-items: center; + width: 100%; + height: 200rpx; + margin-bottom: 10rpx; + .imgqr{ + width: 200rpx; + height: 200rpx; + } + } + .ordno{ + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + .txt{ + font-size: 28rpx; + color:#000; + } + .copy{ + font-size: 28rpx; + color:#1296db; + margin-left: 6rpx; + } } } + + .ztip{ + color:#1296db; + font-size: 26rpx; + padding: 0; + height: 40rpx; + line-height: 40rpx; + } + .jtip{ + color:#feb467; + font-size: 26rpx; + padding: 0; + height: 40rpx; + line-height: 40rpx; + } + .htip{ + border-radius: 12rpx; + color:#fc6900; + font-size: 26rpx; + padding: 0; + height: 40rpx; + line-height: 40rpx; + } + .hwtip{ + color:#FF0000; + font-size: 26rpx; + padding: 0; + height: 40rpx; + line-height: 40rpx; + } + .wtip{ + color:#43cca4; + font-size: 26rpx; + padding: 0; + height: 40rpx; + line-height: 40rpx; + } + .gtip{ + color:#0036D6; + font-size: 26rpx; + padding: 0; + height: 40rpx; + line-height: 40rpx; + } + .ftip{ + color:#6A81F1; + font-size: 26rpx; + padding: 0; + height: 40rpx; + line-height: 40rpx; + } + .ctip{ + color:#888; + font-size: 26rpx; + padding: 0; + height: 40rpx; + line-height: 40rpx; + } } - .ydcon{ - position: relative; - } - .yyright{ - position: absolute; - right: 100rpx; - top:50rpx; - } + .oinfo{ padding:20rpx; position: relative; - margin-bottom: 160rpx; + margin-bottom: 20rpx; .ozc{ display: flex; @@ -577,14 +696,7 @@ } } } - - .red{ - color:#ff3d0e; - } - .green{ - color:#00cd00; - } - + ::v-deep.uni-radio-input-checked{ background-color: #00a89b !important; border-color: #00a89b !important; @@ -595,4 +707,93 @@ display: none!important; } + + + .pcon{ + width: 690rpx; + padding-top:30rpx; + padding-bottom:50rpx; + background: #FCFCFD; + box-shadow: 0rpx 128rpx 128rpx 2rpx rgba(31,47,70,0.12); + border-radius: 16rpx 16rpx 16rpx 16rpx; + position: relative; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + .phtxt{ + width: 600rpx; + margin: 20rpx auto 10rpx; + font-size: 36rpx; + font-family: PingFang SC-Regular, PingFang SC; + font-weight: 600; + color: #23262F; + } + .ptxt + { + width: 620rpx; + display: flex; + align-items: center; + justify-content: center; + margin: 30rpx auto; + border-radius: 16rpx 16rpx 16rpx 16rpx; + opacity: 1; + border: 2rpx solid #F7F8FA; + padding: 30rpx; + .qrimg{ + width: 400rpx; + height: 400rpx; + } + } + .btn{ + width: 520rpx; + height: 80rpx; + line-height: 80rpx; + background: #00A99A; + box-shadow: 0rpx 12rpx 64rpx 2rpx rgba(0,169,154,0.4); + border-radius: 254rpx 254rpx 254rpx 254rpx; + text-align: center; + font-size: 32rpx; + font-family: PingFang SC-Medium, PingFang SC; + font-weight: 500; + color: #FCFCFD; + } + } + + .bottom{ + width: 100%; + margin-bottom: 148rpx; + } + + .submitcon{ + position: fixed; + bottom: 0; + left: 0; + width: 100%; + height: 148rpx; + background: #FFFFFF; + box-shadow: 0rpx -4rpx 60rpx 2rpx rgba(1,31,63,0.1); + opacity: 1; + display: flex; + flex-direction: row; + } + .bbtn{ + margin: 20rpx 50rpx 50rpx; + font-size: 32rpx; + font-family: PingFang SC-Medium, PingFang SC; + font-weight: 500; + color: #FCFCFD; + width: 650rpx; + height: 76rpx; + line-height: 76rpx; + background: #00a89b; + box-shadow: 0rpx 12rpx 64rpx 2rpx rgba(137,150,95,0.4); + border-radius: 10rpx; + opacity: 1; + &::after{ + border:none; + } + } + + diff --git a/pages/book/booklist.vue b/pages/book/booklist.vue index 1d9c138..58a0bc1 100644 --- a/pages/book/booklist.vue +++ b/pages/book/booklist.vue @@ -6,13 +6,13 @@ - + - + {{item.storeName?item.storeName:'门店'}} @@ -27,19 +27,24 @@ - + {{item.courseName}} {{item.claName}} - 教练:{{item.teacherName }} - 上课时间:{{ item.claDate+' '+item.startTime+'-'+item.endTime}} - 教室:{{item.roomName}} + 教练:{{item.teacherName || '-'}} + 上课时间:{{ item.claDate+' '+item.startTime+'-'+item.endTime}} + 教室:{{item.roomName}} + - + + + + + @@ -49,6 +54,7 @@ + @@ -59,6 +65,19 @@ + + + + 预约二维码 + + + + + 关闭 + + + + @@ -79,6 +98,7 @@ userid:"", tabCurrentIndex: 0, scrollLeft: 0,//tabs + qr:'', // 预约二维码 // 1:待上课,2:预约中,3:待评价 list:[ { @@ -370,6 +390,18 @@ },100); }, methods: { + openQR(qr){ + console.log("openQR") + this.qr='data:image/png;base64,'+qr; + this.$forceUpdate(); + this.openDialog(); + }, + closeDialog(){ + this.$refs.pfDialog.close(); + }, + openDialog(){ + this.$refs.pfDialog.open(); + }, getimgRemoteFile(img){ if(img){ img=img.split(',')[0]; @@ -442,17 +474,26 @@ tabSelect(e) { console.log(e) this.tabCurrentIndex = e.currentTarget.dataset.id; - this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60; + this.$forceUpdate(); // 重新加载 暂不需要加载 // this.list[this.tabCurrentIndex].loadStatus="more"; // this.list[this.tabCurrentIndex].slist=[]; - this.loadData(); + // this.loadData(); }, animationfinish({ detail: { current } }) { - this.tabCurrentIndex = current; + // this.tabCurrentIndex = current; + // this.loadData(); + }, + handleChange(e) { + //原在animationfinish中的操作转移到这里 + console.log("handleChange"); + this.tabCurrentIndex = e.detail.current; + this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60; + this.$forceUpdate(); this.loadData(); }, gotoInfo(id){ + id=id+""; // 预约详情 uni.navigateTo({ url: `/pages/book/bookinfo?id=${id}` @@ -460,15 +501,41 @@ }, // 联系教练 gototeacher(item){ - var data={ - id:item.id, - name:"教练A" + console.log(item); + if(item.teacherId){ + uni.showLoading({ + title: '会话创建中...' + }); + // 直接跳转到聊天框 + var chatid="privatechat-" + this.userid +"-"+ item.teacherId; + var timestamp = new Date().getTime(); + var info={ + chatId: "privatechat-" + this.userid +"-"+ item.teacherId, + chatType: "coach", + chatName: item.teacherName, + chatAvatar: item.pic?item.pic:'/static/image/kf.png', + chatTime: timestamp, + userid: this.userid, + friendId: item.teacherId, // 会话教练userid + minId: "", // 已读消息的最大id + sort:"privatechat", // privatechat 私聊 groupchat 群聊 + from:"yh" // yh 用户咨询进入聊天框,message 从消息进入聊天框 + } + var data=encodeURIComponent(JSON.stringify(info)); + uni.navigateTo({ + url: `/pages/chat/chat?data=${data}` + }); + } + else{ + uni.showModal({ + title: '提示', + content: '抱歉!当前预约尚未配置教练在线服务..', + cancelText: '取消', + confirmText: '确定', + success: ress => { + } + }); } - // 联系教练 - var data=encodeURIComponent(JSON.stringify(data)); - uni.navigateTo({ - url: `/pages/teacher/chat?data=${data}` - }) }, // 去评价 gotoevaluate(item){ @@ -530,11 +597,6 @@ this.reset(); } else{ - // uni.showToast({ - // title: res.msg? res.msg:'上课预约失败!', - // icon: 'error', - // duration: 2000 - // }); uni.showModal({ title: '提示', content: res.message? res.message:'课程预约失败!', @@ -891,18 +953,16 @@ flex-direction: row; justify-content: flex-end; border-top: 1rpx solid #eee; - padding: 20rpx 0 10rpx; + padding: 20rpx 0 0; width: 100%; - .omoney{ + .qr{ display: flex; flex:1; - height: 60rpx; - width: 100%; color:#333; align-items: center; - .omtip{ - font-size: 36rpx; - color:rgb(252, 105, 0); + .qrimg{ + width: 50rpx; + height: 50rpx; } } .cancelbtn{ @@ -991,19 +1051,6 @@ .gzbtn::after{ border:0 !important; } - .gzbtn{ - background-color: #f5aa00 !important; - margin-left: 20rpx; - border-radius: 50rpx; - height: 50rpx; - line-height: 48rpx; - padding: 0 20rpx; - font-size: 24rpx; - border:1rpx solid #f5aa00; - } - .gzbtn::after{ - border:0 !important; - } } .oscon{ margin:20rpx 0; @@ -1022,7 +1069,7 @@ flex: 1; display: flex; flex-direction: column; - margin-left: 26rpx; + margin-left: 20rpx; .ntxt{ font-size: 28rpx; color:#000; @@ -1099,4 +1146,56 @@ } + + .pcon{ + width: 690rpx; + padding-top:30rpx; + padding-bottom:50rpx; + background: #FCFCFD; + box-shadow: 0rpx 128rpx 128rpx 2rpx rgba(31,47,70,0.12); + border-radius: 16rpx 16rpx 16rpx 16rpx; + position: relative; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + .phtxt{ + width: 600rpx; + margin: 20rpx auto 10rpx; + font-size: 36rpx; + font-family: PingFang SC-Regular, PingFang SC; + font-weight: 600; + color: #23262F; + } + .ptxt + { + width: 620rpx; + display: flex; + align-items: center; + justify-content: center; + margin: 30rpx auto; + border-radius: 16rpx 16rpx 16rpx 16rpx; + opacity: 1; + border: 2rpx solid #F7F8FA; + padding: 30rpx; + .qrimg{ + width: 400rpx; + height: 400rpx; + } + } + .btn{ + width: 520rpx; + height: 80rpx; + line-height: 80rpx; + background: #00A99A; + box-shadow: 0rpx 12rpx 64rpx 2rpx rgba(0,169,154,0.4); + border-radius: 254rpx 254rpx 254rpx 254rpx; + text-align: center; + font-size: 32rpx; + font-family: PingFang SC-Medium, PingFang SC; + font-weight: 500; + color: #FCFCFD; + } + } + diff --git a/pages/book/bookshop.vue b/pages/book/bookshop.vue index db7bdaf..b6e1322 100644 --- a/pages/book/bookshop.vue +++ b/pages/book/bookshop.vue @@ -5,9 +5,13 @@ - + - {{item.storeName?item.storeName:'门店'}} + + 姓名:{{item.studentName?item.studentName:'-'}} + 性别:{{item.sex==2?'男':(item.sex==1?'女':'未知')}} + + 电话:{{item.phone?item.phone:'-'}} @@ -20,27 +24,29 @@ - - - - + - {{item.courseName}} {{item.claName}} - 教练:{{item.teacherName }} - 上课时间:{{ item.claDate+' '+item.startTime+'-'+item.endTime}} - 教室:{{item.roomName}} + + 课程:{{item.courseName}} + 班级:{{item.claName}} + + + 教练:{{item.teacherName }} + 教室:{{item.roomName}} + + 上课时间:{{ item.claDate+' '+item.startTime+(item.endTime?'-'+item.endTime:'')}} + + 预约人数:{{item.bookAttendCnt}} + 可容纳人数:{{item.atClassCnt}} + - - - - - - + + @@ -123,7 +129,7 @@ uni.showLoading({ title: '数据加载中...' }); - const {data: res} = await uni.$http.get('/api/my/appointmentListForTeacher'); + const {data: res} = await uni.$http.get('/api/my/appointmentListForManager'); if(res&&res.data){ // 全部 this.loadStatus="noMore"; @@ -137,7 +143,6 @@ } }, loadData(){ - console.log('loadData'); // 加载 if(this.loadStatus=="more") { this.loadStatus="loading"; @@ -152,18 +157,6 @@ url: `/pages/book/bookinfo?id=${id}` }); }, - // 联系教练 - gototeacher(item){ - var data={ - id:item.id, - name:"教练A" - } - // 联系教练 - var data=encodeURIComponent(JSON.stringify(data)); - uni.navigateTo({ - url: `/pages/teacher/chat?data=${data}` - }) - }, // 去评价 gotoevaluate(item){ var data=encodeURIComponent(JSON.stringify(item)); @@ -186,52 +179,47 @@ return true; } }, - // 再次预约 - orderdo(e,item){ - console.log(id,item); + // 禁止预约 + stopdo(e,item){ var that = this; - // 再次预约 + // 禁止预约 uni.showModal({ title: '提示', - content: '确定再次预约吗?', + content: '确定禁止预约吗?', cancelText: '取消', confirmText: '确定', success: ress => { if (ress.confirm) { - that.checkdodo(id,item); + that.stopdodo(item); } } }); }, - // 再次预约 - async orderdodo(id,item){ + // 禁止预约 + async stopdodo(item){ var param={ - "courseTimeId": item.courseTimeId + "bookId": item.bookId, + "bookStatus": 2 }; - uni.showToast({ - title: '再次预约中...', - icon: 'success', - duration: 2000 + uni.showLoading({ + title: '禁止预约中...' }); - const {data: res} = await uni.$http.post('/api/course/bookCourse', param); + const {data: res} = await uni.$http.post('/api/my/checkAppointment', param); if(res.success){ uni.showToast({ - title: '上课已预约!', + title: '已禁止预约!', icon: 'success', duration: 2000 }); // 重新加载 + this.loadStatus="more"; + this.$forceUpdate(); this.loadData(); } else{ - // uni.showToast({ - // title: res.msg? res.msg:'上课预约失败!', - // icon: 'error', - // duration: 2000 - // }); uni.showModal({ title: '提示', - content: res.message? res.message:'课程预约失败!', + content: res.message? res.message:'禁止预约失败!', cancelText: '取消', confirmText: '确定', success: ress => { @@ -241,146 +229,59 @@ }); } }, - // 确认上课 + // 确认预约 checkdo(e,item){ console.log(e); var id= e.currentTarget.dataset.id; var that = this; - // 确认上课 + // 确认预约 uni.showModal({ title: '提示', - content: '确定上课吗?', + content: '确认预约吗?', cancelText: '取消', confirmText: '确定', success: ress => { if (ress.confirm) { - that.checkdodo(id,item); + that.checkdodo(item); } } }); }, - // 确认上课 - async checkdodo(id,item){ + // 确认预约 + async checkdodo(item){ var param={ - "courseTimeId": item.courseTimeId, - "startTime": item.startTime, - "endTime": item.endTime + "bookId": item.bookId, + "bookStatus": 1 }; - uni.showToast({ - title: '确定上课中...', - icon: 'success', - duration: 2000 + uni.showLoading({ + title: '确认预约中...' }); - const {data: res} = await uni.$http.post('/api/my/confirmClass', param); - if(res.msg=="successed"){ + const {data: res} = await uni.$http.post('/api/my/checkAppointment', param); + if(res.success){ uni.showToast({ - title: '上课已确认!', + title: '已确认预约!', icon: 'success', duration: 2000 }); // 重新加载 + this.loadStatus="more"; + this.$forceUpdate(); this.loadData(); } else{ - uni.showToast({ - title: res.msg? res.msg:'上课确认失败!', - icon: 'error', - duration: 2000 - }); - } - }, - // 取消预约 - cancelyydo(e){ - console.log(e); - var id= e.currentTarget.dataset.id; - var that = this; - //取消预约 - uni.showModal({ - title: '提示', - content: '确定要取消预约吗?', - cancelText: '取消', - confirmText: '确定', - success: ress => { - if (ress.confirm) { - that.delyydo(id); + uni.showModal({ + title: '提示', + content: res.message? res.message:'确认预约失败!', + cancelText: '取消', + confirmText: '确定', + success: ress => { + if (ress.confirm) { + } } - } - }); - }, - // 取消预约 - async delyydo(id){ - var param={ - "courseTimeId":id - }; - uni.showToast({ - title: '取消中...', - icon: 'success', - duration: 2000 - }); - const {data: res} = await uni.$http.post('/api/course/cancelCourse', param); - if(res.msg=="successed"){ - uni.showToast({ - title: '预约已取消!', - icon: 'success', - duration: 2000 - }); - // 重新加载 - this.loadData(); - } - else{ - uni.showToast({ - title: res.msg? res.msg:'预约取消失败!', - icon: 'error', - duration: 2000 }); } }, - // 取消课程 - cancelkcdo(e){ - console.log(e); - var id= e.currentTarget.dataset.id; - var that = this; - //取消课程 - uni.showModal({ - title: '提示', - content: '确定要取消课程吗?', - cancelText: '取消', - confirmText: '确定', - success: ress => { - if (ress.confirm) { - that.delkcdo(id); - } - } - }); - }, - // 取消课程 - async delkcdo(id){ - var param={ - "courseTimeId":id - }; - uni.showToast({ - title: '取消中...', - icon: 'success', - duration: 2000 - }); - const {data: res} = await uni.$http.post('/api/course/cancelCourse', param); - if(res.msg=="successed"){ - uni.showToast({ - title: '课程已取消!', - icon: 'success', - duration: 2000 - }); - // 重新加载 - this.loadData(); - } - else{ - uni.showToast({ - title: res.msg? res.msg:'课程取消失败!', - icon: 'error', - duration: 2000 - }); - } - } + } } @@ -482,28 +383,26 @@ flex-direction: column; background-color: #FFFFFF; border-radius: 6rpx; - padding: 20rpx; + padding: 20rpx 30rpx; width: 100%; margin-bottom: 20rpx; .otop{ display: flex; flex-direction: row; - padding: 10rpx 0 0; - height: 60rpx; - line-height: 60rpx; width: 100%; + padding: 10rpx 0 10rpx; + border-bottom: 1rpx solid #eee; .hleft{ display: flex; - flex-direction: row; + flex-direction: column; flex:1; - align-items: center; - font-size: 30rpx; + justify-content: flex-start; + font-size: 28rpx; color: #000; } .hright{ display: flex; justify-content: flex-end; - align-items: center; // .ztip{ border-radius: 12rpx; @@ -576,19 +475,14 @@ flex-direction: row; justify-content: flex-end; border-top: 1rpx solid #eee; - padding: 20rpx 0 10rpx; + padding: 20rpx 0 2rpx; width: 100%; .omoney{ display: flex; flex:1; - height: 60rpx; width: 100%; color:#333; - align-items: center; - .omtip{ - font-size: 36rpx; - color:rgb(252, 105, 0); - } + align-items: center; } .cancelbtn{ background-color: #FFFFFF !important; @@ -619,37 +513,7 @@ .viewbtn::after{ border:0 !important; } - .pjbtn{ - background-color: #FFFFFF !important; - margin-left: 20rpx; - border-radius: 50rpx; - border-radius: 50rpx; - height: 50rpx; - line-height: 48rpx; - padding: 0 20rpx; - font-size: 24rpx; - border:1rpx solid rgb(252, 105, 0); - color:rgb(252, 105, 0); - } - .pjbtn::after{ - border:0 !important; - } - .conbtn{ - background-color: #f3f4ef !important; - margin-left: 20rpx; - border-radius: 50rpx; - border-radius: 50rpx; - height: 50rpx; - line-height: 48rpx; - padding: 0 20rpx; - font-size: 24rpx; - border:1rpx solid #00a89b; - color:#595d4d; - } - .conbtn::after{ - border:0 !important; - } - .paybtn{ + .orderbtn{ background-color: #00a89b !important; margin-left: 20rpx; border-radius: 50rpx; @@ -660,38 +524,25 @@ font-size: 24rpx; border:1rpx solid #00a89b; } - .paybtn::after{ - border:0 !important; - } - .gzbtn{ - background-color: #f5aa00 !important; - margin-left: 20rpx; - border-radius: 50rpx; - height: 50rpx; - line-height: 48rpx; - padding: 0 20rpx; - font-size: 24rpx; - border:1rpx solid #f5aa00; - } - .gzbtn::after{ + .orderbtn::after{ border:0 !important; } - .gzbtn{ - background-color: #f5aa00 !important; + .stopbtn{ + background-color: #f47fa0 !important; margin-left: 20rpx; border-radius: 50rpx; height: 50rpx; line-height: 48rpx; padding: 0 20rpx; font-size: 24rpx; - border:1rpx solid #f5aa00; + border:1rpx solid #f47fa0; } - .gzbtn::after{ + .stopbtn::after{ border:0 !important; } } .oscon{ - margin:20rpx 0; + margin:16rpx 0; border-radius: 16rpx; display: flex; flex-direction: row; @@ -707,25 +558,17 @@ flex: 1; display: flex; flex-direction: column; - margin-left: 26rpx; .ntxt{ - font-size: 28rpx; - color:#000; + font-size: 26rpx; + color:#333; line-height: 36rpx; margin-bottom: 8rpx; } .txt{ - font-size: 24rpx; - color:#666; + font-size: 26rpx; + color:#333; } - } - .osprice{ - display: flex; - justify-content: flex-end; - margin-right: 10rpx; - font-size: 30rpx; - color:#666; - } + } } } .sitem { diff --git a/pages/book/bookteacher.vue b/pages/book/bookteacher.vue index db7bdaf..0dd916e 100644 --- a/pages/book/bookteacher.vue +++ b/pages/book/bookteacher.vue @@ -5,9 +5,13 @@ - + - {{item.storeName?item.storeName:'门店'}} + + 姓名:{{item.studentName?item.studentName:'-'}} + 性别:{{item.sex==2?'男':(item.sex==1?'女':'未知')}} + + 电话:{{item.phone?item.phone:'-'}} @@ -20,27 +24,29 @@ - - - - + - {{item.courseName}} {{item.claName}} - 教练:{{item.teacherName }} - 上课时间:{{ item.claDate+' '+item.startTime+'-'+item.endTime}} - 教室:{{item.roomName}} + + 课程:{{item.courseName}} + 班级:{{item.claName}} + + + 教练:{{item.teacherName }} + 教室:{{item.roomName}} + + 上课时间:{{ item.claDate+' '+item.startTime+(item.endTime?'-'+item.endTime:'')}} + + 预约人数:{{item.bookAttendCnt}} + 可容纳人数:{{item.atClassCnt}} + - - - - - - + + @@ -137,7 +143,6 @@ } }, loadData(){ - console.log('loadData'); // 加载 if(this.loadStatus=="more") { this.loadStatus="loading"; @@ -152,18 +157,6 @@ url: `/pages/book/bookinfo?id=${id}` }); }, - // 联系教练 - gototeacher(item){ - var data={ - id:item.id, - name:"教练A" - } - // 联系教练 - var data=encodeURIComponent(JSON.stringify(data)); - uni.navigateTo({ - url: `/pages/teacher/chat?data=${data}` - }) - }, // 去评价 gotoevaluate(item){ var data=encodeURIComponent(JSON.stringify(item)); @@ -186,52 +179,47 @@ return true; } }, - // 再次预约 - orderdo(e,item){ - console.log(id,item); + // 禁止预约 + stopdo(e,item){ var that = this; - // 再次预约 + // 禁止预约 uni.showModal({ title: '提示', - content: '确定再次预约吗?', + content: '确定禁止预约吗?', cancelText: '取消', confirmText: '确定', success: ress => { if (ress.confirm) { - that.checkdodo(id,item); + that.stopdodo(item); } } }); }, - // 再次预约 - async orderdodo(id,item){ + // 禁止预约 + async stopdodo(item){ var param={ - "courseTimeId": item.courseTimeId + "bookId": item.bookId, + "bookStatus": 2 }; - uni.showToast({ - title: '再次预约中...', - icon: 'success', - duration: 2000 + uni.showLoading({ + title: '禁止预约中...' }); - const {data: res} = await uni.$http.post('/api/course/bookCourse', param); + const {data: res} = await uni.$http.post('/api/my/checkAppointment', param); if(res.success){ uni.showToast({ - title: '上课已预约!', + title: '已禁止预约!', icon: 'success', duration: 2000 }); // 重新加载 + this.loadStatus="more"; + this.$forceUpdate(); this.loadData(); } else{ - // uni.showToast({ - // title: res.msg? res.msg:'上课预约失败!', - // icon: 'error', - // duration: 2000 - // }); uni.showModal({ title: '提示', - content: res.message? res.message:'课程预约失败!', + content: res.message? res.message:'禁止预约失败!', cancelText: '取消', confirmText: '确定', success: ress => { @@ -241,146 +229,59 @@ }); } }, - // 确认上课 + // 确认预约 checkdo(e,item){ console.log(e); var id= e.currentTarget.dataset.id; var that = this; - // 确认上课 + // 确认预约 uni.showModal({ title: '提示', - content: '确定上课吗?', + content: '确认预约吗?', cancelText: '取消', confirmText: '确定', success: ress => { if (ress.confirm) { - that.checkdodo(id,item); + that.checkdodo(item); } } }); }, - // 确认上课 - async checkdodo(id,item){ + // 确认预约 + async checkdodo(item){ var param={ - "courseTimeId": item.courseTimeId, - "startTime": item.startTime, - "endTime": item.endTime + "bookId": item.bookId, + "bookStatus": 1 }; - uni.showToast({ - title: '确定上课中...', - icon: 'success', - duration: 2000 + uni.showLoading({ + title: '确认预约中...' }); - const {data: res} = await uni.$http.post('/api/my/confirmClass', param); - if(res.msg=="successed"){ + const {data: res} = await uni.$http.post('/api/my/checkAppointment', param); + if(res.success){ uni.showToast({ - title: '上课已确认!', + title: '已确认预约!', icon: 'success', duration: 2000 }); // 重新加载 + this.loadStatus="more"; + this.$forceUpdate(); this.loadData(); } else{ - uni.showToast({ - title: res.msg? res.msg:'上课确认失败!', - icon: 'error', - duration: 2000 - }); - } - }, - // 取消预约 - cancelyydo(e){ - console.log(e); - var id= e.currentTarget.dataset.id; - var that = this; - //取消预约 - uni.showModal({ - title: '提示', - content: '确定要取消预约吗?', - cancelText: '取消', - confirmText: '确定', - success: ress => { - if (ress.confirm) { - that.delyydo(id); + uni.showModal({ + title: '提示', + content: res.message? res.message:'确认预约失败!', + cancelText: '取消', + confirmText: '确定', + success: ress => { + if (ress.confirm) { + } } - } - }); - }, - // 取消预约 - async delyydo(id){ - var param={ - "courseTimeId":id - }; - uni.showToast({ - title: '取消中...', - icon: 'success', - duration: 2000 - }); - const {data: res} = await uni.$http.post('/api/course/cancelCourse', param); - if(res.msg=="successed"){ - uni.showToast({ - title: '预约已取消!', - icon: 'success', - duration: 2000 - }); - // 重新加载 - this.loadData(); - } - else{ - uni.showToast({ - title: res.msg? res.msg:'预约取消失败!', - icon: 'error', - duration: 2000 }); } }, - // 取消课程 - cancelkcdo(e){ - console.log(e); - var id= e.currentTarget.dataset.id; - var that = this; - //取消课程 - uni.showModal({ - title: '提示', - content: '确定要取消课程吗?', - cancelText: '取消', - confirmText: '确定', - success: ress => { - if (ress.confirm) { - that.delkcdo(id); - } - } - }); - }, - // 取消课程 - async delkcdo(id){ - var param={ - "courseTimeId":id - }; - uni.showToast({ - title: '取消中...', - icon: 'success', - duration: 2000 - }); - const {data: res} = await uni.$http.post('/api/course/cancelCourse', param); - if(res.msg=="successed"){ - uni.showToast({ - title: '课程已取消!', - icon: 'success', - duration: 2000 - }); - // 重新加载 - this.loadData(); - } - else{ - uni.showToast({ - title: res.msg? res.msg:'课程取消失败!', - icon: 'error', - duration: 2000 - }); - } - } + } } @@ -482,28 +383,26 @@ flex-direction: column; background-color: #FFFFFF; border-radius: 6rpx; - padding: 20rpx; + padding: 20rpx 30rpx; width: 100%; margin-bottom: 20rpx; .otop{ display: flex; flex-direction: row; - padding: 10rpx 0 0; - height: 60rpx; - line-height: 60rpx; width: 100%; + padding: 10rpx 0 10rpx; + border-bottom: 1rpx solid #eee; .hleft{ display: flex; - flex-direction: row; + flex-direction: column; flex:1; - align-items: center; - font-size: 30rpx; + justify-content: flex-start; + font-size: 28rpx; color: #000; } .hright{ display: flex; justify-content: flex-end; - align-items: center; // .ztip{ border-radius: 12rpx; @@ -576,19 +475,14 @@ flex-direction: row; justify-content: flex-end; border-top: 1rpx solid #eee; - padding: 20rpx 0 10rpx; + padding: 20rpx 0 2rpx; width: 100%; .omoney{ display: flex; flex:1; - height: 60rpx; width: 100%; color:#333; - align-items: center; - .omtip{ - font-size: 36rpx; - color:rgb(252, 105, 0); - } + align-items: center; } .cancelbtn{ background-color: #FFFFFF !important; @@ -619,37 +513,7 @@ .viewbtn::after{ border:0 !important; } - .pjbtn{ - background-color: #FFFFFF !important; - margin-left: 20rpx; - border-radius: 50rpx; - border-radius: 50rpx; - height: 50rpx; - line-height: 48rpx; - padding: 0 20rpx; - font-size: 24rpx; - border:1rpx solid rgb(252, 105, 0); - color:rgb(252, 105, 0); - } - .pjbtn::after{ - border:0 !important; - } - .conbtn{ - background-color: #f3f4ef !important; - margin-left: 20rpx; - border-radius: 50rpx; - border-radius: 50rpx; - height: 50rpx; - line-height: 48rpx; - padding: 0 20rpx; - font-size: 24rpx; - border:1rpx solid #00a89b; - color:#595d4d; - } - .conbtn::after{ - border:0 !important; - } - .paybtn{ + .orderbtn{ background-color: #00a89b !important; margin-left: 20rpx; border-radius: 50rpx; @@ -660,38 +524,25 @@ font-size: 24rpx; border:1rpx solid #00a89b; } - .paybtn::after{ - border:0 !important; - } - .gzbtn{ - background-color: #f5aa00 !important; - margin-left: 20rpx; - border-radius: 50rpx; - height: 50rpx; - line-height: 48rpx; - padding: 0 20rpx; - font-size: 24rpx; - border:1rpx solid #f5aa00; - } - .gzbtn::after{ + .orderbtn::after{ border:0 !important; } - .gzbtn{ - background-color: #f5aa00 !important; + .stopbtn{ + background-color: #f47fa0 !important; margin-left: 20rpx; border-radius: 50rpx; height: 50rpx; line-height: 48rpx; padding: 0 20rpx; font-size: 24rpx; - border:1rpx solid #f5aa00; + border:1rpx solid #f47fa0; } - .gzbtn::after{ + .stopbtn::after{ border:0 !important; } } .oscon{ - margin:20rpx 0; + margin:16rpx 0; border-radius: 16rpx; display: flex; flex-direction: row; @@ -707,25 +558,17 @@ flex: 1; display: flex; flex-direction: column; - margin-left: 26rpx; .ntxt{ - font-size: 28rpx; - color:#000; + font-size: 26rpx; + color:#333; line-height: 36rpx; margin-bottom: 8rpx; } .txt{ - font-size: 24rpx; - color:#666; + font-size: 26rpx; + color:#333; } - } - .osprice{ - display: flex; - justify-content: flex-end; - margin-right: 10rpx; - font-size: 30rpx; - color:#666; - } + } } } .sitem { diff --git a/pages/category/category.vue b/pages/category/category.vue index 14daaa8..0fd6d8f 100644 --- a/pages/category/category.vue +++ b/pages/category/category.vue @@ -79,8 +79,8 @@ - - + + @@ -100,6 +100,28 @@ + + + + {{title}} + + {{description}} + + + + + + {{(j+1)+'、'+cell.content}} + + + + + + + + + @@ -148,7 +170,7 @@ userid:"", tabCurrentIndex: 0, scrollLeft: 0, - shopid:myCache('myshopid')?myCache('myshopid'):'', + shopid:myCache('myshopid')?myCache('myshopid'):null, shop:myCache('myshop')?myCache('myshop'):'', tabIndex: 0, id:1, @@ -254,6 +276,30 @@ }] }, }, + items: [ + { + value: '2', + name: '2', + text: '2' + }, + { + value: '1', + text: '1', + name: '1' + }, + { + value: '0', + text: '0', + name: '0' + } + ], + + description:"(亲爱的伽人,欢迎来到中医九种体质自测普查,此版本适用人群:全年龄段评分标准:请根据近1年真实情况勾选。打分规则:完全符合 = 2分 | 偶尔有 = 1分 | 完全不符合 = 0分请选择)", + title:"中医九种体质自测普查", + surveyId:null, + scores:0, + sessionId:null, + }; }, onLoad(option) { @@ -296,6 +342,199 @@ },100); }, methods: { + numberToChinese(num) { + const chineseNums = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']; + const sections = ['', '十', '百', '千']; + const units = ['', '万', '亿']; + num = String(num).split("").reverse().join(""); // 将数字反转以便从低位到高位处理 + let result = ''; + let unitIndex = 0; + + for (let i = 0; i < num.length; i++) { + let n = Number(num[i]); + if (n !== 0) { + result = chineseNums[n] + sections[i % 4] + result; + if (i % 4 === 0 && i !== 0) { + result = units[unitIndex] + result; + unitIndex++; + } + } else { + if (result.charAt(0) !== chineseNums[0]) { // 避免连续多个零 + result = chineseNums[0] + result; + } + } + } + + return result.replace(/零([亿万])/g, "$1").replace(/零+/g, "零"); // 处理连续零和结果尾部的零 + }, + getoption(options){ + var arrs=[]; + if(options&&options.length>0){ + options.forEach(option=>{ + arrs.push({value:option.score,text:option.optionText}) + }) + } + return arrs; + }, + checkboxChange(e,i,j){ + console.log('e:',e,i,j); + if(e.detail.data){ + this.list[this.tabCurrentIndex].slist[i].questions[j]["score"]=e.detail.value; + this.$forceUpdate(); + this.list[this.tabCurrentIndex].slist[i].questions[j].options.forEach(op=>{ + if(e.detail.value==op.score){ + this.list[this.tabCurrentIndex].slist[i].questions[j]["optionId"]=op.optionId; + this.$forceUpdate(); + } + }) + this.scores=0; + this.list[this.tabCurrentIndex].slist.forEach((item,ind) => { + var score=0 + if(item.questions){ + item.questions.forEach(cell => { + if(cell.score){ + this.scores+=cell.score; + score+=cell.score; + this.$forceUpdate(); + } + }); + } + this.list[this.tabCurrentIndex].slist[ind]["score"]=score; + this.$forceUpdate(); + }); + this.$forceUpdate(); + } + }, + tzsubmit(ref) { + var answers=[]; + var tj=0; + this.list[this.tabCurrentIndex].slist.forEach(item => { + if(item.questions){ + item.questions.forEach(cell => { + if(cell.optionId){ + tj++; + answers.push({ + questionId:cell.questionId, + optionId:cell.optionId + }); + } + }); + } + + }) + if(tj>0){ + this.tzsavedo(answers) + } + else{ + uni.showModal({ + title: '提示', + content: "请选择体质测评数据后提交!", + cancelText: '取消', + confirmText: '确定', + success: ress => { + if (ress.confirm) { + } + } + }); + } + }, + async tzsavedo(answers){ + var params={ + answers:answers, + surveyId:this.surveyId, + sessionId:this.sessionId, + } + try{ + const {data: res} = await uni.$http.post('/api/questionnaire/submit', params); + if(res&&res.success){ + var data=res.data; + var constitutionScores=data.constitutionScores?data.constitutionScores:[]; + + // 1.若平和质总分 ≥ 8分,且其他所有体质总分均 < 6分) + // 则跳出为:恭喜您,您的体质为“为平和体质”,非常完美。请联系您的馆主或教练,领取训练及生活方案,继续保持哦。 + + // 2.(若某一种偏颇体质(气虚/阳虚/阴虚等)总分 ≥ 8分) + // 亲爱的伽人您好,您的体质为典型(气虚/阳虚/阴虚等,是什么就跳出什么)体质。请联系您的馆主或教练,领取训练机生活方案,快速调整哦。 + + // 3.(若某一种偏颇体质总分在 6 ~ 7分 之间)则跳出为: + // 亲爱的伽人您好,您的体质为典型(气虚/阳虚/阴虚等,是什么就跳出什么)倾向体质。请联系您的馆主或教练,领取训练机生活方案,快速调整哦。 + + // 4.(若有两种及以上偏颇体质分数都7分含7分以上,)则跳出: + // 亲爱的伽人您好,您的体质为复合型体质典型,建议综合调理。请联系您的馆主或教练,领取训练机生活方案,快速调整哦。 + var ifone=0,iftwo=0,ifthree=0,iffour=0; + var twostr=[],threestr=[]; + constitutionScores.forEach(item=>{ + // 1.若平和质总分 ≥ 8分,且其他所有体质总分均 < 6分) + if(item.constitutionAlias=="pinghe"){ + if(item.totalScore>=8) + { + ifone=2; + } + } + else{ + if(item.totalScore>6) + { + ifone=ifone-1; + } + if(item.totalScore>=8) + { + iftwo=iftwo+1; + twostr.push(item.constitutionName.replace("体质","")) + } + if(item.totalScore>=7&&item.totalScore<=6) + { + ifthree=ifthree+1; + threestr.push(item.constitutionName.replace("体质","")) + } + if(item.totalScore>=7) + { + iffour=iffour+1; + } + } + }); + var tips=data.resultText?data.resultText:"体质测评提交成功!"; + if(ifone==2){ + tips="恭喜您,您的体质为“为平和体质”,非常完美。请联系您的馆主或教练,领取训练及生活方案,继续保持哦。" + } + else if(iftwo>0){ + tips="亲爱的伽人您好,您的体质为典型"+twostr.toString('/')+"体质。请联系您的馆主或教练,领取训练机生活方案,快速调整哦。" + } + else if(ifthree>0){ + tips="亲爱的伽人您好,您的体质为典型"+threestr.toString('/')+"倾向体质。请联系您的馆主或教练,领取训练机生活方案,快速调整哦。" + } + else if(iffour>1){ + tips="亲爱的伽人您好,您的体质为复合型体质典型,建议综合调理。请联系您的馆主或教练,领取训练机生活方案,快速调整哦。" + } + + uni.showModal({ + title: '提示', + content: tips, + cancelText: '取消', + confirmText: '确定', + success: ress => { + if (ress.confirm) {} + } + }); + } + else{ + uni.showModal({ + title: '提示', + content: res.message? res.message:'体质测评提交失败!请重试!', + cancelText: '取消', + confirmText: '确定' + }); + } + } + catch{ + uni.showModal({ + title: '提示', + content: '计算异常!请重试!', + cancelText: '取消', + confirmText: '确定' + }); + } + + }, async getSort() { // 分类 const {data: res} = await uni.$http.get('/api/index/getIndex'); @@ -413,36 +652,103 @@ // 吃瘦练美(健康饮食) url="/api/healthy/getList"; } + else if(this.list[this.tabCurrentIndex].id==10){ + // 体质测评 + url="/api/questionnaire/getOne"; + } else{ return false; } uni.showLoading({ title: '数据加载中...' }); - // 获取数据 - const {data: res} = await uni.$http.post(url, para); - if(res.data){ - this.list[this.tabCurrentIndex].loadStatus="noMore"; - if(this.list[this.tabCurrentIndex].id==3){ - console.log(res.data) - // 了解场馆 - var companyIntroduction=res.data&&res.data.companyIntroduction?res.data.companyIntroduction:''; - if(companyIntroduction){ - this.html1=companyIntroduction.profile; //企业简介 - this.html2=companyIntroduction.founder; //创始人 + + // 体质测评 + if(this.list[this.tabCurrentIndex].id==10){ + // 获取体质测评项 + const {data: res} = await uni.$http.get(url); + if(res.data){ + var data=res.data; + this.list[this.tabCurrentIndex].loadStatus="noMore"; + this.list[this.tabCurrentIndex].slist=data.constitutions?data.constitutions:[]; + this.description=data.description; + this.title=data.title; + this.surveyId=data.surveyId; + this.sessionId=data.sessionId; + this.$forceUpdate(); + + if(this.userid){ + // 获取体质测评上次答题结果(需登录) + const {data: rest} = await uni.$http.get("/api/questionnaire/result"); + if(rest.data){ + var resultText=rest.data.resultText; + if(resultText){ + uni.showModal({ + title: '上次测评结果', + content: resultText, + cancelText: '取消', + confirmText: '确定', + success: ress => { + if (ress.confirm) {} + } + }); + } + // var constitutionScores=rest.data.constitutionScores?rest.data.constitutionScores:[]; + + // var answers=rest.data.answers?rest.data.answers:[]; + // answers.forEach(cell=>{ + // this.list[this.tabCurrentIndex].slist.forEach((item,ii)=>{ + // if(item.questions&&item.questions.length>0){ + // item.questions.forEach((qt,kk)=>{ + // if(qt.questionId==answers.questionId){ + // if(qt.options){ + // qt.options.forEach((opt,hh)=>{ + // if(opt.optionId==answers.optionId){ + // this.list[this.tabCurrentIndex].slist[ii].questions[kk]["score"]=opt.score; + // this.$forceUpdate(); + // } + // }); + // } + // } + // }) + // } + // }); + // }); + + } } - this.shoplist=res.data&&res.data.storeList?res.data.storeList:[]; - this.$forceUpdate(); } else{ - this.list[this.tabCurrentIndex].slist=res.data; + this.list[this.tabCurrentIndex].loadStatus="noMore"; this.$forceUpdate(); } - this.$forceUpdate(); } else{ - this.list[this.tabCurrentIndex].loadStatus="noMore"; - this.$forceUpdate(); + // 获取数据 + const {data: res} = await uni.$http.post(url, para); + if(res.data){ + this.list[this.tabCurrentIndex].loadStatus="noMore"; + if(this.list[this.tabCurrentIndex].id==3){ + console.log(res.data) + // 了解场馆 + var companyIntroduction=res.data&&res.data.companyIntroduction?res.data.companyIntroduction:''; + if(companyIntroduction){ + this.html1=companyIntroduction.profile; //企业简介 + this.html2=companyIntroduction.founder; //创始人 + } + this.shoplist=res.data&&res.data.storeList?res.data.storeList:[]; + this.$forceUpdate(); + } + else{ + this.list[this.tabCurrentIndex].slist=res.data; + this.$forceUpdate(); + } + this.$forceUpdate(); + } + else{ + this.list[this.tabCurrentIndex].loadStatus="noMore"; + this.$forceUpdate(); + } } } }, @@ -488,7 +794,7 @@ }, animationfinish({ detail: { current } }) { - console.log("animationfinish") + // console.log("animationfinish") // this.tabCurrentIndex = current; }, handleChange(e) { @@ -526,7 +832,7 @@ }, tabChangeDo(){ this.scrollLeft = (this.tabCurrentIndex - 1) * 90; - if(this.list[this.tabCurrentIndex].id==2||this.list[this.tabCurrentIndex].id==10){ + if(this.list[this.tabCurrentIndex].id==2){ var that=this; // 健康指数 体质测评 setTimeout(() => { @@ -674,7 +980,7 @@ } .swiper-box { flex: 1; - height: calc(100vh - var(--window-top) - var(--window-bottom) - 280rpx) !important; + height: calc(100vh - var(--window-top) - var(--window-bottom) - 200rpx) !important; } .swiper-item { height: 100%; @@ -866,8 +1172,6 @@ /* autoprefixer: off */ -webkit-box-orient: vertical; //属性规定框的子元素应该被水平或垂直排列 /* autoprefixer: on */ - - } } } @@ -933,6 +1237,111 @@ } } } - - + + ::v-deep.uni-data-checklist .checklist-group .checklist-box .checklist-content .checklist-text{ + line-height: 40rpx !important; + font-size: 28rpx !important; + font-family: PingFang SC-Regular, PingFang SC !important; + font-weight: 400 !important; + color: #23262F !important; + } + ::v-deep .uni-forms-item.is-direction-top .uni-forms-item__label{ + font-size: 30rpx !important; + font-family: PingFang SC-Semibold, PingFang SC !important; + font-weight: 500 !important; + color: #333333 !important; + } + ::v-deep .uni-forms-item__label{ + height: auto !important; + } + ::v-deep .uni-forms-item__error{ + display: none !important; + } + ::v-deep .uni-forms-item{ + margin-bottom: 16rpx !important; + } + .uni-list-cell{ + display: flex; + flex-direction: row; + padding: 20rpx 0; + } + .rtxt{ + margin-left: 16rpx; + font-size: 28rpx; + font-family: PingFang SC-Regular, PingFang SC; + font-weight: 400; + color: #23262F; + } + .rtip{ + font-size: 28rpx; + color:#F45A45; + margin-right: 5rpx; + } + .rtitle{ + color:#666666; + height: 40rpx; + line-height: 40rpx; + font-size: 28rpx; + font-family: PingFang SC-Regular, PingFang SC; + font-weight: 400; + color: #23262F; + } + .tvalue{ + display: flex; + flex:1; + justify-content: flex-end; + font-size: 24rpx; + font-family: PingFang SC-Regular, PingFang SC; + font-weight: 400; + color: #666666; + height: 40rpx; + line-height: 40rpx; + margin-left: 16rpx; + } + .nvalue{ + display: flex; + flex:1; + justify-content: flex-end; + font-size: 24rpx; + font-family: PingFang SC-Regular, PingFang SC; + font-weight: 400; + color: #999999; + height: 40rpx; + line-height: 40rpx; + margin-left: 16rpx; + } + .example { + margin: 20rpx 8rpx 0; + padding: 20rpx; + background-color: #FFFFFF; + border-radius: 16rpx; + } + .optxt{ + width: 100%; + line-height: 40rpx; + font-size: 28rpx; + color: #23262F; + text-align: left; + } + .tztitle{ + width: 100%; + line-height: 60rpx; + font-size: 36rpx; + font-weight: 600; + color: #000; + } + .tztxt{ + width: 100%; + line-height: 32rpx; + font-size: 28rpx; + color: #000; + text-align: left; + } + .tzcontent{ + background-color: rgba(255, 255,255, 0.5); + border-radius: 20rpx; + margin: 30rpx; + padding:20rpx 20rpx; + text-align: center; + } diff --git a/pages/chat/chat.vue b/pages/chat/chat.vue new file mode 100644 index 0000000..f92c327 --- /dev/null +++ b/pages/chat/chat.vue @@ -0,0 +1,1807 @@ + + + + + diff --git a/pages/chat/groupchat.vue b/pages/chat/groupchat.vue new file mode 100644 index 0000000..9a1f8cb --- /dev/null +++ b/pages/chat/groupchat.vue @@ -0,0 +1,2005 @@ + + + + + diff --git a/pages/product/service.vue b/pages/chat/groupchat0.vue similarity index 98% rename from pages/product/service.vue rename to pages/chat/groupchat0.vue index 87e9b1e..6919b6a 100644 --- a/pages/product/service.vue +++ b/pages/chat/groupchat0.vue @@ -217,17 +217,6 @@ // 在组件销毁前,确保关闭 WebSocket 连接 this.closeWebSocket(); }, - //点击导航栏 buttons 时触发 添加任务 - onNavigationBarButtonTap: async function(e) { - const _that = this; - const index = e.index; - if (index === 0) { - var data=encodeURIComponent(JSON.stringify(_that.info)); - uni.navigateTo({ - url: `/pages/chat/chatset?data=${data}` - }); - } - }, methods: { gotoInfo(item){ var data=encodeURIComponent(JSON.stringify(item)); @@ -237,7 +226,7 @@ }, handleImageError(e,index){ console.log(e,index); - this.unshiftmsg[index]["headimg"]= require("@/static/image/girl.jpg"); + this.unshiftmsg[index]["headimg"]= require("@/static/image/girl.png"); this.$forceUpdate(); }, // 获取聊天缓存 @@ -263,7 +252,7 @@ else if(cell.type=='txt'){ cell.content=decodeURIComponent(cell.content); } - cell["headimg"]=require("@/static/image/girl.jpg"); //this.imgurl+'/images/'+ cell.fromuser+".jpg?id="+Math.random()*100; + cell["headimg"]=require("@/static/image/girl.png"); //this.imgurl+'/images/'+ cell.fromuser+".jpg?id="+Math.random()*100; this.unshiftmsg.push(cell); // 跳转到最后一条数据 与前面的:id进行对照 setTimeout(() => { @@ -567,7 +556,7 @@ let data = { "fromname": this.friendName, "fromuser": this.friendcode, - "headimg":require("@/static/image/girl.jpg"), + "headimg":require("@/static/image/girl.png"), "toname": this.info.name, // 接收人 "touser": this.info.id, // 接收人姓名 "content": e.type=='audio'?e.message.voice:e.message, diff --git a/pages/chat/groupchat1.vue b/pages/chat/groupchat1.vue new file mode 100644 index 0000000..30833e6 --- /dev/null +++ b/pages/chat/groupchat1.vue @@ -0,0 +1,1830 @@ + + + + + diff --git a/pages/components/cart.vue b/pages/components/cart.vue index 37d1e9f..5bce8a9 100644 --- a/pages/components/cart.vue +++ b/pages/components/cart.vue @@ -203,7 +203,7 @@ export default { spData:JSON.stringify(this.product.spData),// this.retSku(this.product.spData) 展示时候再解析,保持数据一致, // 保存字符串 this.product.spData, skuId:this.product.skuId, quantity:this.product.quantity, - storeId:myCache('myshopid')?myCache('myshopid'):'', + storeId:this.product.storeId, isCourse:this.product.isCourse, }; const {data: res1} = await uni.$http.post('/api/cart/add',param); diff --git a/pages/components/selShop.vue b/pages/components/selShop.vue index 347291e..b63a2f8 100644 --- a/pages/components/selShop.vue +++ b/pages/components/selShop.vue @@ -27,8 +27,11 @@ - - + + + + + @@ -86,8 +89,8 @@ export default { default: false, }, shopid: { - type: Number, - default: 0, + type: String, + default: '0', }, shop: { type: String, @@ -111,11 +114,28 @@ export default { } }, // 切换门店 - changeArea(item){ - myCache('myshop',item.storeName); - myCache('myshopid',item.id); - this._hide(); - this.$emit("changeArea", item); + async changeArea(item){ + uni.showLoading({ + title: '门店切换中...' + }); + const {data: res} = await uni.$http.post('/api/index/changeStore',{"visitStoreId":item.id}); + if(res&&res.success){ + var data=res.data; + myCache('myshop',data.storeName); + myCache('myshopid',data.id); + this._hide(); + this.$emit("changeArea", data); + } + else{ + // 切换门店 + uni.showModal({ + title: '提示', + content: res.message? res.message : '切换门店失败!请重试!', + cancelText: '取消', + confirmText: '确定', + success: ress => {} + }); + } }, _show() { this.areas= myCache('shoplist'); @@ -276,6 +296,10 @@ export default { padding: 20rpx 0 20rpx 10rpx; margin: 10rpx 30rpx 0 30rpx; align-items: center; + .sarr{ + width: 30rpx; + margin-right: 10rpx; + } .stimg{ width: 80rpx; height: 80rpx; diff --git a/pages/components/service.vue b/pages/components/service.vue index e511450..5a83ae2 100644 --- a/pages/components/service.vue +++ b/pages/components/service.vue @@ -13,8 +13,9 @@ export default { }, methods: { goservice(){ - console.log('linemobile',myCache('linemobile')) - myCache('linemobile','18900000001') + var shop=myCache('shop'); + var phone=shop&&shop.phone?shop.phone:""; + myCache('linemobile',phone) // 在线客服 if(myCache('linemobile')){ // 在线客服 @@ -28,38 +29,7 @@ export default { } }); } - else{ - // this.getlinemobile(); - } this.$emit("goservice", "goservice"); - }, - async getlinemobile(){ - const {data: res} = await uni.$http.get('/platform/getHotline'); - console.log(res) - if (res) { - myCache('linemobile',res); - uni.makePhoneCall({ - phoneNumber: String(myCache('linemobile')), - success:function(){ - console.log('拨打电话成功'); - }, - fail() { - console.log('打电话失败了'); - } - }); - } - else{ - uni.showModal({ - title: '提示', - content: '在线电话获取失败!请稍后再试!', - cancelText: '取消', - confirmText: '确定', - success: ress => { - if (ress.confirm) { - } - } - }); - } } } } diff --git a/pages/index/index.vue b/pages/index/index.vue index 9e9a07f..eabbe16 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -18,8 +18,8 @@ :duration="1000" :circular="true"> - - + + @@ -104,16 +104,12 @@ openId:"", phone:"", userid:"", - shopid: myCache('myshopid'), + shopid: myCache('myshopid')?myCache('myshopid'):null, shop: myCache('myshop'), // banner swiperList:[ - { - ban_img:"../../static/image/b1.jpg" - }, - { - ban_img:"../../static/image/b2.png" - } + "../../static/image/b1.jpg", + "../../static/image/b2.png" ],// myCache('swiperCache'), colors:[ "#f9d1c8","#c7d7bd","#c4dfe4","#efdddd","#c4ccdf","#fceaac","#d5e7c1", @@ -199,11 +195,18 @@ page: { pageNum: 1, pageSize: 10, - visitStore: myCache('myshopid')?myCache('myshopid'):'', + visitStore: myCache('myshopid')?myCache('myshopid'):null, }, }; }, onLoad() { + var shop=myCache('shop'); + var banner=shop&&shop.banner?shop.banner:""; + banner=banner.split(','); + if(banner.length>0){ + this.swiperList=banner; + this.$forceUpdate(); + } // 获取分类信息 this.getSort(); @@ -212,20 +215,34 @@ this.getservice(); // 获取老师信息 - this.loadData(); + // this.loadData(); + // setTimeout(() => { + // console.log("getCurrentActivity") + // this.getCurrentActivity(); + // },2000); }, onShow() { - this.shopid = myCache('myshopid')?myCache('myshopid'):''; + this.shopid = myCache('myshopid')?myCache('myshopid'):null; this.shop = myCache('myshop')?myCache('myshop'):''; this.$forceUpdate(); - if(myCache("loginindex")=="1"){ - uni.setStorageSync("loginindex", ""); - // 获取老师信息 - this.loadData(); + // 获取老师信息 + this.teacherList=[]; + this.loadStatus="more"; + this.page={ + pageNum: 1, + pageSize: 10, + visitStore:this.shopid } + this.loadData(); + + // if(myCache("loginindex")=="1"){ + // uni.setStorageSync("loginindex", ""); + // // 获取老师信息 + // this.loadData(); + // } this.openId = myCache('openId'); var user = myCache('user'); @@ -286,6 +303,22 @@ this.$refs.topId.topData(e.scrollTop); }, methods: { + getCurrentActivity() { + // 获取当前Activity(仅App端有效) + const mainActivity = plus.android.runtimeMainActivity(); + if (mainActivity) { + console.log('获取到Activity对象:', mainActivity); + // 可进一步调用Activity方法(需通过plus.android.importClass) + plus.android.importClass(mainActivity); + //console.log('Activity类名:', mainActivity.getClass().getSimpleName()); + //console.log('Activity类名:', mainActivity.getClass()); + console.log('Activity类名:', mainActivity.getClassName()); + return mainActivity; + } else { + console.error('无法获取Activity对象'); + return null; + } + }, getimgRemoteFile(img){ if(img){ img=img.split(',')[0]; @@ -391,17 +424,25 @@ this.loadStatus="loading"; setTimeout(() => { this.getTeacherList(); + this.getBanner(); }, 300); } }, async getBanner() { // banner - const {data: res} = await uni.$http.post('/platform/getbanner'); - if (res&&res.length>0) { - this.swiperList=res; - // 保存海报信息 - myCache('swiperCache',this.swiperList); - this.$forceUpdate(); + const {data: res} = await uni.$http.get('/api/getInfo'); + if(res&&res.visitStore){ + var shop=res.visitStore; + var banner=shop&&shop.banner?shop.banner:""; + banner=banner.split(','); + if(banner.length>0){ + this.swiperList=banner; + this.$forceUpdate(); + } + myCache('shop',shop); + myCache('myshop',shop.storeName); + myCache('myshopid',shop.id); + } }, async getSort() { @@ -574,7 +615,7 @@ gotoTeacherMore(){ // 教练风采 uni.reLaunch({ - url: `/pages/category/category?id=2` + url: `/pages/category/category?id=5` }); }, gotoTeacher(info){ diff --git a/pages/login/login.vue b/pages/login/login.vue index d9e4224..9394def 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -259,7 +259,7 @@ // phonenumber:"测试人", // userid:"1", // userphone:"18900000001", - // avatar:"/static/image/girl.jpg" + // avatar:"/static/image/girl.png" // }); // this.$refs.uToast.show({ // title: '登录成功', @@ -363,6 +363,12 @@ if(res.data&&res.data.length>0){ myCache('shoplist',res.data); } + else{ + console.log("shoplist") + var shop=myCache('shop'); + var shoplist=shop?[shop]:[]; + myCache('shoplist',shoplist); + } }, async getUserShopList(){ var _this=this; @@ -435,10 +441,10 @@ } .checkimg{ position: absolute; - top:14rpx; + top: 8rpx; right: 130rpx; - width: 150rpx; - height: 50rpx; + width: 160rpx; + height: 66rpx; } .codebtn{ position: absolute; diff --git a/pages/message/contact.vue b/pages/message/contact.vue index b019ea6..62866c6 100644 --- a/pages/message/contact.vue +++ b/pages/message/contact.vue @@ -9,25 +9,35 @@ - + + - 教练 + 教练 - + + - 客服 + 客服 - + + - 课程顾问 + 课程顾问 - + + - 店长 + 店长 + + + + 学员 + + - 群聊 + 群聊 @@ -40,10 +50,10 @@ - + - {{info.name}} + {{info.friendNickName}} @@ -65,83 +75,84 @@ export default { data() { return { + userid:"", + userName:"", messageText:'', //错误提示框 msgType :'error', tabCurrentIndex:0, imgurl:uni.$http.baseUrl, list:[ { - id:0, + id:"coach", name:'教练', loadStatus:'loadmore', - grouplist:[ - // { - // id:1, - // name:"教练A", - // img:"/static/image/jl.png" - // }, - ] + grouplist:[] }, { - id:1, + id:"customerService", name:'客服', loadStatus:'loadmore', - grouplist:[ - // { - // id:1, - // name:"商城客服-伽伽", - // img:"/static/image/kff.png" - // }, - ] + grouplist:[] }, { - id:2, + id:"adviser", name:'课程顾问', loadStatus:'more', - grouplist:[ - // { - // id:1, - // name:"顾问1", - // img:"/static/image/gw.png" - // }, - ] + grouplist:[] }, { - id:3, + id:"storeManager", name:'店长', loadStatus:'more', - grouplist:[ - // { - // id:1, - // name:"顾问1", - // img:"/static/image/dzh.png" - // }, - ] + grouplist:[] }, { - id:4, + id:"groupchat", name:'群聊', loadStatus:'loadmore', - grouplist:[ - // { - // id:1, - // name:"群聊1", - // img:"/static/image/ql.png" - // }, - ] - } + grouplist:[] + }, + { + id:"consumer", + name:'学员', + loadStatus:'loadmore', + grouplist:[] + }, ], - page:{ - // pageNum:'1', - // pageSize: '10' - } + ifxy:false, } }, onLoad(options) { - // 未选择门店,则退出至首页选择门店 - if(myCache('myshopid')){ - + var userInfo=myCache('userInfo'); + this.userid = userInfo.userId? userInfo.userId:''; + this.userName = userInfo.nickName?userInfo.nickName:""; + var roleId=userInfo&&userInfo.roleId?userInfo.roleId:[]; + if(roleId.length<1){ + this.ifxy=true; + this.$forceUpdate(); + } + roleId.forEach(cell=>{ + if(cell=='107'&&roleId.length<2){ + this.ifxy=true; + this.$forceUpdate(); + } + else{ + this.ifxy=false; + this.$forceUpdate(); + } + }); + + if(this.ifxy){ + this.tabCurrentIndex=0; + this.$forceUpdate(); + } + else{ + this.tabCurrentIndex=5; + this.$forceUpdate(); } + + // 未选择门店,则退出至首页选择门店 + if(myCache('myshopid')){} this.loadData(); }, onShow(){ @@ -159,44 +170,86 @@ this.loadData(); }, methods: { - addContacts(){ - }, + // 新增通讯录 + addContacts(){}, gotoBack(){ // 返回 uni.navigateBack({ delta: 1 }); }, - changeTime(date) { - return dateTime.dateTime(date); - }, - gotoGroup(info){ + // 跳转聊天框 + gotoGroup(item){ + console.log(item); + // 直接跳转到聊天框 + var timestamp = new Date().getTime(); + var info={ + chatId: "privatechat-" + this.userid +"-"+ item.friendId, + chatType: (this.tabCurrentIndex==0?"coach":(this.tabCurrentIndex==1?"customerService":(this.tabCurrentIndex==2?"adviser": + (this.tabCurrentIndex==3?"storeManager":(this.tabCurrentIndex==4?"groupchat":(this.tabCurrentIndex==5?"consumer":"")))))), + chatName: item.friendNickName, + chatAvatar: item.friendHeadImage, + chatTime: timestamp, + userid: this.userid, + friendId: item.friendId, // 会话对象 + minId: null, // 已读消息的最大id + sort: this.tabCurrentIndex==4?"groupchat":"privatechat", // privatechat 私聊 groupchat 群聊 + from: "message" // yh 用户咨询进入聊天框,message 从消息进入聊天框 + } + // id:"coach", + // name:'教练', + // id:"customerService", + // name:'客服', + // id:"adviser", + // name:'课程顾问', + // id:"storeManager", + // name:'店长', + // id:"groupchat", + // name:'群聊', + // id:"consumer", + // name:'学员', + + console.log(info); if(this.tabCurrentIndex==0){ // 教练 var data=encodeURIComponent(JSON.stringify(info)); uni.navigateTo({ - url: `/pages/teacher/chat?data=${data}` + url: `/pages/chat/chat?data=${data}` }); } else if(this.tabCurrentIndex==1){ // 客服 var data=encodeURIComponent(JSON.stringify(info)); uni.navigateTo({ - url: `/pages/product/service?data=${data}` + url: `/pages/chat/chat?data=${data}` }); } else if(this.tabCurrentIndex==2){ // 顾问 var data=encodeURIComponent(JSON.stringify(info)); uni.navigateTo({ - url: `/pages/product/service?data=${data}` + url: `/pages/chat/chat?data=${data}` }); } else if(this.tabCurrentIndex==3){ + // 店长 + var data=encodeURIComponent(JSON.stringify(info)); + uni.navigateTo({ + url: `/pages/chat/chat?data=${data}` + }); + } + else if(this.tabCurrentIndex==4){ // 群聊 var data=encodeURIComponent(JSON.stringify(info)); uni.navigateTo({ - url: `/pages/product/service?data=${data}` + url: `/pages/chat/groupchat?data=${data}` + }); + } + else if(this.tabCurrentIndex==5){ + // 学员 + var data=encodeURIComponent(JSON.stringify(info)); + uni.navigateTo({ + url: `/pages/chat/chat?data=${data}` }); } }, @@ -219,7 +272,7 @@ if(this.list[this.tabCurrentIndex].loadStatus!=="nomore") { // 教练、客服、顾问、店长列表 - if(this.tabCurrentIndex==0||this.tabCurrentIndex==1||this.tabCurrentIndex==2||this.tabCurrentIndex==3){ + if(this.tabCurrentIndex==0||this.tabCurrentIndex==1||this.tabCurrentIndex==2||this.tabCurrentIndex==3||this.tabCurrentIndex==5){ const {data: res} = await uni.$http.get('/api/friend/list'); this.list[0].loadStatus="nomore"; this.list[0].grouplist=[]; @@ -229,48 +282,32 @@ this.list[2].grouplist=[]; this.list[3].loadStatus="nomore"; this.list[3].grouplist=[]; + this.list[5].loadStatus="nomore"; + this.list[5].grouplist=[]; // 教练列表 - if(res.data&&res.data.customerService&&res.data.customerService.length>0){ - res.data.customerService.forEach(cell => { - this.list[0].grouplist.push({ - id: cell.friendId, - name: cell.friendNickName, - img: cell.friendHeadImage?cell.friendHeadImage:'/static/image/ql.png' - }) - }); + if(res.data&&res.data.coach&&res.data.coach.length>0){ + this.list[0].grouplist=res.data.coach; this.$forceUpdate(); } // 客服列表 - if(res.data&&res.data.coach&&res.data.coach.length>0){ - res.data.coach.forEach(cell => { - this.list[1].grouplist.push({ - id: cell.friendId, - name: cell.friendNickName, - img: cell.friendHeadImage?cell.friendHeadImage:'/static/image/kff.png' - }) - }); + if(res.data&&res.data.customerService&&res.data.customerService.length>0){ + this.list[1].grouplist=res.data.customerService; this.$forceUpdate(); } // 顾问列表 if(res.data&&res.data.adviser&&res.data.adviser.length>0){ - res.data.adviser.forEach(cell => { - this.list[2].grouplist.push({ - id: cell.friendId, - name: cell.friendNickName, - img: cell.friendHeadImage?cell.friendHeadImage:'/static/image/gw.png' - }) - }); + this.list[2].grouplist=res.data.adviser; this.$forceUpdate(); } // 店长列表 if(res.data&&res.data.storeManager&&res.data.storeManager.length>0){ - res.data.storeManager.forEach(cell => { - this.list[3].grouplist.push({ - id: cell.friendId, - name: cell.friendNickName, - img: cell.friendHeadImage?cell.friendHeadImage:'/static/image/dzh.png' - }) - }); + this.list[3].grouplist=res.data.storeManager; + this.$forceUpdate(); + } + + // 学员列表 + if(res.data&&res.data.consumer&&res.data.consumer.length>0){ + this.list[5].grouplist=res.data.consumer; this.$forceUpdate(); } } @@ -282,16 +319,14 @@ this.list[this.tabCurrentIndex].grouplist=[]; if(res.data&&res.data.length>0){ res.data.forEach(cell => { - this.list[this.tabCurrentIndex].grouplist.push({ - id: cell.id, - name: cell.name, - img: cell.headImage?cell.headImage:'/static/image/ql.png' + this.list[this.tabCurrentIndex].grouplist.push({...cell, + friendNickName: cell.name, + friendHeadImage: cell.headImage?cell.headImage:'/static/image/ql.png' }) }); this.$forceUpdate(); } } - } }, // 获取状态栏高度 @@ -322,10 +357,7 @@ width: 100%; z-index: 999; background-color: #00a89b; - .text-center { - width: 100%; - text-align: center; - } + .edit { position: absolute; top: 50%; @@ -338,25 +370,39 @@ width: 100%; background-color: #00a89b; margin: 0; - padding: 26rpx 30rpx; + padding: 0 30rpx; + height: 100rpx; display: flex; + flex-direction: row; color: #fff; font-size: 36rpx; + align-items: center; .leftarr{ background-color: rgba(255, 255,255, 0.3); - padding: 5rpx; border-radius: 10rpx; width: 60rpx; + height: 60rpx; + display: flex; + align-items: center; + justify-content: center; + } + .text-center { + display: flex; + flex: 1; + width: 100%; + align-items: center; + justify-content: center; } } .concon{ display: flex; flex-direction: row; background: #fff; - padding: 30rpx 20rpx 20rpx 20rpx; + padding: 20rpx 0; margin: 0; + height: 190rpx; align-items: center; - justify-content: center; + justify-content: left; .concell{ display: flex; flex-direction: column; @@ -364,8 +410,8 @@ justify-content: center; width: 20%; .cimg{ - width: 100rpx; - height: 100rpx; + width: 90rpx; + height: 90rpx; } .ctxt{ font-size: 28rpx; @@ -374,33 +420,41 @@ } .cur1{ color:#ff7530; - font-size: 30rpx; + font-size: 32rpx; font-weight: 600; } .cur2{ color:#46a0fb; - font-size: 30rpx; + font-size: 32rpx; font-weight: 600; } .cur3{ color:#5bd171; - font-size: 30rpx; + font-size: 32rpx; font-weight: 600; } .cur5{ color:#d4237a; - font-size: 30rpx; + font-size: 32rpx; + font-weight: 600; + } + .cur6{ + color:#00a89b; + font-size: 32rpx; font-weight: 600; } .cur4{ color:#fca600; - font-size: 30rpx; + font-size: 32rpx; font-weight: 600; } } } .wrapcon{ - margin: 400rpx 0 0 0; + margin: 370rpx 0 0 0; + /* #ifdef H5 */ + margin: 300rpx 0 0 0; + /* #endif */ padding: 0; width: 100%; position: relative; @@ -433,8 +487,8 @@ justify-content: center; border-radius: 50%; .img{ - width: 100rpx; - height: 100rpx; + width: 80rpx; + height: 80rpx; border-radius: 10rpx; } } diff --git a/pages/message/group.vue b/pages/message/group.vue index 757a437..27e45fc 100644 --- a/pages/message/group.vue +++ b/pages/message/group.vue @@ -6,35 +6,38 @@ - + 暂无消息~ - - - - - - - {{info.name}} - {{ changeTime(info.datetime)}} - - - - {{info.content}} + + + + - - - {{ info.sl}} + + + {{info.name}} + {{ changeTime(info.datetime)}} + + + + {{ info.type==0?info.content:(info.type==1?"图片":(info.type==2?"文件":(info.type==3?"语音":(info.type==4?"视频": + (info.type==5?"订单咨询":(info.type==6?"商品咨询":info.content))))))}} + + + {{ info.sl}} + + - - - + + + + + @@ -53,92 +56,47 @@ export default { data() { return { + openId:"", + phone:"", + userid:"", + userName:"", + userheadimg:"", messageText:'', //错误提示框 msgType :'error', loadStatus:'loadmore', + options: [ + { + text: '删除', + style: { + backgroundColor: '#ed2a28' + } + } + ], //u-swipe-action样式 imgurl:uni.$http.baseUrl, - grouplist:[ - // { - // id:1, - // sl:25, - // name:"商城客服-伽伽", - // img:"../../static/image/girl.jpg", - // content:"测试信息1", - // datetime:"2025-07-10 12:18", - // type:1, // 客服 - // }, - // { - // id:2, - // sl:8, - // name:"教练A", - // img:"../../static/image/girl.jpg", - // content:"测试信息2", - // datetime:"2025-07-05 12:18", - // type:2, // 老师 - // }, - // { - // id:1, - // sl:25, - // name:"商城客服-伽伽", - // img:"../../static/image/girl.jpg", - // content:"测试信息1", - // datetime:"2025-07-10 12:18", - // type:1, // 客服 - // }, - // { - // id:2, - // sl:8, - // name:"教练A", - // img:"../../static/image/girl.jpg", - // content:"测试信息2", - // datetime:"2025-07-05 12:18", - // type:2, // 老师 - // }, - // { - // id:1, - // sl:25, - // name:"商城客服-伽伽", - // img:"../../static/image/girl.jpg", - // content:"测试信息1", - // datetime:"2025-07-10 12:18", - // type:1, // 客服 - // }, - // { - // id:2, - // sl:8, - // name:"教练A", - // img:"../../static/image/girl.jpg", - // content:"测试信息2", - // datetime:"2025-07-05 12:18", - // type:2, // 老师 - // }, - // { - // id:1, - // sl:25, - // name:"商城客服-伽伽", - // img:"../../static/image/girl.jpg", - // content:"测试信息1", - // datetime:"2025-07-10 12:18", - // type:1, // 客服 - // }, - // { - // id:2, - // sl:8, - // name:"教练A", - // img:"../../static/image/girl.jpg", - // content:"测试信息2", - // datetime:"2025-07-05 12:18", - // type:2, // 老师 - // } - ], - + grouplist:[], + socketTask: null, + isConnected: false, // WebSocket连接状态 + socketmsg:[],//接收信息 + heartbeatInterval: null, // 心跳包20秒连接一次 + heartbeatTimeout: 20000, // 心跳间隔时间,例如每20秒发送一次 } }, onLoad(options) { - // this.getgroupsmembers(); + // socket接收信息初始化 + // this.socketinit(); }, onShow(){ - this.loadStatus='loadmore'; + this.openId = myCache('openId'); + var user = myCache('user'); + this.userid = user.userid? user.userid:''; + this.userName=user.nickName?user.nickName:""; + this.userheadimg=user.avatar?user.avatar:require("@/static/image/girl.png"); + this.phone = user.userphone; + // 如果心跳包在发送,先停止,再启动 + if(this.heartbeatInterval){ + clearInterval(this.heartbeatInterval); // 停止心跳包发送 + } + // 从缓存聊天群里获取聊天群列表 chatlist this.loadData(); }, onPullDownRefresh() { @@ -147,12 +105,250 @@ uni.stopPullDownRefresh() },500); }, - onReachBottom() { - console.log('onReachBottom'); - // 暂不分页 - // this.loadData(); + onBackPress(options) { + if (options.from === 'backbutton') { + // 来自顶部菜单的返回按钮 + // 在这里处理你的逻辑 + console.log('返回按钮被点击'); + this.closeWebSocket(); + uni.onSocketClose(function (res) { + console.log('WebSocket 已关闭!'); + }); + return false; + } + }, + beforeDestroy() { + console.log('界面关闭socket,beforeDestroy'); + // 在组件销毁前,确保关闭 WebSocket 连接 + this.closeWebSocket(); + clearInterval(this.heartbeatInterval); // 停止心跳包发送 + }, + beforeRouteLeave(to, from, next) { + console.log('界面关闭socket,beforeRouteLeave'); + next(); }, methods: { + // 删除 + actionClick(info,index) { + console.log(info,index); + var that=this; + uni.showModal({ + title: '提示', + content: "确定要删除此聊天记录吗?", + cancelText: '取消', + confirmText: '确定', + success: ress => { + if (ress.confirm) { + myCache(info.id,""); + that.grouplist.splice(index, 1); + that.$forceUpdate(); + myCache("chatlist",that.grouplist); + } + } + }); + }, + // 定时心跳包 + startHeartbeat() { + console.log("startHeartbeat") + this.heartbeatInterval = setInterval(() => { + if (this.socketTask) { + this.socketTask.send({ + data: JSON.stringify({ + 'cmd': 1,//心跳 + 'data': { + 'accessToken':uni.getStorageSync("token") + }, + }) // 发送心跳包数据 + }); + } + }, this.heartbeatTimeout); + }, + // ws接收消息 + socketinit(){ + var that = this; + // if (!that.isConnected) { + + that.socketTask=uni.connectSocket({ + url: "wss://www.sanduolantoyoga.com/yoga-imserver/", + header: { + // 'content-type': 'application/json', + Authorization: uni.getStorageSync("token"), + }, + success: (res) => { + console.log(res, 'socket连接成功success'); + }, + fail: (res) => { + console.log(res, 'socket连接失败') + }, + complete: (res) => { + console.log(res,'socket连接成功complete'); + } + }); + + uni.onSocketOpen(resopen => { + console.log('WebSocket连接已打开!'); + that.isConnected = true; + that.$forceUpdate() + uni.sendSocketMessage({ + data: JSON.stringify({ + "cmd": 0,//心跳 + "data": { + "accessToken":uni.getStorageSync("token"), + }, + }), // 发送心跳包数据 // 发送的消息内容 + success(re) { + console.log(re); + console.log('消息发送成功!') + }, + fail(err) { + console.log(err); + console.log('消息发送失败!') + } + }); + + // 发送心跳包 + this.startHeartbeat(); + }); + + uni.onSocketMessage(res => { + console.log('收到WebSocket服务器消息:'); + if(res.data){ + var rs=JSON.parse(res.data); + console.log(rs); + if(rs.cmd==3){ + // 私聊 + if(rs.data){ + var data=rs.data; + if(data.recvId&&(data.recvId).toString()==(that.userid).toString()){ + // 是这个用户的接收的私聊信息 + // 加入聊天记录 + // 消息类型 0:文字 1:图片 2:文件 3:语音 4:视频 10, "撤回" 11, "已读 "12, "消息已读回执 " 30,"加载中标记" + if(data.type==0){ + data.content=decodeURIComponent(data.content); + } + if(data.type==0||data.type==1||data.type==2||data.type==3||data.type==4||data.type==5||data.type==6){ + var ifexist=0,idx=null; + that.grouplist.forEach((cell,index)=>{ + if(cell.fromuser==data.sendId&&cell.userid==data.recvId&&cell.sort=="privatechat"){ + ifexist=1; + idx=index; + that.grouplist[index].sl=(that.grouplist[index].sl?that.grouplist[index].sl+1:1); + that.grouplist[index].content=data.content; + that.grouplist[index].datetime=data.sendTime; + that.grouplist[index].type=data.type; + that.$forceUpdate(); + } + }); + + if(ifexist==0){ + // 未保存缓存 + // 接收到socket后更新聊天列表记录 + var chatlastinfo={ + id: "privatechat-" + data.recvId +"-" + data.sendId, + content: data.content, + minId: data.id, + sl:1, + datetime: data.sendTime, + type: data.type, + name: "", + userid: data.recvId, + fromuser: data.sendId, + img: "", + sort:"privatechat" + }; + that.updateChatList(chatlastinfo,ifexist); + } + else{ + that.updateChatList(that.grouplist[idx],ifexist); + } + } + else{ + // 10, "撤回" 11, "已读 " 12, "消息已读回执 " 30,"加载中标记" + } + } + } + } + else if(rs.cmd==4){ + // 群聊 + if(rs.data){ + var data=rs.data; + if(data.atUserIds&&data.atUserIds.includes(that.userid)){ + // 是这个用户的接收的群聊信息 + // 加入聊天记录 + // 消息类型 0:文字 1:图片 2:文件 3:语音 4:视频 10, "撤回" 11, "已读 "12, "消息已读回执 " 30,"加载中标记" + if(data.type==0){ + data.content=decodeURIComponent(data.content); + } + if(data.type==0||data.type==1||data.type==2||data.type==3||data.type==4||data.type==5||data.type==6){ + var ifexist=0,idx=null; + that.grouplist.forEach((cell,index)=>{ + if(cell.groupId==data.groupId&&cell.sort=="groupchat"){ + ifexist=1; + idx=index; + that.grouplist[index].sl=(that.grouplist[index].sl?that.grouplist[index].sl+1:1); + that.grouplist[index].content=data.content; + that.grouplist[index].datetime=data.sendTime; + that.grouplist[index].fromuser=data.sendId; + that.grouplist[index].type=data.type; + that.$forceUpdate(); + } + }); + + if(ifexist==0){ + // 未保存缓存 + // 接收到socket后更新聊天列表记录 + var chatlastinfo={ + id: "groupchat-" + data.groupId, + groupId:data.groupId, + content: data.content, + minId: data.id, + sl:1, + datetime: data.sendTime, + type: data.type, + name: "", + userid: this.userid, + fromuser: data.sendId, + img: "", + sendId: data.sendId, + sendNickName: data.sendNickName, + sort:"groupchat" + }; + that.getGroupInfo(chatlastinfo,ifexist); + } + else{ + that.getGroupInfo(that.grouplist[idx],ifexist); + } + } + else{ + // 10, "撤回" 11, "已读 " 12, "消息已读回执 " 30,"加载中标记" + } + } + } + } + } + }); + + uni.onSocketClose(res => { + console.log('WebSocket连接已关闭!',res); + that.isConnected = false; + that.$forceUpdate(); + clearInterval(that.heartbeatInterval); // 停止心跳包发送 + }); + + uni.onSocketError(err => { + console.error('WebSocket连接打开失败,请检查:', err); + that.isConnected = false; + that.$forceUpdate(); + clearInterval(that.heartbeatInterval); // 停止心跳包发送 + }); + // } + }, + // 关闭WebSocket连接 + closeWebSocket() { + uni.closeSocket(); + this.isConnected = false; + this.$forceUpdate() + }, gotoContacts(){ uni.navigateTo({ url: `/pages/message/contact` @@ -161,57 +357,448 @@ changeTime(date) { return dateTime.dateTime(date); }, - gotoGroup(info){ + gotoGroup(chat,index){ + // 当前消息未读数据消除 + this.grouplist[index]["sl"]=0; + this.$forceUpdate(); + myCache("chatlist",this.grouplist); // 去聊天室 - if(info.type==1){ - // 客服 + if(chat.sort=="privatechat"){ + // 私聊 + var info={ + chatId: chat.id, + chatName: chat.name, + chatAvatar: chat.img, + chatTime: chat.datetime, + friendId: chat.fromuser, + minId: chat.minId, + sort:"privatechat", + from:"message" // yh 用户咨询进入聊天框,message 从消息进入聊天框 + } var data=encodeURIComponent(JSON.stringify(info)); uni.navigateTo({ - url: `/pages/product/service?data=${data}` + url: `/pages/chat/chat?data=${data}` }); } - else if(info.type==2){ - // 老师 + else if(chat.sort=="groupchat"){ + // 群聊 + var info={ + chatId: chat.id, + groupId: chat.groupId, + chatName: chat.name, + chatAvatar: chat.img, + chatTime: chat.datetime, + friendId: chat.fromuser, + teacherId: chat.teacherId, + minId: chat.minId, + sort:"groupchat", // privatechat 私聊 groupchat 群聊 + from:"message", // yh 用户咨询进入聊天框,message 从消息进入聊天框 + notice: chat.notice, + remarkNickName: chat.remarkNickName, + showNickName: chat.showNickName, + showGroupName: chat.showGroupName, + remarkGroupName: chat.remarkGroupName, + reason: chat.reason, + customerService: chat.customerService, + instructor: chat.instructor, + productId: chat.productId, + productName: chat.productName + } var data=encodeURIComponent(JSON.stringify(info)); + console.log(data); uni.navigateTo({ - url: `/pages/teacher/chat?data=${data}` + url: `/pages/chat/groupchat?data=${data}` }); } }, loadData(){ - // 底部数据加载 - if(this.loadStatus=="loadmore") { - this.loadStatus="loading"; - setTimeout(() => { - this.getgroupsmembers(); - }, 300); - } + // 信息列表加载 + this.loadStatus="loading"; + setTimeout(() => { + this.getgroupsmembers(); + }, 300); }, - // 获取群聊 + // 获取群聊列表 async getgroupsmembers(){ - if(this.loadStatus!=="nomore") - { - this.loadStatus="nomore"; - var chatlist=myCache("chatlist"); - this.grouplist=chatlist?chatlist:[]; - this.grouplist.forEach((cell,i)=>{ - this.grouplist[i]["sl"]=this.getgroupsnums(cell.minId) - }); - this.loadStatus="nomore"; - this.$forceUpdate(); + // 获取聊天群列表 + this.grouplist=[]; + var chatlist=myCache("chatlist")?myCache("chatlist"):[]; + chatlist.forEach(cell=>{ + if(cell.userid==this.userid){ + this.grouplist.push(cell); + } + }); + this.grouplist.forEach((cell,i)=>{ + if(cell.minId){ + // 通过某个会话中已读消息的最大id 获取离线消息 + this.readUp(i,cell); + } + }); + this.loadStatus="nomore"; + this.$forceUpdate(); + var that=this; + setTimeout(() => { + that.reorder(); + myCache("chatlist",that.grouplist); + }, 300); + + // socket接收实时消息 + this.socketinit(); + }, + // 重新排序 + reorder(){ + this.grouplist.sort((a, b) => b.datetime - a.datetime); + this.$forceUpdate(); + }, + // 已读推送 + async readUp(i,item) { + if(item.sort=="groupchat"){ + const {data: res} = await uni.$http.put('/api/message/group/readed?groupId='+item.groupId); + this.getgroupsnums(i,item); + } + else{ + const {data: res} = await uni.$http.put('/api/message/private/readed?friendId='+item.fromuser); + this.getgroupsnums(i,item); + } + }, + // 获取群聊中离线信息 + async getgroupsnums(i,item){ + if(item.sort=="groupchat"){ + // 群聊 + const {data: res} = await uni.$http.get("/api/message/group/pullOfflineMessage",{minId:item.minId}); + if(res.data&&res.data.length>0){ + // 获取消息后对消息进行缓存处理 + var data=res.data; + // 获取离线消息数量返回 + this.grouplist[i]["sl"]=res.data.length; + var last=res.data[res.data.length-1]; + if(last.type==0){ + last.content=decodeURIComponent(last.content); + } + if(last.type==0||last.type==1||last.type==2||last.type==3||last.type==4||data.type==5||data.type==6){ + this.grouplist[i].content=last.content; + this.grouplist[i].type=last.type; + this.grouplist[i].datetime=last.datetime; + this.$forceUpdate(); + // 重新排序 + this.reorder(); + myCache("chatlist",this.grouplist); + } + } + } + else{ + // 私聊 + const {data: res} = await uni.$http.get("/api/message/private/pullOfflineMessage",{minId:item.minId}); + if(res.data&&res.data.length>0){ + // 获取消息后对消息进行缓存处理 + var data=res.data; + // 获取离线消息数量返回 + this.grouplist[i]["sl"]=res.data.length; + var last=res.data[res.data.length-1]; + if(last.type==0){ + last.content=decodeURIComponent(last.content); + } + if(last.type==0||last.type==1||last.type==2||last.type==3||last.type==4||data.type==5||data.type==6){ + this.grouplist[i].content=last.content; + this.grouplist[i].type=last.type; + this.grouplist[i].datetime=last.datetime; + this.$forceUpdate(); + // 重新排序 + this.reorder(); + myCache("chatlist",this.grouplist); + } + } + } + }, + // 获取群信息 + async getGroupInfo(info,ifexist) { + const {data: res} = await uni.$http.get('/api/group/find/'+info.groupId); + if(res.data){ + var data = res.data; + info.name=data.name; + info.img=data.headImage||'/static/image/qltx.png'; + info.notice=data.notice; + info.remarkNickName=data.remarkNickName; + info.showNickName=data.showNickName; + info.showGroupName=data.showGroupName; + info.remarkGroupName=data.remarkGroupName; + info.customerService=data.customerService; + info.instructor=data.instructor; + info.productId=data.productId; + info.productName=data.productName; + this.updateChatGroupList(info,ifexist); + } + }, + async updateChatGroupList(info,ifexist){ + var name=info.name,img=info.img||require("@/static/image/girl.png"); + const {data: res} = await uni.$http.get("/api/friend/find/"+info.sendId); + if(res.data){ + var data=res.data; + name=data.nickName?data.nickName:"匿名"; + img=data.headImage?data.headImage:require("@/static/image/girl.png"); + if(ifexist==0){ + this.grouplist.push(info); + this.$forceUpdate(); + } + // 重新排序 保存缓存 + this.reorder(); + myCache("chatlist",this.grouplist); + // 聊天框消息缓存 + var msgchat=myCache(info.id); + if(ifexist==0||!msgchat){ + // 第一条聊天记录保存缓存 + let firstmsg = [{ + "fromname": name, // 发送人 + "fromuser": info.fromuser, // 发送人 + "headimg": img, // 发送人 + "toname": this.userName, // 接收人 + "touser": this.userid, // 接收人姓名 + "content": info.content, + "time": info.type==3?5:0, + "ifaudio":info.type==3? true:false, + "fromtime": info.datetime, + "type": info.type==0?'txt':(info.type==1?'image':info.type==3?'audio':(info.type==4?'video':'product')), + "id": info.id, + "minId": info.minId, + "sendId": info.sendId, + "send": info.type==6?await this.getProduct(info.content):(info.type==5?await this.getOrder(info.content):null) + }]; + console.log("firstmsg",firstmsg) + myCache(info.id,firstmsg); + } + else{ + // 聊天框信息 保存缓存 + let firstmsg = { + "fromname": name, // 发送人 + "fromuser": info.fromuser, // 发送人 + "headimg": img, // 发送人 + "toname": this.userName, // 接收人 + "touser": this.userid, // 接收人姓名 + "content": info.content, + "time": info.type==3?5:0, + "ifaudio":info.type==3? true:false, + "fromtime": info.datetime, + "type": info.type==0?'txt':(info.type==1?'image':info.type==3?'audio':(info.type==4?'video':'product')), + "id": info.id, + "minId": info.minId, + "sendId": info.sendId, + "send": info.type==6?await this.getProduct(info.content):(info.type==5?await this.getOrder(info.content):null) + }; + msgchat.push(firstmsg); + myCache(info.id,msgchat); + } + } + else{ + name="匿名"; + img="../../static/image/girl.png"; + if(ifexist==0){ + this.grouplist.push(info); + this.$forceUpdate(); + } + // 重新排序 + this.reorder(); + myCache("chatlist",this.grouplist); + var msgchat=myCache(info.id); + if(ifexist==0||!msgchat){ + // 第一条聊天记录保存缓存 + let firstmsg = [{ + "fromname": name, // 发送人 + "fromuser": info.fromuser, // 发送人 + "headimg": img, // 发送人 + "toname": this.userName, // 接收人 + "touser": this.userid, // 接收人姓名 + "content": info.content, + "time": info.type==3?5:0, + "ifaudio":info.type==3? true:false, + "fromtime": info.datetime, + "type": info.type==0?'txt':(info.type==1?'image':info.type==3?'audio':(info.type==4?'video':'product')), + "id": info.id, + "minId": info.minId, + "sendId": info.sendId, + "send": info.type==6?await this.getProduct(info.content):(info.type==5?await this.getOrder(info.content):null) + }]; + myCache(info.id,firstmsg); + } + else{ + // 聊天框信息 保存缓存 + let firstmsg = { + "fromname": name, // 发送人 + "fromuser": info.fromuser, // 发送人 + "headimg": img, // 发送人 + "toname": this.userName, // 接收人 + "touser": this.userid, // 接收人姓名 + "content": info.content, + "time": info.type==3?5:0, + "ifaudio":info.type==3? true:false, + "fromtime": info.datetime, + "type": info.type==0?'txt':(info.type==1?'image':info.type==3?'audio':(info.type==4?'video':'product')), + "id": info.id, + "minId": info.minId, + "sendId": info.sendId, + "send": info.type==6?await this.getProduct(info.content):(info.type==5?await this.getOrder(info.content):null) + }; + msgchat.push(firstmsg); + myCache(info.id,msgchat); + } + } + }, + async updateChatList(info,ifexist){ + const {data: res} = await uni.$http.get("/api/friend/find/"+info.fromuser); + if(res.data){ + var data=res.data; + info.name=data.nickName?data.nickName:"匿名"; + info.img=data.headImage?data.headImage:require("@/static/image/girl.png"); + if(ifexist==0){ + this.grouplist.push(info); + this.$forceUpdate(); + } + // 重新排序 保存缓存 + this.reorder(); + myCache("chatlist",this.grouplist); + // 聊天框消息缓存 + var msgchat=myCache(info.id); + if(ifexist==0||!msgchat){ + // 第一条聊天记录保存缓存 + let firstmsg = [{ + "fromname": info.name, // 发送人 + "fromuser": info.fromuser, // 发送人 + "headimg": info.img, // 发送人 + "toname": this.userName, // 接收人 + "touser": this.userid, // 接收人姓名 + "content": info.content, + "time": info.type==3?5:0, + "ifaudio":info.type==3? true:false, + "fromtime": info.datetime, + "type": info.type==0?'txt':(info.type==1?'image':info.type==3?'audio':(info.type==4?'video':'product')), + "id": info.id, + "minId": info.minId, + "recvId": info.recvId, + "sendId": info.sendId, + "send": info.type==6?await this.getProduct(info.content):(info.type==5?await this.getOrder(info.content):null) + }]; + myCache(info.id,firstmsg); + } + else{ + // 聊天框信息 保存缓存 + let firstmsg = { + "fromname": info.name, // 发送人 + "fromuser": info.fromuser, // 发送人 + "headimg": info.img, // 发送人 + "toname": this.userName, // 接收人 + "touser": this.userid, // 接收人姓名 + "content": info.content, + "time": info.type==3?5:0, + "ifaudio":info.type==3? true:false, + "fromtime": info.datetime, + "type": info.type==0?'txt':(info.type==1?'image':info.type==3?'audio':(info.type==4?'video':'product')), + "id": info.id, + "minId": info.minId, + "recvId": info.recvId, + "sendId": info.sendId, + "send": info.type==6?await this.getProduct(info.content):(info.type==5?await this.getOrder(info.content):null) + }; + msgchat.push(firstmsg); + myCache(info.id,msgchat); + } + } + else{ + info.name="匿名"; + info.img="../../static/image/girl.png"; + if(ifexist==0){ + this.grouplist.push(info); + this.$forceUpdate(); + } + // 重新排序 + this.reorder(); + myCache("chatlist",this.grouplist); + var msgchat=myCache(info.id); + if(ifexist==0||!msgchat){ + // 第一条聊天记录保存缓存 + let firstmsg = [{ + "fromname": info.name, // 发送人 + "fromuser": info.fromuser, // 发送人 + "headimg": info.img, // 发送人 + "toname": this.userName, // 接收人 + "touser": this.userid, // 接收人姓名 + "content": info.content, + "time": info.type==3?5:0, + "ifaudio":info.type==3? true:false, + "fromtime": info.datetime, + "type": info.type==0?'txt':(info.type==1?'image':info.type==3?'audio':(info.type==4?'video':'product')), + "id": info.id, + "minId": info.minId, + "recvId": info.recvId, + "sendId": info.sendId, + "send": info.type==6?await this.getProduct(info.content):(info.type==5?await this.getOrder(info.content):null) + }]; + myCache(info.id,firstmsg); + } + else{ + // 聊天框信息 保存缓存 + let firstmsg = { + "fromname": info.name, // 发送人 + "fromuser": info.fromuser, // 发送人 + "headimg": info.img, // 发送人 + "toname": this.userName, // 接收人 + "touser": this.userid, // 接收人姓名 + "content": info.content, + "time": info.type==3?5:0, + "ifaudio":info.type==3? true:false, + "fromtime": info.datetime, + "type": info.type==0?'txt':(info.type==1?'image':info.type==3?'audio':(info.type==4?'video':'product')), + "id": info.id, + "minId": info.minId, + "recvId": info.recvId, + "sendId": info.sendId, + "send": info.type==6?await this.getProduct(info.content):(info.type==5?await this.getOrder(info.content):null) + }; + msgchat.push(firstmsg); + myCache(info.id,msgchat); + } } }, - // 获取群聊 - async getgroupsnums(id){ - var nums=0 - const {data: res} = await uni.$http.get("/api/message/private/pullOfflineMessage",{"minId":id}); - if(res.data&&res.data.length>0){ - nums=res.data.length; - return nums; + async getProduct(id){ + console.log("getProduct",id) + var rets=null; + const {data: res} = await uni.$http.post("/api/message/private/getProductForIm",{"productId":id}); + if(res.data){ + var data=res.data; + rets={ + type:data.isCourse==0?1:2,// 1 商品,2 课程,3订单 + id:data.id, + name:data.name, + pic:data.pic, + price:data.price, + unit: data.unit, + brandName:data.brandName, + isCourse:data.isCourse + } + console.log(rets) + return rets; } else{ - console.log("nums",nums) - return nums; + return rets; + } + }, + async getOrder(id){ + var rets=null; + const {data: res} = await uni.$http.post("/api/message/private/getOrderForIm",{"orderItemId":id}); + if(res.data){ + var data=res.data; + rets={ + type:3,// 1 商品,2 课程,3订单 + id:data.id, + orderId:data.orderId, + name:data.productName, + pic:data.pic?data.pic:'/static/image/nopic.png', + price:data.totalAmount, + quantity:data.quantity, + spData: data.spData? JSON.parse(data.spData):null + } + return rets; + } + else{ + return rets; } }, // 获取状态栏高度 @@ -263,29 +850,31 @@ width: 100%; position: relative; margin: 180rpx 0 0 0; - min-height: calc(100vh - 100rpx); + min-height: calc(100vh - 180rpx); /* #ifdef H5 */ margin: calc( 110rpx + var(--window-top)) 0 0 0; - min-height: calc(100vh - var(--window-top) - var(--window-bottom) - 100rpx); + min-height: calc(100vh - var(--window-top) - var(--window-bottom) - 180rpx); /* #endif */ overflow-y: auto; } .listcell{ background: #fff; margin: 0; + width: 100%; .lcon{ border-bottom: 1rpx solid #eee; - padding-top: 28rpx; - padding-bottom: 28rpx; + padding-top: 20rpx; + padding-bottom: 20rpx; opacity: 1; display: flex; flex-direction: row; align-items: center; + width: 100%; .limg{ - width: 120rpx; - height: 120rpx; - margin-right: 24rpx; - margin-left: 24rpx; + width: 100rpx; + height: 100rpx; + margin-right: 20rpx; + margin-left: 20rpx; display: flex; flex-direction: row; flex-wrap: wrap; @@ -293,8 +882,8 @@ justify-content: center; border-radius: 50%; .img{ - width: 120rpx; - height: 120rpx; + width: 100rpx; + height: 100rpx; } } .lright{ diff --git a/pages/message/group0.vue b/pages/message/group0.vue new file mode 100644 index 0000000..9341fd1 --- /dev/null +++ b/pages/message/group0.vue @@ -0,0 +1,505 @@ + + + + + diff --git a/pages/message/group1.vue b/pages/message/group1.vue new file mode 100644 index 0000000..c011b0a --- /dev/null +++ b/pages/message/group1.vue @@ -0,0 +1,731 @@ + + + + + diff --git a/pages/order/orderinfo.vue b/pages/order/orderinfo.vue index c4d75c6..493ac38 100644 --- a/pages/order/orderinfo.vue +++ b/pages/order/orderinfo.vue @@ -173,7 +173,7 @@ - + @@ -447,18 +447,104 @@ url: `/pages/order/orderpj?data=${id}` }); }, - gotosj(){ + // 在线客服 + async gotoSevice(){ + // 商品中获取客服信息 + var orderItemList=this.info.orderItemList?this.info.orderItemList[0]:null; + if(orderItemList) + { + const {data: res1} = await uni.$http.get('/api/product/detail/'+orderItemList.productId); + if(res1&&res1.product){ + var product=res1.product; + var customerService=product.customerService;// 客服id; + if(!customerService){ + uni.showModal({ + title: '提示', + content: '抱歉!当前订单尚未配置客服服务..', + cancelText: '取消', + confirmText: '确定', + success: ress => { + } + }); + return false; + } + var nickName="客服"; + var headImage="/static/image/kfr.png"; + uni.showLoading({ + title: '会话创建中...' + }); + const {data: res} = await uni.$http.get("/api/friend/find/"+customerService); + console.log(res) + if(res.data){ + // 客服头像和名称 + var data = res.data; + nickName=data.nickName?data.nickName:"客服"; + headImage=data.headImage?data.headImage:'/static/image/kfr.png'; + this.gotoSeviceTZ(nickName,headImage,customerService); + } + else{ + this.gotoSeviceTZ(nickName,headImage,customerService); + } + } + else{ + uni.showModal({ + title: '提示', + content: '抱歉!当前订单尚未配置客服服务..', + cancelText: '取消', + confirmText: '确定', + success: ress => { + } + }); + return false; + } + } + else{ + uni.showModal({ + title: '提示', + content: '抱歉!当前订单尚未配置客服服务..', + cancelText: '取消', + confirmText: '确定', + success: ress => { + } + }); + return false; + } + }, + gotoSeviceTZ(nickName,headImage,customerService){ // 在线客服 - uni.makePhoneCall({ - phoneNumber: "18900000001", - success:function(){ - console.log('拨打电话成功'); - }, - fail() { - console.log('打电话失败了'); + // 私聊 + // 直接跳转到聊天框 + var chatid="privatechat-" + this.userid +"-"+ customerService; + var timestamp = new Date().getTime(); + var sp=this.info.orderItemList[0]; + var info={ + chatId: chatid, + chatType: "customerService", // 客服 + chatName: nickName, + chatAvatar: headImage, + chatTime: timestamp, + userid: this.userid, + friendId: customerService, // 会话教练userid + minId: "", // 已读消息的最大id + sort:"privatechat", // privatechat 私聊 groupchat 群聊 + from:"yh", // yh 用户咨询进入聊天框,message 从消息进入聊天框 + sendinfo:{ + type:3,// 1 商品,2 课程,3订单 + id:sp.id, + orderId:sp.orderId, + name:sp.productName, + pic:sp.pic?sp.pic:'/static/image/nopic.png', + price:this.info.totalAmount, + quantity:sp.quantity, + spData: sp.spData? JSON.parse(sp.spData):null } + } + var data=encodeURIComponent(JSON.stringify(info)); + uni.navigateTo({ + url: `/pages/chat/chat?data=${data}` }); }, + async getinfo() { uni.showLoading({ title: '数据加载中...' diff --git a/pages/product/cdetail.vue b/pages/product/cdetail.vue index 41a714e..0fba6b2 100644 --- a/pages/product/cdetail.vue +++ b/pages/product/cdetail.vue @@ -452,7 +452,8 @@ img:product.pic?product.pic:'',// 详情 img1:product.pic?getRemoteFile(product.pic):'../../static/image/imgicon.png', // 规格图片 商品详情默认图片 state:product.showStatus, // 1:已上架 2:审核中 3:已下架 4:未通过 5:草稿 - customerService:product.scustomerService,// 客服id + storeId:product.storeId, + customerService:product.customerService,// 客服id pjnum:0, // 总评价数量 quantity:1, // 商品数量 ifspec: res1.skus&&res1.skus.length>0?'1':'0', @@ -609,7 +610,7 @@ spData:this.product.spData, skuId:this.product.skuId, quantity:this.product.quantity, - storeId:myCache('myshopid')?myCache('myshopid'):'', + storeId:this.product.storeId, isCourse:this.product.isCourse, }; // 加入购物车 @@ -680,11 +681,133 @@ url: `/pages/cart/cart` }); }, - gotoSevice(){ - // 在线客服 - uni.navigateTo({ - url: `/pages/product/service` + async gotoSevice(){ + if(!this.product.instructor&&!this.product.customerService){ + uni.showModal({ + title: '提示', + content: '抱歉!当前课程暂未配置客服咨询..', + cancelText: '取消', + confirmText: '确定', + success: ress => { + } + }); + return false; + } + var nickName="客服"; + var headImage="/static/image/kfr.png"; + uni.showLoading({ + title: '会话创建中...' }); + const {data: res} = await uni.$http.get("/api/friend/find/"+this.product.customerService); + if(res.data){ + // 客服头像和名称 + var data = res.data; + nickName=data.nickName?data.nickName:"客服"; + headImage=data.headImage?data.headImage:'/static/image/kfr.png'; + this.gotoSeviceTZ(nickName,headImage); + } + else{ + this.gotoSeviceTZ(nickName,headImage); + } + }, + async gotoSeviceTZ(nickName,headImage){ + // 在线客服 + if(this.product.instructor&&this.product.customerService&&this.product.instructor!=this.product.customerService) + { + // 群聊 + // 创建群聊 + var params={ + "productId": this.product.id, //商品id + "productName": this.product.name, //商品名 + "customerService": this.product.customerService, //客服(顾问)id + "instructor": this.product.instructor //教练id + } + const {data: res} = await uni.$http.post("/api/group/create",params); + console.log(res) + if(res&&res.data){ + var data=res.data; + var timestamp = new Date().getTime(); + var chatid="groupchat-" + data.id; + var info={ + chatId: chatid, + groupId: data.id, + chatName: data.name, + chatAvatar: data.headImage?data.headImage:'/static/image/kfr.png', + chatTime: timestamp, + userid: data.ownerId, + friendId: this.product.customerService, // 客服userid + teacherId: this.product.instructor, // 教练userid + minId: "", // 已读消息的最大id + sort:"groupchat", // privatechat 私聊 groupchat 群聊 + from:"yh", // yh 用户咨询进入聊天框,message 从消息进入聊天框 + notice: data.notice, + remarkNickName: data.remarkNickName, + showNickName: data.showNickName, + showGroupName: data.showGroupName, + remarkGroupName: data.remarkGroupName, + reason: data.reason, + customerService: data.customerService, + instructor: data.instructor, + productId: data.productId, + productName: data.productName, + sendinfo:{ + type:1,// 1 商品,2 课程,3订单 + id:this.product.id, + name:this.product.name, + pic:this.product.pic, + price:this.product.price, + unit: this.product.unit, + brandName:this.product.brandName, + isCourse:this.product.isCourse + } + } + var data=encodeURIComponent(JSON.stringify(info)); + uni.navigateTo({ + url: `/pages/chat/groupchat?data=${data}` + }); + } + else{ + uni.showModal({ + title: '提示', + content: res.msg? res.msg:'当前会话创建失败..', + cancelText: '取消', + confirmText: '确定', + success: ress => {} + }); + } + } + else{ + // 私聊 + // 直接跳转到聊天框 + var chatid="privatechat-" + this.userid +"-"+ this.product.customerService; + var timestamp = new Date().getTime(); + var info={ + chatId: chatid, + chatName: nickName, + chatAvatar: headImage, + chatTime: timestamp, + userid: this.userid, + friendId: this.product.customerService, // 会话教练userid + minId: "", // 已读消息的最大id + sort:"privatechat", // privatechat 私聊 groupchat 群聊 + from:"yh", // yh 用户咨询进入聊天框,message 从消息进入聊天框 + sendinfo:{ + type:2,// 1 商品,2 课程,3订单 + id:this.product.id, + name:this.product.name, + pic:this.product.pic, + price:this.product.price, + unit: this.product.unit, + brandName:this.product.brandName, + isCourse:this.product.isCourse + } + } + var data=encodeURIComponent(JSON.stringify(info)); + uni.navigateTo({ + url: `/pages/chat/chat?data=${data}` + }); + + } }, gotoCourse(){ // 课程表 diff --git a/pages/product/cxlist.vue b/pages/product/cxlist.vue index 9b77285..47c7427 100644 --- a/pages/product/cxlist.vue +++ b/pages/product/cxlist.vue @@ -96,7 +96,7 @@ searchValue:"", cartnum:getcartNum(),// 购物车数量 ifsear:false, - shopid:myCache('myshopid')?myCache('myshopid'):'', + shopid:myCache('myshopid')?myCache('myshopid'):null, shop:myCache('myshop')?myCache('myshop'):'', contentText: { contentdown: '查看更多', @@ -274,6 +274,7 @@ img:product.pic?product.pic:'',// 详情 img1:product.pic?getRemoteFile(product.pic):'../../static/image/imgicon.png', // 规格图片 商品详情默认图片 state:product.showStatus, // 1:已上架 2:审核中 3:已下架 4:未通过 5:草稿 + storeId:product.storeId, customerService:product.scustomerService,// 客服id quantity:1, // 商品数量 ifspec: res1.skus&&res1.skus.length>0?'1':'0', @@ -321,7 +322,7 @@ spData:this.product.spData, skuId:this.product.skuId, quantity:this.product.quantity, - storeId:myCache('myshopid')?myCache('myshopid'):'', + storeId:this.product.storeId, isCourse:this.product.isCourse, }; // 加入购物车 @@ -439,10 +440,11 @@ return text.replace(regex, `${keyword}`); }, input(res) { - if(!this.ifsear){ - this.ifsear=true; - this.getld(res); - } + console.log('input',res); + // if(!this.ifsear){ + // this.ifsear=true; + // this.getld(res); + // } }, async getld(keywords) { const {data: res} = await uni.$http.post('/yoga/getProductsBykeywords',{keywords:keywords}); @@ -458,18 +460,26 @@ }, focus(res){ console.log('focus',res); - this.ifshow=false; + // this.ifshow=false; this.$forceUpdate(); }, search(res) { + // 查询商品事件 + console.log('search',res); this.ifsear=false; - this.ifshow=true; + // this.ifshow=true; this.$forceUpdate(); - this.getList(); + if(res.value){ + this.loadStatus="more"; + this.goodsList=[]; + this.page.pageNum=1; + this.$forceUpdate(); + this.getList(); + } }, clear(res) { this.searchValue=""; - this.ifshow=true; + // this.ifshow=true; this.$forceUpdate(); this.getList(); }, @@ -479,7 +489,7 @@ // icon: 'none' // }) this.searchValue=""; - this.ifshow=true; + // this.ifshow=true; this.$forceUpdate(); this.getList(); }, diff --git a/pages/product/detail.vue b/pages/product/detail.vue index 87fdcc3..ff35ff7 100644 --- a/pages/product/detail.vue +++ b/pages/product/detail.vue @@ -406,7 +406,8 @@ img:product.pic?product.pic:'',// 详情 img1:product.pic?getRemoteFile(product.pic):'../../static/image/imgicon.png', // 规格图片 商品详情默认图片 state:product.showStatus, // 1:已上架 2:审核中 3:已下架 4:未通过 5:草稿 - customerService:product.scustomerService,// 客服id + storeId:product.storeId, + customerService:product.customerService,// 客服id pjnum:0, // 总评价数量 quantity:1, // 商品数量 ifspec: res1.skus&&res1.skus.length>0?'1':'0', @@ -564,7 +565,7 @@ spData:this.product.spData, skuId:this.product.skuId, quantity:this.product.quantity, - storeId:myCache('myshopid')?myCache('myshopid'):'', + storeId:this.product.storeId, isCourse:this.product.isCourse, }; // 加入购物车 @@ -638,10 +639,67 @@ url: `/pages/cart/cart` }); }, - gotoSevice(){ + async gotoSevice(){ + if(!this.product.instructor&&!this.product.customerService){ + uni.showModal({ + title: '提示', + content: '抱歉!当前课商品未配置客服咨询..', + cancelText: '取消', + confirmText: '确定', + success: ress => { + } + }); + return false; + } + + var nickName="客服"; + var headImage="/static/image/kfr.png"; + uni.showLoading({ + title: '会话创建中...' + }); + const {data: res} = await uni.$http.get("/api/friend/find/"+this.product.customerService); + if(res.data){ + // 客服头像和名称 + var data = res.data; + nickName=data.nickName?data.nickName:"客服"; + headImage=data.headImage?data.headImage:'/static/image/kfr.png'; + this.gotoSeviceTZ(nickName,headImage); + } + else{ + this.gotoSeviceTZ(nickName,headImage); + } + }, + async gotoSeviceTZ(nickName,headImage){ + console.log(this.product.instructor,this.product.customerService) // 在线客服 + // 私聊 + // 直接跳转到聊天框 + var timestamp = new Date().getTime(); + var chatid="privatechat-" + this.userid +"-"+ this.product.customerService; + var info={ + chatId: chatid, + chatName: nickName, + chatAvatar: headImage, + chatTime: timestamp, + userid: this.userid, + friendId: this.product.customerService, // 会话教练userid + minId: "", // 已读消息的最大id + sort:"privatechat", // privatechat 私聊 groupchat 群聊 + from:"yh", // yh 用户咨询进入聊天框,message 从消息进入聊天框 + sendinfo:{ + type:1,// 1 商品,2 课程,3订单 + id:this.product.id, + name:this.product.name, + pic:this.product.pic, + price:this.product.price, + unit: this.product.unit, + brandName:this.product.brandName, + isCourse:this.product.isCourse + } + } + var data=encodeURIComponent(JSON.stringify(info)); uni.navigateTo({ - url: `/pages/product/service` + url: `/pages/chat/chat?data=${data}` }); }, gotoShop(){ diff --git a/pages/product/list.vue b/pages/product/list.vue index 64af66c..0ca6010 100644 --- a/pages/product/list.vue +++ b/pages/product/list.vue @@ -24,8 +24,8 @@ - - + + 达人好物 买贵双倍赔 @@ -37,7 +37,7 @@ - + 精品课程 @@ -52,7 +52,7 @@ - + - + @@ -118,7 +118,7 @@ ifshow:true, // 显示检索商品 searchValue:"", ifsear:false, - shopid: myCache('myshopid'), + shopid: myCache('myshopid')?myCache('myshopid'):null, shop: myCache('myshop'), scrollLeft: 0, tabCurrentIndex:0, @@ -300,6 +300,7 @@ img:product.pic?product.pic:'',// 详情 img1:product.pic?getRemoteFile(product.pic):'../../static/image/imgicon.png', // 规格图片 商品详情默认图片 state:product.showStatus, // 1:已上架 2:审核中 3:已下架 4:未通过 5:草稿 + storeId:product.storeId, customerService:product.scustomerService,// 客服id quantity:1, // 商品数量 ifspec: res1.skus&&res1.skus.length>0?'1':'0', @@ -347,7 +348,7 @@ spData:this.product.spData, skuId:this.product.skuId, quantity:this.product.quantity, - storeId:myCache('myshopid')?myCache('myshopid'):'', + storeId:this.product.storeId, isCourse:this.product.isCourse, }; const {data: res1} = await uni.$http.post('/api/cart/add',param); @@ -644,6 +645,7 @@ res.content.forEach((cell,idx)=>{ var celnew={ id:cell.id, + isCourse:cell.isCourse, name:cell.name, type:cell.isCourse=='1'?'2':'1', img: cell.pic, @@ -704,6 +706,7 @@ }) }, navToList(item){ + console.log("item",item) if(item.isCourse==1){ uni.navigateTo({ url: `/pages/product/cdetail?id=${item.id}` diff --git a/pages/product/order.vue b/pages/product/order.vue index 81767d7..ddd406a 100644 --- a/pages/product/order.vue +++ b/pages/product/order.vue @@ -661,7 +661,7 @@ }); }, adrchange(e){ - console.log(e); + // console.log(e); if(e.detail.value||e.detail.value=='0'){ var data= this.myaddresslist[parseInt(e.detail.value)]; // 订单收货信息 diff --git a/pages/teacher/chat.vue b/pages/teacher/chat.vue deleted file mode 100644 index 8f1e3ea..0000000 --- a/pages/teacher/chat.vue +++ /dev/null @@ -1,1091 +0,0 @@ - - - - - diff --git a/pages/teacher/course.vue b/pages/teacher/course.vue index 8fcea59..b2ef30f 100644 --- a/pages/teacher/course.vue +++ b/pages/teacher/course.vue @@ -30,8 +30,14 @@ + + :style="{ + fontSize:(dd.fontSize?dd.fontSize+'px':'26rpx'), + color: (dd.fontColor?dd.fontColor:'#000'), + backgroundColor:( dd.claColor?dd.claColor:colorlist[index].color), + borderLeftColor: '#fef2ce' + }" > {{dd.startTime}}-{{dd.endTime}} {{dd.courseName}} {{dd.claName}} @@ -794,11 +800,12 @@ flex-direction: column; width: 100%; height: 240rpx; - justify-content: center; + justify-content:flex-start; align-items: center; border-bottom: 1rpx dotted #ccc; color:#000; font-size: 28rpx; + padding-top: 10rpx; } .courheadtext{ display: flex; @@ -808,13 +815,12 @@ justify-content: center; align-items: center; border-radius: 10rpx; - border-radius: 10rpx; - border-left-width: 10rpx; + border-left-width: 6rpx; border-left: solid; } .ctxt{ - font-size: 24rpx; line-height: 30rpx; + padding-bottom: 4rpx; margin-bottom: 6rpx; } } diff --git a/pages/teacher/detail.vue b/pages/teacher/detail.vue index aaaef7e..9076e2f 100644 --- a/pages/teacher/detail.vue +++ b/pages/teacher/detail.vue @@ -44,8 +44,8 @@ - - + + @@ -79,6 +79,7 @@ nickName:"", html:``, id:'', + appUserId:'', intro:'', teacherName:'', sex:'', @@ -164,9 +165,9 @@ }; try{ const {data: res} = await uni.$http.post('/api/context/getOne',params); - console.log(res.data); if (res&&res.success) { var data=res.data; + this.appUserId=data.appUserId; this.teacherName=data.userName; this.sex=data.sex=='1'?'女':(data.sex=='2'?'男':'未知'); this.html=getRemoteHtmlFile(data.context); @@ -178,7 +179,6 @@ ban_img:item }) }) - console.log(this.swiperList); this.$forceUpdate(); } else{ @@ -222,27 +222,29 @@ }, // 咨询 async goconsult(){ - // 获取某个会话中已读消息的最大id(已读完的最后一条) - uni.showLoading("会话创建中.."); - var params = { - friendId: this.id - }; - try{ - const {data: res} = await uni.$http.get("/api/message/private/maxReadedId",params); + // uni.showLoading({ + // title: '会话创建中...' + // }); + try{ + // 直接跳转到聊天框 + var chatid="privatechat-" + this.userid +"-"+ this.id; var timestamp = new Date().getTime(); var info={ - chatId: "teacher-" + this.userid +"-"+ this.id, - chatType: "teacher", + chatId: "privatechat-" + this.userid +"-"+ this.id, + chatType: "coach", chatName: this.teacherName, chatAvatar: this.avatar, chatTime: timestamp, - minId: res.data, // 已读消息的最大id - friendId: this.id, // 会话人id + userid: this.userid, + friendId: this.appUserId, // 会话教练userid + minId: "", // 已读消息的最大id + sort: "privatechat", // privatechat 私聊 groupchat 群聊 + from: "yh" // yh 用户咨询进入聊天框,message 从消息进入聊天框 } var data=encodeURIComponent(JSON.stringify(info)); uni.navigateTo({ - url: `/pages/teacher/chat?data=${data}` - }) + url: `/pages/chat/chat?data=${data}` + }); } catch(e){ console.log(e); @@ -255,6 +257,31 @@ }); } }, + groupListChange(chatlastinfo){ + // 消息群列表更新 + var chatlist = myCache("chatlist"); + if(chatlist&&chatlist.length>0){ + var ifexist=0; + chatlist.forEach((cell,i)=>{ + if(cell.id==chatlastinfo.id){ + ifexist++; + chatlist[i]=chatlastinfo; + } + }); + if(ifexist==0){ + // 新增的添加 + chatlist.unshift(chatlastinfo); + } + // 重新保存聊天列表记录 + myCache("chatlist",chatlist); + } + else{ + chatlist=[]; + chatlist.push(chatlastinfo); + myCache("chatlist",chatlist); + } + + }, gocourse(){ // 课程表 uni.navigateTo({ diff --git a/pages/user/cdlist.vue b/pages/user/cdlist.vue index 859caf6..aaa65c4 100644 --- a/pages/user/cdlist.vue +++ b/pages/user/cdlist.vue @@ -275,18 +275,6 @@ url: `/pages/book/bookinfo?id=${id}` }); }, - // 联系教练 - gototeacher(item){ - var data={ - id:item.id, - name:"教练A" - } - // 联系教练 - var data=encodeURIComponent(JSON.stringify(data)); - uni.navigateTo({ - url: `/pages/teacher/chat?data=${data}` - }) - }, // 去评价 gotoevaluate(info){ var data=encodeURIComponent(JSON.stringify(info)); diff --git a/pages/user/courselist.vue b/pages/user/courselist.vue index 6ca242c..51a6360 100644 --- a/pages/user/courselist.vue +++ b/pages/user/courselist.vue @@ -36,7 +36,7 @@ - {{item.courseName}} + {{item.courseName||'-'}} {{item.startTime+'-'+item.endTime}} @@ -49,9 +49,10 @@ - {{item.claName}} - {{item.claName}} - + + {{item.claName}} + @@ -126,15 +127,22 @@ + + :style="{ + fontSize:(dd.fontSize?dd.fontSize+'px':'26rpx'), + color: (dd.fontColor?dd.fontColor:'#000'), + backgroundColor: ( dd.claColor?dd.claColor:colorlist[index].color), + borderLeftColor: '#fef2ce' + }"> + {{dd.startTime}}-{{dd.endTime}} {{dd.courseName}} {{dd.claName}} {{dd.staffName}} {{dd.roomName}} - - 预约 + + 不可预约 @@ -143,7 +151,6 @@ - @@ -697,11 +704,11 @@ uni.showLoading(); this.loading=true; try{ - const {data: res1} = await uni.$http.get('/api/course/getCourseList'); - console.log(res1); + const {data: res} = await uni.$http.get('/api/course/getCourseList'); + console.log(res); this.loading=false; - if (res1.success) { - var data = res1.data; + if (res.success) { + var data = res.data; this.columnTitles=data.columnTitles?data.columnTitles:[]; this.claTimeContainer=data.claTimeContainer?data.claTimeContainer:[]; this.list=[]; @@ -715,9 +722,9 @@ week:item.weekName, slist:[] } - this.list.push(lcell) - }) - this.$forceUpdate(); + this.list.push(lcell); + this.$forceUpdate(); + }); this.getOrderList(); } else{ @@ -1229,10 +1236,10 @@ position: sticky; top: 0; z-index: 19; - height: calc(100vh - 240rpx); - /* #ifdef H5 */ - height: calc(100vh - 240rpx - var(--window-top)); - /* #endif */ + // height: calc(100vh - 240rpx); + // /* #ifdef H5 */ + // height: calc(100vh - 240rpx - var(--window-top)); + // /* #endif */ background: #f8f8f8; } ::v-deep .uni-table-tr{ @@ -1265,7 +1272,7 @@ } .courcon{ width: 100%; - height: calc(100vh); + height: calc(100vh - 100rpx); /* #ifdef H5 */ height: calc(100vh - 100rpx - var(--window-top)); /* #endif */ @@ -1342,11 +1349,12 @@ width: 100%; height: 280rpx; background-color: #F2F2F2; - justify-content: center; + justify-content: flex-start; align-items: center; border-bottom: 1rpx dotted #ccc; color:#000; font-size: 28rpx; + padding-top: 10rpx; } .courheadtext{ display: flex; @@ -1356,38 +1364,41 @@ justify-content: center; align-items: center; border-radius: 10rpx; - border-radius: 10rpx; - border-left-width: 10rpx; + border-left-width: 6rpx; border-left: solid; } .ctxt{ - font-size: 24rpx; line-height: 30rpx; + padding-bottom: 4rpx; margin-bottom: 6rpx; } .orderbtn{ - background-color: #00A99A !important; + background-color: #ddd !important; border-radius: 40rpx; height: 40rpx; line-height: 38rpx; - padding: 0 20rpx; + padding: 0 16rpx; font-size: 24rpx; - border:1rpx solid #00A99A; + border:1rpx solid #ddd; margin-top: 6rpx; + color:#000; } .orderbtn::after{ border:0 !important; } .noorderbtn{ - background-color: #c8c8c8 !important; + background-color: #eee !important; border-radius: 40rpx; height: 40rpx; line-height: 38rpx; - padding: 0 20rpx; + padding: 0 16rpx; font-size: 24rpx; - border:1rpx solid #c8c8c8; + border:1rpx solid #eee; margin-top: 6rpx; - color:#666; + color:#888; + } + .noorderbtn::after{ + border:0 !important; } } .bbtn{ diff --git a/pages/user/kslist.vue b/pages/user/kslist.vue index 89573a7..050a50f 100644 --- a/pages/user/kslist.vue +++ b/pages/user/kslist.vue @@ -283,18 +283,6 @@ this.tabCurrentIndex = current; this.loadData(); }, - // 联系教练 - gototeacher(item){ - var data={ - id:item.id, - name:"教练A" - } - // 联系教练 - var data=encodeURIComponent(JSON.stringify(data)); - uni.navigateTo({ - url: `/pages/teacher/chat?data=${data}` - }) - }, reset(){ // 重新加载数据 this.list.forEach((cell,idx)=>{ diff --git a/pages/user/mycollect.vue b/pages/user/mycollect.vue index 5c4f415..0743e34 100644 --- a/pages/user/mycollect.vue +++ b/pages/user/mycollect.vue @@ -272,6 +272,7 @@ img:product.pic?product.pic:'',// 详情 img1:product.pic?product.pic:'../../static/image/imgicon.png', // 规格图片 商品详情默认图片 state:product.showStatus, // 1:已上架 2:审核中 3:已下架 4:未通过 5:草稿 + storeId:product.storeId, customerService:product.scustomerService,// 客服id quantity:1, // 商品数量 ifspec: res1.skus&&res1.skus.length>0?'1':'0', @@ -319,7 +320,7 @@ spData:this.product.spData, skuId:this.product.skuId, quantity:this.product.quantity, - storeId:myCache('myshopid')?myCache('myshopid'):'', + storeId:this.product.storeId, isCourse:this.product.isCourse, }; const {data: res1} = await uni.$http.post('/api/cart/add',param); diff --git a/pages/user/tclist.vue b/pages/user/tclist.vue index 37761e7..79051e2 100644 --- a/pages/user/tclist.vue +++ b/pages/user/tclist.vue @@ -433,18 +433,6 @@ url: `/pages/book/bookinfo?id=${id}` }); }, - // 联系教练 - gototeacher(item){ - var data={ - id:item.id, - name:"教练A" - } - // 联系教练 - var data=encodeURIComponent(JSON.stringify(data)); - uni.navigateTo({ - url: `/pages/teacher/chat?data=${data}` - }) - }, iflogin(){ this.openId = myCache('openId'); var user = myCache('user'); diff --git a/pages/user/user.vue b/pages/user/user.vue index eaef789..0f531b9 100644 --- a/pages/user/user.vue +++ b/pages/user/user.vue @@ -87,63 +87,70 @@ {{servers[3].name}} - + {{servers[12].name}} - + {{servers[13].name}} + + + + + + {{servers[14].name}} + - + {{servers[4].name}} - + {{servers[6].name}} - + {{servers[7].name}} - + {{servers[8].name}} - + {{servers[9].name}} - + {{servers[10].name}} - + @@ -151,9 +158,9 @@ - + - {{servers[14].name}} + {{servers[15].name}} @@ -286,6 +293,11 @@ img:'../../static/image/yyjl.png', name:'预约学员',// 店长 }, + { + key:14, + img:'../../static/image/qd.png', + name:'学员签到',// 教练/顾问 + }, { key:99, img:'../../static/image/tc.png', @@ -348,15 +360,24 @@ uni.stopPullDownRefresh() },500); }, + // onTabItemTap(){ + // console.log('界面关闭socket,onTabItemTap'); + // // 在组件销毁前,确保关闭 WebSocket 连接 + // uni.closeSocket(); + // }, methods: { ifview(value){ // 描述:角色ID;顾问:103 ;教练:104 ;店长:105 ;普通用户:107; var str=false; + var arrs= value.split(','); this.roleId.forEach(item=>{ - if(item==value) - { - str=true; - } + arrs.forEach(cell=>{ + if(item==cell) + { + str=true; + return true; + } + }); }); return str; }, @@ -491,9 +512,13 @@ else if(ii==13){ // 预约学员-店长 uni.navigateTo({ - url: `/pages/book/booktshop` + url: `/pages/book/bookshop` }); } + else if(ii==14){ + // 学员签到 + this.scando(); + } else if(ii==99){ // 退出登录 uni.showModal({ @@ -580,6 +605,44 @@ }); } }, + // 学员签到扫码 + scando(){ + var _this=this; + // 允许从相机和相册扫码 + //qrCode,barCode + // #ifdef APP-PLUS + uni.scanCode({ + scanType: ['qrCode', 'barCode'], + success: function(res) { + console.log(res); + console.log('条码类型:' + res.scanType); + console.log('条码内容:' + res.result); + // 入库扫码内容确认 + var rmbm=res.result; + console.log(rmbm); + if(rmbm){ + // 预约详情 + uni.navigateTo({ + url: `/pages/book/bookinfo?id=${rmbm}&type=qd` + }); + } + else{ + uni.showModal({ + title: '提示', + content: '扫码异常,请正确扫码绑定推广员!', + cancelText: '取消', + confirmText: '确定', + success: ress => { + if (ress.confirm) { + } + } + }); + } + } + }); + // #endif + }, + async logoff(){ uni.showLoading({ title: '账号注销中...' @@ -946,7 +1009,7 @@ height: 32rpx; line-height: 32rpx; padding: 0 2rpx; - border-radius: 50% 50%; + border-radius: 32rpx; background-color: #ff0000; color: #FFF; font-size: 22rpx; diff --git a/pages/user/xslist.vue b/pages/user/xslist.vue index 6b660b3..8f89979 100644 --- a/pages/user/xslist.vue +++ b/pages/user/xslist.vue @@ -307,18 +307,6 @@ this.tabCurrentIndex = current; this.loadData(); }, - // 联系教练 - gototeacher(item){ - var data={ - id:item.id, - name:"教练A" - } - // 联系教练 - var data=encodeURIComponent(JSON.stringify(data)); - uni.navigateTo({ - url: `/pages/teacher/chat?data=${data}` - }) - }, reset(){ this.orderlists=[]; // 重新加载数据 diff --git a/static/image/girl.jpg b/static/image/girl.jpg deleted file mode 100644 index 7c25bcb..0000000 Binary files a/static/image/girl.jpg and /dev/null differ diff --git a/static/image/girl.png b/static/image/girl.png new file mode 100644 index 0000000..c5af96c Binary files /dev/null and b/static/image/girl.png differ diff --git a/static/image/jltx.png b/static/image/jltx.png new file mode 100644 index 0000000..d16d3a4 Binary files /dev/null and b/static/image/jltx.png differ diff --git a/static/image/kf.png b/static/image/kf.png index da32397..10078c4 100644 Binary files a/static/image/kf.png and b/static/image/kf.png differ diff --git a/static/image/mr.png b/static/image/mr.png new file mode 100644 index 0000000..80204b2 Binary files /dev/null and b/static/image/mr.png differ diff --git a/static/image/qd.png b/static/image/qd.png new file mode 100644 index 0000000..b4f7db2 Binary files /dev/null and b/static/image/qd.png differ diff --git a/static/image/qltx.png b/static/image/qltx.png new file mode 100644 index 0000000..96075fa Binary files /dev/null and b/static/image/qltx.png differ diff --git a/static/image/xy.png b/static/image/xy.png new file mode 100644 index 0000000..19cb8f2 Binary files /dev/null and b/static/image/xy.png differ diff --git a/static/qlfont.ttf b/static/qlfont.ttf new file mode 100644 index 0000000..f5f00bf Binary files /dev/null and b/static/qlfont.ttf differ