From eb0d648f6aab155c22f88d9f03b40acc29d2d977 Mon Sep 17 00:00:00 2001 From: luyuan <1162963624@qq.com> Date: Fri, 7 Aug 2020 11:40:13 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/api/shop.js | 4 ++++ common/http.interceptor.js | 8 +++---- pageB/sdetails/index.vue | 35 +++++++++++++++++++++++++++++-- pages/index/index.vue | 19 ++++++++++++++++- pages/information/information.vue | 16 +------------- 5 files changed, 60 insertions(+), 22 deletions(-) diff --git a/common/api/shop.js b/common/api/shop.js index 2db23d5..d3c4551 100644 --- a/common/api/shop.js +++ b/common/api/shop.js @@ -318,6 +318,10 @@ export default { addFavoriteStore({ id }) { return vm.$u.post('member/addFavoriteStore',{ fid: id }) }, + //店家id获取用户信息 + getAtwillUserInfo({ id }) { + return vm.$u.post('Specialci/getAtwillUserInfo',{ store_id: id }) + }, } } diff --git a/common/http.interceptor.js b/common/http.interceptor.js index 5484ac8..c1b271c 100644 --- a/common/http.interceptor.js +++ b/common/http.interceptor.js @@ -4,7 +4,7 @@ const install = (Vue, vm) => { baseUrl: 'https://dmmall.sdbairui.com/api', loadingText: '努力加载中~', loadingTime: 800, - // originalData: true + originalData: true }); // 请求拦截,配置Token等参数 @@ -20,12 +20,12 @@ const install = (Vue, vm) => { // 响应拦截,如配置,每次请求结束都会执行本方法 Vue.prototype.$u.http.interceptor.response = (res) => { - if(parseInt(res.errCode) == 0) { + if(parseInt(res.data.errCode) == 0) { // res为服务端返回值,可能有errCode,result等字段 // 这里对res.result进行返回,将会在this.$u.post(url).then(res => {})的then回调中的res的到 // 如果配置了originalData为true,请留意这里的返回值 - return res; - } else if(res.errCode == 401) { + return res.data; + } else if(res.data.errCode == 401) { // 假设201为token失效,这里跳转登录 vm.$u.toast('验证失败,请重新登录'); setTimeout(() => { diff --git a/pageB/sdetails/index.vue b/pageB/sdetails/index.vue index 8b3237f..15b5768 100644 --- a/pageB/sdetails/index.vue +++ b/pageB/sdetails/index.vue @@ -139,7 +139,7 @@ 店铺 - + 客服 @@ -159,7 +159,7 @@ 店铺 - + 客服 @@ -204,6 +204,7 @@ export default { sel: "", // 拼接的规格 quanxuan: false, // 规格是否选择 debounce: true, + storeid:0 //店铺id } }, components: { @@ -238,6 +239,34 @@ export default { clearInterval(this.timer); }, methods: { + customers(){ + function Friend(uuid, name, avatar,time = "", text = "",date = "") { + this.uuid = uuid; + this.name = name; + this.avatar = avatar; + this.online = false; + this.unReadMessage = 0; + this.text = text; + this.time = time; + this.date = date + } + console.log(123) + this.$u.api.getAtwillUserInfo({ + id:this.storeid + }).then((res)=>{ + console.log(res) + let user = new Friend(res.data.member_id,res.data.member_nickname,res.data.member_avatar) + this.$u.route({ + url:"/pageD/privateChat/privateChat", + params:{ + id:JSON.stringify(user) + } + + }) + }).catch((err)=>{ + console.log(err) + }) + }, setSwiperList(list) { let img = []; list.forEach(item => { @@ -309,12 +338,14 @@ export default { // 普通商品详情 ordinaryDetails(id) { this.$u.api.getGoodsDetails({ id: id }).then((res)=>{ + console.log(res) if (res.errCode == 0) { this.evaluate = res.data.goods_evaluate_info; this.goodsInfo = res.data.goods; this.storeInfo = res.data.store; this.setSwiperList(res.data.goods_image); this.glist = res.data.spec_list; + this.storeid = res.data.store.store_id // console.log(this.goodsInfo.mobile_body); } }) diff --git a/pages/index/index.vue b/pages/index/index.vue index 6107732..97074b8 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -231,6 +231,23 @@ this.tabLiveList(); this.getFollowList(); }, + onLoad(){ + if(this.$store.state.hasLogin){ + const user = uni.getStorageSync('user_info'); + console.log(user) + this.imService.login(user.member.member_id,user.member.member_nickname,user.member.member_avatar) + this.imService.connectIM() + let that = this + setTimeout(function(){ + that.imService.disconnect() + console.log("guanbi") + },1000) + setTimeout(function(){ + console.log("lianjie") + that.imService.connectIM() + },2000) + } + }, onPullDownRefresh() { this.getArticlelist(); // this.getManicureList({ load: 'reload' }); @@ -356,4 +373,4 @@ }, }, } - + diff --git a/pages/information/information.vue b/pages/information/information.vue index d901848..5f7d672 100644 --- a/pages/information/information.vue +++ b/pages/information/information.vue @@ -100,21 +100,7 @@ if (this.hasLogin) { this.messageIndex(); } - if(this.$store.state.hasLogin){ - const user = uni.getStorageSync('user_info'); - console.log(user) - this.imService.login(user.member.member_id,user.member.member_nickname,user.member.member_avatar) - this.imService.connectIM() - let that = this - setTimeout(function(){ - that.imService.disconnect() - console.log("guanbi") - },1000) - setTimeout(function(){ - console.log("lianjie") - that.imService.connectIM() - },2000) - } + }, methods: { gochat(id){ -- 2.47.2 From f4313dce9dfc3893992fed1626cf90eca6f4b9f3 Mon Sep 17 00:00:00 2001 From: luyuan <1162963624@qq.com> Date: Fri, 7 Aug 2020 14:39:15 +0800 Subject: [PATCH 2/4] md5 --- common/http.interceptor.js | 22 ++++++++++++++++++++-- package-lock.json | 5 +++++ package.json | 5 +++-- static/js/md5.min.js | 2 ++ 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 static/js/md5.min.js diff --git a/common/http.interceptor.js b/common/http.interceptor.js index 4d75a25..4bff349 100644 --- a/common/http.interceptor.js +++ b/common/http.interceptor.js @@ -1,3 +1,4 @@ +var md5 = require("../static/js/md5.min.js") const install = (Vue, vm) => { // 此为自定义配置参数,具体参数见上方说明 Vue.prototype.$u.http.setConfig({ @@ -12,8 +13,25 @@ const install = (Vue, vm) => { const token = uni.getStorageSync('token'); - config.header.Authorization = 'Bearer' + " " + token; - + config.header.Authorization = 'Bearer' + " " + token; + Date.prototype.Format = function (fmt) { // author: meizz + var o = { + "M+": this.getMonth() + 1, // 月份 + "d+": this.getDate(), // 日 + "h+": this.getHours(), // 小时 + "m+": this.getMinutes(), // 分 + "s+": this.getSeconds(), // 秒 + "q+": Math.floor((this.getMonth() + 3) / 3), // 季度 + "S": this.getMilliseconds() // 毫秒 + }; + if (/(y+)/.test(fmt)) + fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); + for (var k in o) + if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); + return fmt; + } + let time = new Date().Format("yyyyMMddhhmmss") + config.header.Sign = md5('DBCA4F8DA7BC0BA2' + time) + '-' + time return config; } diff --git a/package-lock.json b/package-lock.json index dde9e73..ee7f5ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,11 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "blueimp-md5": { + "version": "2.17.0", + "resolved": "https://registry.npm.taobao.org/blueimp-md5/download/blueimp-md5-2.17.0.tgz?cache=0&sync_timestamp=1595922448921&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fblueimp-md5%2Fdownload%2Fblueimp-md5-2.17.0.tgz", + "integrity": "sha1-9PysCIsRX3tARfGfXaWenQGxu5Y=" + }, "uview-ui": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/uview-ui/-/uview-ui-1.5.0.tgz", diff --git a/package.json b/package.json index 2d632c1..a54aec3 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,10 @@ "url": "http://git.luyuan.tk/luyuan/deming.git" }, "author": "", - "license": "ISC", + "license": "ISC", "dependencies": { - "uview-ui": "^1.5.0", + "blueimp-md5": "^2.17.0", + "uview-ui": "^1.5.0", "vuex": "^3.5.1" } } diff --git a/static/js/md5.min.js b/static/js/md5.min.js new file mode 100644 index 0000000..1456fcc --- /dev/null +++ b/static/js/md5.min.js @@ -0,0 +1,2 @@ +!function(n){"use strict";function d(n,t){var r=(65535&n)+(65535&t);return(n>>16)+(t>>16)+(r>>16)<<16|65535&r}function f(n,t,r,e,o,u){return d((c=d(d(t,n),d(e,u)))<<(f=o)|c>>>32-f,r);var c,f}function l(n,t,r,e,o,u,c){return f(t&r|~t&e,n,t,o,u,c)}function v(n,t,r,e,o,u,c){return f(t&e|r&~e,n,t,o,u,c)}function g(n,t,r,e,o,u,c){return f(t^r^e,n,t,o,u,c)}function m(n,t,r,e,o,u,c){return f(r^(t|~e),n,t,o,u,c)}function i(n,t){var r,e,o,u;n[t>>5]|=128<>>9<<4)]=t;for(var c=1732584193,f=-271733879,i=-1732584194,a=271733878,h=0;h>5]>>>e%32&255);return t}function h(n){var t=[];for(t[(n.length>>2)-1]=void 0,e=0;e>5]|=(255&n.charCodeAt(e/8))<>>4&15)+r.charAt(15&t);return e}function r(n){return unescape(encodeURIComponent(n))}function o(n){return a(i(h(t=r(n)),8*t.length));var t}function u(n,t){return function(n,t){var r,e,o=h(n),u=[],c=[];for(u[15]=c[15]=void 0,16 Date: Fri, 7 Aug 2020 16:54:54 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=81=8A=E5=A4=A9=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pageD/privateChat/privateChat.vue | 6 +++--- pages/information/information.vue | 12 ++++++++++++ static/imservice.js | 10 +++++----- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/pageD/privateChat/privateChat.vue b/pageD/privateChat/privateChat.vue index b6ef7c7..04e834c 100644 --- a/pageD/privateChat/privateChat.vue +++ b/pageD/privateChat/privateChat.vue @@ -134,8 +134,8 @@ }); setTimeout(() => { uni.setNavigationBarColor({ - backgroundColor : '#D02129', - frontColor : '#ffffff' + backgroundColor : '#FF780F', + frontColor : '#333333' }); }, 10); @@ -567,7 +567,7 @@ } .chatInterface .message-item.self .content span{ color: #ffffff; - background:#D02129; + background:#FF780F; word-break: break-all; text-align: left; max-width: 520rpx; diff --git a/pages/information/information.vue b/pages/information/information.vue index 5f7d672..726086f 100644 --- a/pages/information/information.vue +++ b/pages/information/information.vue @@ -23,6 +23,8 @@ {{item.name}} {{item.text}} {{item.time}} + + @@ -180,6 +182,15 @@