Commit f69f2b5e by 施宇

聊天系统修改 商品分享 商品列表下拉

parent 6bd9dcb5
...@@ -49,14 +49,14 @@ App({ ...@@ -49,14 +49,14 @@ App({
}); });
}, },
onLaunch() { onLaunch() {
wx.removeStorageSync('im');
//验证是否授权 //验证是否授权
if (this.globalData.auth) { if (this.globalData.auth) {
//是否登录 //是否登录
if (this.globalData.token) { if (this.globalData.token) {
// wx.switchTab({ wx.switchTab({
// url: '/pages/tab/home/home' url: '/pages/tab/home/home'
// }); });
} else { } else {
wx.redirectTo({ wx.redirectTo({
url: '/pages/person/login/index' url: '/pages/person/login/index'
......
// pages/detail/chat/index.js // pages/detail/chat/index.js
let disp = require("../../../utils/broadcast"); let disp = require("../../../utils/broadcast");
import {
reloginIm
} from '../../../utils/util.js';
Page({ Page({
data: { data: {
...@@ -23,6 +26,9 @@ Page({ ...@@ -23,6 +26,9 @@ Page({
title: username.title title: username.title
}); });
} }
if (wx.getStorageSync('im')) {
reloginIm()
}
}, },
......
// pages/detail/good/index.js // pages/detail/good/index.js
import { import {
getData, getData,
changeTime changeTime,
judgeToken
} from '../../../utils/util.js'; } from '../../../utils/util.js';
import { import {
apis apis
...@@ -13,6 +14,9 @@ Page({ ...@@ -13,6 +14,9 @@ Page({
*/ */
data: { data: {
info: null, info: null,
name: "", //埋点统计
price: "", //埋点统计
img: "", //埋点统计
editOrShow: -1, //1编辑 2在线沟通 editOrShow: -1, //1编辑 2在线沟通
goodId: "", goodId: "",
type: "", type: "",
...@@ -27,7 +31,7 @@ Page({ ...@@ -27,7 +31,7 @@ Page({
goodId: options.goodId || '', goodId: options.goodId || '',
type: options.type || '' type: options.type || ''
}) })
console.log(options)
}, },
getData: function() { getData: function() {
let me = this; let me = this;
...@@ -35,15 +39,15 @@ Page({ ...@@ -35,15 +39,15 @@ Page({
let url = ""; let url = "";
let goodId = me.data.goodId; let goodId = me.data.goodId;
let type = me.data.type; let type = me.data.type;
if (type == 1) { // if (type == 1) {
url = apis.goodsInfo; // url = apis.goodsInfo;
} else if (type == 2 || type == 3) { // } else if (type == 2 || type == 3) {
url = apis.goodsSearch; // url = apis.goodsSearch;
} else { // } else {
return; // return;
} // }
getData(url, 'get', { getData(apis.goodsSearch, 'get', {
"goods_id/eq": goodId, "goods_id/eq": goodId,
"token": token, "token": token,
}, function(res) { }, function(res) {
...@@ -59,7 +63,7 @@ Page({ ...@@ -59,7 +63,7 @@ Page({
me.setData({ me.setData({
editOrShow: 1 editOrShow: 1
}) })
} else if (type == 2) { } else if (type == 2 || type == 3) {
if (userId == targetId) { if (userId == targetId) {
me.setData({ me.setData({
editOrShow: 1 editOrShow: 1
...@@ -74,6 +78,14 @@ Page({ ...@@ -74,6 +78,14 @@ Page({
me.setData({ me.setData({
info: res.goods_list[goodId] info: res.goods_list[goodId]
}) })
let data = me.data.info;
if (data) {
me.setData({
name: data.goods_name || '',
img: data.goods_images || '',
price: data.currency == 1 ? '¥' + data.price : '$' + data.price
})
}
} }
} else { } else {
...@@ -84,11 +96,17 @@ Page({ ...@@ -84,11 +96,17 @@ Page({
}, true) }, true)
}, },
editGood: function() { editGood: function() {
if (!judgeToken(true) && this.data.type == 3) {
return
}
wx.navigateTo({ wx.navigateTo({
url: "/pages/form/good/index?goodId=" + this.data.goodId, url: "/pages/form/good/index?goodId=" + this.data.goodId,
}) })
}, },
sendTemplate: function() { sendTemplate: function() {
if (!judgeToken(true) && this.data.type == 3) {
return
}
let data = this.data.info; let data = this.data.info;
let my = wx.getStorageSync("myUsername"); let my = wx.getStorageSync("myUsername");
let companyName = wx.getStorageSync("company_name"); let companyName = wx.getStorageSync("company_name");
......
...@@ -96,7 +96,7 @@ Page({ ...@@ -96,7 +96,7 @@ Page({
}, 1000) }, 1000)
} else { } else {
tips('提交失败') tips(res.errmsg)
me.setData({ me.setData({
isClick: true isClick: true
}) })
......
...@@ -158,7 +158,7 @@ Page({ ...@@ -158,7 +158,7 @@ Page({
}, 1000) }, 1000)
} else { } else {
tips('操作失败') tips(res.errmsg)
me.setData({ me.setData({
isClick: true isClick: true
}) })
......
...@@ -82,10 +82,13 @@ Page({ ...@@ -82,10 +82,13 @@ Page({
tips('发布成功') tips('发布成功')
me.setData({ me.setData({
isClick: true isClick: true
}) });
setTimeout(() => {
wx.navigateBack()
}, 1000)
} else { } else {
tips('发布失败') tips(res.errmsg)
me.setData({ me.setData({
isClick: true isClick: true
}) })
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<view> <view>
<button wx:if="{{canIUse}}" class="btn-com btn-com-b" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">一键授权</button> <button wx:if="{{canIUse}}" class="btn-com btn-com-b" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">一键授权</button>
<view wx:else>请升级微信版本</view> <view wx:else>请升级微信版本</view>
<view class="btn-com btn-com-c" bindtap="toUrl">暂不注册,先看看</view> <view class="btn-com btn-com-c tosee" bindtap="toUrl">暂不注册,先看看</view>
</view> </view>
<view class="text-wrap row"> <view class="text-wrap row">
<navigator url="/pages/person/verifycode/index" class="btn-text mr">验证码登录</navigator> <navigator url="/pages/person/verifycode/index" class="btn-text mr">验证码登录</navigator>
......
...@@ -15,6 +15,7 @@ Page({ ...@@ -15,6 +15,7 @@ Page({
key: "", key: "",
confirmKey: "", confirmKey: "",
isShowBottom:false, isShowBottom:false,
isFixed:false,
}, },
/** /**
...@@ -43,7 +44,7 @@ Page({ ...@@ -43,7 +44,7 @@ Page({
this.getData(); this.getData();
}, },
getData: function () { getData: function (isRefresh) {
let me = this; let me = this;
let token = wx.getStorageSync('access_token') let token = wx.getStorageSync('access_token')
getData(apis.goodsInfo,'get', { getData(apis.goodsInfo,'get', {
...@@ -66,15 +67,21 @@ Page({ ...@@ -66,15 +67,21 @@ Page({
priceList: newArr, priceList: newArr,
total: res.total, total: res.total,
}); });
if (isRefresh){
wx.stopPullDownRefresh()
}
} else if (res.errcode === 110001 || res.errcode === 103001) { } else if (res.errcode === 110001 || res.errcode === 103001) {
if (me.data.p == 1) { if (me.data.p == 1) {
me.setData({ me.setData({
priceList: [] priceList: []
}) })
} }
if (isRefresh) {
wx.stopPullDownRefresh()
}
} }
}, true) }, isRefresh?false:true)
}, },
/** /**
...@@ -83,7 +90,18 @@ Page({ ...@@ -83,7 +90,18 @@ Page({
onReady: function () { onReady: function () {
}, },
onPageScroll:function(e){
console.log(e.scrollTop);
if(e.scrollTop>90){
this.setData({
isFixed:true
})
}else{
this.setData({
isFixed: false
})
}
},
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
...@@ -109,7 +127,11 @@ Page({ ...@@ -109,7 +127,11 @@ Page({
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh: function () { onPullDownRefresh: function () {
this.setData({
p: 1,
isShowBottom: false
});
this.getData(true);
}, },
/** /**
......
<!--pages/tab/good/good.wxml--> <!--pages/tab/good/good.wxml-->
<wxs module="dateUtil" src="../../../utils/timeUtil.wxs"></wxs> <wxs module="dateUtil" src="../../../utils/timeUtil.wxs"></wxs>
<view class="good-view"> <view class="good-view {{isFixed?'fixed-good-view':''}}">
<view class="search-com"> <view class="search-com {{isFixed?'search-com-fixed':''}}">
<text class="icon iconfont iconiconxiantiaoshouji8"></text> <text class="icon iconfont iconiconxiantiaoshouji8"></text>
<input placeholder='请输入芯片型号' placeholder-class="placeholderClass" bindinput="bindKeyInput" bindconfirm="bindKeyConfirm"></input> <input placeholder='请输入芯片型号' placeholder-class="placeholderClass" bindinput="bindKeyInput" bindconfirm="bindKeyConfirm"></input>
</view> </view>
<view class="good-total row bothSide verCenter px-hr-bottom"> <view class="good-total row bothSide verCenter px-hr-bottom {{isFixed?'good-total-fixed':''}}">
<view class="good-num"> <view class="good-num">
<text>已发布商品: </text> <text>已发布商品: </text>
<text class="num bold">{{total}}</text> <text class="num bold">{{total}}</text>
......
...@@ -2,20 +2,25 @@ ...@@ -2,20 +2,25 @@
.good-view { .good-view {
min-height: 100%; min-height: 100%;
padding:0 0 118rpx; padding-bottom:118rpx;
box-sizing: border-box; box-sizing: border-box;
} }
.fixed-good-view{
padding-top:180rpx;
}
.good-view .search-com { .good-view .search-com {
height: 86rpx; height: 86rpx;
box-sizing: border-box; box-sizing: border-box;
/* position: fixed; */
top: 0; top: 0;
left: 0; left: 0;
right: 0; right: 0;
background-color: #fff; background-color: #fff;
z-index: 2; z-index: 2;
} }
.good-view .search-com-fixed{
position: fixed;
}
.good-total { .good-total {
padding: 37rpx 24rpx 24rpx 0; padding: 37rpx 24rpx 24rpx 0;
...@@ -24,7 +29,6 @@ ...@@ -24,7 +29,6 @@
color: #adb6bf; color: #adb6bf;
height: 94rpx; height: 94rpx;
box-sizing: border-box; box-sizing: border-box;
/* position: fixed; */
top: 86rpx; top: 86rpx;
left: 0; left: 0;
right: 0; right: 0;
...@@ -32,6 +36,9 @@ ...@@ -32,6 +36,9 @@
z-index: 2; z-index: 2;
} }
.good-total-fixed{
position: fixed;
}
.good-total .good-num { .good-total .good-num {
font-size: 24rpx; font-size: 24rpx;
......
...@@ -5,7 +5,8 @@ import { ...@@ -5,7 +5,8 @@ import {
judgeToken, judgeToken,
getData, getData,
interval, interval,
matchReg matchReg,
reloginIm
} from '../../../utils/util.js'; } from '../../../utils/util.js';
import { import {
...@@ -29,12 +30,12 @@ Page({ ...@@ -29,12 +30,12 @@ Page({
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function(options) {
if (judgeToken(true)) { if (judgeToken(true)) {
let me = this; let me = this;
let my = wx.getStorageSync("myUsername"); let my = wx.getStorageSync("myUsername");
//监听未读消息数 //监听未读消息数
disp.on("em.xmpp.unreadspot", function (message) { disp.on("em.xmpp.unreadspot", function(message) {
if (getApp().globalData.customerNum != my) { if (getApp().globalData.customerNum != my) {
me.getCustom(); me.getCustom();
} }
...@@ -46,7 +47,7 @@ Page({ ...@@ -46,7 +47,7 @@ Page({
} }
}, },
getCustom: function () { getCustom: function() {
let my = wx.getStorageSync("myUsername"); let my = wx.getStorageSync("myUsername");
let companyName = wx.getStorageSync("company_name") || ''; let companyName = wx.getStorageSync("company_name") || '';
let userId = wx.getStorageSync("user_id") || ''; let userId = wx.getStorageSync("user_id") || '';
...@@ -119,7 +120,7 @@ Page({ ...@@ -119,7 +120,7 @@ Page({
return array; return array;
}, },
into_singleChatRoom: function (detail) { into_singleChatRoom: function(detail) {
let my = wx.getStorageSync("myUsername"); let my = wx.getStorageSync("myUsername");
let nameList = { let nameList = {
myName: my, myName: my,
...@@ -136,14 +137,14 @@ Page({ ...@@ -136,14 +137,14 @@ Page({
url: "/pages/detail/chat/index?username=" + JSON.stringify(nameList) url: "/pages/detail/chat/index?username=" + JSON.stringify(nameList)
}); });
}, },
into_chatRoom: function (event) { into_chatRoom: function(event) {
let detail = event.currentTarget.dataset.item; let detail = event.currentTarget.dataset.item;
this.into_singleChatRoom(detail) this.into_singleChatRoom(detail)
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady: function () { onReady: function() {
}, },
...@@ -151,10 +152,11 @@ Page({ ...@@ -151,10 +152,11 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function() {
let my = wx.getStorageSync("myUsername"); let my = wx.getStorageSync("myUsername");
let token = wx.getStorageSync('access_token') || ''; let token = wx.getStorageSync('access_token') || '';
this.getSys(token) let im = wx.getStorageSync('im') || '';
this.getSys(token) //获取系统消息
if (getApp().globalData.customerNum != my) { if (getApp().globalData.customerNum != my) {
this.getCustom(); this.getCustom();
this.setData({ this.setData({
...@@ -169,42 +171,46 @@ Page({ ...@@ -169,42 +171,46 @@ Page({
arr: this.getChatList(), arr: this.getChatList(),
userId: wx.getStorageSync('user_id'), userId: wx.getStorageSync('user_id'),
}); });
if (wx.getStorageSync('im')) {
reloginIm()
}
}, },
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide: function () { onHide: function() {
}, },
/** /**
* 生命周期函数--监听页面卸载 * 生命周期函数--监听页面卸载
*/ */
onUnload: function () { onUnload: function() {
}, },
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh: function () { onPullDownRefresh: function() {
}, },
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom: function () { onReachBottom: function() {
}, },
getSys: function (token) { getSys: function(token) {
let me = this; let me = this;
getData(apis.userSysmsg, 'get', { getData(apis.userSysmsg, 'get', {
token: token, token: token,
"limit": 1, "limit": 1,
"page": 1, "page": 1,
}, function (res) { }, function(res) {
if (res.errcode == 0) { if (res.errcode == 0) {
me.setData({ me.setData({
count: res.data.act_unread_msg + res.data.sys_unread_msg count: res.data.act_unread_msg + res.data.sys_unread_msg
...@@ -213,13 +219,13 @@ Page({ ...@@ -213,13 +219,13 @@ Page({
} }
}, true) }, true)
}, },
getAct: function (token, sysarr) { getAct: function(token, sysarr) {
let me = this; let me = this;
getData(apis.userActmsg, 'get', { getData(apis.userActmsg, 'get', {
token: token, token: token,
"limit": 1, "limit": 1,
"page": 1, "page": 1,
}, function (res) { }, function(res) {
if (res.errcode == 0) { if (res.errcode == 0) {
let actarr = res.data['act_msg'].data; let actarr = res.data['act_msg'].data;
let nowDate = Date.parse(new Date()); let nowDate = Date.parse(new Date());
...@@ -253,13 +259,13 @@ Page({ ...@@ -253,13 +259,13 @@ Page({
}, false) }, false)
}, },
deleteChatItem: function (e) { //拉黑 deleteChatItem: function(e) { //拉黑
this.del_chat(e, 2) this.del_chat(e, 2)
}, },
deleteChat: function (e) { //删除记录 deleteChat: function(e) { //删除记录
this.del_chat(e, 1) this.del_chat(e, 1)
}, },
del_chat: function (event, type) { del_chat: function(event, type) {
let detail = event.currentTarget.dataset.item; let detail = event.currentTarget.dataset.item;
let your = detail.username; let your = detail.username;
let myName = wx.getStorageSync("myUsername"); let myName = wx.getStorageSync("myUsername");
...@@ -268,7 +274,7 @@ Page({ ...@@ -268,7 +274,7 @@ Page({
wx.showModal({ wx.showModal({
title: title, title: title,
confirmText: "确定", confirmText: "确定",
success: function (res) { success: function(res) {
if (res.confirm) { if (res.confirm) {
if (type == 1) { if (type == 1) {
let member = wx.getStorageSync('member'); let member = wx.getStorageSync('member');
...@@ -292,7 +298,7 @@ Page({ ...@@ -292,7 +298,7 @@ Page({
WebIM.conn.addToBlackList({ WebIM.conn.addToBlackList({
list: list, list: list,
type: 'jid', type: 'jid',
success: function () { success: function() {
let member = wx.getStorageSync('member'); let member = wx.getStorageSync('member');
let index = member.indexOf(your); let index = member.indexOf(your);
member.splice(index, 1); member.splice(index, 1);
...@@ -304,7 +310,7 @@ Page({ ...@@ -304,7 +310,7 @@ Page({
} }
disp.fire("em.chat.session.remove"); disp.fire("em.chat.session.remove");
}, },
error: function () { error: function() {
wx.showToast({ wx.showToast({
title: '加入黑名单失败', title: '加入黑名单失败',
icon: 'none', icon: 'none',
...@@ -317,15 +323,15 @@ Page({ ...@@ -317,15 +323,15 @@ Page({
} }
}, },
fail: function (err) { } fail: function(err) {}
}); });
}, },
closeTip: function () { closeTip: function() {
this.setData({ this.setData({
isShowTip: false isShowTip: false
}) })
}, },
toSys: function () { toSys: function() {
wx.navigateTo({ wx.navigateTo({
url: "/pages/list/notice/index" url: "/pages/list/notice/index"
}); });
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
"list": [] "list": []
}, },
"miniprogram": { "miniprogram": {
"current": 29, "current": 30,
"list": [ "list": [
{ {
"id": -1, "id": -1,
...@@ -259,6 +259,13 @@ ...@@ -259,6 +259,13 @@
"pathName": "pages/detail/good/index", "pathName": "pages/detail/good/index",
"query": "goodId=156393707673258&type=3", "query": "goodId=156393707673258&type=3",
"scene": null "scene": null
},
{
"id": 30,
"name": "pages/detail/good/index",
"pathName": "pages/detail/good/index",
"query": "goodId=156628347362412&type=3",
"scene": null
} }
] ]
} }
......
import { import {
getData getData,
reloginIm
} from '../utils/util.js'; } from '../utils/util.js';
import { import {
apis apis
...@@ -61,6 +62,14 @@ const webimListen = () => { ...@@ -61,6 +62,14 @@ const webimListen = () => {
let my = wx.getStorageSync('myUsername') || ''; let my = wx.getStorageSync('myUsername') || '';
WebIM.conn.listen({ WebIM.conn.listen({
onOpened(message) { onOpened(message) {
let im = wx.getStorageSync('im');
wx.removeStorageSync('im');
if (im) {
wx.showToast({
title: "登录成功",
duration: 2000
});
}
WebIM.conn.setPresence(); WebIM.conn.setPresence();
}, },
onReconnect() { onReconnect() {
...@@ -137,18 +146,20 @@ const webimListen = () => { ...@@ -137,18 +146,20 @@ const webimListen = () => {
// 各种异常 // 各种异常
onError(error) { onError(error) {
if (error.type == 8) { if (error.type == 8) {
wx.showModal({ let pages = getCurrentPages();
title: '提示', let curPage = pages[pages.length - 1];
content: '您的聊天账号被迫下线!', wx.setStorageSync('im', true);
showCancel: false if (curPage.route == "pages/detail/chat/index" || curPage.route == 'pages/tab/message/message') {
}) reloginIm()
}
} else { } else {
wx.showModal({ wx.showModal({
title: '提示', title: '提示',
content: '聊天系统出现异常!', content: '聊天系统出现异常!',
showCancel: false showCancel: false
}) })
disp.fire("em.xmpp.error.sendMsgErr", error); disp.fire("em.xmpp.error.sendMsgErr", error);
} }
}, },
......
...@@ -314,6 +314,25 @@ const matchReg = (str) => { ...@@ -314,6 +314,25 @@ const matchReg = (str) => {
let newStr = str.replace(reg, ''); let newStr = str.replace(reg, '');
return newStr return newStr
} }
const reloginIm = ()=>{
wx.showModal({
title: '提示',
content: '您的聊天账号被迫下线!',
confirmText: "重新登录",
success: function (res) {
if (res.confirm) {
wx.showLoading();
setTimeout(() => {
getApp().getImUser()
}, 1000)
} else if (res.cancel) {
wx.switchTab({
url: '/pages/tab/home/home'
});
}
}
})
}
module.exports = { module.exports = {
getData: getData, getData: getData,
chooseImg: chooseImg, chooseImg: chooseImg,
...@@ -322,5 +341,6 @@ module.exports = { ...@@ -322,5 +341,6 @@ module.exports = {
dataEncryption: dataEncryption, dataEncryption: dataEncryption,
judgeToken: judgeToken, judgeToken: judgeToken,
interval: interval, interval: interval,
matchReg: matchReg matchReg: matchReg,
reloginIm: reloginIm
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment