add
This commit is contained in:
parent
b8aaa100b4
commit
6605fe5571
|
@ -99,6 +99,10 @@ export const vipRechargeApi = (data) => {
|
||||||
return request.post('/store/store/recharge', data);
|
return request.post('/store/store/recharge', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const reVipRechargeApi = (data) => {
|
||||||
|
return request.post('/store/store/again_recharge', data);
|
||||||
|
}
|
||||||
|
|
||||||
export const rechargeCountApi = (data) => {
|
export const rechargeCountApi = (data) => {
|
||||||
return request.get('/store/store/recharge_count', data);
|
return request.get('/store/store/recharge_count', data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
let BASE_URL
|
let BASE_URL
|
||||||
|
let WSS_URL
|
||||||
import store from "@/store/user.js"
|
import store from "@/store/user.js"
|
||||||
// 环境
|
// 环境
|
||||||
let env = "dev"
|
let env = "dev"
|
||||||
|
@ -8,12 +9,15 @@ let env = "dev"
|
||||||
switch (env) {
|
switch (env) {
|
||||||
case 'dev':
|
case 'dev':
|
||||||
BASE_URL = 'https://test-multi-store.lihaink.cn';
|
BASE_URL = 'https://test-multi-store.lihaink.cn';
|
||||||
|
WSS_URL = 'wss://test-multi-store.lihaink.cn/pull'
|
||||||
break;
|
break;
|
||||||
case 'liu':
|
case 'liu':
|
||||||
BASE_URL = 'http://192.168.1.201:8545';
|
BASE_URL = 'http://192.168.1.201:8545';
|
||||||
|
WSS_URL = 'wss://test-multi-store.lihaink.cn/pull'
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BASE_URL = 'https://multi-store.lihaink.cn';
|
BASE_URL = 'https://multi-store.lihaink.cn';
|
||||||
|
WSS_URL = 'wss://test-multi-store.lihaink.cn/pull'
|
||||||
}
|
}
|
||||||
|
|
||||||
let HTTP_REQUEST_URL
|
let HTTP_REQUEST_URL
|
||||||
|
@ -21,6 +25,7 @@ let HEADER
|
||||||
|
|
||||||
let config = {
|
let config = {
|
||||||
HTTP_REQUEST_URL: BASE_URL,
|
HTTP_REQUEST_URL: BASE_URL,
|
||||||
|
WSS_URL: WSS_URL,
|
||||||
HEADER: {
|
HEADER: {
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
//#ifdef MP
|
//#ifdef MP
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
<view class="li" v-for="(item,index) in lists" :key="index">
|
<view class="li" v-for="(item,index) in lists" :key="index">
|
||||||
<view class="li-top">
|
<view class="li-top">
|
||||||
<text>{{item.title}}</text>
|
<text>{{item.title}}</text>
|
||||||
<text style="font-weight: bold;" :style="{color:item.financial_pm?'#50C758':'red'
|
<text style="font-weight: bold;" :style="{color:!item.financial_pm?'#50C758':'red'
|
||||||
}">{{ item.financial_pm?'+':'-' }}{{item.number}}</text>
|
}">{{ !item.financial_pm?'+':'-' }}{{item.number}}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="li-top" style="margin-bottom: 0;">
|
<view class="li-top" style="margin-bottom: 0;">
|
||||||
<text style="font-size: 24rpx;color: grey;">{{item.create_time}}</text>
|
<text style="font-size: 24rpx;color: grey;">{{item.create_time}}</text>
|
||||||
|
@ -33,8 +33,8 @@
|
||||||
<view class="li" v-for="(item,index) in lists" :key="index">
|
<view class="li" v-for="(item,index) in lists" :key="index">
|
||||||
<view class="li-top">
|
<view class="li-top">
|
||||||
<text>{{item.order_sn}}</text>
|
<text>{{item.order_sn}}</text>
|
||||||
<text style="font-weight: bold;" :style="{color:item.status?'#50C758':'red'
|
<text style="font-weight: bold;" :style="{color:!item.status?'#50C758':'red'
|
||||||
}">{{ item.status?'+':'-' }}{{item.number}}</text>
|
}">{{ !item.status?'+':'-' }}{{item.number}}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="li-top" style="margin-bottom: 0;">
|
<view class="li-top" style="margin-bottom: 0;">
|
||||||
<text style="font-size: 24rpx;color: grey;">{{item.create_time}}</text>
|
<text style="font-size: 24rpx;color: grey;">{{item.create_time}}</text>
|
||||||
|
@ -68,10 +68,10 @@
|
||||||
name: '全部'
|
name: '全部'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '支出'
|
name: '收入'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '收入'
|
name: '支出'
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -81,7 +81,6 @@
|
||||||
getLists()
|
getLists()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const lists = ref([])
|
const lists = ref([])
|
||||||
let type = ref('')
|
let type = ref('')
|
||||||
const getLists = async (isPullDown = false) => {
|
const getLists = async (isPullDown = false) => {
|
||||||
|
|
|
@ -28,19 +28,19 @@
|
||||||
{{Role==1?'行业会员':'商户'}}开通报备
|
{{Role==1?'行业会员':'商户'}}开通报备
|
||||||
</view>
|
</view>
|
||||||
<up-form labelPosition="left" :model="formData" :borderBottom='false'>
|
<up-form labelPosition="left" :model="formData" :borderBottom='false'>
|
||||||
<up-form-item label="" prop="userInfo.name">
|
<up-form-item label="">
|
||||||
<up-input v-model="formData.real_name" border="none" prefixIcon="account" placeholder="请输入真实姓名"
|
<up-input v-model="formData.real_name" border="none" prefixIcon="account" placeholder="请输入真实姓名"
|
||||||
:customStyle="{background:'#F3F3F3',padding:'20rpx','border-radius':'30rpx'}"
|
:customStyle="{background:'#F3F3F3',padding:'20rpx','border-radius':'30rpx'}"
|
||||||
:placeholderStyle="{color:'#444444'}"
|
:placeholderStyle="{color:'#444444'}"
|
||||||
:prefixIconStyle="{'margin-right':'40rpx'}"></up-input>
|
:prefixIconStyle="{'margin-right':'40rpx'}"></up-input>
|
||||||
</up-form-item>
|
</up-form-item>
|
||||||
<up-form-item label="" prop="userInfo.name">
|
<up-form-item label="">
|
||||||
<up-input v-model="formData.mobile" border="none" prefixIcon="phone" placeholder="请输入电话号码"
|
<up-input v-model="formData.mobile" border="none" prefixIcon="phone" placeholder="请输入电话号码"
|
||||||
:customStyle="{background:'#F3F3F3',padding:'20rpx','border-radius':'30rpx'}"
|
:customStyle="{background:'#F3F3F3',padding:'20rpx','border-radius':'30rpx'}"
|
||||||
:placeholderStyle="{color:'#444444'}"
|
:placeholderStyle="{color:'#444444'}"
|
||||||
:prefixIconStyle="{'margin-right':'40rpx'}"></up-input>
|
:prefixIconStyle="{'margin-right':'40rpx'}"></up-input>
|
||||||
</up-form-item>
|
</up-form-item>
|
||||||
<up-form-item label="" prop="userInfo.name">
|
<up-form-item label="">
|
||||||
<view @click="showPop=true" style="width: 100%;">
|
<view @click="showPop=true" style="width: 100%;">
|
||||||
<up-input style="pointer-events: none" v-model="formData.address" border="none"
|
<up-input style="pointer-events: none" v-model="formData.address" border="none"
|
||||||
prefixIcon="map" readonly placeholder="点击选择地址" :customStyle="{background:'#F3F3F3',padding:'20rpx',
|
prefixIcon="map" readonly placeholder="点击选择地址" :customStyle="{background:'#F3F3F3',padding:'20rpx',
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
</view>
|
</view>
|
||||||
</up-form-item>
|
</up-form-item>
|
||||||
|
|
||||||
<up-form-item label="" prop="userInfo.name" v-if='Role==1'>
|
<up-form-item label="" v-if='Role==1'>
|
||||||
<view @click="showPop1=true" style="width: 100%;">
|
<view @click="showPop1=true" style="width: 100%;">
|
||||||
<up-input style="pointer-events: none" v-model="formData.label_name" border="none"
|
<up-input style="pointer-events: none" v-model="formData.label_name" border="none"
|
||||||
prefixIcon="man-add" readonly placeholder="点击选择用户身份" :customStyle="{background:'#F3F3F3',padding:'20rpx',
|
prefixIcon="man-add" readonly placeholder="点击选择用户身份" :customStyle="{background:'#F3F3F3',padding:'20rpx',
|
||||||
|
@ -107,15 +107,21 @@
|
||||||
<uni-td style="font-size: 20rpx;" align="center" v-if='Role==1'>{{item.label_name}}</uni-td>
|
<uni-td style="font-size: 20rpx;" align="center" v-if='Role==1'>{{item.label_name}}</uni-td>
|
||||||
<uni-td style="font-size: 20rpx;" align="center">
|
<uni-td style="font-size: 20rpx;" align="center">
|
||||||
<view v-if="item.paid ==1 ||Role==4">已开通</view>
|
<view v-if="item.paid ==1 ||Role==4">已开通</view>
|
||||||
<view v-else @click="upadtaStatus(item)" style="color:#33B83A ;">未开通,查询</view>
|
<view v-else style="color:#33B83A ;">
|
||||||
|
<view @click="upadtaStatus(item)">
|
||||||
|
未开通,查询
|
||||||
|
</view>
|
||||||
|
<view @click="rePay(item)">
|
||||||
|
重新支付
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</uni-td>
|
</uni-td>
|
||||||
</uni-tr>
|
</uni-tr>
|
||||||
</uni-table>
|
</uni-table>
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
</view>
|
</view>
|
||||||
|
<view style="height: 50rpx;" />
|
||||||
|
|
||||||
|
|
||||||
<!-- 地址选择器 -->
|
<!-- 地址选择器 -->
|
||||||
<up-popup :show="showPop" @close="showPop=false" @open="showPop=true" :round="10">
|
<up-popup :show="showPop" @close="showPop=false" @open="showPop=true" :round="10">
|
||||||
|
@ -169,6 +175,7 @@
|
||||||
reactive,
|
reactive,
|
||||||
ref
|
ref
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
|
import useUserStore from "@/store/user";
|
||||||
import {
|
import {
|
||||||
provinceListApi,
|
provinceListApi,
|
||||||
cityListApi,
|
cityListApi,
|
||||||
|
@ -180,6 +187,7 @@
|
||||||
import {
|
import {
|
||||||
vipRechargeApi,
|
vipRechargeApi,
|
||||||
rechargeCountApi,
|
rechargeCountApi,
|
||||||
|
reVipRechargeApi,
|
||||||
rechargeListsApi,
|
rechargeListsApi,
|
||||||
updataOrderApi,
|
updataOrderApi,
|
||||||
getStoreByPhone,
|
getStoreByPhone,
|
||||||
|
@ -187,11 +195,59 @@
|
||||||
getUserShip,
|
getUserShip,
|
||||||
getCreateLists
|
getCreateLists
|
||||||
} from "@/api/user.js"
|
} from "@/api/user.js"
|
||||||
|
import Push from "@/utils/push.js"
|
||||||
import {
|
import {
|
||||||
onPullDownRefresh,
|
onPullDownRefresh,
|
||||||
onLoad
|
onLoad
|
||||||
} from "@dcloudio/uni-app"
|
} from "@dcloudio/uni-app"
|
||||||
|
import {
|
||||||
|
config
|
||||||
|
} from "@/config/app.js"
|
||||||
|
|
||||||
|
|
||||||
|
// scoket
|
||||||
|
let timer = null
|
||||||
|
const userInfo = useUserStore().userInfo;
|
||||||
|
const connection = new Push({
|
||||||
|
url: config.WSS_URL, // websocket地址
|
||||||
|
app_key: '2ce3ce22329517213caa7dad261f5695',
|
||||||
|
});
|
||||||
|
|
||||||
|
// 浏览器监听user-1
|
||||||
|
const user_channel = connection.subscribe(`wechat_mmp_${userInfo.id}}`);
|
||||||
|
|
||||||
|
user_channel.on('message', function(data) {
|
||||||
|
console.log("收到消息--", data);
|
||||||
|
try {
|
||||||
|
if (timer) clearTimeout(timer);
|
||||||
|
uni.hideLoading()
|
||||||
|
currentTab.value = 2
|
||||||
|
formData.real_name = ''
|
||||||
|
formData.mobile = ''
|
||||||
|
formData.address = ''
|
||||||
|
formData.label_name = ''
|
||||||
|
formData.city = ''
|
||||||
|
formData.area = ''
|
||||||
|
formData.street = ''
|
||||||
|
formData.village = ''
|
||||||
|
formData.brigade = ''
|
||||||
|
currentAddressIndex.value = 0
|
||||||
|
tabsList.forEach(item => {
|
||||||
|
item.name = '请选择'
|
||||||
|
})
|
||||||
|
getLists()
|
||||||
|
getCount()
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 断线事件
|
||||||
|
user_channel.on('close', function() {
|
||||||
|
|
||||||
|
});
|
||||||
|
// scoket结束
|
||||||
|
|
||||||
|
|
||||||
const showPop1 = ref(false)
|
const showPop1 = ref(false)
|
||||||
const Role = ref('')
|
const Role = ref('')
|
||||||
|
@ -377,22 +433,28 @@
|
||||||
formData.recharge_type = 'INDUSTRYMEMBERS'
|
formData.recharge_type = 'INDUSTRYMEMBERS'
|
||||||
formData.user_ship = 1
|
formData.user_ship = 1
|
||||||
vipRechargeApi(formData).then(res => {
|
vipRechargeApi(formData).then(res => {
|
||||||
uni.$u.toast('操作成功');
|
uni.showLoading({
|
||||||
currentTab.value = 2
|
title: '支付中...'
|
||||||
formData.real_name = ''
|
});
|
||||||
formData.mobile = ''
|
timer = setTimeout(() => {
|
||||||
formData.address = ''
|
uni.hideLoading();
|
||||||
formData.label_name = ''
|
uni.$u.toast('支付超时');
|
||||||
formData.city = ''
|
// formData.real_name = ''
|
||||||
formData.area = ''
|
// formData.mobile = ''
|
||||||
formData.street = ''
|
// formData.address = ''
|
||||||
formData.village = ''
|
// formData.label_name = ''
|
||||||
formData.brigade = ''
|
// formData.city = ''
|
||||||
currentAddressIndex.value = 0
|
// formData.area = ''
|
||||||
|
// formData.street = ''
|
||||||
|
// formData.village = ''
|
||||||
|
// formData.brigade = ''
|
||||||
|
// currentAddressIndex.value = 0
|
||||||
|
// tabsList.forEach(item => {
|
||||||
|
// item.name = '请选择'
|
||||||
|
// })
|
||||||
|
}, 30000)
|
||||||
|
|
||||||
tabsList.forEach(item => {
|
// uni.$u.toast('操作成功');
|
||||||
item.name = '请选择'
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
})
|
||||||
getCount()
|
getCount()
|
||||||
|
@ -426,6 +488,24 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const rePay = (item) => {
|
||||||
|
uni.scanCode({
|
||||||
|
success: function(res) {
|
||||||
|
reVipRechargeApi({
|
||||||
|
id: item.id,
|
||||||
|
auth_code: res.result
|
||||||
|
}).then(res => {
|
||||||
|
uni.$u.toast('操作成功');
|
||||||
|
getCount()
|
||||||
|
getLists()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 邀请用户数
|
// 邀请用户数
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
const getCount = async () => {
|
const getCount = async () => {
|
||||||
|
@ -451,7 +531,6 @@
|
||||||
})
|
})
|
||||||
lists.value = res.data.lists
|
lists.value = res.data.lists
|
||||||
count.value = res.data.count
|
count.value = res.data.count
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -464,13 +543,15 @@
|
||||||
updataOrderApi({
|
updataOrderApi({
|
||||||
order_no: item.order_id,
|
order_no: item.order_id,
|
||||||
recharge: 1
|
recharge: 1
|
||||||
|
}).then(res => {
|
||||||
|
getCount()
|
||||||
|
getLists()
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
getUserShip().then(res => {
|
getUserShip().then(res => {
|
||||||
console.log(res)
|
|
||||||
|
|
||||||
range.value = res.data.lists.map(item => {
|
range.value = res.data.lists.map(item => {
|
||||||
return {
|
return {
|
||||||
value: item.id,
|
value: item.id,
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "个人中心",
|
"navigationBarTitleText": "个人中心",
|
||||||
"enablePullDownRefresh": true,
|
"enablePullDownRefresh": true,
|
||||||
"navigationStyle": "custom"
|
"navigationBarBackgroundColor": "#D3FDCA"
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"path": "pages/charge/charge_record",
|
"path": "pages/charge/charge_record",
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
</style>
|
</style>
|
||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
<up-navbar title="我的" :autoBack="true" bgColor="transparent" :fixed="true">
|
<!-- <up-navbar title="我的" :autoBack="true" bgColor="transparent" :fixed="true">
|
||||||
</up-navbar>
|
</up-navbar> -->
|
||||||
<view class="user-info">
|
<view class="user-info">
|
||||||
<image class="bg" src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/e3a7b202404261113002322.webp"
|
<image class="bg" src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/e3a7b202404261113002322.webp"
|
||||||
mode="widthFix"></image>
|
mode="widthFix"></image>
|
||||||
|
@ -198,7 +198,7 @@
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 750rpx;
|
width: 750rpx;
|
||||||
height: 350rpx;
|
height: 250rpx;
|
||||||
|
|
||||||
.bg {
|
.bg {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -212,7 +212,7 @@
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 50rpx 0 50rpx 50rpx;
|
padding: 50rpx 0 50rpx 50rpx;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 150rpx;
|
top: 50rpx;
|
||||||
left: 0;
|
left: 0;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
240
utils/push.js
240
utils/push.js
|
@ -1,6 +1,4 @@
|
||||||
|
function Push(options) {
|
||||||
|
|
||||||
export const Push = function Push(options) {
|
|
||||||
this.doNotConnect = 0;
|
this.doNotConnect = 0;
|
||||||
options = options || {};
|
options = options || {};
|
||||||
options.heartbeat = options.heartbeat || 25000;
|
options.heartbeat = options.heartbeat || 25000;
|
||||||
|
@ -47,6 +45,7 @@ Push.prototype.createConnection = function () {
|
||||||
}
|
}
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var url = this.config.url;
|
var url = this.config.url;
|
||||||
|
|
||||||
function updateSubscribed() {
|
function updateSubscribed() {
|
||||||
for (var i in _this.channels) {
|
for (var i in _this.channels) {
|
||||||
_this.channels[i].subscribed = false;
|
_this.channels[i].subscribed = false;
|
||||||
|
@ -76,7 +75,8 @@ Push.prototype.createConnection = function () {
|
||||||
if (event === 'pusher:error') {
|
if (event === 'pusher:error') {
|
||||||
throw Error(params.data.message);
|
throw Error(params.data.message);
|
||||||
}
|
}
|
||||||
var data = JSON.parse(params.data), channel;
|
var data = JSON.parse(params.data),
|
||||||
|
channel;
|
||||||
if (event === 'pusher_internal:subscription_succeeded') {
|
if (event === 'pusher_internal:subscription_succeeded') {
|
||||||
channel = _this.channels[channel_name];
|
channel = _this.channels[channel_name];
|
||||||
channel.subscribed = true;
|
channel.subscribed = true;
|
||||||
|
@ -125,7 +125,12 @@ Push.prototype.unsubscribe = function (channel_name) {
|
||||||
if (this.channels[channel_name]) {
|
if (this.channels[channel_name]) {
|
||||||
delete this.channels[channel_name];
|
delete this.channels[channel_name];
|
||||||
if (this.connection.state === 'connected') {
|
if (this.connection.state === 'connected') {
|
||||||
this.connection.send(JSON.stringify({event:"pusher:unsubscribe", data:{channel:channel_name}}));
|
this.connection.send(JSON.stringify({
|
||||||
|
event: "pusher:unsubscribe",
|
||||||
|
data: {
|
||||||
|
channel: channel_name
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -154,30 +159,39 @@ Push.prototype.subscribe = function (channel_name) {
|
||||||
};
|
};
|
||||||
Push.instances = [];
|
Push.instances = [];
|
||||||
|
|
||||||
function createChannel(channel_name, push)
|
function createChannel(channel_name, push) {
|
||||||
{
|
|
||||||
var channel = new Channel(push.connection, channel_name);
|
var channel = new Channel(push.connection, channel_name);
|
||||||
push.channels[channel_name] = channel;
|
push.channels[channel_name] = channel;
|
||||||
channel.subscribeCb = function() {
|
channel.subscribeCb = function() {
|
||||||
push.connection.send(JSON.stringify({event:"pusher:subscribe", data:{channel:channel_name}}));
|
push.connection.send(JSON.stringify({
|
||||||
|
event: "pusher:subscribe",
|
||||||
|
data: {
|
||||||
|
channel: channel_name
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
channel.processSubscribe();
|
channel.processSubscribe();
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPrivateChannel(channel_name, push)
|
function createPrivateChannel(channel_name, push) {
|
||||||
{
|
|
||||||
var channel = new Channel(push.connection, channel_name);
|
var channel = new Channel(push.connection, channel_name);
|
||||||
push.channels[channel_name] = channel;
|
push.channels[channel_name] = channel;
|
||||||
channel.subscribeCb = function() {
|
channel.subscribeCb = function() {
|
||||||
__ajax({
|
__ajax({
|
||||||
url: push.config.auth,
|
url: push.config.auth,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: {channel_name: channel_name, socket_id: push.connection.socket_id},
|
data: {
|
||||||
|
channel_name: channel_name,
|
||||||
|
socket_id: push.connection.socket_id
|
||||||
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
data.channel = channel_name;
|
data.channel = channel_name;
|
||||||
push.connection.send(JSON.stringify({event:"pusher:subscribe", data:data}));
|
push.connection.send(JSON.stringify({
|
||||||
|
event: "pusher:subscribe",
|
||||||
|
data: data
|
||||||
|
}));
|
||||||
},
|
},
|
||||||
error: function(e) {
|
error: function(e) {
|
||||||
throw Error(e);
|
throw Error(e);
|
||||||
|
@ -188,13 +202,12 @@ function createPrivateChannel(channel_name, push)
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPresenceChannel(channel_name, push)
|
function createPresenceChannel(channel_name, push) {
|
||||||
{
|
|
||||||
return createPrivateChannel(channel_name, push);
|
return createPrivateChannel(channel_name, push);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*window.addEventListener('online', function(){
|
uni.onNetworkStatusChange(function(res) {
|
||||||
var con;
|
if (res.isConnected) {
|
||||||
for (var i in Push.instances) {
|
for (var i in Push.instances) {
|
||||||
con = Push.instances[i].connection;
|
con = Push.instances[i].connection;
|
||||||
con.reconnectInterval = 1;
|
con.reconnectInterval = 1;
|
||||||
|
@ -202,8 +215,8 @@ function createPresenceChannel(channel_name, push)
|
||||||
con.connect();
|
con.connect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});*/
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function Connection(options) {
|
function Connection(options) {
|
||||||
this.dispatcher = new Dispatcher();
|
this.dispatcher = new Dispatcher();
|
||||||
|
@ -225,10 +238,82 @@ Connection.prototype.updateNetworkState = function(state){
|
||||||
var old_state = this.state;
|
var old_state = this.state;
|
||||||
this.state = state;
|
this.state = state;
|
||||||
if (old_state !== state) {
|
if (old_state !== state) {
|
||||||
this.emit('state_change', { previous: old_state, current: state });
|
this.emit('state_change', {
|
||||||
|
previous: old_state,
|
||||||
|
current: state
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Connection.prototype.connect = function() {
|
||||||
|
this.doNotConnect = 0;
|
||||||
|
if (this.networkState == 'connecting' || this.networkState == 'established') {
|
||||||
|
console.log('networkState is ' + this.networkState + ' and do not need connect');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.reconnectTimer) {
|
||||||
|
clearTimeout(this.reconnectTimer);
|
||||||
|
this.reconnectTimer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.closeAndClean();
|
||||||
|
|
||||||
|
var options = this.options;
|
||||||
|
var _this = this;
|
||||||
|
_this.updateNetworkState('connecting');
|
||||||
|
var cb = function() {
|
||||||
|
uni.onSocketOpen(function(res) {
|
||||||
|
_this.reconnectInterval = 1;
|
||||||
|
if (_this.doNotConnect) {
|
||||||
|
_this.updateNetworkState('closing');
|
||||||
|
uni.closeSocket();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_this.updateNetworkState('established');
|
||||||
|
if (options.onOpen) {
|
||||||
|
options.onOpen(res);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (options.onMessage) {
|
||||||
|
uni.onSocketMessage(options.onMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.onSocketClose(function(res) {
|
||||||
|
_this.updateNetworkState('disconnected');
|
||||||
|
if (!_this.doNotConnect) {
|
||||||
|
_this.waitReconnect();
|
||||||
|
}
|
||||||
|
if (options.onClose) {
|
||||||
|
options.onClose(res);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
uni.onSocketError(function(res) {
|
||||||
|
_this.close();
|
||||||
|
if (!_this.doNotConnect) {
|
||||||
|
_this.waitReconnect();
|
||||||
|
}
|
||||||
|
if (options.onError) {
|
||||||
|
options.onError(res);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
uni.connectSocket({
|
||||||
|
url: options.url,
|
||||||
|
fail: function(res) {
|
||||||
|
console.log('uni.connectSocket fail');
|
||||||
|
console.log(res);
|
||||||
|
_this.updateNetworkState('disconnected');
|
||||||
|
_this.waitReconnect();
|
||||||
|
},
|
||||||
|
success: function() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
Connection.prototype.connect = function() {
|
Connection.prototype.connect = function() {
|
||||||
this.doNotConnect = 0;
|
this.doNotConnect = 0;
|
||||||
if (this.state === 'connected') {
|
if (this.state === 'connected') {
|
||||||
|
@ -243,29 +328,28 @@ Connection.prototype.connect = function () {
|
||||||
this.closeAndClean();
|
this.closeAndClean();
|
||||||
|
|
||||||
var options = this.options;
|
var options = this.options;
|
||||||
var websocket = new WebSocket(options.url+'/app/'+options.app_key);
|
|
||||||
|
|
||||||
this.updateNetworkState('connecting');
|
this.updateNetworkState('connecting');
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
websocket.onopen = function (res) {
|
var cb = function() {
|
||||||
|
uni.onSocketOpen(function(res) {
|
||||||
_this.reconnectInterval = 1;
|
_this.reconnectInterval = 1;
|
||||||
if (_this.doNotConnect) {
|
if (_this.doNotConnect) {
|
||||||
_this.updateNetworkState('disconnected');
|
_this.updateNetworkState('disconnected');
|
||||||
websocket.close();
|
uni.closeSocket();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (options.onOpen) {
|
if (options.onOpen) {
|
||||||
options.onOpen(res);
|
options.onOpen(res);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
if (options.onMessage) {
|
if (options.onMessage) {
|
||||||
websocket.onmessage = options.onMessage;
|
uni.onSocketMessage(options.onMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
websocket.onclose = function (res) {
|
uni.onSocketClose(function(res) {
|
||||||
websocket.onmessage = websocket.onopen = websocket.onclose = websocket.onerror = null;
|
|
||||||
_this.updateNetworkState('disconnected');
|
_this.updateNetworkState('disconnected');
|
||||||
if (!_this.doNotConnect) {
|
if (!_this.doNotConnect) {
|
||||||
_this.waitReconnect();
|
_this.waitReconnect();
|
||||||
|
@ -273,9 +357,9 @@ Connection.prototype.connect = function () {
|
||||||
if (options.onClose) {
|
if (options.onClose) {
|
||||||
options.onClose(res);
|
options.onClose(res);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
websocket.onerror = function (res) {
|
uni.onSocketError(function(res) {
|
||||||
_this.close();
|
_this.close();
|
||||||
if (!_this.doNotConnect) {
|
if (!_this.doNotConnect) {
|
||||||
_this.waitReconnect();
|
_this.waitReconnect();
|
||||||
|
@ -283,19 +367,28 @@ Connection.prototype.connect = function () {
|
||||||
if (options.onError) {
|
if (options.onError) {
|
||||||
options.onError(res);
|
options.onError(res);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
this.connection = websocket;
|
uni.connectSocket({
|
||||||
|
url: options.url + '/app/' + options.app_key,
|
||||||
|
fail: function(res) {
|
||||||
|
console.log('uni.connectSocket fail');
|
||||||
|
console.log(res);
|
||||||
|
_this.updateNetworkState('disconnected');
|
||||||
|
_this.waitReconnect();
|
||||||
|
},
|
||||||
|
success: function() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cb();
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection.prototype.closeAndClean = function() {
|
Connection.prototype.closeAndClean = function() {
|
||||||
if(this.connection) {
|
if (this.state === 'connected') {
|
||||||
var websocket = this.connection;
|
uni.closeSocket();
|
||||||
websocket.onmessage = websocket.onopen = websocket.onclose = websocket.onerror = null;
|
|
||||||
try {
|
|
||||||
websocket.close();
|
|
||||||
} catch (e) {}
|
|
||||||
this.updateNetworkState('disconnected');
|
|
||||||
}
|
}
|
||||||
|
this.updateNetworkState('disconnected');
|
||||||
};
|
};
|
||||||
|
|
||||||
Connection.prototype.waitReconnect = function() {
|
Connection.prototype.waitReconnect = function() {
|
||||||
|
@ -329,17 +422,25 @@ Connection.prototype.send = function(data) {
|
||||||
console.trace('networkState is "' + this.state + '", can not send ' + data);
|
console.trace('networkState is "' + this.state + '", can not send ' + data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.connection.send(data);
|
uni.sendSocketMessage({
|
||||||
|
data: data
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection.prototype.close = function() {
|
Connection.prototype.close = function() {
|
||||||
this.updateNetworkState('disconnected');
|
this.updateNetworkState('disconnected');
|
||||||
this.connection.close();
|
uni.closeSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
var __extends = (this && this.__extends) || function(d, b) {
|
var __extends = (this && this.__extends) || function(d, b) {
|
||||||
for (var p in b) if (b.hasOwnProperty(p)) {d[p] = b[p];}
|
for (var p in b)
|
||||||
function __() { this.constructor = d; }
|
if (b.hasOwnProperty(p)) {
|
||||||
|
d[p] = b[p];
|
||||||
|
}
|
||||||
|
|
||||||
|
function __() {
|
||||||
|
this.constructor = d;
|
||||||
|
}
|
||||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -380,7 +481,11 @@ Channel.prototype.trigger = function (event, data) {
|
||||||
}
|
}
|
||||||
var _this = this;
|
var _this = this;
|
||||||
this.queue.push(function() {
|
this.queue.push(function() {
|
||||||
_this.connection.send(JSON.stringify({ event: event, data: data, channel: _this.channelName }));
|
_this.connection.send(JSON.stringify({
|
||||||
|
event: event,
|
||||||
|
data: data,
|
||||||
|
channel: _this.channelName
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
this.processQueue();
|
this.processQueue();
|
||||||
};
|
};
|
||||||
|
@ -388,6 +493,7 @@ Channel.prototype.trigger = function (event, data) {
|
||||||
////////////////
|
////////////////
|
||||||
var Collections = (function() {
|
var Collections = (function() {
|
||||||
var exports = {};
|
var exports = {};
|
||||||
|
|
||||||
function extend(target) {
|
function extend(target) {
|
||||||
var sources = [];
|
var sources = [];
|
||||||
for (var _i = 1; _i < arguments.length; _i++) {
|
for (var _i = 1; _i < arguments.length; _i++) {
|
||||||
|
@ -399,8 +505,7 @@ var Collections = (function () {
|
||||||
if (extensions[property] && extensions[property].constructor &&
|
if (extensions[property] && extensions[property].constructor &&
|
||||||
extensions[property].constructor === Object) {
|
extensions[property].constructor === Object) {
|
||||||
target[property] = extend(target[property] || {}, extensions[property]);
|
target[property] = extend(target[property] || {}, extensions[property]);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
target[property] = extensions[property];
|
target[property] = extensions[property];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -409,13 +514,13 @@ var Collections = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.extend = extend;
|
exports.extend = extend;
|
||||||
|
|
||||||
function stringify() {
|
function stringify() {
|
||||||
var m = ["Push"];
|
var m = ["Push"];
|
||||||
for (var i = 0; i < arguments.length; i++) {
|
for (var i = 0; i < arguments.length; i++) {
|
||||||
if (typeof arguments[i] === "string") {
|
if (typeof arguments[i] === "string") {
|
||||||
m.push(arguments[i]);
|
m.push(arguments[i]);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
m.push(safeJSONStringify(arguments[i]));
|
m.push(safeJSONStringify(arguments[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -423,6 +528,7 @@ var Collections = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.stringify = stringify;
|
exports.stringify = stringify;
|
||||||
|
|
||||||
function arrayIndexOf(array, item) {
|
function arrayIndexOf(array, item) {
|
||||||
var nativeIndexOf = Array.prototype.indexOf;
|
var nativeIndexOf = Array.prototype.indexOf;
|
||||||
if (array === null) {
|
if (array === null) {
|
||||||
|
@ -440,6 +546,7 @@ var Collections = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.arrayIndexOf = arrayIndexOf;
|
exports.arrayIndexOf = arrayIndexOf;
|
||||||
|
|
||||||
function objectApply(object, f) {
|
function objectApply(object, f) {
|
||||||
for (var key in object) {
|
for (var key in object) {
|
||||||
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
||||||
|
@ -449,6 +556,7 @@ var Collections = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.objectApply = objectApply;
|
exports.objectApply = objectApply;
|
||||||
|
|
||||||
function keys(object) {
|
function keys(object) {
|
||||||
var keys = [];
|
var keys = [];
|
||||||
objectApply(object, function(_, key) {
|
objectApply(object, function(_, key) {
|
||||||
|
@ -458,6 +566,7 @@ var Collections = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.keys = keys;
|
exports.keys = keys;
|
||||||
|
|
||||||
function values(object) {
|
function values(object) {
|
||||||
var values = [];
|
var values = [];
|
||||||
objectApply(object, function(value) {
|
objectApply(object, function(value) {
|
||||||
|
@ -467,6 +576,7 @@ var Collections = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.values = values;
|
exports.values = values;
|
||||||
|
|
||||||
function apply(array, f, context) {
|
function apply(array, f, context) {
|
||||||
for (var i = 0; i < array.length; i++) {
|
for (var i = 0; i < array.length; i++) {
|
||||||
f.call(context || (window), array[i], i, array);
|
f.call(context || (window), array[i], i, array);
|
||||||
|
@ -474,6 +584,7 @@ var Collections = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.apply = apply;
|
exports.apply = apply;
|
||||||
|
|
||||||
function map(array, f) {
|
function map(array, f) {
|
||||||
var result = [];
|
var result = [];
|
||||||
for (var i = 0; i < array.length; i++) {
|
for (var i = 0; i < array.length; i++) {
|
||||||
|
@ -483,6 +594,7 @@ var Collections = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.map = map;
|
exports.map = map;
|
||||||
|
|
||||||
function mapObject(object, f) {
|
function mapObject(object, f) {
|
||||||
var result = {};
|
var result = {};
|
||||||
objectApply(object, function(value, key) {
|
objectApply(object, function(value, key) {
|
||||||
|
@ -492,6 +604,7 @@ var Collections = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.mapObject = mapObject;
|
exports.mapObject = mapObject;
|
||||||
|
|
||||||
function filter(array, test) {
|
function filter(array, test) {
|
||||||
test = test || function(value) {
|
test = test || function(value) {
|
||||||
return !!value;
|
return !!value;
|
||||||
|
@ -506,6 +619,7 @@ var Collections = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.filter = filter;
|
exports.filter = filter;
|
||||||
|
|
||||||
function filterObject(object, test) {
|
function filterObject(object, test) {
|
||||||
var result = {};
|
var result = {};
|
||||||
objectApply(object, function(value, key) {
|
objectApply(object, function(value, key) {
|
||||||
|
@ -517,6 +631,7 @@ var Collections = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.filterObject = filterObject;
|
exports.filterObject = filterObject;
|
||||||
|
|
||||||
function flatten(object) {
|
function flatten(object) {
|
||||||
var result = [];
|
var result = [];
|
||||||
objectApply(object, function(value, key) {
|
objectApply(object, function(value, key) {
|
||||||
|
@ -526,6 +641,7 @@ var Collections = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.flatten = flatten;
|
exports.flatten = flatten;
|
||||||
|
|
||||||
function any(array, test) {
|
function any(array, test) {
|
||||||
for (var i = 0; i < array.length; i++) {
|
for (var i = 0; i < array.length; i++) {
|
||||||
if (test(array[i], i, array)) {
|
if (test(array[i], i, array)) {
|
||||||
|
@ -536,6 +652,7 @@ var Collections = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.any = any;
|
exports.any = any;
|
||||||
|
|
||||||
function all(array, test) {
|
function all(array, test) {
|
||||||
for (var i = 0; i < array.length; i++) {
|
for (var i = 0; i < array.length; i++) {
|
||||||
if (!test(array[i], i, array)) {
|
if (!test(array[i], i, array)) {
|
||||||
|
@ -546,6 +663,7 @@ var Collections = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.all = all;
|
exports.all = all;
|
||||||
|
|
||||||
function encodeParamsObject(data) {
|
function encodeParamsObject(data) {
|
||||||
return mapObject(data, function(value) {
|
return mapObject(data, function(value) {
|
||||||
if (typeof value === "object") {
|
if (typeof value === "object") {
|
||||||
|
@ -556,6 +674,7 @@ var Collections = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.encodeParamsObject = encodeParamsObject;
|
exports.encodeParamsObject = encodeParamsObject;
|
||||||
|
|
||||||
function buildQueryString(data) {
|
function buildQueryString(data) {
|
||||||
var params = filterObject(data, function(value) {
|
var params = filterObject(data, function(value) {
|
||||||
return value !== undefined;
|
return value !== undefined;
|
||||||
|
@ -564,8 +683,10 @@ var Collections = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.buildQueryString = buildQueryString;
|
exports.buildQueryString = buildQueryString;
|
||||||
|
|
||||||
function decycleObject(object) {
|
function decycleObject(object) {
|
||||||
var objects = [], paths = [];
|
var objects = [],
|
||||||
|
paths = [];
|
||||||
return (function derez(value, path) {
|
return (function derez(value, path) {
|
||||||
var i, name, nu;
|
var i, name, nu;
|
||||||
switch (typeof value) {
|
switch (typeof value) {
|
||||||
|
@ -575,7 +696,9 @@ var Collections = (function () {
|
||||||
}
|
}
|
||||||
for (i = 0; i < objects.length; i += 1) {
|
for (i = 0; i < objects.length; i += 1) {
|
||||||
if (objects[i] === value) {
|
if (objects[i] === value) {
|
||||||
return {$ref: paths[i]};
|
return {
|
||||||
|
$ref: paths[i]
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
objects.push(value);
|
objects.push(value);
|
||||||
|
@ -585,8 +708,7 @@ var Collections = (function () {
|
||||||
for (i = 0; i < value.length; i += 1) {
|
for (i = 0; i < value.length; i += 1) {
|
||||||
nu[i] = derez(value[i], path + '[' + i + ']');
|
nu[i] = derez(value[i], path + '[' + i + ']');
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
nu = {};
|
nu = {};
|
||||||
for (name in value) {
|
for (name in value) {
|
||||||
if (Object.prototype.hasOwnProperty.call(value, name)) {
|
if (Object.prototype.hasOwnProperty.call(value, name)) {
|
||||||
|
@ -604,11 +726,11 @@ var Collections = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.decycleObject = decycleObject;
|
exports.decycleObject = decycleObject;
|
||||||
|
|
||||||
function safeJSONStringify(source) {
|
function safeJSONStringify(source) {
|
||||||
try {
|
try {
|
||||||
return JSON.stringify(source);
|
return JSON.stringify(source);
|
||||||
}
|
} catch (e) {
|
||||||
catch (e) {
|
|
||||||
return JSON.stringify(decycleObject(source));
|
return JSON.stringify(decycleObject(source));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -645,8 +767,7 @@ var Dispatcher = (function () {
|
||||||
for (i = 0; i < callbacks.length; i++) {
|
for (i = 0; i < callbacks.length; i++) {
|
||||||
callbacks[i].fn.call(callbacks[i].context || (window), data);
|
callbacks[i].fn.call(callbacks[i].context || (window), data);
|
||||||
}
|
}
|
||||||
}
|
} else if (this.failThrough) {
|
||||||
else if (this.failThrough) {
|
|
||||||
this.failThrough(eventName, data);
|
this.failThrough(eventName, data);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
@ -677,14 +798,14 @@ var CallbackRegistry = (function () {
|
||||||
var names = name ? [prefix(name)] : Collections.keys(this._callbacks);
|
var names = name ? [prefix(name)] : Collections.keys(this._callbacks);
|
||||||
if (callback || context) {
|
if (callback || context) {
|
||||||
this.removeCallback(names, callback, context);
|
this.removeCallback(names, callback, context);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.removeAllCallbacks(names);
|
this.removeAllCallbacks(names);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
CallbackRegistry.prototype.removeCallback = function(names, callback, context) {
|
CallbackRegistry.prototype.removeCallback = function(names, callback, context) {
|
||||||
Collections.apply(names, function(name) {
|
Collections.apply(names, function(name) {
|
||||||
this._callbacks[name] = Collections.filter(this._callbacks[name] || [], function (oning) {
|
this._callbacks[name] = Collections.filter(this._callbacks[name] || [], function(
|
||||||
|
oning) {
|
||||||
return (callback && callback !== oning.fn) ||
|
return (callback && callback !== oning.fn) ||
|
||||||
(context && context !== oning.context);
|
(context && context !== oning.context);
|
||||||
});
|
});
|
||||||
|
@ -700,6 +821,7 @@ var CallbackRegistry = (function () {
|
||||||
};
|
};
|
||||||
return CallbackRegistry;
|
return CallbackRegistry;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
function prefix(name) {
|
function prefix(name) {
|
||||||
return "_" + name;
|
return "_" + name;
|
||||||
}
|
}
|
||||||
|
@ -708,7 +830,7 @@ function __ajax(options){
|
||||||
options = options || {};
|
options = options || {};
|
||||||
options.type = (options.type || 'GET').toUpperCase();
|
options.type = (options.type || 'GET').toUpperCase();
|
||||||
options.dataType = options.dataType || 'json';
|
options.dataType = options.dataType || 'json';
|
||||||
params=formatParams(options.data);
|
var params = formatParams(options.data);
|
||||||
|
|
||||||
var xhr;
|
var xhr;
|
||||||
if (window.XMLHttpRequest) {
|
if (window.XMLHttpRequest) {
|
||||||
|
@ -746,6 +868,4 @@ function formatParams(data){
|
||||||
return arr.join('&');
|
return arr.join('&');
|
||||||
}
|
}
|
||||||
|
|
||||||
// export const push = {
|
export default Push
|
||||||
// a:6
|
|
||||||
// }
|
|
Loading…
Reference in New Issue