Commit f69f2b5e by 施宇

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

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