diff --git a/common/api/shop.js b/common/api/shop.js index 94feed6..aea37d9 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 }) + }, // 收藏商品 addFavoriteGoods({ fid }) { return vm.$u.post('member/addFavoriteGoods',{ fid: fid }) diff --git a/common/http.interceptor.js b/common/http.interceptor.js index 79483b9..c21e20c 100644 --- a/common/http.interceptor.js +++ b/common/http.interceptor.js @@ -1,10 +1,11 @@ +var md5 = require("../static/js/md5.min.js") const install = (Vue, vm) => { // 此为自定义配置参数,具体参数见上方说明 Vue.prototype.$u.http.setConfig({ baseUrl: 'https://dmmall.sdbairui.com/api', loadingText: '努力加载中~', loadingTime: 800, - // originalData: true + originalData: true }); // 请求拦截,配置Token等参数 @@ -12,20 +13,37 @@ 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; } // 响应拦截,如配置,每次请求结束都会执行本方法 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('您还没有登录哦,请先去登录!'); if (res.data.action != "memberinfo") { 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/pageB/sdetails/index.vue b/pageB/sdetails/index.vue index d937efc..fd86d90 100644 --- a/pageB/sdetails/index.vue +++ b/pageB/sdetails/index.vue @@ -146,7 +146,7 @@ 店铺 - + 客服 @@ -166,7 +166,7 @@ 店铺 - + 客服 @@ -211,6 +211,7 @@ export default { sel: "", // 拼接的规格 quanxuan: false, // 规格是否选择 debounce: true, + storeid:0 //店铺id } }, components: { @@ -247,6 +248,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 => { @@ -314,12 +343,15 @@ 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); this.type = res.data.view_type; this.setTitle(); if(this.type == 1) { 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/index/index.vue b/pages/index/index.vue index 1dff598..4dc3e82 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -233,6 +233,23 @@ this.getArticlelist(); this.getSwiper(); }, + 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' }); @@ -373,4 +390,4 @@ } }, } - + diff --git a/pages/information/information.vue b/pages/information/information.vue index d901848..f44ad09 100644 --- a/pages/information/information.vue +++ b/pages/information/information.vue @@ -23,6 +23,8 @@ {{item.name}} {{item.text}} {{item.time}} + + @@ -100,21 +102,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){ @@ -173,10 +161,14 @@ }, // 清空消息 delMessage(){ + this.$u.api.delMessage({ type : "all" }).then((res)=>{ console.log(res) + this.imService.friends = {}; + this.information_dl = []; + uni.setStorageSync('imlist',JSON.stringify([])); if(res.errCode == 0){ this.$refs.uToast.show({ title: '清除成功', @@ -194,6 +186,15 @@