Commit f3a77362 by 施宇

11

parent feba233e
Showing with 2375 additions and 536 deletions
......@@ -2,9 +2,9 @@
App({
onLaunch: function () {
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// var logs = wx.getStorageSync('logs') || []
// logs.unshift(Date.now())
// wx.setStorageSync('logs', logs)
// 登录
wx.login({
......
{
"pages": [
"pages/tab/home/home",
"pages/form/good/index",
"pages/tab/good/good",
"pages/tab/price/price",
"pages/form/bj/index",
"pages/list/bj/index",
"pages/detail/xj/index",
"pages/list/xj/index",
"pages/login/index",
"pages/tab/price/price",
"pages/tab/home/home",
"pages/tab/message/message",
"pages/tab/me/me",
"pages/search/index/index",
"pages/searchresult/index"
"pages/search/result/index",
"pages/form/xj/index",
"pages/detail/good/index",
"pages/detail/xj/index"
],
"window": {
"backgroundTextStyle": "light",
......
......@@ -45,7 +45,84 @@ image {
}
/*复用样式*/
/* 公共导航切换样式 */
.switch-tab-com{
height: 88rpx;
line-height: 88rpx;
text-align: center;
}
.switch-tab-com view {
font-size: 32rpx;
flex: 1;
font-weight: 600;
position: relative;
color: #515559;
}
.switch-tab-com view.active {
color: #0d84d1;
}
.switch-tab-com view.active .active-bg {
position: absolute;
display: inline-block;
width: 68rpx;
height: 25rpx;
background-color: rgba(13, 132, 209, 0.1);
bottom: 15rpx;
left: 50%;
margin-left: -34rpx;
border-radius: 30rpx;
}
/* 公共导航切换样式 */
/* /头部搜索公共样式 */
.search-com{
padding: 15rpx 24rpx;
position: relative;
}
.search-com .icon {
position: absolute;
font-size: 40rpx;
color: #adb6bf;
top: 22rpx;
left: 49rpx;
}
.search-com input {
background: #fff;
height: 58rpx;
border-radius: 50rpx;
padding: 0 18rpx 0 75rpx;
box-sizing: border-box;
background-color: #f0f4f7;
font-size: 24rpx;
}
.search-com .placeholderClass {
color: #adb6bf;
}
/* /头部搜索公共样式 */
/* 暂无数据公共样式 */
.nodata {
text-align: center;
}
.nodata .img {
width: 600rpx;
height: 393rpx;
margin: 0 auto;
}
.nodata .h3 {
font-size: 48rpx;
color: #2e3033;
}
.nodata .p {
font-size: 26rpx;
color: #8a9299;
}
/* 暂无数据公共样式 */
.px-hr-top {
border-top: 1px solid #f5f9fc;
}
......@@ -63,7 +140,8 @@ image {
.bold {
font-weight: 600;
}
.nobold{
.nobold {
font-weight: 400;
}
......@@ -78,14 +156,16 @@ image {
.nowrap {
white-space: nowrap;
}
.t-com{
color:#8A9299;
.t-com {
color: #8a9299;
}
.c-com{
color:#515559;
.c-com {
color: #515559;
}
/**询报价列表**/
/**询报价列表**/
.xb-com-content {
border-radius: 20rpx 20rpx 0px 0px;
background-color: #fff;
......@@ -106,6 +186,10 @@ image {
font-size: 22rpx;
color: #adb6bf;
}
.xb-com-content .title .price {
font-size: 32rpx;
color: #EA1717;
}
.xb-com-content .desc {
padding: 7rpx 24rpx 40rpx 40rpx;
......@@ -113,21 +197,24 @@ image {
font-size: 26rpx;
color: #515559;
}
.xb-com-content .desc .left{
flex:1;
}
.xb-com-content .desc .left view {
padding-top: 16rpx;
}
.xb-com-content .desc .left .t-com{
.xb-com-content .desc .left .t-com {
flex: 0 0 78rpx;
}
.xb-com-content .desc .left .price .t-com {
flex: 0 0 104rpx;
}
.xb-com-content .desc .right {
height: 220rpx;
width: 220rpx;
flex:0 0 220rpx;
height:220rpx;
margin-top: 16px;
}
......@@ -145,22 +232,26 @@ image {
height: 30rpx;
width: 2px;
}
.btn-com{
height:98rpx;
.btn-com {
height: 98rpx;
font-size: 32rpx;
color:#fff;
margin:0 55rpx;
color: #fff;
margin: 0 55rpx;
text-align: center;
line-height: 98rpx;
border-radius:8rpx;
border-radius: 8rpx;
}
.btn-com-y{
background-color: #EAAD37;
box-shadow:0px 6px 10px 0px rgba(242,191,97,0.5);
.btn-com-y {
background-color: #eaad37;
box-shadow: 0px 6px 10px 0px rgba(242, 191, 97, 0.5);
}
.btn-com-b{
background-color: #0D84D1;
box-shadow:0px 6px 10px 0px rgba(97,160,242,0.3);
.btn-com-b {
background-color: #0d84d1;
box-shadow: 0px 6px 10px 0px rgba(97, 160, 242, 0.3);
}
/**询报价列表**/
/**字体**/
@import 'res/fonts/iconfont.wxss'
......@@ -29,6 +29,8 @@ Component({
* 组件的方法列表
*/
methods: {
emitevent:function(){
this.triggerEvent('emitevent')
}
}
})
......@@ -2,7 +2,7 @@
<block>
<!-- 询报价展示 -->
<block wx:if="{{priceType==1}}">
<view class="price-item" wx:for="{{priceList}}" wx:key="*this">
<view class="price-item" wx:for="{{priceList}}" wx:key="*this" bindtap="emitevent">
<view class="item-header px-hr-bottom row verCenter bothSide nowrap">
<view class="row verCenter">
<text class="mark xun" wx:if="{{xb==1}}">询</text>
......@@ -27,7 +27,7 @@
</block>
<!-- 搜索页的商品展示 -->
<block wx:if="{{priceType==2}}">
<view class="price-item" wx:for="{{priceList}}" wx:key="*this">
<view class="price-item" wx:for="{{priceList}}" wx:key="*this" bindtap="emitevent">
<view class="item-header px-hr-bottom row verCenter bothSide nowrap">
<view class="row verCenter">
<text class="mark bao" wx:if="{{item.type==1}}">贸易商</text>
......@@ -49,7 +49,7 @@
</block>
<!-- 搜索页面询报价展示 -->
<block wx:if="{{priceType==3}}">
<view class="price-item" wx:for="{{priceList}}" wx:key="*this">
<view class="price-item" wx:for="{{priceList}}" wx:key="*this" bindtap="emitevent">
<view class="item-header px-hr-bottom row verCenter bothSide nowrap">
<view class="row verCenter">
<text class="mark xun" wx:if="{{xb==1}}">询价</text>
......@@ -76,8 +76,8 @@
</view>
</block>
<!-- 我的报价展示 -->
<block wx:if="{{priceType==4}}">
<view class="price-item" wx:for="{{priceList}}" wx:key="*this">
<block wx:if="{{priceType==4}}">
<view class="price-item" wx:for="{{priceList}}" wx:key="*this" bindtap="emitevent">
<view class="item-header px-hr-bottom row verCenter bothSide nowrap">
<view class="row verCenter">
<text class="mark bao">报价</text>
......@@ -93,7 +93,7 @@
<text class="brand ellipsis"><text>品牌:</text>{{item.brand}}</text>
<text class="num"><text>封装:</text>{{item.fz}}</text>
</view>
<view class="item-middle row verCenter nowrap">
<view class="item-middle row verCenter nowrap">
<text class="brand ellipsis bold"><text class="nobold">数量:</text>{{item.num}}PCS</text>
<text class="num"><text>货期:</text>{{item.hq}}</text>
</view>
......@@ -102,4 +102,20 @@
</view>
</view>
</block>
<!-- 商品管理 -->
<block wx:if="{{priceType == 5}}">
<view class="price-item" wx:for="{{priceList}}" wx:key="*this" bindtap="emitevent">
<view class="item-header row verCenter bothSide nowrap">
<view class="row verCenter">
<text class="name ellipsis good-name">{{item.name}}</text>
<text class="icon iconfont iconiconxiantiaoshouji14 good-icon"></text>
</view>
<text class="price">¥{{item.price}}</text>
</view>
<view class="item-middle row verCenter nowrap">
<text class="brand ellipsis"><text>品牌:</text>{{item.brand}}</text>
<text class="num bold"><text class="nobold">库存: </text>{{item.num}}PCS</text>
</view>
</view>
</block>
</block>
\ No newline at end of file
......@@ -12,6 +12,7 @@
overflow: hidden;
}
.item-header .mark {
border-radius: 2px;
font-size: 24rpx;
......@@ -35,7 +36,6 @@
}
.p
.price-item .name, .price-item .company {
color: #515559;
margin-right: 24rpx;
......@@ -44,7 +44,16 @@
.price-item .name {
font-size: 32rpx;
}
.price-item .good-name{
margin-right:0;
flex:1;
}
.item-header .good-icon{
font-size: 50rpx;
color:#ADB6BF;
flex:0 0 50rpx;
margin:0 16rpx;
}
.price-item .company {
font-size: 26rpx;
}
......
// pages/detail/good/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"usingComponents": {},
"navigationBarBackgroundColor": "#0D84D1",
"navigationBarTextStyle": "white",
"backgroundColor": "#0d84d1",
"navigationBarTitleText": ""
}
\ No newline at end of file
<!--pages/detail/good/index.wxml-->
<view class="detail-view">
<view class="t-desc">
<view class="top row bothSide verCenter">
<view class="company row verCenter">
<text class="name bold">深圳市德卡科技股份有限公司深圳</text>
</view>
<text class="icon iconfont iconiconxiantiaoshouji6"></text>
</view>
<view class="bottom row">
<view class="yes">
<text class="icon iconfont iconiconxiantiaoshouji11"></text>
<text>公司认证</text>
</view>
<view class="yes">
<text class="icon iconfont iconiconxiantiaoshouji11"></text>
<text>贸易商</text>
</view>
</view>
</view>
<view class="xb-com-content">
<view class="title row bothSide verCenter nowrap px-hr-bottom">
<text class="name bold ellipsis">STM32F407ZGT6STM32F407ZGT6STM32F407ZGT6</text>
<text class="price bold">¥100.0120</text>
</view>
<view class="desc row bothSide">
<view class="left">
<view class="brand row">
<text class="t-com">品牌:</text>
<text class="c-com">Texas Instruments</text>
</view>
<view class="fz row">
<text class="t-com">封装:</text>
<text class="c-com">LQFP-64</text>
</view>
<view class="hq row">
<text class="t-com">货期:</text>
<text class="c-com">现货</text>
</view>
<view class="num row">
<text class="t-com">库存:</text>
<text class="c-com bold">100,000 PCS</text>
</view>
<view class="bjsj row">
<text class="t-com">更新时间:</text>
<text class="c-com">2019-05-10 10:15</text>
</view>
</view>
<cover-image class="right" src="/res/images/imgs/iclogo.png"></cover-image>
</view>
</view>
<!-- <view class="zxgt btn-com btn-com-y">
<text class="icon iconfont iconiconxiantiaoshouji11"></text>
<text class="gt-t">在线沟通</text>
</view> -->
<view class="zxgt btn-com btn-com-b">
<text class="gt-t">编辑商品</text>
</view>
</view>
\ No newline at end of file
/* pages/detail/good/index.wxss */
@import '/res/css/detail.wxss'
\ No newline at end of file
// pages/detail/xj/index.js
let arr = [
{
name: "STM32F407ZGT6",
price: "100.012",
brand: "Texas InstrumentsTexas",
num: "100,000",
desc: "深圳地区原装现货深圳地区原装现货",
time: "05-10 10:15",
company: "朗新科技股份有限公司"
},
{
name: "STM32F407ZGT6",
price: "100.012",
brand: "Texas InstrumentsTexas",
num: "100,000",
desc: "深圳地区原装现货深圳地区原装现货",
time: "05-10 10:15",
company: "深圳邦马特科技有限公司"
}
]
Page({
/**
* 页面的初始数据
*/
data: {
priceList: undefined,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let seft = this;
wx.showLoading({
title: '加载中',
})
setTimeout(() => {
wx.hideLoading()
seft.setData({ priceList: arr })
}, 2000)
},
/**
......
{
"usingComponents": {
"priceItem": "/components/priceItem/priceItem"
},
"usingComponents": {},
"navigationBarBackgroundColor": "#0D84D1",
"navigationBarTextStyle": "white",
"backgroundColor": "#0d84d1",
......
<!--pages/detail/xj/index.wxml-->
<view class="xj-detail-view">
<view class="detail-view">
<view class="t-desc">
<view class="top row bothSide verCenter">
<view class="company row verCenter">
......@@ -19,12 +19,12 @@
</view>
</view>
</view>
<view class="bj-desc">
<view class="xb-com-content">
<view class="title row bothSide verCenter nowrap px-hr-bottom">
<text class="name bold ellipsis">STM32F407ZGT6STM32</text>
<text class="price bold">¥100.0120</text>
</view>
<view class="desc">
<view class="desc desc-xj-detail">
<view class="brand row">
<text class="t-com">品牌:</text>
<text class="c-com">Texas Instruments</text>
......@@ -33,7 +33,7 @@
<text class="t-com">封装:</text>
<text class="c-com">LQFP-64</text>
</view>
<view class="num row">
<view class="num row">
<text class="t-com">数量:</text>
<text class="c-com bold">100,000 PCS</text>
</view>
......@@ -45,7 +45,7 @@
<text class="t-com">备注:</text>
<text class="c-com">有货的请尽快回复,比较急着要货</text>
</view>
<view class="bjsj row">
<view class="bjsj row">
<text class="t-com">报价时间:</text>
<text class="c-com">2019-05-10 10:15</text>
</view>
......
/* pages/detail/xj/index.wxss */
.t-desc {
background-color: #0d84d1;
color: #fff;
font-size: 26rpx;
padding: 24rpx 24rpx 62rpx;
}
.company {
flex: 1;
}
.company .bao {
flex: 0 0 87rpx;
height: 36rpx;
text-align: center;
line-height: 36rpx;
border-radius: 2rpx;
margin-right: 24rpx;
}
.company .name {
font-size: 32rpx;
flex: 1;
}
.top .icon {
font-size: 40rpx;
}
.bottom {
flex-wrap: wrap;
}
.bottom .yes {
margin: 24rpx 24rpx 0 0;
}
.yes .icon {
color: #61a0f2;
font-size: 30rpx;
margin-right: 12rpx;
}
.bj-desc{
border-radius: 20rpx 20rpx 0px 0px;
position: relative;
background-color: #fff;
top:-22rpx;
}
.bj-desc .title {
margin-left: 24rpx;
padding: 32rpx 24rpx 24rpx 0;
}
.title .name {
font-size: 36rpx;
color: #2e3033;
}
.title .price {
font-size: 32rpx;
color: #ea1717;
margin-left: 27rpx;
}
.bj-desc .desc {
padding: 0 40rpx;
font-size: 26rpx;
}
.bjsj .t-com{
flex:0 0 130rpx;
}
.bjsj .c-com,.bz .c-com{
color:#8A9299
}
.desc view {
padding-top: 16rpx;
}
.zxgt{
position: absolute;
bottom:94rpx;
left:0;
right:0;
}
.zxgt .icon{
margin-right:7rpx;
font-size: 40rpx;
vertical-align:middle;
}
\ No newline at end of file
@import '/res/css/detail.wxss'
\ No newline at end of file
/* pages/form/bj/index.wxss */
.form-view {
}
.tip {
padding: 12rpx 24rpx;
background-color: #fff6e6;
}
.tip .close-icon {
color: #d8dfe6;
}
.tip .icon {
font-size: 30rpx;
}
.tip-left {
color: #eaa217;
}
.tip-left .tip-icon {
margin-right: 7rpx;
vertical-align: middle;
}
.tip-c {
font-size: 24rpx;
}
.form-item {
margin-left: 24rpx;
padding: 27rpx 0;
font-size: 28rpx;
color: #515559;
position: relative;
}
.form-item .placeholderClass {
color: #adb6bf;
font-size: 28rpx;
}
.form-item-title {
flex: 0 0 71rpx;
text-align: right;
}
.form-item-right {
flex: 1;
padding: 0 24rpx 0 117rpx;
}
.bj-item .price-type {
border-left: 1px solid #d8dfe6;
}
.price-type .price-value {
font-size: 32rpx;
color: #515559;
padding: 7rpx 11rpx 7rpx 16rpx;
}
.price-type .icon {
color: #d8dfe6;
font-size: 26rpx;
}
.qx-item {
text-align: right;
}
.qx-item radio {
margin-left: 50rpx;
}
.form-hr {
height: 10rpx;
background-color: #f5f9fc;
}
textarea {
width: 100%;
height: 150rpx;
}
.hf-btn {
margin: 60rpx 55rpx;
}
.price-ul {
position: absolute;
top: 100rpx;
right: 24rpx;
background-color: #fff;
box-shadow: 2px 2px 5px #ddd;
z-index: 2;
border-radius: 2rpx;
display: none;
}
.price-ul.show {
display: block;
}
.price-ul .price-li {
padding: 25rpx 40rpx;
text-align: center;
font-size: 32rpx;
}
.price-ul .price-li.active {
color: #0d84d1;
}
@import '/res/css/form.wxss'
// pages/form/good/index.js
Page({
/**
* 页面的初始数据
*/
data: {
isShowSwitch: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
switchPrice: function () {
this.setData({
isShowSwitch: !this.data.isShowSwitch
})
}
})
\ No newline at end of file
{
"usingComponents": {},
"navigationBarTitleText": "新增商品"
}
\ No newline at end of file
<!--pages/form/good/index.wxml-->
<view class="form-view">
<view class="tip row bothSide verCenter">
<view class="tip-left">
<text class="icon iconfont iconiconxiantiaoshouji12 tip-icon"></text>
<text class="tip-c">批量商品上传请到<text class="pc-url">www.icsales.com</text>操作</text>
</view>
<text class="icon iconfont iconiconxiantiaoshouji13 close-icon"></text>
</view>
<view class="upload-view column verCenter">
<view class="upload column verCenter rowCenter">
<text class="icon iconfont iconiconxiantiaoshouji15"></text>
<text class="upload-text">上传图片</text>
</view>
<view class="text">据说上传图片更容易被采纳报价</view>
</view>
<view class="form-item row verCenter">
<text class="form-item-title">*型号</text>
<view class="form-item-right">
<input placeholder="请输入产品型号(必填)" placeholder-class="placeholderClass"></input>
</view>
</view>
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title">*品牌</text>
<view class="form-item-right">
<input placeholder="请输入品牌(必填)" placeholder-class="placeholderClass"></input>
</view>
</view>
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title"> 封装</text>
<view class="form-item-right">
<input placeholder="请输入封装" placeholder-class="placeholderClass"></input>
</view>
</view>
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title">*库存</text>
<view class="form-item-right">
<input placeholder="请输入库存数量(必填)" placeholder-class="placeholderClass"></input>
</view>
</view>
<view class="form-item row verCenter px-hr-top bj-item">
<text class="form-item-title">*报价</text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入单价" placeholder-class="placeholderClass"></input>
<view class="price-type" bindtap="switchPrice">
<text class="price-value">RMB</text>
<text class="icon iconfont iconbianzu1"></text>
</view>
</view>
<view class="price-ul {{isShowSwitch?'show':''}}">
<view class="price-li active">RMB</view>
<view class="price-li px-hr-top">USD</view>
</view>
</view>
<view class="form-item row verCenter px-hr-top qx-item px-hr-bottom">
<text class="form-item-title">*货期</text>
<view class="form-item-right">
<radio-group>
<label>
<radio value="1" checked/>现货
</label>
<label>
<radio value="2" checked/>期货
</label>
</radio-group>
</view>
</view>
<view class="btn-com btn-com-b hf-btn">
<text class="icon iconfont iconiconxiantiaoshouji15"></text>
<text>新增商品</text>
</view>
</view>
\ No newline at end of file
/* pages/form/good/index.wxss */
@import '/res/css/form.wxss'
\ No newline at end of file
// pages/form/xj/index.js
Page({
/**
* 页面的初始数据
*/
data: {
isShowSwitch: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
switchPrice: function () {
this.setData({
isShowSwitch: !this.data.isShowSwitch
})
}
})
\ No newline at end of file
{
"usingComponents": {},
"navigationBarTitleText": "发布询价"
}
\ No newline at end of file
<!--pages/form/xj/index.wxml-->
<view class="form-view">
<view class="tip row bothSide verCenter">
<view class="tip-left">
<text class="icon iconfont iconiconxiantiaoshouji12 tip-icon"></text>
<text class="tip-c">填写完整信息,有利于提高回复报价效率</text>
</view>
<text class="icon iconfont iconiconxiantiaoshouji13 close-icon"></text>
</view>
<view class="upload-view column verCenter">
<view class="upload column verCenter rowCenter">
<text class="icon iconfont iconiconxiantiaoshouji15"></text>
<text class="upload-text">上传图片</text>
</view>
<view class="text">据说上传图片更容易让人报价</view>
</view>
<view class="form-item row verCenter">
<text class="form-item-title">*型号</text>
<view class="form-item-right">
<input placeholder="请输入产品型号(必填)" placeholder-class="placeholderClass"></input>
</view>
</view>
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title">*品牌</text>
<view class="form-item-right">
<input placeholder="请输入品牌(必填)" placeholder-class="placeholderClass"></input>
</view>
</view>
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title"> 封装</text>
<view class="form-item-right">
<input placeholder="请输入封装" placeholder-class="placeholderClass"></input>
</view>
</view>
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title">*数量</text>
<view class="form-item-right">
<input placeholder="请输入数量(必填)" placeholder-class="placeholderClass"></input>
</view>
</view>
<view class="form-item row verCenter px-hr-top bj-item">
<text class="form-item-title">*价格</text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入单价" placeholder-class="placeholderClass"></input>
<view class="price-type" bindtap="switchPrice">
<text class="price-value">RMB</text>
<text class="icon iconfont iconbianzu1"></text>
</view>
</view>
<view class="price-ul {{isShowSwitch?'show':''}}">
<view class="price-li active">RMB</view>
<view class="price-li px-hr-top">USD</view>
</view>
</view>
<view class="form-item row verCenter px-hr-top qx-item">
<text class="form-item-title">*货期</text>
<view class="form-item-right">
<radio-group>
<label>
<radio value="1" checked/>现货
</label>
<label>
<radio value="2" checked/>期货
</label>
</radio-group>
</view>
</view>
<view class="form-hr"></view>
<view class="form-item row px-hr-bottom">
<text class="form-item-title">备注</text>
<view class="form-item-right">
<textarea placeholder="请输入备注" placeholder-class="placeholderClass" maxlength="-1" />
</view>
</view>
<view class="btn-com btn-com-b hf-btn">发布询价</view>
</view>
\ No newline at end of file
/* pages/form/xj/index.wxss */
@import '/res/css/form.wxss'
\ No newline at end of file
......@@ -111,5 +111,10 @@ Page({
*/
onShareAppMessage: function () {
},
goBj:function(){
wx.navigateTo({
url: "/pages/form/bj/index",
})
}
})
\ No newline at end of file
......@@ -60,5 +60,5 @@
</view>
</view>
<view class="btn-com btn-com-b bj-btn">继续报价,剩余1次</view>
<view class="btn-com btn-com-b bj-btn" bindtap="goBj">继续报价,剩余1次</view>
</view>
\ No newline at end of file
......@@ -93,5 +93,10 @@ Page({
*/
onShareAppMessage: function () {
},
emitevent:function(){
wx.navigateTo({
url: "/pages/detail/xj/index",
})
}
})
\ No newline at end of file
......@@ -48,7 +48,7 @@
<view wx:if="{{priceList&&priceList.length==0}}" class="nodata">
暂无数据
</view>
<priceItem price-list="{{priceList}}" wx:if="{{priceList&&priceList.length!==0}}" price-type="3" xb="2"></priceItem>
<priceItem price-list="{{priceList}}" wx:if="{{priceList&&priceList.length!==0}}" price-type="3" xb="2" bindemitevent="emitevent"></priceItem>
</view>
</view>
</view>
\ No newline at end of file
......@@ -62,5 +62,10 @@ Page({
*/
onShareAppMessage: function () {
},
confirmTap:function(){
wx.navigateTo({
url: "/pages/search/result/index",
})
}
})
\ No newline at end of file
<!--pages/search/index/index.wxml-->
<view class="search-view">
<view class="search-section">
<view class="search-com">
<text class="icon iconfont iconiconxiantiaoshouji8"></text>
<input placeholder='请输入芯片型号' placeholder-class="placeholderClass" bindtap="toSearch"></input>
<input placeholder='请输入芯片型号' placeholder-class="placeholderClass" auto-focus bindconfirm="confirmTap"></input>
</view>
<view class="rm_search">
<text class="title beforeLine">热门搜索</text>
......@@ -11,8 +11,8 @@
<view class="search-item">TJA1027</view>
<view class="search-item">贴片电阻330k</view>
<view class="search-item">PFB0824GHE</view>
<view class="search-item">T6738-4K</view>
<view class="search-item">ECW-FA2J155J</view>
<view class="search-item">T6738-4K</view>
<view class="search-item">ECW-FA2J155J</view>
</view>
</view>
<view class="ls_search">
......
/* pages/search/index/index.wxss */
.search-section {
padding: 15rpx 24rpx;
position: relative;
}
.search-section .icon {
position: absolute;
font-size: 40rpx;
color: #adb6bf;
top: 22rpx;
left: 49rpx;
}
.search-section input {
background: #fff;
height: 58rpx;
border-radius: 50rpx;
padding: 0 18rpx 0 75rpx;
box-sizing: border-box;
background-color: #f0f4f7;
font-size: 24rpx;
}
.search-section .placeholderClass {
color: #adb6bf;
}
.title {
font-weight: 600;
font-size: 28rpx;
......
......@@ -181,5 +181,10 @@ Page({
}
},
toXj:function(){
wx.navigateTo({
url: "/pages/form/xj/index"
})
}
})
\ No newline at end of file
{
"usingComponents": {
"priceItem": "/components/priceItem/priceItem"
}
},
"navigationBarTitleText": "搜索"
}
\ No newline at end of file
<!--pages/searchresult/index.wxml-->
<view class="searchresult-view">
<view class="search-section">
<view class="search-com">
<text class="icon iconfont iconiconxiantiaoshouji8"></text>
<input placeholder='请输入芯片型号' placeholder-class="placeholderClass" bindtap="toSearch"></input>
</view>
<view class="searchresult-tab row">
<view class="switch-tab-com row">
<view bindtap="switchTab" class="{{tabIndex == 1&&'active'}}" data-index="1">
<text>商品</text>
<text class="active-bg"></text>
......@@ -17,19 +17,19 @@
<view class="searchresult-content">
<view wx:if="{{priceList&&priceList.length==0}}" class="nodata">
<cover-image src="/res/images/imgs/nodata.png" class="img"></cover-image>
<view class="h3">未搜索到相关信息</view>
<view class="h3 bold">未搜索到相关信息</view>
<view class="p">您还可以发布询价。</view>
<view class="nodata_fb fb_btn">
<view class="nodata_fb btn-com btn-com-b" bindtap="toXj">
<text>快速发布询价</text>
</view>
</view>
<priceItem price-list="{{priceList}}" wx:if="{{priceList&&priceList.length!==0}}" price-type="{{type}}"></priceItem>
<priceItem price-list="{{priceList}}" wx:if="{{priceList&&priceList.length!==0}}" price-type="{{type}}" xb="1"></priceItem>
</view>
<view class="fast_fb fb_btn" wx:if="{{priceList&&priceList.length!==0}}">
<view class="fast_fb btn-com btn-com-b" wx:if="{{priceList&&priceList.length!==0}}" bindtap="toXj">
<text>快速发布询价</text>
</view>
<view class="concat_custom" wx:if="{{priceList&&priceList.length==0}}">
<text class="icon iconfont iconiconxiantiaoshouji11"></text>
<text>快速发布询价</text>
<text>联系客服帮您找</text>
</view>
</view>
\ No newline at end of file
/* pages/searchresult/index.wxss */
.searchresult-view {
min-height: 100%;
position: relative;
padding-bottom: 234rpx;
box-sizing: border-box;
}
.fast_fb {
position: absolute;
bottom: 68rpx;
left:0;
right:0;
}
.nodata .p {
margin-top: 14rpx;
}
.nodata_fb {
margin-top:40rpx;
}
.concat_custom {
position: absolute;
bottom: 68rpx;
left: 0;
right: 0;
text-align: center;
color:#61A0F2;
font-size: 28rpx;
}
.concat_custom .icon{
font-size: 40rpx;
margin-right:16rpx;
vertical-align: sub;
}
/* pages/searchresult/index.wxss */
.searchresult-view {
min-height: 100%;
position: relative;
padding-bottom: 234rpx;
box-sizing: border-box;
}
.search-section {
padding: 15rpx 24rpx;
position: relative;
}
.search-section .icon {
position: absolute;
font-size: 40rpx;
color: #adb6bf;
top: 22rpx;
left: 49rpx;
}
.search-section input {
background: #fff;
height: 58rpx;
border-radius: 50rpx;
padding: 0 18rpx 0 75rpx;
box-sizing: border-box;
background-color: #f0f4f7;
font-size: 24rpx;
}
.search-section .placeholderClass {
color: #adb6bf;
}
.searchresult-tab {
height: 88rpx;
line-height: 88rpx;
text-align: center;
}
.searchresult-tab view {
font-size: 32rpx;
flex: 1;
font-weight: 600;
position: relative;
color: #515559;
}
.searchresult-tab view.active {
color: #0d84d1;
}
.searchresult-tab view.active .active-bg {
position: absolute;
display: inline-block;
width: 68rpx;
height: 25rpx;
background-color: rgba(13, 132, 209, 0.1);
bottom: 15rpx;
left: 50%;
margin-left: -34rpx;
border-radius: 30rpx;
}
.fast_fb {
position: absolute;
bottom: 68rpx;
left: 55rpx;
right: 55rpx;
}
.nodata {
text-align: center;
}
.nodata .img {
width: 600rpx;
height: 393rpx;
margin: 0 auto;
}
.nodata .h3 {
font-weight: 600;
font-size: 48rpx;
color: #2e3033;
}
.nodata .p {
font-size: 26rpx;
color: #8a9299;
margin-top: 14rpx;
}
.nodata_fb {
margin: 40rpx 55rpx;
}
.concat_custom {
position: absolute;
bottom: 68rpx;
left: 0;
right: 0;
text-align: center;
color:#61A0F2;
font-size: 28rpx;
}
.concat_custom .icon{
font-size: 40rpx;
margin-right:16rpx;
vertical-align: sub;
}
// pages/tab/good/good.js
let arr = [
{
name: "STM32F407ZGT6",
price: "100.012",
brand: "Texas InstrumentsTexas",
num: "100,000",
}
]
Page({
/**
* 页面的初始数据
*/
data: {
priceList:undefined
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let seft = this;
wx.showLoading({
title: '加载中',
})
setTimeout(() => {
wx.hideLoading()
seft.setData({ priceList: arr })
}, 2000)
},
/**
......@@ -54,7 +73,7 @@ Page({
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
console.log(1111)
},
/**
......@@ -62,5 +81,15 @@ Page({
*/
onShareAppMessage: function () {
},
fbGood: function () {
wx.navigateTo({
url: "/pages/form/good/index",
})
},
emitevent:function(){
wx.navigateTo({
url: "/pages/detail/good/index",
})
}
})
\ No newline at end of file
{
"usingComponents": {},
"usingComponents": {
"priceItem": "/components/priceItem/priceItem"
},
"navigationBarTitleText": "商品管理"
}
\ No newline at end of file
<!--pages/tab/good/good.wxml-->
<view class="good-view">
<view class="search-section">
<view class="search-com">
<text class="icon iconfont iconiconxiantiaoshouji8"></text>
<input placeholder='请输入芯片型号' placeholder-class="placeholderClass" bindtap="toSearch"></input>
</view>
......@@ -14,4 +14,24 @@
<text>2019-05-14 10:40</text>
</text>
</view>
</view>
<view class="good-content">
<view wx:if="{{priceList&&priceList.length==0}}" class="nodata">
<cover-image src="/res/images/imgs/nodata.png" class="img"></cover-image>
<view class="h3 bold">未搜索到相关信息</view>
<view class="p">您还可以发布询价。</view>
<view class="btn-com btn-com-b add-good-btn">
<text class="icon iconfont iconiconxiantiaoshouji15"></text>
<text>新增商品</text>
</view>
</view>
<priceItem price-list="{{priceList}}" wx:if="{{priceList&&priceList.length!==0}}" price-type="5" bindemitevent="emitevent"></priceItem>
</view>
<view class="good-btn-div" wx:if="{{priceList&&priceList.length!==0}}">
<view class="btn-com btn-com-b add-good-btn" bindtap="fbGood">
<text class="icon iconfont iconiconxiantiaoshouji15"></text>
<text>新增商品</text>
</view>
</view>
</view>
\ No newline at end of file
/* pages/tab/good/good.wxss */
.search-section {
padding: 15rpx 24rpx;
position: relative;
}
.search-section .icon {
position: absolute;
font-size: 40rpx;
.good-view {
min-height: 100%;
padding-bottom: 118rpx;
box-sizing: border-box;
}
.good-total {
padding: 37rpx 24rpx 24rpx 0;
margin-left: 24rpx;
font-size: 22rpx;
color: #adb6bf;
top: 22rpx;
left: 49rpx;
}
.search-section input {
background: #fff;
height: 58rpx;
border-radius: 50rpx;
padding: 0 18rpx 0 75rpx;
box-sizing: border-box;
background-color: #f0f4f7;
.good-total .good-num {
font-size: 24rpx;
}
.search-section .placeholderClass {
color: #adb6bf;
.good-total .good-num .num {
color: #515559;
}
.good-total {
padding:37rpx 24rpx 24rpx 0;
margin-left:24rpx;
font-size: 22rpx;
color:#ADB6BF;
.good-btn-div{
position: fixed;
left:0;
bottom:0;
right:0;
background-color: #fff;
height:118rpx;
}
.good-total .good-num{
font-size: 24rpx;
.add-good-btn {
margin-top:10rpx;
}
.add-good-btn .icon {
margin-right: 8rpx;
font-size: 32rpx;
}
.good-total .good-num .num{
color:#515559;
.nodata .p{
margin-top:14rpx;
}
.nodata .add-good-btn{
margin-top:40rpx;
}
\ No newline at end of file
......@@ -133,5 +133,20 @@ Page({
wx.navigateTo({
url: '/pages/search/index/index',
})
},
toXj: function () {
wx.navigateTo({
url: "/pages/form/xj/index"
})
},
fbGood:function(){
wx.navigateTo({
url: "/pages/form/good/index",
})
},
emitevent:function(){
wx.navigateTo({
url: "/pages/list/bj/index",
})
}
})
\ No newline at end of file
<!--pages/tab/home/home.wxml-->
<view class="home-view">
<view class="search-section">
<text class="icon iconfont iconiconxiantiaoshouji8"></text>
<input placeholder='请输入芯片型号' placeholder-class="placeholderClass" bindtap="toSearch"></input>
<text class="icon iconfont iconiconxiantiaoshouji8"></text>
<input placeholder='请输入芯片型号' placeholder-class="placeholderClass" bindtap="toSearch" disabled></input>
</view>
<view class="home-content">
<view class="home-function bothSide row">
<view class="function-item column verCenter">
<view class="function-item column verCenter" bindtap="toXj">
<cover-image src="/res/images/icons/home-s-1.png" class="img"></cover-image>
<text class="text">发布询价</text>
</view>
......@@ -14,7 +14,7 @@
<cover-image src="/res/images/icons/home-s-2.png" class="img"></cover-image>
<text class="text">抢单专区</text>
</view>
<view class="function-item column verCenter">
<view class="function-item column verCenter" bindtap="fbGood">
<cover-image src="/res/images/icons/home-s-3.png" class="img"></cover-image>
<text class="text">发布商品</text>
</view>
......@@ -44,7 +44,7 @@
</view>
</view>
<view class="more-item">
<text class="icon iconfont iconiconxiantiaoshouji6"></text>
<text class="icon iconfont iconiconxiantiaoshouji6"></text>
</view>
</view>
</view>
......@@ -54,12 +54,12 @@
<view class="price-title">
<view class="price-title-content row bothSide verCenter px-hr-bottom ">
<text class="xb-t beforeLine">我的询报价</text>
<text class="icon iconfont iconiconxiantiaoshouji5"></text>
<text class="icon iconfont iconiconxiantiaoshouji5"></text>
</view>
</view>
<view class="price-content">
<view wx:if="{{priceList&&priceList.length==0}}">暂无数据</view>
<priceItem price-list="{{priceList}}" wx:if="{{priceList&&priceList.length!==0}}" price-type="1"></priceItem>
<priceItem price-list="{{priceList}}" wx:if="{{priceList&&priceList.length!==0}}" price-type="1" bindemitevent="emitevent"></priceItem>
</view>
</view>
</view>
......
{
"usingComponents": {}
"usingComponents": {},
"navigationBarTitleText": "消息"
}
\ No newline at end of file
......@@ -16,7 +16,7 @@ let arr = [
desc: "深圳地区原装现货深圳地区原装现货",
time: "05-10 10:15"
},
{
name: "STM32F407ZGT6",
price: "100.012",
......@@ -32,8 +32,8 @@ Page({
* 页面的初始数据
*/
data: {
tabIndex:1,
xb:1,
tabIndex: 1,
xb: 1,
priceList: undefined,
},
......@@ -118,7 +118,7 @@ Page({
this.setData({
tabIndex: i,
priceList: [],
xb:2
xb: 2
});
}
......@@ -126,5 +126,21 @@ Page({
}
},
toXj: function () {
wx.navigateTo({
url: "/pages/form/xj/index"
})
},
emitevent:function(){
if(this.data.xb == 1){
wx.navigateTo({
url: "/pages/list/xj/index",
})
}else{
wx.navigateTo({
url: "/pages/list/bj/index",
})
}
}
})
\ No newline at end of file
<!--pages/tab/price/price.wxml-->
<view class="price-view">
<view class="searchresult-tab row">
<view class="switch-tab-com row">
<view bindtap="switchTab" class="{{tabIndex == 1&&'active'}}" data-index="1">
<text>我的询价</text>
<text class="active-bg"></text>
......@@ -11,14 +11,14 @@
</view>
</view>
<view class="price-content">
<view wx:if="{{priceList&&priceList.length==0}}" class="nodata">
<view wx:if="{{priceList&&priceList.length==0}}" class="nodata">
<cover-image src="/res/images/imgs/noxb.png" class="img"></cover-image>
<view class="h3">暂无询报价信息</view>
<view class="h3 bold">暂无询报价信息</view>
<view class="p">您还可以发布询价。</view>
<view class="fb_btn">
<view class="fb_btn btn-com btn-com-b" bindtap="toXj">
<text>快速发布询价</text>
</view>
</view>
<priceItem price-list="{{priceList}}" wx:if="{{priceList&&priceList.length!==0}}" price-type="1" xb="{{xb}}"></priceItem>
<priceItem price-list="{{priceList}}" wx:if="{{priceList&&priceList.length!==0}}" price-type="1" xb="{{xb}}" bindemitevent="emitevent"></priceItem>
</view>
</view>
\ No newline at end of file
/* pages/tab/price/price.wxss */
.searchresult-tab {
height: 88rpx;
line-height: 88rpx;
text-align: center;
}
.searchresult-tab view {
font-size: 32rpx;
flex: 1;
font-weight: 600;
position: relative;
color: #515559;
}
.searchresult-tab view.active {
color: #0d84d1;
}
.searchresult-tab view.active .active-bg {
position: absolute;
display: block;
width: 68rpx;
height: 25rpx;
background-color: rgba(13, 132, 209, 0.1);
bottom: 15rpx;
left: 50%;
transform: translateX(-50%);
border-radius: 30rpx;
}
.nodata {
text-align: center;
}
.nodata .img {
width: 600rpx;
height: 393rpx;
margin: 0 auto;
}
.nodata .h3 {
font-weight: 600;
font-size: 48rpx;
color: #2e3033;
}
.nodata .p {
font-size: 26rpx;
color: #8a9299;
margin-top: 14rpx;
}
.nodata .fb_btn {
margin:40rpx 55rpx 0
margin-top:40rpx
}
.t-desc {
background-color: #0d84d1;
color: #fff;
font-size: 26rpx;
padding: 24rpx 24rpx 62rpx;
}
.company {
flex: 1;
}
.company .bao {
flex: 0 0 87rpx;
height: 36rpx;
text-align: center;
line-height: 36rpx;
border-radius: 2rpx;
margin-right: 24rpx;
}
.company .name {
font-size: 32rpx;
flex: 1;
}
.top .icon {
font-size: 40rpx;
}
.bottom {
flex-wrap: wrap;
}
.bottom .yes {
margin: 24rpx 24rpx 0 0;
}
.yes .icon {
color: #61a0f2;
font-size: 30rpx;
margin-right: 12rpx;
}
.xb-com-content {
top: -22rpx;
}
.xb-com-content .desc {
border: none;
}
.xb-com-content .desc .left .bjsj .t-com {
flex: 0 0 130rpx;
}
.bjsj .c-com, .bz .c-com {
color: #8a9299;
}
.desc-xj-detail view{
padding-top:16rpx;
}
.zxgt {
position: absolute;
bottom: 94rpx;
left: 0;
right: 0;
}
.zxgt .icon {
margin-right: 7rpx;
font-size: 40rpx;
vertical-align: middle;
}
.form-view {
}
.tip {
padding: 12rpx 24rpx;
background-color: #fff6e6;
}
.tip .close-icon {
color: #d8dfe6;
}
.tip .icon {
font-size: 30rpx;
}
.tip-left {
color: #eaa217;
}
.tip-left .tip-icon {
margin-right: 7rpx;
vertical-align: middle;
}
.tip-c {
font-size: 24rpx;
}
.tip-c .pc-url{
color:#61A0F2;
}
.form-item {
margin-left: 24rpx;
padding: 27rpx 0;
font-size: 28rpx;
color: #515559;
position: relative;
}
.form-item .placeholderClass {
color: #adb6bf;
font-size: 28rpx;
}
.form-item-title {
flex: 0 0 71rpx;
text-align: right;
}
.form-item-right {
flex: 1;
padding: 0 24rpx 0 117rpx;
}
.bj-item .price-type {
border-left: 1px solid #d8dfe6;
}
.price-type .price-value {
font-size: 32rpx;
color: #515559;
padding: 7rpx 11rpx 7rpx 16rpx;
}
.price-type .icon {
color: #d8dfe6;
font-size: 26rpx;
}
.qx-item {
text-align: right;
}
.qx-item radio {
margin-left: 50rpx;
}
.form-hr {
height: 10rpx;
background-color: #f5f9fc;
}
textarea {
width: 100%;
height: 150rpx;
}
.hf-btn {
margin: 60rpx 55rpx;
}
.price-ul {
position: absolute;
top: 100rpx;
right: 24rpx;
background-color: #fff;
box-shadow: 2px 2px 5px #ddd;
z-index: 2;
border-radius: 2rpx;
display: none;
}
.price-ul.show {
display: block;
}
.price-ul .price-li {
padding: 25rpx 40rpx;
text-align: center;
font-size: 32rpx;
}
.price-ul .price-li.active {
color: #0d84d1;
}
.hf-btn .icon {
margin-right: 8rpx;
font-size: 32rpx;
}
.upload-view{
margin:20rpx 0;
}
.upload-view .upload{
height:220rpx;
width:220rpx;
background-color: #F0F6FA;
color:#8A9299;
font-size: 24rpx;
}
.upload-view .upload .icon{
font-size: 80rpx;
margin-bottom:20rpx;
}
.upload-view .text{
color:#ADB6BF;
font-size: 22rpx;
margin-top:25rpx;
}
\ No newline at end of file
This diff could not be displayed because it is too large.
function DOMParser(options) {
this.options = options || {locator: {}};
}
DOMParser.prototype.parseFromString = function (source, mimeType) {
var options = this.options;
var sax = new XMLReader();
var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler
var errorHandler = options.errorHandler;
var locator = options.locator;
var defaultNSMap = options.xmlns || {};
var entityMap = {'lt': '<', 'gt': '>', 'amp': '&', 'quot': '"', 'apos': "'"}
if (locator) {
domBuilder.setDocumentLocator(locator)
}
sax.errorHandler = buildErrorHandler(errorHandler, domBuilder, locator);
sax.domBuilder = options.domBuilder || domBuilder;
if (/\/x?html?$/.test(mimeType)) {
entityMap.nbsp = '\xa0';
entityMap.copy = '\xa9';
defaultNSMap[''] = 'http://www.w3.org/1999/xhtml';
}
defaultNSMap.xml = defaultNSMap.xml || 'http://www.w3.org/XML/1998/namespace';
if (source) {
sax.parse(source, defaultNSMap, entityMap);
} else {
sax.errorHandler.error("invalid document source");
}
return domBuilder.document;
}
function buildErrorHandler(errorImpl, domBuilder, locator) {
if (!errorImpl) {
if (domBuilder instanceof DOMHandler) {
return domBuilder;
}
errorImpl = domBuilder;
}
var errorHandler = {}
var isCallback = errorImpl instanceof Function;
locator = locator || {}
function build(key) {
var fn = errorImpl[key];
if (!fn && isCallback) {
fn = errorImpl.length == 2 ? function (msg) {
errorImpl(key, msg)
} : errorImpl;
}
errorHandler[key] = fn && function (msg) {
fn('[xmldom ' + key + ']\t' + msg + _locator(locator));
} || function () {
};
}
build('warning');
build('error');
build('fatalError');
return errorHandler;
}
//console.log('#\n\n\n\n\n\n\n####')
/**
* +ContentHandler+ErrorHandler
* +LexicalHandler+EntityResolver2
* -DeclHandler-DTDHandler
*
* DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler
* DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2
* @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html
*/
function DOMHandler() {
this.cdata = false;
}
function position(locator, node) {
node.lineNumber = locator.lineNumber;
node.columnNumber = locator.columnNumber;
}
/**
* @see org.xml.sax.ContentHandler#startDocument
* @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
*/
DOMHandler.prototype = {
startDocument: function () {
this.document = new DOMImplementation().createDocument(null, null, null);
if (this.locator) {
this.document.documentURI = this.locator.systemId;
}
},
startElement: function (namespaceURI, localName, qName, attrs) {
var doc = this.document;
var el = doc.createElementNS(namespaceURI, qName || localName);
var len = attrs.length;
appendElement(this, el);
this.currentElement = el;
this.locator && position(this.locator, el)
for (var i = 0; i < len; i++) {
var namespaceURI = attrs.getURI(i);
var value = attrs.getValue(i);
var qName = attrs.getQName(i);
var attr = doc.createAttributeNS(namespaceURI, qName);
if (attr.getOffset) {
position(attr.getOffset(1), attr)
}
attr.value = attr.nodeValue = value;
el.setAttributeNode(attr)
}
},
endElement: function (namespaceURI, localName, qName) {
var current = this.currentElement;
var tagName = current.tagName;
this.currentElement = current.parentNode;
},
startPrefixMapping: function (prefix, uri) {
},
endPrefixMapping: function (prefix) {
},
processingInstruction: function (target, data) {
var ins = this.document.createProcessingInstruction(target, data);
this.locator && position(this.locator, ins)
appendElement(this, ins);
},
ignorableWhitespace: function (ch, start, length) {
},
characters: function (chars, start, length) {
chars = _toString.apply(this, arguments)
//console.log(chars)
if (this.currentElement && chars) {
if (this.cdata) {
var charNode = this.document.createCDATASection(chars);
this.currentElement.appendChild(charNode);
} else {
var charNode = this.document.createTextNode(chars);
this.currentElement.appendChild(charNode);
}
this.locator && position(this.locator, charNode)
}
},
skippedEntity: function (name) {
},
endDocument: function () {
this.document.normalize();
},
setDocumentLocator: function (locator) {
if (this.locator = locator) {// && !('lineNumber' in locator)){
locator.lineNumber = 0;
}
},
//LexicalHandler
comment: function (chars, start, length) {
chars = _toString.apply(this, arguments)
var comm = this.document.createComment(chars);
this.locator && position(this.locator, comm)
appendElement(this, comm);
},
startCDATA: function () {
//used in characters() methods
this.cdata = true;
},
endCDATA: function () {
this.cdata = false;
},
startDTD: function (name, publicId, systemId) {
var impl = this.document.implementation;
if (impl && impl.createDocumentType) {
var dt = impl.createDocumentType(name, publicId, systemId);
this.locator && position(this.locator, dt)
appendElement(this, dt);
}
},
/**
* @see org.xml.sax.ErrorHandler
* @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
*/
warning: function (error) {
//console.warn('[xmldom warning]\t' + error, _locator(this.locator));
},
error: function (error) {
//console.error('[xmldom error]\t' + error, _locator(this.locator));
},
fatalError: function (error) {
//console.error('[xmldom fatalError]\t' + error, _locator(this.locator));
throw error;
}
}
function _locator(l) {
if (l) {
return '\n@' + (l.systemId || '') + '#[line:' + l.lineNumber + ',col:' + l.columnNumber + ']'
}
}
function _toString(chars, start, length) {
if (typeof chars == 'string') {
return chars.substr(start, length)
} else {//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
if (chars.length >= start + length || start) {
return new java.lang.String(chars, start, length) + '';
}
return chars;
}
}
/*
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
* used method of org.xml.sax.ext.LexicalHandler:
* #comment(chars, start, length)
* #startCDATA()
* #endCDATA()
* #startDTD(name, publicId, systemId)
*
*
* IGNORED method of org.xml.sax.ext.LexicalHandler:
* #endDTD()
* #startEntity(name)
* #endEntity(name)
*
*
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
* IGNORED method of org.xml.sax.ext.DeclHandler
* #attributeDecl(eName, aName, type, mode, value)
* #elementDecl(name, model)
* #externalEntityDecl(name, publicId, systemId)
* #internalEntityDecl(name, value)
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
* IGNORED method of org.xml.sax.EntityResolver2
* #resolveEntity(String name,String publicId,String baseURI,String systemId)
* #resolveEntity(publicId, systemId)
* #getExternalSubset(name, baseURI)
* @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
* IGNORED method of org.xml.sax.DTDHandler
* #notationDecl(name, publicId, systemId) {};
* #unparsedEntityDecl(name, publicId, systemId, notationName) {};
*/
"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g, function (key) {
DOMHandler.prototype[key] = function () {
return null
}
})
/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
function appendElement(hander, node) {
if (!hander.currentElement) {
hander.document.appendChild(node);
} else {
hander.currentElement.appendChild(node);
}
}//appendChild and setAttributeNS are preformance key
if (typeof require == 'function') {
var XMLReader = require('./sax').XMLReader;
var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation;
var XMLSerializer = exports.XMLSerializer = require('./dom').XMLSerializer;
exports.DOMParser = DOMParser;
var DOMParser = {
DOMImplementation: DOMImplementation,
XMLSerializer: XMLSerializer,
DOMParser: DOMParser
}
module.exports = DOMParser
}
var StropheAll = require("./libs/strophe");
(function(){
var _utils = require("./utils").utils;
var Message = function(type, id){
if(!(this instanceof Message)){
return new Message(type);
}
this._msg = {};
if(typeof Message[type] === "function"){
Message[type].prototype.setGroup = this.setGroup;
this._msg = new Message[type](id);
}
return this._msg;
};
Message.prototype.setGroup = function(group){
this.body.group = group;
};
/*
* Read Message
*/
Message.read = function(id){
this.id = id;
this.type = "read";
};
Message.read.prototype.set = function(opt){
this.body = {
ackId: opt.id
, to: opt.to
};
};
/*
* text message
*/
Message.txt = function(id){
this.id = id;
this.type = "txt";
this.body = {};
};
Message.txt.prototype.set = function(opt){
this.value = opt.msg;
this.body = {
id: this.id,
from: opt.from,
to: opt.to,
msg: this.value,
type: this.type,
roomType: opt.roomType,
chatType: opt.chatType,
ext: opt.ext || {},
success: opt.success,
fail: opt.fail
};
!opt.roomType && delete this.body.roomType;
};
/*
* cmd message
*/
Message.cmd = function(id){
this.id = id;
this.type = "cmd";
this.body = {};
};
Message.cmd.prototype.set = function(opt){
this.value = "";
this.body = {
to: opt.to,
from: opt.from,
action: opt.action,
msg: this.value,
type: this.type,
roomType: opt.roomType,
ext: opt.ext || {}
};
!opt.roomType && delete this.body.roomType;
};
/*
* loc message
*/
Message.location = function(id){
this.id = id;
this.type = "loc";
this.body = {};
};
Message.location.prototype.set = function(opt){
this.body = {
to: opt.to,
from: opt.from,
type: this.type,
roomType: opt.roomType,
addr: opt.addr,
lat: opt.lat,
lng: opt.lng,
chatType: opt.chatType,
ext: opt.ext || {}
};
};
/*
* img message
*/
Message.img = function(id){
this.id = id;
this.type = "img";
this.body = {};
};
Message.img.prototype.set = function(opt){
// opt.file = opt.file || _utils.getFileUrl(opt.fileInputId);
// //console.log(opt)
this.value = opt.file;
this.body = {
id: this.id,
file: this.value,
apiUrl: opt.apiUrl,
to: opt.to,
from: opt.from,
type: this.type,
ext: opt.ext || {},
roomType: opt.roomType,
onFileUploadError: opt.onFileUploadError,
onFileUploadComplete: opt.onFileUploadComplete,
success: opt.success,
fail: opt.fail,
flashUpload: opt.flashUpload,
width: opt.width,
height: opt.height,
body: opt.body
};
!opt.roomType && delete this.body.roomType;
};
/*
* audio message
*/
Message.audio = function(id){
this.id = id;
this.type = "audio";
this.body = {};
};
Message.audio.prototype.set = function(opt){
opt.file = opt.file || _utils.getFileUrl(opt.fileInputId);
this.value = opt.file;
this.filename = opt.filename || this.value.filename;
this.body = {
id: this.id,
file: this.value,
filename: this.filename,
apiUrl: opt.apiUrl,
accessToken: opt.accessToken,
to: opt.to,
from: opt.from,
type: this.type,
ext: opt.ext || {},
length: opt.length || 0,
roomType: opt.roomType,
file_length: opt.file_length,
onFileUploadError: opt.onFileUploadError,
onFileUploadComplete: opt.onFileUploadComplete,
success: opt.success,
fail: opt.fail,
flashUpload: opt.flashUpload,
body: opt.body
};
!opt.roomType && delete this.body.roomType;
};
/*
* file message
*/
Message.file = function(id){
this.id = id;
this.type = "file";
this.body = {};
};
Message.file.prototype.set = function(opt){
opt.file = opt.file || _utils.getFileUrl(opt.fileInputId);
this.value = opt.file;
this.filename = opt.filename || this.value.filename;
this.body = {
id: this.id,
file: this.value,
filename: this.filename,
apiUrl: opt.apiUrl,
to: opt.to,
from: opt.from,
type: this.type,
ext: opt.ext || {},
roomType: opt.roomType,
onFileUploadError: opt.onFileUploadError,
onFileUploadComplete: opt.onFileUploadComplete,
success: opt.success,
fail: opt.fail,
flashUpload: opt.flashUpload,
body: opt.body
};
!opt.roomType && delete this.body.roomType;
};
/*
* video message
*/
Message.video = function(id){
this.id = id;
this.type = "file";
this.body = {};
};
Message.video.prototype.set = function(opt){
opt.file = opt.file || _utils.getFileUrl(opt.fileInputId);
this.value = opt.file;
this.filename = opt.filename || this.value.filename;
this.body = {
id: this.id,
file: this.value,
filename: this.filename,
apiUrl: opt.apiUrl,
to: opt.to,
from: opt.from,
type: this.type,
ext: opt.ext || {},
roomType: opt.roomType,
onFileUploadError: opt.onFileUploadError,
onFileUploadComplete: opt.onFileUploadComplete,
success: opt.success,
fail: opt.fail,
flashUpload: opt.flashUpload,
body: opt.body
};
!opt.roomType && delete this.body.roomType;
};
function _Message(message){
if(!(this instanceof _Message)){
return new _Message(message);
}
this.msg = message;
}
_Message.prototype.send = function(conn){
var me = this;
var _send = function(message){
message.ext = message.ext || {};
message.ext.weichat = message.ext.weichat || {};
message.ext.weichat.originType = message.ext.weichat.originType || "webim";
let json = {
from: conn.context.userId || "",
to: message.to,
bodies: [message.body],
ext: message.ext || {},
};
let jsonstr = _utils.stringify(json);
let dom = StropheAll
.$msg({
type: message.group || "chat",
to: message.toJid,
id: message.id,
xmlns: "jabber:client",
})
.c("body")
.t(jsonstr);
if(message.roomType){
dom
.up()
.c("roomtype", {
xmlns: "easemob:x:roomtype",
type: "chatroom"
});
}
if(message.bodyId){
dom = StropheAll
.$msg({
from: conn.context.jid || "",
to: message.toJid,
id: message.id,
xmlns: "jabber:client"
})
.c("body")
.t(message.bodyId);
let delivery = {
xmlns: "urn:xmpp:receipts",
id: message.bodyId
};
dom.up().c("delivery", delivery);
}
if(message.ackId){
if(conn.context.jid.indexOf(message.toJid) >= 0){
return;
}
dom = StropheAll.$msg({
from: conn.context.jid || ""
, to: message.toJid
, id: message.id
, xmlns: "jabber:client"
}).c("body").t(message.ackId);
let read = {
xmlns: "urn:xmpp:receipts"
, id: message.ackId
};
dom.up().c("acked", read);
}
// setTimeout(function(){
// if(typeof _msgHash !== "undefined" && _msgHash[message.id]){
// _msgHash[message.id].msg.fail instanceof Function
// && _msgHash[message.id].msg.fail(message.id);
// }
// }, 60000);
conn.sendCommand(dom.tree(), message.id);
};
if(me.msg.file){
if(me.msg.body && me.msg.body.url){// Only send msg
_send(me.msg);
return;
}
let _tmpComplete = me.msg.onFileUploadComplete;
let _complete = function(data){
if(data.entities[0]["file-metadata"]){
let file_len = data.entities[0]["file-metadata"]["content-length"];
me.msg.file_length = file_len;
me.msg.filetype = data.entities[0]["file-metadata"]["content-type"];
if(file_len > 204800){
me.msg.thumbnail = true;
}
}
me.msg.body = {
type: me.msg.type || "file",
url: data.uri + "/" + data.entities[0].uuid,
secret: data.entities[0]["share-secret"],
filename: me.msg.file.filename || me.msg.filename,
size: {
width: me.msg.width || 0
, height: me.msg.height || 0
},
length: me.msg.length || 0,
file_length: me.msg.file_length || 0,
filetype: me.msg.filetype,
};
_send(me.msg);
_tmpComplete instanceof Function && _tmpComplete(data, me.msg.id);
};
me.msg.onFileUploadComplete = _complete;
_utils.uploadFile.call(conn, me.msg);
}
else if(me.msg.type === "img"){ // 添加img判断规则 wjy
_send(me.msg);
}
else{
me.msg.body = {
type: me.msg.type === "chat" ? "txt" : me.msg.type
, msg: me.msg.msg
};
if(me.msg.type === "cmd"){
me.msg.body.action = me.msg.action;
}
else if(me.msg.type === "loc"){
me.msg.body.addr = me.msg.addr;
me.msg.body.lat = me.msg.lat;
me.msg.body.lng = me.msg.lng;
}
_send(me.msg);
}
};
exports._msg = _Message;
exports.message = Message;
}());
This diff could not be displayed because it is too large.
const fs = require('fs');
const path = require('path');
fs.readFile(path.join(__dirname, './build/output/connection.js'), 'utf8', function (err, data) {
var newContent = "var " + data;
fs.writeFile(path.join(__dirname, './build/output/connection.js'), newContent, 'utf8', (err) => {
if (err) {
console.log(err);
}
console.log('success done');
});
})
{
"name": "sdk",
"version": "1.0.0",
"description": "",
"main": "connection.js",
"scripts": {
"build": "parcel build connection.js NODE_ENV=production -d build/output; node package.buildxcx.js"
},
"keywords": [
"sdk"
],
"author": "",
"license": "ISC",
"devDependencies": {
"parcel-bundler": "^1.12.0",
"rollup-plugin-commonjs": "^9.2.1",
"webpack": "^4.29.6",
"webpack-cli": "^3.2.3"
}
}
(function(){
function Array_h(length){
this.array = length === undefined ? [] : new Array(length);
}
Array_h.prototype = {
/**
* 返回数组长度
*
* @return {Number} length [数组长度]
*/
length: function(){
return this.array.length;
},
at: function(index){
return this.array[index];
},
set: function(index, obj){
this.array[index] = obj;
},
/**
* 向数组的末尾添加一个或多个元素,并返回新的长度。
*
* @param {*} obj [description]
* @return {Number} length [新数组的长度]
*/
push: function(obj){
return this.array.push(obj);
},
/**
* 返回数组中选定的元素
*
* @param {Number} start [开始索引值]
* @param {Number} end [结束索引值]
* @return {Array} newArray [新的数组]
*/
slice: function(start, end){
this.array = this.array.slice(start, end);
return this.array;
},
concat: function(array){
this.array = this.array.concat(array);
},
remove: function(index, count){
count = count === undefined ? 1 : count;
this.array.splice(index, count);
},
join: function(separator){
return this.array.join(separator);
},
clear: function(){
this.array.length = 0;
}
};
/**
* 先进先出队列 (First Input First Output)
*
* 一种先进先出的数据缓存器
*/
let Queue = function(){
this._array_h = new Array_h();
};
Queue.prototype = {
_index: 0,
/**
* 排队
*
* @param {Object} obj [description]
* @return {[type]} [description]
*/
push: function(obj){
this._array_h.push(obj);
},
/**
* 出队
*
* @return {Object} [description]
*/
pop: function(){
var ret = null;
if(this._array_h.length()){
ret = this._array_h.at(this._index);
if(++this._index * 2 >= this._array_h.length()){
this._array_h.slice(this._index);
this._index = 0;
}
}
return ret;
},
/**
* 返回队列中头部(即最新添加的)的动态对象
*
* @return {Object} [description]
*/
head: function(){
var ret = null, len = this._array_h.length();
if(len){
ret = this._array_h.at(len - 1);
}
return ret;
},
/**
* 返回队列中尾部(即最早添加的)的动态对象
*
* @return {Object} [description]
*/
tail: function(){
var ret = null, len = this._array_h.length();
if(len){
ret = this._array_h.at(this._index);
}
return ret;
},
/**
* 返回数据队列长度
*
* @return {Number} [description]
*/
length: function(){
return this._array_h.length() - this._index;
},
/**
* 队列是否为空
*
* @return {Boolean} [description]
*/
empty: function(){
return (this._array_h.length() === 0);
},
clear: function(){
this._array_h.clear();
}
};
exports.Queue = Queue;
}());
(function(){
var connIndex = 0;
exports.code = {
WEBIM_CONNCTION_USER_NOT_ASSIGN_ERROR: connIndex++,
WEBIM_CONNCTION_OPEN_ERROR: connIndex++,
WEBIM_CONNCTION_AUTH_ERROR: connIndex++,
WEBIM_CONNCTION_OPEN_USERGRID_ERROR: connIndex++,
WEBIM_CONNCTION_ATTACH_ERROR: connIndex++,
WEBIM_CONNCTION_ATTACH_USERGRID_ERROR: connIndex++,
WEBIM_CONNCTION_REOPEN_ERROR: connIndex++,
WEBIM_CONNCTION_SERVER_CLOSE_ERROR: connIndex++, // 7: client-side network offline (net::ERR_INTERNET_DISCONNECTED)
WEBIM_CONNCTION_SERVER_ERROR: connIndex++, // 8: offline by multi login
WEBIM_CONNCTION_IQ_ERROR: connIndex++,
WEBIM_CONNCTION_PING_ERROR: connIndex++,
WEBIM_CONNCTION_NOTIFYVERSION_ERROR: connIndex++,
WEBIM_CONNCTION_GETROSTER_ERROR: connIndex++,
WEBIM_CONNCTION_CROSSDOMAIN_ERROR: connIndex++,
WEBIM_CONNCTION_LISTENING_OUTOF_MAXRETRIES: connIndex++,
WEBIM_CONNCTION_RECEIVEMSG_CONTENTERROR: connIndex++,
WEBIM_CONNCTION_DISCONNECTED: connIndex++, // 16: server-side close the websocket connection
WEBIM_CONNCTION_AJAX_ERROR: connIndex++,
WEBIM_CONNCTION_JOINROOM_ERROR: connIndex++,
WEBIM_CONNCTION_GETROOM_ERROR: connIndex++,
WEBIM_CONNCTION_GETROOMINFO_ERROR: connIndex++,
WEBIM_CONNCTION_GETROOMMEMBER_ERROR: connIndex++,
WEBIM_CONNCTION_GETROOMOCCUPANTS_ERROR: connIndex++,
WEBIM_CONNCTION_LOAD_CHATROOM_ERROR: connIndex++,
WEBIM_CONNCTION_NOT_SUPPORT_CHATROOM_ERROR: connIndex++,
WEBIM_CONNCTION_JOINCHATROOM_ERROR: connIndex++,
WEBIM_CONNCTION_QUITCHATROOM_ERROR: connIndex++,
WEBIM_CONNCTION_APPKEY_NOT_ASSIGN_ERROR: connIndex++,
WEBIM_CONNCTION_TOKEN_NOT_ASSIGN_ERROR: connIndex++,
WEBIM_CONNCTION_SESSIONID_NOT_ASSIGN_ERROR: connIndex++,
WEBIM_CONNCTION_RID_NOT_ASSIGN_ERROR: connIndex++,
WEBIM_CONNCTION_CALLBACK_INNER_ERROR: connIndex++,
WEBIM_CONNCTION_CLIENT_OFFLINE: connIndex++, // 32: client offline
WEBIM_CONNCTION_CLIENT_LOGOUT: connIndex++, // 33: client logout
WEBIM_UPLOADFILE_BROWSER_ERROR: 100,
WEBIM_UPLOADFILE_ERROR: 101,
WEBIM_UPLOADFILE_NO_LOGIN: 102,
WEBIM_UPLOADFILE_NO_FILE: 103,
WEBIM_DOWNLOADFILE_ERROR: 200,
WEBIM_DOWNLOADFILE_NO_LOGIN: 201,
WEBIM_DOWNLOADFILE_BROWSER_ERROR: 202,
WEBIM_MESSAGE_REC_TEXT: 300,
WEBIM_MESSAGE_REC_TEXT_ERROR: 301,
WEBIM_MESSAGE_REC_EMOTION: 302,
WEBIM_MESSAGE_REC_PHOTO: 303,
WEBIM_MESSAGE_REC_AUDIO: 304,
WEBIM_MESSAGE_REC_AUDIO_FILE: 305,
WEBIM_MESSAGE_REC_VEDIO: 306,
WEBIM_MESSAGE_REC_VEDIO_FILE: 307,
WEBIM_MESSAGE_REC_FILE: 308,
WEBIM_MESSAGE_SED_TEXT: 309,
WEBIM_MESSAGE_SED_EMOTION: 310,
WEBIM_MESSAGE_SED_PHOTO: 311,
WEBIM_MESSAGE_SED_AUDIO: 312,
WEBIM_MESSAGE_SED_AUDIO_FILE: 313,
WEBIM_MESSAGE_SED_VEDIO: 314,
WEBIM_MESSAGE_SED_VEDIO_FILE: 315,
WEBIM_MESSAGE_SED_FILE: 316,
STATUS_INIT: 400,
STATUS_DOLOGIN_USERGRID: 401,
STATUS_DOLOGIN_IM: 402,
STATUS_OPENED: 403,
STATUS_CLOSING: 404,
STATUS_CLOSED: 405,
STATUS_ERROR: 406,
};
}());
var dispCbs = [];
var dispIns = [];
function Dispatcher(){
dispIns.push(this);
dispCbs.push({});
}
Dispatcher.prototype = {
on(type, cb){
let cbtypes = dispCbs[dispIns.indexOf(this)];
let cbs = cbtypes[type] = (cbtypes[type] || []);
if(!~cbs.indexOf(cb)){
cbs.push(cb);
}
},
off(type, cb){
let cbtypes = dispCbs[dispIns.indexOf(this)];
let cbs = cbtypes[type] = (cbtypes[type] || []);
let curTypeCbIdx = cbs.indexOf(cb);
if(~curTypeCbIdx){
cbs.splice(curTypeCbIdx, 1);
}
},
fire(type, ...args){
let cbtypes = dispCbs[dispIns.indexOf(this)];
let cbs = cbtypes[type] = (cbtypes[type] || []);
for(let i = 0; i < cbs.length; i++){
cbs[i].apply(null, args);
}
}
};
module.exports = Dispatcher;
var obsCbs = obsCbs || [];
var obsObjs = obsObjs || [];
var cloneObjs = cloneObjs || [];
function newOne(obj){
obsObjs.push(obj);
obsCbs.push([]);
cloneObjs.push(Object.assign({}, obj));
}
module.exports = {
del(obj, cb){
let curObjIdx = obsObjs.indexOf(obj);
if(~curObjIdx){
let cbs = obsCbs[curObjIdx];
let curCbIdx = cbs.indexOf(cb);
if(~curCbIdx){
cbs.splice(curCbIdx, 1);
if(!cbs.length){
obsObjs.splice(curObjIdx, 1);
}
}
}
},
add(obj, cb){
let curIdx = obsObjs.indexOf(obj);
if(!~curIdx){
curIdx = obsObjs.length;
newOne(obj);
}
let cbs = obsCbs[curIdx];
cbs.push(cb);
for(let key in obj){
Object.defineProperty(obj, key, {
set: function(val){
cloneObjs[curIdx][key] = val;
for(let i = 0; i < cbs.length; i++){
cbs[i].apply(obj, [val, key]);
}
},
get: function(){
return cloneObjs[curIdx][key];
}
});
}
return obj;
},
};
import Strophe from "../sdk/libs/strophe";
//import xmldom from "../sdk/libs/xmldom/dom-parser";
import websdk from "../sdk/connection";
import config from "./WebIMConfig";
console.group = console.group || {};
console.groupEnd = console.groupEnd || {};
var window = {};
let WebIM = window.WebIM = websdk;
window.WebIM.config = config;
//var DOMParser = window.DOMParser = xmldom.DOMParser;
//let document = window.document = new DOMParser().parseFromString("<?xml version='1.0'?>\n", "text/xml");
WebIM.isDebug = function(option){
if (option) {
WebIM.config.isDebug = option.isDebug
openDebug(WebIM.config.isDebug)
}
function openDebug(value){
function ts(){
var d = new Date();
var Hours = d.getHours(); // 获取当前小时数(0-23)
var Minutes = d.getMinutes(); // 获取当前分钟数(0-59)
var Seconds = d.getSeconds(); // 获取当前秒数(0-59)
return (Hours < 10 ? "0" + Hours : Hours) + ":" + (Minutes < 10 ? "0" + Minutes : Minutes) + ":" + (Seconds < 10 ? "0" + Seconds : Seconds) + " ";
}
Strophe.Strophe.log = function(level, msg){
// console.log(ts(), level, msg);
};
if (value) {
Strophe.Strophe.Connection.prototype.rawOutput = function(data){
try{
console.group("%csend # " + ts(), "color: blue; font-size: large");
console.log("%c" + data, "color: blue");
console.groupEnd();
}
catch(e){
console.log(e);
}
};
}else{
Strophe.Strophe.Connection.prototype.rawOutput = function(){};
}
}
}
/**
* Set autoSignIn as true (autoSignInName and autoSignInPwd are configured below),
* You can auto signed in each time when you refresh the page in dev model.
*/
WebIM.config.autoSignIn = false;
if(WebIM.config.autoSignIn){
WebIM.config.autoSignInName = "lwz2";
WebIM.config.autoSignInPwd = "1";
}
// var stropheConn = new window.Strophe.Connection("ws://im-api.easemob.com/ws/", {
// inactivity: 30,
// maxRetries: 5,
// pollingTime: 4500
// });
//
// stropheConn.connect(
// '$t$' + 'YWMtmbQEBKKIEeaGmMtXyg5n1wAAAVlkQvGO2WOJGlMCEJKM4VV9GCMnb_XLCXU',
// function() {
// console.log(arguments, 'ggogogo');
// }, stropheConn.wait, stropheConn.hold);
WebIM.parseEmoji = function(msg){
if(typeof WebIM.Emoji === "undefined" || typeof WebIM.Emoji.map === "undefined"){
return msg;
}
var emoji = WebIM.Emoji,
reg = null;
var msgList = [];
var objList = [];
for(var face in emoji.map){
if(emoji.map.hasOwnProperty(face)){
while(msg.indexOf(face) > -1){
msg = msg.replace(face, "^" + emoji.map[face] + "^");
}
}
}
var ary = msg.split("^");
var reg = /^e.*g$/;
for(var i = 0; i < ary.length; i++){
if(ary[i] != ""){
msgList.push(ary[i]);
}
}
for(var i = 0; i < msgList.length; i++){
if(reg.test(msgList[i])){
var obj = {};
obj.data = msgList[i];
obj.type = "emoji";
objList.push(obj);
}
else{
var obj = {};
obj.data = msgList[i];
obj.type = "txt";
objList.push(obj);
}
}
return objList;
};
WebIM.time = function(){
var date = new Date();
var Hours = date.getHours();
var Minutes = date.getMinutes();
var Seconds = date.getSeconds();
var time = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " "
+ (Hours < 10 ? "0" + Hours : Hours) + ":" + (Minutes < 10 ? "0" + Minutes : Minutes) + ":" + (Seconds < 10 ? "0" + Seconds : Seconds);
return time;
};
WebIM.Emoji = {
path: "../../../../../images/faces/",
map: {
"[):]": "ee_1.png",
"[:D]": "ee_2.png",
"[;)]": "ee_3.png",
"[:-o]": "ee_4.png",
"[:p]": "ee_5.png",
"[(H)]": "ee_6.png",
"[:@]": "ee_7.png",
"[:s]": "ee_8.png",
"[:$]": "ee_9.png",
"[:(]": "ee_10.png",
"[:'(]": "ee_11.png",
"[<o)]": "ee_12.png",
"[(a)]": "ee_13.png",
"[8o|]": "ee_14.png",
"[8-|]": "ee_15.png",
"[+o(]": "ee_16.png",
"[|-)]": "ee_17.png",
"[:|]": "ee_18.png",
"[*-)]": "ee_19.png",
"[:-#]": "ee_20.png",
"[^o)]": "ee_21.png",
"[:-*]": "ee_22.png",
"[8-)]": "ee_23.png",
"[del]": "btn_del.png",
"[(|)]": "ee_24.png",
"[(u)]": "ee_25.png",
"[(S)]": "ee_26.png",
"[(*)]": "ee_27.png",
"[(#)]": "ee_28.png",
"[(R)]": "ee_29.png",
"[({)]": "ee_30.png",
"[(})]": "ee_31.png",
"[(k)]": "ee_32.png",
"[(F)]": "ee_33.png",
"[(W)]": "ee_34.png",
"[(D)]": "ee_35.png"
}
};
WebIM.EmojiObj = {
// 相对 emoji.js 路径
path: "../../../../../images/faces/",
map1: {
"[):]": "ee_1.png",
"[:D]": "ee_2.png",
"[;)]": "ee_3.png",
"[:-o]": "ee_4.png",
"[:p]": "ee_5.png",
"[(H)]": "ee_6.png",
"[:@]": "ee_7.png"
},
map2: {
"[:s]": "ee_8.png",
"[:$]": "ee_9.png",
"[:(]": "ee_10.png",
"[:'(]": "ee_11.png",
"[<o)]": "ee_12.png",
"[(a)]": "ee_13.png",
"[8o|]": "ee_14.png"
},
map3: {
"[8-|]": "ee_15.png",
"[+o(]": "ee_16.png",
"[|-)]": "ee_17.png",
"[:|]": "ee_18.png",
"[*-)]": "ee_19.png",
"[:-#]": "ee_20.png",
"[del]": "del.png"
},
map4: {
"[^o)]": "ee_21.png",
"[:-*]": "ee_22.png",
"[8-)]": "ee_23.png",
"[(|)]": "ee_24.png",
"[(u)]": "ee_25.png",
"[(S)]": "ee_26.png",
"[(*)]": "ee_27.png"
},
map5: {
"[(#)]": "ee_28.png",
"[(R)]": "ee_29.png",
"[({)]": "ee_30.png",
"[(})]": "ee_31.png",
"[(k)]": "ee_32.png",
"[(F)]": "ee_33.png",
"[(W)]": "ee_34.png",
"[(D)]": "ee_35.png"
},
map6: {
"[del]": "del.png"
}
};
// wx.connectSocket({url: WebIM.config.xmppURL, method: "GET"})
WebIM.conn = new WebIM.connection({
isMultiLoginSessions: WebIM.config.isMultiLoginSessions,
https: typeof WebIM.config.https === "boolean" ? WebIM.config.https : location.protocol === "https:",
url: WebIM.config.xmppURL,
apiUrl: WebIM.config.apiURL,
isAutoLogin: false,
heartBeatWait: WebIM.config.heartBeatWait,
autoReconnectNumMax: WebIM.config.autoReconnectNumMax,
autoReconnectInterval: WebIM.config.autoReconnectInterval
});
// async response
// WebIM.conn.listen({
// onOpened: () => dispatch({type: Types.ON_OPEND})
// })
// export default WebIM;
module.exports = {
"default": WebIM
};
/**
* git do not control webim.config.js
* everyone should copy webim.config.js to webim.config.js
* and have their own configs.
* In this way , others won't be influenced by this config while git pull.
*
*/
// for react native
let location = {
protocol: "https"
};
let config = {
/*
* XMPP server
*/
xmppURL: "wss://im-api.easemob.com/ws/",
// xmppURL: '172.17.3.122:5280',
/*
* Backend REST API URL
*/
// apiURL: (location.protocol === 'https:' ? 'https:' : 'http:') + '//a1.easemob.com',
// ios must be https!!! by lwz
apiURL: "https://a1.easemob.com",
// apiURL: (location.protocol === 'https:' ? 'https:' : 'http:') + '//172.17.3.155:8080',
/*
* Application AppKey
*/
appkey: "easemob-demo#chatdemoui",
/*
* Whether to use HTTPS '1177161227178308#xcx'
* @parameter {Boolean} true or false
*/
https: false,
/*
* isMultiLoginSessions
* true: A visitor can sign in to multiple webpages and receive messages at all the webpages.
* false: A visitor can sign in to only one webpage and receive messages at the webpage.
*/
isMultiLoginSessions: false,
/**
* Whether to use window.doQuery()
* @parameter {Boolean} true or false
*/
isWindowSDK: false,
/**
* isSandBox=true: xmppURL: 'im-api.sandbox.easemob.com', apiURL: '//a1.sdb.easemob.com',
* isSandBox=false: xmppURL: 'im-api.easemob.com', apiURL: '//a1.easemob.com',
* @parameter {Boolean} true or false
*/
isSandBox: false,
/**
* Whether to console.log in strophe.log()
* @parameter {Boolean} true or false
*/
isDebug: false,
/**
* will auto connect the xmpp server autoReconnectNumMax times in background when client is offline.
* won't auto connect if autoReconnectNumMax=0.
*/
autoReconnectNumMax: 15,
/**
* the interval secons between each atuo reconnectting.
* works only if autoReconnectMaxNum >= 2.
*/
autoReconnectInterval: 2,
/**
* webrtc supports WebKit and https only
*/
isWebRTC: false,
/*
* Set to auto sign-in
*/
isAutoLogin: true
};
export default config;
var Dispatcher = require("./Dispatcher");
module.exports = new Dispatcher();
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