jbzfilmsdk
Advanced tools
Comparing version 1.0.4-beta6 to 1.1.0-beta0
@@ -7,3 +7,3 @@ import typescript from 'rollup-plugin-typescript'; | ||
module.exports = () => { | ||
return { | ||
return [{ | ||
input: './src/index.ts', | ||
@@ -16,2 +16,20 @@ output: { | ||
}, | ||
file: './dist/index.js', | ||
format: 'umd' | ||
}, | ||
plugins: [ | ||
json(), | ||
resolve(), | ||
commonjs(), | ||
typescript({lib: ["es5", "es6", "dom"], target: "es5"}) | ||
], | ||
external: [ 'moment', 'axios' ] | ||
}, { | ||
input: './src/index.ts', | ||
output: { | ||
name: 'jbzfilmsdk', | ||
globals: { | ||
moment: 'moment', | ||
axios: 'axios' | ||
}, | ||
file: './dist/index.min.js', | ||
@@ -28,3 +46,3 @@ format: 'umd' | ||
external: [ 'moment', 'axios' ] | ||
} | ||
}] | ||
}; |
@@ -1,3 +0,3 @@ | ||
import unify from './spd.network.unify'; | ||
import url from './spd.url.config' | ||
// import unify from './spd.network.unify'; | ||
// import url from './spd.url.config' | ||
import config from './JConfig'; | ||
@@ -26,7 +26,6 @@ | ||
class NetworkOther extends jbzfilmsdk.JNetworkOther{ | ||
class _NetworkOther extends jbzfilmsdk.JNetworkOther{ | ||
} | ||
const NetworkOther = revealNetwork(_NetworkOther, 'NetworkOther', config) | ||
const _NetworkOther = revealNetwork(NetworkOther, 'NetworkOther', config) | ||
let delegate = { | ||
@@ -46,2 +45,11 @@ globalBodyData: function () { | ||
return gp; | ||
}, | ||
requestInterceptor(config){ | ||
if (config.url === '/otaadmin/otaAdmin/city/getHotCities'){ | ||
config.url = '/test' | ||
config.params = { | ||
method: 'M00001' | ||
} | ||
} | ||
return config; | ||
} | ||
@@ -90,4 +98,5 @@ }; | ||
}), | ||
NetworkOther: new _NetworkOther({ | ||
baseUrl: 'http://10.1.1.70:10002/cmbc/', | ||
NetworkOther: new NetworkOther({ | ||
// baseUrl: 'http://10.1.1.70:10002/cmbc/', | ||
baseUrl: 'https://local.idoupiao.com', | ||
delegate, | ||
@@ -94,0 +103,0 @@ carryHeaders: function () { |
@@ -8,3 +8,3 @@ // import JNetworkBanner from './JNetworkBanner'; | ||
const DEFAULT_CONFIG = { | ||
const DEFAULT_NETWORK_CONFIG = { | ||
precook: (_) => _.data, | ||
@@ -20,6 +20,7 @@ cook: (_) => _, | ||
useBodyData: [], | ||
rule: [1, 0, 2] | ||
rule: [0, 1, 2] | ||
} | ||
export default { | ||
DEFAULT_NETWORK_CONFIG, | ||
// JNetworkBanner, | ||
@@ -36,8 +37,16 @@ // JNetworkCinema, | ||
} | ||
}, | ||
test: { | ||
url: '/otaadmin/otaAdmin/city/getHotCities', | ||
params: { | ||
page: true, | ||
pageSize: true, | ||
status: true | ||
}, | ||
headers: { | ||
authorization: false | ||
}, | ||
} | ||
} | ||
}; | ||
export { | ||
DEFAULT_CONFIG | ||
}; |
{ | ||
"name": "jbzfilmsdk", | ||
"version": "1.0.4-beta6", | ||
"version": "1.1.0-beta0", | ||
"description": "jinbaozheng film sdk", | ||
@@ -27,3 +27,5 @@ "main": "lib/index.js", | ||
"axios": "^0.18.0", | ||
"icemilk": "^1.0.9-beta11" | ||
"icemilk": "1.0.9-beta11", | ||
"jsencrypt": "^3.0.0-rc.1", | ||
"md5": "^2.2.1" | ||
}, | ||
@@ -30,0 +32,0 @@ "devDependencies": { |
@@ -5,2 +5,6 @@ /** | ||
/* eslint-disable */ | ||
import JNetworkAccount from './network/JNetworkAccount'; | ||
import JNetworkMine from './network/JNetworkMine'; | ||
import JNetworkTrade from './network/JNetworkTrade'; | ||
import JNetworkCity from './network/JNetworkCity'; | ||
import JNetworkBanner from './network/JNetworkBanner'; | ||
@@ -16,2 +20,6 @@ import JNetworkCinema from './network/JNetworkCinema'; | ||
export { | ||
JNetworkAccount, | ||
JNetworkMine, | ||
JNetworkTrade, | ||
JNetworkCity, | ||
JNetworkBanner, | ||
@@ -30,9 +38,9 @@ JNetworkCinema, | ||
import ManagerSeat from './util/JManagerSeat'; | ||
// import ManagerTrade from './util/JManagerTrade'; | ||
import ManagerTrade from './util/JManagerTrade'; | ||
export { | ||
JSDK, | ||
ManagerSeat as JManagerSeat, | ||
// ManagerTrade as JManagerTrade | ||
ManagerTrade as JManagerTrade | ||
}; | ||
/* eslint-enable */ |
import {JNetwork, INetworkStandardPromiseType, JNetworkGroup} from 'icemilk'; | ||
import JConfig from '../unify/JConfig'; | ||
import JEncryptionTool from './../util/JEncryptionTool'; | ||
const BUS_GW = '/bus/gw'; | ||
const DEFAULT_NETWORK_CONFIG = { | ||
precook: (_) => _.data, | ||
cook: (_) => _, | ||
method: 'get', | ||
url: '', | ||
book: null, | ||
params: {}, | ||
headers: {}, | ||
bodyData: {}, | ||
useParams: [], | ||
useHeaders: [], | ||
useBodyData: [], | ||
rule: [0, 1, 2], | ||
encryption: true | ||
} | ||
let _config: object = JConfig; | ||
@@ -39,2 +56,14 @@ export default class JNetworkWorker extends JNetwork{ | ||
// export const needSecret = (isNeed: boolean | (() => boolean)) => { | ||
// _config['DEF...']['encryption'] = isNeed | ||
// } | ||
// | ||
// needSecret(function () { | ||
// if (sdasdaw) | ||
// return true | ||
// else | ||
// return false | ||
// }) | ||
export const revealNetwork = function<T extends new(...args: any[]) => JNetworkWorker>(networkClass: T, networkName: string = networkClass.name, config?: object): T{ | ||
@@ -45,3 +74,8 @@ if (!JNetworkWorker.isPrototypeOf(networkClass)){ | ||
let classConfig = config ? config[networkName] : _config[networkName]; | ||
let defaultNetworkConfig = config ? config['DEFAULT_NETWORK_CONFIG'] : _config['DEFAULT_NETWORK_CONFIG']; | ||
// config[DEFAULT_NETWORK_CONFIG]为用户默认配置 _config['DEFAULT_NETWORK_CONFIG'] 为SDK默认配置 | ||
// 目前没有实现revealNetwork内部默认配置 | ||
let defaultNetworkConfig = { | ||
...DEFAULT_NETWORK_CONFIG, | ||
...(config ? config['DEFAULT_NETWORK_CONFIG'] : _config['DEFAULT_NETWORK_CONFIG']) | ||
} | ||
if (!classConfig){ | ||
@@ -112,3 +146,4 @@ if (config){ | ||
useHeaders, | ||
useBodyData | ||
useBodyData, | ||
encryption | ||
} = { | ||
@@ -121,3 +156,2 @@ ...defaultNetworkConfig, | ||
} | ||
// if (Array.isArray(params)){ | ||
@@ -132,2 +166,4 @@ // } else if (typeof params === 'object'){ | ||
networkClass.prototype[key] = function (...args) { | ||
// 解决url 闭包被修改,初始化地址 | ||
url = config.url; | ||
try { | ||
@@ -158,3 +194,13 @@ let networkArgs = args; | ||
}, useHeaders, url); | ||
if (encryption){ | ||
let b = this.config.inType; | ||
let paramsObj = JEncryptionTool.encryption(url, paramsValue, b); | ||
if (!paramsObj){ | ||
throw new Error(`url参数出错`); | ||
} | ||
url = BUS_GW; | ||
paramsValue = { | ||
...paramsObj, | ||
}; | ||
} | ||
let pizza = { | ||
@@ -161,0 +207,0 @@ params: paramsValue, |
@@ -0,1 +1,5 @@ | ||
import JNetworkAccount from './JNetworkAccount'; | ||
import JNetworkMine from './JNetworkMine'; | ||
import JNetworkTrade from './JNetworkTrade'; | ||
import JNetworkCity from './JNetworkCity'; | ||
import JNetworkBanner from './JNetworkBanner'; | ||
@@ -20,6 +24,11 @@ import JNetworkCinema from './JNetworkCinema'; | ||
useBodyData: [], | ||
rule: [1, 0, 2] | ||
rule: [0, 1, 2], | ||
encryption: true | ||
}; | ||
export default { | ||
JNetworkAccount, | ||
JNetworkMine, | ||
JNetworkTrade, | ||
JNetworkCity, | ||
JNetworkBanner, | ||
@@ -26,0 +35,0 @@ JNetworkCinema, |
@@ -1,5 +0,16 @@ | ||
function _netBanner(banner) { | ||
return {cityId:banner.cityId, column: banner.column, id: banner.id, imgUrl: banner.imgUrl, title: banner.title, href: banner.link}; | ||
} | ||
const JNetworkBanner = { | ||
banners: { | ||
url: '/banners' | ||
bannerList: { | ||
url: '/banner/banners', | ||
params: { | ||
location: true, | ||
cityId: false | ||
}, | ||
book: [ | ||
'location', | ||
'cityId' | ||
], | ||
cook: _=>_.map(_netBanner) | ||
} | ||
@@ -6,0 +17,0 @@ }; |
import {JToolDate} from 'icemilk' | ||
import JManagerSeat from './../util/JManagerSeat'; | ||
function _netcinema(cinema) { | ||
return { | ||
address: cinema.cinemaAddress, | ||
id: cinema.cinemaId, | ||
name: cinema.cinemaName, | ||
distance: cinema.distance, | ||
comparecount: cinema.maxCompareCount, | ||
comparedNames: JSON.parse(cinema.maxCompareNames), | ||
minprice: cinema.minPrice | ||
} | ||
} | ||
function _cinemaScreeningItems(data) { | ||
return data = { | ||
...data, | ||
showItems: data.showItems.map(_ => ({ | ||
..._, | ||
...data | ||
})) | ||
} | ||
// let showItems = data.showItems; | ||
// let showItemsObj = { | ||
// cinemaId: data.cinemaId, | ||
// cityId: data.cityId, | ||
// cityName: data.cityName, | ||
// compareCount: data.compareCount, | ||
// compareNames: data.compareNames, | ||
// dimensional: data.dimensional, | ||
// duration: data.duration, | ||
// filmId: data.filmId, | ||
// filmName: data.filmName, | ||
// hallName: data.hallName, | ||
// jbzEndTime: data.jbzEndTime, | ||
// jbzShowTime: data.jbzShowTime, | ||
// language: data.language, | ||
// minPrice: data.minPrice, | ||
// showDate: data.showDate, | ||
// showTime: data.showTime, | ||
// }; | ||
// for (let i = 0; i < data.showItems.length; i++) { | ||
// showItems[i] = Object.assign({}, showItems[i], showItemsObj); | ||
// } | ||
// return { | ||
// cinemaId: data.cinemaId, | ||
// cityId: data.cityId, | ||
// cityName: data.cityName, | ||
// compareCount: data.compareCount, | ||
// compareNames: data.compareNames, | ||
// dimensional: data.dimensional, | ||
// duration: data.duration, | ||
// filmId: data.filmId, | ||
// filmName: data.filmName, | ||
// hallName: data.hallName, | ||
// jbzEndTime: data.jbzEndTime, | ||
// jbzShowTime: data.jbzShowTime, | ||
// language: data.language, | ||
// minPrice: data.minPrice, | ||
// showDate: data.showDate, | ||
// showTime: data.showTime, | ||
// showItems: showItems | ||
// } | ||
} | ||
const JNetworkCinema = { | ||
cinemas: { | ||
url: '/cinema/cinemas', | ||
bodyData: { | ||
"filmId": false, | ||
"date": false, | ||
"feature": false, | ||
"limit": false, | ||
"orderType": false, | ||
"regionName": false | ||
cinemaDetail: { | ||
url: '/cinema/cinemadetail', | ||
params: { | ||
cinemaId: true, | ||
openId: false | ||
}, | ||
useBodyData: [ | ||
'cityId', | ||
'coordinate' | ||
book: [ | ||
'cinemaId', | ||
'openId' | ||
] | ||
}, | ||
cinemaDetail: { | ||
url: '/cinema/detail', | ||
bodyData: { | ||
cinemaId: true | ||
} | ||
cinemasList: { | ||
url: '/cinema/cinemasbycityordertype', | ||
params: { | ||
cityId: true, | ||
longitude: true, | ||
latitude: true, | ||
orderType: true, | ||
regionName: false, | ||
filmId: false, | ||
feature: false, | ||
page: false, | ||
size: false, | ||
date: false, | ||
}, | ||
book: [ | ||
'cityId', | ||
'longitude', | ||
'latitude', | ||
'orderType', | ||
'regionName', | ||
'filmId', | ||
'feature', | ||
'page', | ||
'size', | ||
'date' | ||
], | ||
cook: _ => _.map(_netcinema) | ||
}, | ||
cinemaScreeningFilmList: { | ||
url: '/cinema/films', | ||
bodyData: { | ||
params: { | ||
cinemaId: true | ||
} | ||
}, | ||
book: [ | ||
'cinemaId' | ||
] | ||
}, | ||
cinemaScreeningDateList: { | ||
url: '/cinema/filmShowDates', | ||
bodyData: { | ||
url: '/cinema/filmshowdates', | ||
params: { | ||
cinemaId: true, | ||
filmId: true | ||
}, | ||
cook: ({data}) => { | ||
return data.map(date => { | ||
return JToolDate.timeIntervalFromDateString(date); | ||
}); | ||
} | ||
book: [ | ||
'cinemaId', | ||
'filmId' | ||
], | ||
cook: data => data.map(dateString => { | ||
return JToolDate.timeIntervalFromDateString(dateString); | ||
}) | ||
}, | ||
cinemaScreeningItems:{ | ||
url: '/cinema/filmShows', | ||
bodyData: { | ||
cinemaScreeningItems: { | ||
url: '/cinema/filmshows', | ||
params: { | ||
cinemaId: true, | ||
filmId: true, | ||
date: { | ||
required: true, | ||
cook: _ => JToolDate.dateStringFromTimeInterval(_, 'yyyy-MM-dd') | ||
cook: _ => { | ||
return JToolDate.dateStringFromTimeInterval(_, 'yyyy-MM-dd'); | ||
} | ||
} | ||
}, | ||
book: [ | ||
'cinemaId', | ||
'filmId', | ||
'date' | ||
], | ||
cook: _ => _.map(_cinemaScreeningItems) | ||
}, | ||
cinemaSmartSeats: { | ||
url: '/cinema/realtimeseats', | ||
params: { | ||
type: { | ||
require: true, | ||
cook: _ => ((_ === 'meituan' || _ === 'dazhong') ? 'maoyan' : _) | ||
}, | ||
filmId: true | ||
cinemaId: true, | ||
showId: true, | ||
sectionId: false | ||
}, | ||
cook: (_, {params}) => { | ||
if (_.requestId) { | ||
return _; | ||
} else if (_){ | ||
if (params.type === 'ytb'){ | ||
const {seatMap} = _; | ||
for(let seatKey in seatMap){ | ||
const seat = seatMap[seatKey]; | ||
seat.seatCol = seat.seatCol || '1'; | ||
seat.seatRow = seat.seatRow || '1'; | ||
} | ||
} | ||
return JManagerSeat.defaultManager().smartSeatsFromSeats(params.type, _); | ||
} | ||
return _; | ||
} | ||
}, | ||
cinemaSeats:{ | ||
url: '/cinema/realTimeSeats', | ||
bodyData: { | ||
jbzCinemaId: true, | ||
platform: true, | ||
sectionId: false, | ||
showId: true | ||
// 这里传type是座位图进行判断的,绝望的异步 | ||
realTimeSeatsInfo: { | ||
url: '/cinema/realtimeseatsinfo', | ||
params: { | ||
type: { | ||
require: true, | ||
cook: _ => ((_ === 'meituan' || _ === 'dazhong') ? 'maoyan' : _) | ||
}, | ||
requestId: true | ||
}, | ||
book: [ | ||
'requestId', | ||
'type' | ||
], | ||
cook: (_, {params}) => { | ||
if (_) { | ||
if (params.type === 'ytb'){ | ||
const {seatMap} = _; | ||
for(let seatKey in seatMap){ | ||
const seat = seatMap[seatKey]; | ||
seat.seatCol = seat.seatCol || '1'; | ||
seat.seatRow = seat.seatRow || '1'; | ||
} | ||
} | ||
return JManagerSeat.defaultManager().smartSeatsFromSeats(params.type, _); | ||
} | ||
return _; | ||
} | ||
@@ -62,0 +206,0 @@ } |
@@ -1,84 +0,69 @@ | ||
import {JToolDate} from 'icemilk'; | ||
import FilmModel from '../model/FilmModel'; | ||
import FilmSimpleModel from '../model/FilmSimpleModel'; | ||
import CommentModel from '../model/CommentModel'; | ||
const JNetworkFilm = { | ||
filmDetail: { | ||
url: '/film/detail', | ||
bodyData: { | ||
filmId: true | ||
}, | ||
cook: (data) => ({ | ||
film: FilmModel.create(data.film), | ||
comment: data.hotComments.map(_ => CommentModel.create(_)) | ||
}) | ||
filmHotfilms: { | ||
url: '/film/hotfilms', | ||
cook: data => { | ||
console.log(data) | ||
let films = data.films.map(_ => FilmModel.create(_)) | ||
return {count: data.count, films}; | ||
} | ||
}, | ||
filmDetailByPlatform: { | ||
url: '/film/detailByPartner', | ||
bodyData: { | ||
platform: true, | ||
platformFilmId: true | ||
hotFilmsPage: { | ||
url: '/film/hotfilmspage', | ||
params: { | ||
page: true, | ||
size: true | ||
}, | ||
cook: (data) => FilmModel.create(data) | ||
book: [ | ||
'page', | ||
'size' | ||
], | ||
cook: (data) => data.map(_ => FilmModel.create(_)) | ||
}, | ||
filmDateList: { | ||
url: '/film/filmDate', | ||
bodyData: { | ||
filmId: true | ||
filmWaitfilms: { | ||
url: '/film/soonfilms', | ||
cook: data => { | ||
console.log(data) | ||
let films = data.films.map(_ => FilmModel.create(_)) | ||
return {count: data.count, films}; | ||
} | ||
}, | ||
soonFilmsPage: { | ||
url: '/film/soonfilmspage', | ||
params: { | ||
page: true, | ||
size: true | ||
}, | ||
useBodyData: [ | ||
'cityId' | ||
book: [ | ||
'page', | ||
'size' | ||
], | ||
cook: (data) => data.map(_ => JToolDate.timeIntervalFromDateString(_)) | ||
cook: (data) => data.map(_ => FilmModel.create(_)) | ||
}, | ||
filmVideo: { | ||
url: '/film/filmVideo', | ||
bodyData: { | ||
filmFilm: { | ||
url: '/film/film', | ||
params: { | ||
filmId: true | ||
}, | ||
description: '无数据' | ||
book:[ | ||
'filmId' | ||
], | ||
cook: (data) => ({ | ||
film: FilmModel.create(data) | ||
}) | ||
}, | ||
hotComments: { | ||
url: '/film/hotComments', | ||
bodyData: { | ||
filmHotComments: { | ||
url: '/film/hotcomments', | ||
params: { | ||
filmId: true | ||
}, | ||
book: [ | ||
'filmId' | ||
], | ||
description: '无数据' | ||
}, | ||
hotfilms: { | ||
url: '/film/hotFilms', | ||
cook: (data) => data.map(_ => FilmModel.create(_)) | ||
}, | ||
hotFilmsByPage: { | ||
url: '/film/hotFilmsPage', | ||
bodyData: { | ||
page: { | ||
required: true, | ||
default: 1 | ||
} | ||
}, | ||
cook: (data) => data.map(_ => FilmModel.create(_)), | ||
description: '系统异常' | ||
}, | ||
hotFilmsSimple: { | ||
url: '/film/hotFilmsSimple', | ||
cook: (data) => data.map(_ => FilmSimpleModel.create(_)) | ||
}, | ||
waitFilms: { | ||
url: '/film/upcomingFilms', | ||
cook: (data) => data.map(_ => FilmModel.create(_)) | ||
}, | ||
waitFilmsByPage: { | ||
url: '/film/upcomingFilmsPage', | ||
bodyData: { | ||
page: { | ||
required: true, | ||
default: 1 | ||
} | ||
}, | ||
descirption: '系统异常' | ||
} | ||
}; | ||
export default JNetworkFilm; |
const JNetworkOther = { | ||
decrypt: { | ||
url: '/system/decrypt', | ||
params: { | ||
key: true | ||
}, | ||
book: [ | ||
'key' | ||
] | ||
}, | ||
@@ -9,6 +15,15 @@ encrypt: { | ||
key: true | ||
} | ||
}, | ||
book: [ | ||
'key' | ||
] | ||
}, | ||
login: { | ||
url: '/system/login' | ||
url: '/system/login', | ||
params: { | ||
key: true | ||
}, | ||
book: [ | ||
'key' | ||
] | ||
} | ||
@@ -15,0 +30,0 @@ } |
@@ -1,4 +0,1 @@ | ||
import FilmModel from '../model/FilmModel'; | ||
import CinemaModel from '../model/CinemaModel'; | ||
const JNetworkSearch = { | ||
@@ -8,15 +5,20 @@ hotQuery: { | ||
}, | ||
search: { | ||
url: '/search/search', | ||
bodyData: { | ||
queryStr: true | ||
searchall: { | ||
url: '/search/searchall', | ||
params: { | ||
cityId: true, | ||
key: true, | ||
longitude: true, | ||
latitude: true, | ||
page: true, | ||
size: false | ||
}, | ||
useBodyData: [ | ||
'cityId', | ||
'coordinate' | ||
book: [ | ||
'cityId', | ||
'key', | ||
'longitude', | ||
'latitude', | ||
'page', | ||
'size' | ||
], | ||
cook: data => ({ | ||
filmList: data.films.map(_ => FilmModel.create(_)), | ||
cinemaList: data.cinemas.map(_ => CinemaModel.create(_)) | ||
}), | ||
description: 'cinema 无数据' | ||
@@ -23,0 +25,0 @@ } |
@@ -1,399 +0,195 @@ | ||
// /** | ||
// * Created by cuppi on 2016/12/7. | ||
// */ | ||
/** | ||
* Created by cuppi on 2016/12/7. | ||
* 交易相关 | ||
*/ | ||
'use strict' | ||
import NetworkTrade from '../network/JNetworkTrade'; | ||
// /** | ||
// * 交易管理类 | ||
// * @memberOf module:manager | ||
// */ | ||
let instance: TradeManager = null; | ||
let instance = null; | ||
class TradeManager { | ||
callbackCityInfo: Function; | ||
constructor() { | ||
if (!instance) { | ||
instance = this; | ||
constructor() { | ||
if (!instance) { | ||
instance = this; | ||
} | ||
return instance; | ||
} | ||
return instance; | ||
} | ||
/** | ||
* 获取单例实例 | ||
* @returns {TradeManager} | ||
*/ | ||
static defaultManager(delegate: any) { | ||
if (!delegate.hasOwnProperty('callbackCityInfo')){ | ||
console.log('没有找到城市信息实现'); | ||
return null; | ||
/** | ||
* 获取单例实例 | ||
* @returns {TradeManager} | ||
*/ | ||
static defaultManager() { | ||
return new TradeManager(); | ||
} | ||
instance = new TradeManager(); | ||
instance.callbackCityInfo = delegate.callbackCityInfo as Function; | ||
return instance; | ||
} | ||
/** | ||
* 获取交易商务参数(与座位无关的) | ||
* @param platform 平台类型 | ||
* @param platformData 平台数据 | ||
* @param filmId 电影Id | ||
* @param filmName 电影名称 | ||
* @param cinemaId 影院Id | ||
* @param cinemaName 影院名称 | ||
* @returns {*} 商务参数 | ||
*/ | ||
static tradeParasFromPlatform(platform, platformData, filmId, filmName, cinemaId, cinemaName) { | ||
if (platform === 'wangpiao') { | ||
return { | ||
jbzFilmId: filmId, | ||
filmId: platformData.filmId, | ||
showId: platformData.showIndex, | ||
cinemaName: cinemaName, | ||
platformCinemaId: platformData.cinemaId, | ||
cinemaId | ||
}; | ||
} | ||
/** | ||
* 获取锁座时需要的座位参数 | ||
* @param type 平台类型 | ||
* @param seatList 座位列表(需要购买的) | ||
* @param mobile 手机号码 | ||
* @param xsessionId 身份标识符(目前跟手机号码一样) | ||
* @returns {*} 返回参数对象 | ||
*/ | ||
seatInforParas(type, seatList) { | ||
// 网票 | ||
if (type === 'wangpiao') { | ||
let seatInfosArr = []; | ||
let seatInfos = []; | ||
for (let seat of seatList) { | ||
seatInfosArr.push(seat.seatModel.SeatIndex); | ||
seatInfos.push(seat.rowNumber + ':' + seat.colNumber); | ||
} | ||
return { | ||
seatIds: seatInfosArr.join('|'), | ||
count: seatInfosArr.length, | ||
seatInfos: seatInfos.join('|') | ||
} | ||
} | ||
// 蜘蛛 | ||
if (type === 'spider') { | ||
let seatInfosArr = []; | ||
let seatInfos = []; | ||
for (let seat of seatList) { | ||
seatInfosArr.push(seat.seatModel.rowId + ':' + seat.seatModel.columnId); | ||
seatInfos.push(seat.rowNumber + ':' + seat.colNumber); | ||
} | ||
return { | ||
seatIds: seatInfosArr.join('|'), | ||
count: seatInfosArr.length, | ||
seatInfos: seatInfos.join('|') | ||
} | ||
} | ||
// 卖座 | ||
if (type === 'maizuo') { | ||
let seatInfosArr = []; | ||
let seatInfos = []; | ||
for (let seat of seatList) { | ||
seatInfosArr.push(seat.seatModel.rowId + ':' + seat.seatModel.columnId); | ||
seatInfos.push(seat.rowNumber + ':' + seat.colNumber); | ||
} | ||
return { | ||
seatIds: seatInfosArr.join('|'), | ||
count: seatInfosArr.length, | ||
seatInfos: seatInfos.join('|') | ||
} | ||
} | ||
// 单车 | ||
if (type === 'danche') { | ||
let seatInfosArr = []; | ||
let seatInfos = []; | ||
for (let seat of seatList) { | ||
seatInfosArr.push(seat.seatModel.rowId + ':' + seat.seatModel.columnId); | ||
seatInfos.push(seat.rowNumber + ':' + seat.colNumber); | ||
} | ||
return { | ||
seatIds: seatInfosArr.join('|'), | ||
count: seatInfosArr.length, | ||
seatInfos: seatInfos.join('|') | ||
} | ||
} | ||
// 猫眼 | ||
if (type === 'maoyan' || type === 'meituan' || type === 'dazhong') { | ||
let seatInfosArr = []; | ||
let seatInfos = []; | ||
for (let seat of seatList) { | ||
if (!seat.seatModel) { | ||
console.log(seat); | ||
} | ||
seatInfosArr.push({ | ||
sectionId: seat.seatModel.sectionId, | ||
columnId: seat.seatModel.columnId, | ||
rowId: seat.seatModel.rowId, | ||
seatNo: seat.seatModel.seatNo | ||
}); | ||
seatInfos.push(seat.rowNumber + ':' + seat.colNumber); | ||
} | ||
return { | ||
seatIds: JSON.stringify({ | ||
count: seatList.length, | ||
list: seatInfosArr | ||
}), | ||
areaInfo: '', | ||
count: seatList.length, | ||
seatInfos: seatInfos.join('|') | ||
} | ||
} | ||
if (platform === 'spider') { | ||
return { | ||
jbzFilmId: filmId, | ||
filmId: platformData.filmId, | ||
showId: platformData.showId, | ||
platformCinemaId: platformData.cinemaId, | ||
cinemaId | ||
} | ||
} | ||
// 百度 | ||
if (type === 'baidu') { | ||
let seatIds = []; | ||
let areaInfos = []; | ||
let seatInfos = []; | ||
for (let seat of seatList) { | ||
seatIds.push(seat.seatModel.seatNo); | ||
seatInfos.push(seat.rowNumber + ':' + seat.colNumber); | ||
if (seat.areaInfo) { | ||
areaInfos.push(seat.areaInfo); | ||
} | ||
} | ||
return { | ||
count: seatIds.length, | ||
// 后台设置特意反过来的 | ||
seatIds: seatIds.join('|'), | ||
areaInfo: areaInfos.join('|'), | ||
seatInfos: seatInfos.join('|') | ||
} | ||
} | ||
if (platform === 'maizuo') { | ||
return { | ||
jbzFilmId: filmId, | ||
filmId: platformData.filmId, | ||
showId: platformData.foretellId, | ||
filmName: filmName, | ||
cinemaName: cinemaName, | ||
platformCinemaId: platformData.cinemaId, | ||
cinemaId | ||
}; | ||
} | ||
if (platform === 'danche') { | ||
return { | ||
jbzFilmId: filmId, | ||
filmId: platformData.filmId, | ||
showId: platformData.id, | ||
platformCinemaId: platformData.cinemaId, | ||
cinemaId | ||
}; | ||
} | ||
if (platform === 'maoyan' || platform === 'meituan' || platform === 'dazhong') { | ||
return { | ||
jbzFilmId: filmId, | ||
filmId: platformData.filmId, | ||
showId: platformData.showId, | ||
cinemaName: cinemaName, | ||
platformCinemaId: platformData.cinemaId, | ||
cinemaId | ||
}; | ||
} | ||
if (platform === 'baidu') { | ||
return { | ||
showId: platformData.seqid, | ||
platformCinemaId: platformData.cinemaId, | ||
cinemaId | ||
}; | ||
} | ||
if (platform === 'taobao'){ | ||
return { | ||
jbzFilmId: filmId, | ||
filmId: platform.filmId, | ||
showId: platform.showId, | ||
cinemaName: cinemaName, | ||
platformCinemaId: platform.cinemaId, | ||
filmName, | ||
cinemaId | ||
}; | ||
} | ||
} | ||
/** | ||
* 获取锁座处理者 | ||
* @param type 平台类型 | ||
* @param paras 参数 | ||
* @returns {*} 返回请求promise | ||
*/ | ||
lockSeatHandlerFrom(type, paras) { | ||
return NetworkTrade.tradeLockSeat(type, paras); | ||
} | ||
/** | ||
* 获取下订单处理者 | ||
* @param type 平台类型 | ||
* @param paras 参数 | ||
* @returns {{terminate, then}|*} 返回请求promise | ||
*/ | ||
confirmOrderHandlerFrom(type, paras) { | ||
return NetworkTrade.tradeApplyOrder(type, paras); | ||
} | ||
/** | ||
* 获取锁座时需要的座位参数 | ||
* @param type 平台类型 | ||
* @param seatList 座位列表(需要购买的) | ||
* @param mobile 手机号码 | ||
* @param openId 身份标识符(目前跟手机号码一样) | ||
* @returns {*} 返回参数对象 | ||
*/ | ||
seatInforParas(type, seatList, mobile, openId?) { | ||
// 网票 | ||
if (type === 'wangpiao') { | ||
let seatInfos = []; | ||
let seatNumberInfos = []; | ||
for (let seat of seatList) { | ||
seatInfos.push(seat.seatModel.SeatIndex); | ||
seatNumberInfos.push(seat.rowNumber + ':' + seat.colNumber); | ||
} | ||
return { | ||
seatIds: seatInfos.join('|'), | ||
count: seatInfos.length, | ||
seatNumberInfos: seatNumberInfos.join('|'), | ||
mobile, | ||
openId | ||
} | ||
} | ||
// 蜘蛛 | ||
if (type === 'spider') { | ||
let seatInfos = []; | ||
let seatNumberInfos = []; | ||
for (let seat of seatList) { | ||
seatInfos.push(seat.seatModel.rowId + ':' + seat.seatModel.columnId); | ||
seatNumberInfos.push(seat.rowNumber + ':' + seat.colNumber); | ||
} | ||
return { | ||
seatIds: seatInfos.join('|'), | ||
count: seatInfos.length, | ||
seatNumberInfos: seatNumberInfos.join('|'), | ||
mobile, | ||
openId | ||
} | ||
} | ||
// 卖座 | ||
if (type === 'maizuo') { | ||
let seatInfos = []; | ||
let seatNumberInfos = []; | ||
for (let seat of seatList) { | ||
seatInfos.push(seat.seatModel.rowId + ':' + seat.seatModel.columnId); | ||
seatNumberInfos.push(seat.rowNumber + ':' + seat.colNumber); | ||
} | ||
return { | ||
seatIds: seatInfos.join('|'), | ||
count: seatInfos.length, | ||
seatNumberInfos: seatNumberInfos.join('|'), | ||
mobile, | ||
openId | ||
} | ||
} | ||
// 单车 | ||
if (type === 'danche') { | ||
let seatInfos = []; | ||
let seatNumberInfos = []; | ||
for (let seat of seatList) { | ||
seatInfos.push(seat.seatModel.rowId + ':' + seat.seatModel.columnId); | ||
seatNumberInfos.push(seat.rowNumber + ':' + seat.colNumber); | ||
} | ||
return { | ||
seatIds: seatInfos.join('|'), | ||
count: seatInfos.length, | ||
seatNumberInfos: seatNumberInfos.join('|'), | ||
mobile, | ||
openId | ||
} | ||
} | ||
// 猫眼 | ||
if (type === 'maoyan' || type === 'meituan' || type === 'dazhong') { | ||
let seatInfos = []; | ||
let seatNumberInfos = []; | ||
for (let seat of seatList) { | ||
if (!seat.seatModel || true) { | ||
console.log(seat); | ||
// 淘票票 | ||
if (type === 'taobao') { | ||
let seatNames = []; | ||
let areaInfo = []; | ||
let seatIds = []; | ||
let seatInfos = []; | ||
for (let seat of seatList) { | ||
seatNames.push(seat.seatModel.name); | ||
areaInfo.push(seat.seatModel.name); | ||
seatInfos.push(seat.rowNumber + ':' + seat.colNumber); | ||
seatIds.push(seat.seatModel.seatId); | ||
} | ||
return { | ||
count: seatList.length, | ||
areaInfo: areaInfo.join('|'), | ||
seatNames: seatNames.join('|'), | ||
seatInfos: seatInfos.join('|'), | ||
seatIds: seatIds.join('|') | ||
} | ||
} | ||
console.log(seat.seatModel); | ||
seatInfos.push({ | ||
sectionId: seat.seatModel.sectionId, | ||
columnId: seat.seatModel.columnId, | ||
rowId: seat.seatModel.rowId, | ||
seatNo: seat.seatModel.seatNo | ||
}); | ||
seatNumberInfos.push(seat.rowNumber + ':' + seat.colNumber); | ||
} | ||
return { | ||
seatIds: JSON.stringify({ | ||
count: seatList.length, | ||
list: seatInfos | ||
}), | ||
seatNumberInfos: seatNumberInfos.join('|'), | ||
mobile, | ||
openId | ||
} | ||
// 影托帮 | ||
if (type === 'ytb') { | ||
let seatsName = []; | ||
let areaInfo = []; | ||
let seatIds = []; | ||
let seatInfos = []; | ||
for (let seat of seatList) { | ||
seatsName.push(seat.seatModel.seatPieceName); | ||
areaInfo.push(seat.seatModel.seatPieceName); | ||
seatInfos.push(seat.rowNumber + ':' + seat.colNumber); | ||
seatIds.push(seat.seatModel.seatNo); | ||
} | ||
return { | ||
count: seatList.length, | ||
areaInfo: areaInfo.join('|'), | ||
seatsName: seatsName.join('|'), | ||
seatInfos: seatInfos.join('|'), | ||
seatIds: seatIds.join('|') | ||
} | ||
} | ||
} | ||
// 百度 | ||
if (type === 'baidu') { | ||
let seatIds = []; | ||
let seatNumberInfos = []; | ||
for (let seat of seatList) { | ||
seatIds.push(seat.seatModel.seatNo); | ||
seatNumberInfos.push(seat.seatModel.rowId + ':' + seat.seatModel.columnId); | ||
} | ||
return { | ||
count: seatIds.length, | ||
// 后台设置特意反过来的 | ||
seatIds: seatNumberInfos.join('|'), | ||
seatNumberInfos: seatIds.join('|'), | ||
mobile, | ||
openId | ||
} | ||
} | ||
// 淘票票 | ||
if (type === 'taobao') { | ||
let seatInfos = []; | ||
let seatNumberInfos = []; | ||
let seatNameInfos = []; | ||
for (let seat of seatList) { | ||
seatInfos.push(seat.seatModel.seatId); | ||
seatNumberInfos.push(seat.rowOriNumber + ':' + seat.colOriNumber); | ||
seatNameInfos.push(seat.seatModel.name); | ||
} | ||
return { | ||
seatIds: seatInfos.join('|'), | ||
count: seatInfos.length, | ||
seatNumberInfos: seatNumberInfos.join('|'), | ||
seatsName: seatNameInfos.join('|'), | ||
applyKey: '', | ||
mobile, | ||
openId | ||
} | ||
} | ||
// 影托帮 | ||
if (type === 'ytb') { | ||
let seatsName = []; | ||
let areaInfo = []; | ||
let seatIds = []; | ||
let seatNumberInfos = []; | ||
for (let seat of seatList) { | ||
seatsName.push(seat.seatModel.seatPieceName); | ||
areaInfo.push(seat.seatModel.seatPieceName); | ||
seatNumberInfos.push(seat.rowNumber + ':' + seat.colNumber); | ||
seatIds.push(seat.seatModel.seatNo); | ||
} | ||
return { | ||
count: seatList.length, | ||
areaInfo: areaInfo.join('|'), | ||
seatsName: seatsName.join('|'), | ||
seatNumberInfos: seatNumberInfos.join('|'), | ||
seatIds: seatIds.join('|') | ||
} | ||
} | ||
} | ||
/** | ||
* 购票(执行锁座 下订单 的事务) | ||
* @param type 平台类型 | ||
* @param tradeParas 商务参数(与座位无关的参数集合) | ||
* @param seatList 座位列表 | ||
* @param mobile 手机号码 | ||
* @param openId 身份标识符(同上) | ||
* @returns {*} 返回请求promise | ||
*/ | ||
buyTicket(type, tradeParas, seatList, mobile) { | ||
let paras = {...tradeParas, ...this.seatInforParas(type, seatList, mobile)}; | ||
let bridgeSelf = this; | ||
return { | ||
next: function (lockSeatCallback) { | ||
return { | ||
next: function (confirmOrderCallback) { | ||
bridgeSelf.lockSeatHandlerFrom(type, {...paras, cinemaId: paras.platformCinemaId}).then(data => { | ||
lockSeatCallback(null, data); | ||
let orderId = data.orderId; | ||
let {cinemaId, jbzFilmId, filmId, showId} = paras; | ||
let city = this.callbackCityInfo(); | ||
let cityId = city.id; | ||
let cityName = city.name; | ||
bridgeSelf.confirmOrderHandlerFrom(type, { | ||
orderId, | ||
cinemaId, | ||
jbzFilmId, | ||
filmId, | ||
showId, | ||
cityId, | ||
cityName | ||
}).then(data => { | ||
confirmOrderCallback(null, data); | ||
}, error => { | ||
confirmOrderCallback(error, null); | ||
}); | ||
}, error => { | ||
lockSeatCallback(error, null); | ||
}); | ||
} | ||
/** | ||
* 锁座 | ||
* @param tradeParas 商务参数(与座位无关的参数集合) | ||
* @param seatList 座位列表 | ||
* @param mobile 手机号码 | ||
* @returns {Promise} 返回请求promise | ||
*/ | ||
lockSeat(tradeParas) { | ||
if (tradeParas.type === 'meituan' || tradeParas.type === 'dazhong') { | ||
tradeParas.type = 'maoyan' | ||
} | ||
} | ||
let paras = {...tradeParas, ...this.seatInforParas(tradeParas.type, tradeParas.selectedSeats)}; | ||
console.log(paras); | ||
return paras; | ||
} | ||
} | ||
} | ||
/** | ||
* 锁座 | ||
* @param type 平台类型 | ||
* @param tradeParas 商务参数(与座位无关的参数集合) | ||
* @param seatList 座位列表 | ||
* @param mobile 手机号码 | ||
* @returns {Promise} 返回请求promise | ||
*/ | ||
lockSeat(type, tradeParas, seatList, mobile) { | ||
let paras = {...tradeParas, ...this.seatInforParas(type, seatList, mobile)}; | ||
return new Promise((resolve, reject) => { | ||
this.lockSeatHandlerFrom(type, {...paras, cinemaId: paras.platformCinemaId}).then(data => { | ||
let orderId = data.orderId; | ||
let amount = data.originalAmount; | ||
let {cinemaId, jbzFilmId, filmId, showId} = paras; | ||
// 下面两个 | ||
let city = this.callbackCityInfo(); | ||
let cityId = city.id; | ||
let cityName = city.name; | ||
resolve({ | ||
orderId, | ||
amount, | ||
cinemaId, | ||
jbzFilmId, | ||
filmId, | ||
showId, | ||
cityId, | ||
cityName | ||
}); | ||
}, error => { | ||
reject(error); | ||
}); | ||
}) | ||
} | ||
/** | ||
* 确认订单 | ||
* @param type 平台类型 | ||
* @param lockSeatResultData 锁座成功返回的数据 | ||
* @returns {Promise} | ||
*/ | ||
applyOrder(type, lockSeatResultData) { | ||
return new Promise((resolve, reject) => { | ||
this.confirmOrderHandlerFrom(type, lockSeatResultData).then(data => { | ||
resolve(data); | ||
}, error => { | ||
reject(error); | ||
}); | ||
}); | ||
} | ||
} | ||
export default TradeManager; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
722677
68
8617
5
+ Addedjsencrypt@^3.0.0-rc.1
+ Addedmd5@^2.2.1
+ Addedcharenc@0.0.2(transitive)
+ Addedcrypt@0.0.2(transitive)
+ Addedicemilk@1.0.9-beta11(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedjsencrypt@3.3.2(transitive)
+ Addedmd5@2.3.0(transitive)
- Removedicemilk@1.0.9-beta9(transitive)
Updatedicemilk@1.0.9-beta11