diff --git a/src/components/mina-touch.js b/src/components/mina-touch.js new file mode 100644 index 0000000..9dec9f7 --- /dev/null +++ b/src/components/mina-touch.js @@ -0,0 +1,393 @@ +const DEFAULT_OPTIONS = { + touchStart: function () {}, + touchMove: function () {}, + touchEnd: function () {}, + touchCancel: function () {}, + multipointStart: function () {}, + multipointEnd: function () {}, + tap: function () {}, + doubleTap: function () {}, + longTap: function () {}, + singleTap: function () {}, + rotate: function () {}, + pinch: function () {}, + pressMove: function () {}, + swipe: function () {} +}; +export default class MinaTouch { + constructor(_page, name, option = {}) { + this.preV = { + x: null, + y: null + }; + this.pinchStartLen = null; + this.scale = 1; + this.isDoubleTap = false; + this.delta = null; + this.last = null; + this.now = null; + this.tapTimeout = null; + this.singleTapTimeout = null; + this.longTapTimeout = null; + this.swipeTimeout = null; + this.x1 = this.x2 = this.y1 = this.y2 = null; + this.preTapPosition = { + x: null, + y: null + }; + this.lastZoom = 1; + this.tempZoom = 1; + + try { + if (this._checkBeforeCreate(_page, name)) { + this._name = name; + this._option = { ...DEFAULT_OPTIONS, ...option }; + _page[name] = this; + + this._bindFunc(_page); + } + } catch (error) { + console.error(error); + } + } + + _checkBeforeCreate(_page, name) { + if (!_page || !name) { + throw new Error('MinaTouch实例化时,必须传入page对象和引用名'); + } + + if (_page[name]) { + throw new Error('MinaTouch实例化error: ' + name + ' 已经存在page中'); + } + + return true; + } + + _bindFunc(_page) { + let funcNames = ['start', 'move', 'end', 'cancel']; + + for (let funcName of funcNames) { + _page[this._name + '.' + funcName] = this[funcName].bind(this); + } + } + + start(evt) { + if (!evt.touches) { + return; + } + + this.now = new Date(); + + if (evt.touches[0].pageX == null) { + this.x1 = evt.touches[0].x; + } else { + this.x1 = evt.touches[0].pageX; + } + + if (evt.touches[0].pageY == null) { + this.y1 = evt.touches[0].y; + } else { + this.y1 = evt.touches[0].pageY; + } + + this.delta = this.now - (this.last || this.now); + + this._option.touchStart(evt); + + if (this.preTapPosition.x !== null) { + this.isDoubleTap = this.delta > 0 && this.delta <= 250 && Math.abs(this.preTapPosition.x - this.x1) < 30 && Math.abs(this.preTapPosition.y - this.y1) < 30; + } + + this.preTapPosition.x = this.x1; + this.preTapPosition.y = this.y1; + this.last = this.now; + let preV = this.preV; + let len = evt.touches.length; + if (len > 1) { + this._cancelLongTap(); + + this._cancelSingleTap(); + + let otx = evt.touches[1].pageX == null ? evt.touches[1].x : evt.touches[1].pageX; + let oty = evt.touches[1].pageY == null ? evt.touches[1].y : evt.touches[1].pageY; + let v = { + x: otx - this.x1, + y: oty - this.y1 + }; + preV.x = v.x; + preV.y = v.y; + this.pinchStartLen = getLen(preV); + + this._option.multipointStart(evt); + } + + this.longTapTimeout = setTimeout( + function () { + evt.type = 'longTap'; + + this._option.longTap(evt); + }.bind(this), + 750 + ); + } + + move(evt) { + if (!evt.touches) { + return; + } + + let preV = this.preV; + let len = evt.touches.length; + let currentX = evt.touches[0].pageX == null ? evt.touches[0].x : evt.touches[0].pageX; + let currentY = evt.touches[0].pageY == null ? evt.touches[0].y : evt.touches[0].pageY; + this.isDoubleTap = false; + + if (len > 1) { + // #ifdef MP-TOUTIAO + if(!this.toutuaoMultipointStart){ + this._cancelLongTap(); + + this._cancelSingleTap(); + + let otx = evt.touches[1].pageX == null ? evt.touches[1].x : evt.touches[1].pageX; + let oty = evt.touches[1].pageY == null ? evt.touches[1].y : evt.touches[1].pageY; + let v = { + x: otx - currentX, + y: oty - currentX + }; + preV.x = v.x; + preV.y = v.y; + this.pinchStartLen = getLen(preV); + + this._option.multipointStart(evt); + this.toutuaoMultipointStart = true + } + // #endif + let otx = evt.touches[1].pageX == null ? evt.touches[1].x : evt.touches[1].pageX; + let oty = evt.touches[1].pageY == null ? evt.touches[1].y : evt.touches[1].pageY; + let v = { + x: otx - currentX, + y: oty - currentY + }; + if (preV.x !== null) { + if (this.pinchStartLen > 0) { + evt.singleZoom = getLen(v) / this.pinchStartLen; + evt.zoom = evt.singleZoom * this.lastZoom; + this.tempZoom = evt.zoom; + evt.type = 'pinch'; + + this._option.pinch(evt); + } + + evt.angle = getRotateAngle(v, preV); + evt.type = 'rotate'; + + this._option.rotate(evt); + } + + preV.x = v.x; + preV.y = v.y; + } else { + if (this.x2 !== null) { + evt.deltaX = currentX - this.x2; + evt.deltaY = currentY - this.y2; + } else { + evt.deltaX = 0; + evt.deltaY = 0; + } + + this._option.pressMove(evt); + } + + this._option.touchMove(evt); + + this._cancelLongTap(); + + this.x2 = currentX; + this.y2 = currentY; + + if (len > 1) { + // evt.preventDefault(); + } + } + + end(evt) { + if (!evt.changedTouches) { + return; + } + + this._cancelLongTap(); + + let self = this; + evt.direction = this._swipeDirection(this.x1, this.x2, this.y1, this.y2); //在结束钩子都加入方向判断,但触发swipe瞬时必须位移大于30 + + if (evt.touches.length < 2) { + this.lastZoom = this.tempZoom; + + this._option.multipointEnd(evt); + this.toutuaoMultipointStart = false + } + + this._option.touchEnd(evt); //swipe + + if ((this.x2 && Math.abs(this.x1 - this.x2) > 30) || (this.y2 && Math.abs(this.y1 - this.y2) > 30)) { + // evt.direction = this._swipeDirection(this.x1, this.x2, this.y1, this.y2); + this.swipeTimeout = setTimeout(function () { + evt.type = 'swipe'; + + self._option.swipe(evt); + }, 0); + } else { + this.tapTimeout = setTimeout(function () { + evt.type = 'tap'; + + self._option.tap(evt); // trigger double tap immediately + + if (self.isDoubleTap) { + evt.type = 'doubleTap'; + + self._option.doubleTap(evt); + + clearTimeout(self.singleTapTimeout); + self.isDoubleTap = false; + } + }, 0); + + if (!self.isDoubleTap) { + self.singleTapTimeout = setTimeout(function () { + self._option.singleTap(evt); + }, 250); + } + } + + this.preV.x = 0; + this.preV.y = 0; + this.scale = 1; + this.pinchStartLen = null; + this.x1 = this.x2 = this.y1 = this.y2 = null; + } + + cancel(evt) { + clearTimeout(this.singleTapTimeout); + clearTimeout(this.tapTimeout); + clearTimeout(this.longTapTimeout); + clearTimeout(this.swipeTimeout); + + this._option.touchCancel(evt); + } + + _cancelLongTap() { + clearTimeout(this.longTapTimeout); + } + + _cancelSingleTap() { + clearTimeout(this.singleTapTimeout); + } + + _swipeDirection(x1, x2, y1, y2) { + return Math.abs(x1 - x2) >= Math.abs(y1 - y2) ? (x1 - x2 > 0 ? 'Left' : 'Right') : y1 - y2 > 0 ? 'Up' : 'Down'; + } + + destroy() { + if (this.singleTapTimeout) { + clearTimeout(this.singleTapTimeout); + } + + if (this.tapTimeout) { + clearTimeout(this.tapTimeout); + } + + if (this.longTapTimeout) { + clearTimeout(this.longTapTimeout); + } + + if (this.swipeTimeout) { + clearTimeout(this.swipeTimeout); + } + + this._option.rotate = null; + this._option.touchStart = null; + this._option.multipointStart = null; + this._option.multipointEnd = null; + this._option.pinch = null; + this._option.swipe = null; + this._option.tap = null; + this._option.doubleTap = null; + this._option.longTap = null; + this._option.singleTap = null; + this._option.pressMove = null; + this._option.touchMove = null; + this._option.touchEnd = null; + this._option.touchCancel = null; + this.preV = + this.pinchStartLen = + this.scale = + this.isDoubleTap = + this.delta = + this.last = + this.now = + this.tapTimeout = + this.singleTapTimeout = + this.longTapTimeout = + this.swipeTimeout = + this.x1 = + this.x2 = + this.y1 = + this.y2 = + this.preTapPosition = + this.rotate = + this.touchStart = + this.multipointStart = + this.multipointEnd = + this.pinch = + this.swipe = + this.tap = + this.doubleTap = + this.longTap = + this.singleTap = + this.pressMove = + this.touchMove = + this.touchEnd = + this.touchCancel = + null; + return null; + } +} + +function getLen(v) { + return Math.sqrt(v.x * v.x + v.y * v.y); +} + +function dot(v1, v2) { + return v1.x * v2.x + v1.y * v2.y; +} + +function getAngle(v1, v2) { + let mr = getLen(v1) * getLen(v2); + + if (mr === 0) { + return 0; + } + + let r = dot(v1, v2) / mr; + + if (r > 1) { + r = 1; + } + + return Math.acos(r); +} + +function cross(v1, v2) { + return v1.x * v2.y - v2.x * v1.y; +} + +function getRotateAngle(v1, v2) { + let angle = getAngle(v1, v2); + + if (cross(v1, v2) > 0) { + angle *= -1; + } + + return (angle * 180) / Math.PI; +} diff --git a/src/components/seatChoose.vue b/src/components/seatChoose.vue index 6a34800..1eead33 100644 --- a/src/components/seatChoose.vue +++ b/src/components/seatChoose.vue @@ -1,17 +1,35 @@ - test + + + + ¥{{ item.price }} + + + + + 您的浏览器版本过低,不支持canvas,请升级浏览器或使用chrome浏览器 + + diff --git a/src/components/seatImg.js b/src/components/seatImg.js new file mode 100644 index 0000000..e9a4ba9 --- /dev/null +++ b/src/components/seatImg.js @@ -0,0 +1,144 @@ +const seatImg = { + '00': { + name: 'default', + url: '@/static/images/seats/00.png', + color: '#D8D8D8' + }, + '01': { + name: 'checked', + url: '@/static/images/seats/01.png', + color: '#007800' + }, + A: { + name: 'A', + url: '/static/images/seats/A.png', + color: '#ff3b30' + }, + B: { + name: 'B', + url: '/static/images/seats/B.png', + color: '#fe9400' + }, + C: { + name: 'C', + url: '/static/images/seats/C.png', + color: '#f6eb77' + }, + D: { + name: 'D', + url: '/static/images/seats/D.png', + color: '#4bd863' + }, + E: { + name: 'E', + url: '/static/images/seats/E.png', + color: '#0079fe' + }, + F: { + name: 'F', + url: '/static/images/seats/F.png', + color: '#e6109b' + }, + G: { + name: 'G', + url: '/static/images/seats/G.png', + color: '#ebddd5' + }, + H: { + name: 'H', + url: '/static/images/seats/H.png', + color: '#ff403a' + }, + I: { + name: 'I', + url: '/static/images/seats/I.png', + color: '#f5a433' + }, + J: { + name: 'J', + url: '/static/images/seats/J.png', + color: '#e8ff8c' + }, + K: { + name: 'K', + url: '/static/images/seats/K.png', + color: '#bad4aa' + }, + L: { + name: 'L', + url: '/static/images/seats/L.png', + color: '#abe0ff' + }, + M: { + name: 'M', + url: '/static/images/seats/M.png', + color: '#e5daf9' + }, + N: { + name: 'N', + url: '/static/images/seats/N.png', + color: '#b3907d' + }, + O: { + name: 'O', + url: '/static/images/seats/O.png', + color: '#f45c93' + }, + P: { + name: 'P', + url: '/static/images/seats/P.png', + color: '#db5200' + }, + Q: { + name: 'Q', + url: '/static/images/seats/Q.png', + color: '#e8e363' + }, + R: { + name: 'R', + url: '/static/images/seats/R.png', + color: '#2db3a0' + }, + S: { + name: 'S', + url: '/static/images/seats/S.png', + color: '#bff1ff' + }, + T: { + name: 'T', + url: '/static/images/seats/T.png', + color: '#ffe3fb' + }, + U: { + name: 'U', + url: '/static/images/seats/U.png', + color: '#a60040' + }, + V: { + name: 'V', + url: '/static/images/seats/V.png', + color: '#ffdec9' + }, + W: { + name: 'W', + url: '/static/images/seats/W.png', + color: '#f6ffe3' + }, + X: { + name: 'X', + url: '/static/images/seats/X.png', + color: '#8ab4e8' + }, + Y: { + name: 'Y', + url: '/static/images/seats/Y.png', + color: '#ebf5df' + }, + Z: { + name: 'Z', + url: '/static/images/seats/Z.png', + color: '#a82f5a' + } +}; + +module.exports = seatImg \ No newline at end of file diff --git a/src/request/index.js b/src/request/index.js index a71876b..42b3336 100644 --- a/src/request/index.js +++ b/src/request/index.js @@ -1,64 +1,57 @@ -/* - * @Author: your name - * @Date: 2021-10-13 09:28:02 - * @LastEditTime: 2021-12-23 16:21:07 - * @LastEditors: Please set LastEditors - * @Description: In User Settings Edit - * @FilePath: /data-show/src/request/index.js - */ -import axios from 'axios'; -import qs from 'qs'; -function filterRequestData(obj) { - let o = {}; - for(let key in obj) { - let b1 = obj[key] === 0; - let b2 = obj[key] === false; - if(obj[key] || b1 || b2) { - o[key] = obj[key] - } - } - return o; -} +import axios from "axios" + //创建axios的实例 const httpService = axios.create({ baseURL: 'https://mm.kaixinguopiao.com',// TODO:具体的配置可以根据项目情况而来 - // timeout: 5000 + timeout: 5000 }) -//axios的拦截--request httpService.interceptors.request.use(config => { - // 请求成功处理 - // if(localStorage.getItem('token')){//判断浏览器中的cookie中是否存在项目的token - // config.headers.token = localStorage.getItem('token') - // } - const rqParams = filterRequestData(config.params); - const rqData = filterRequestData(config.data); - if(config.method === 'post') { - config.data = qs.stringify(rqData); - } else { - config.data = rqData; - config.params = rqParams; - } - return config; -},err => { - Promise.reject(err);// 请求错误处理 + config.headers['Content-Type'] = "application/json"; + config.headers['Access-Control-Allow-Origin'] = '*'; + // config.headers['admin-token'] = store.getters.getToken; + // config.headers['device-type'] = "web"; + return config +}, err => { + return Promise.reject(err) }) -//4、axios的拦截--response + httpService.interceptors.response.use(response => { - // TODO:具体的code对应的处理可继续添加修改 let msg = ''; + let data = null; let res = response.data; - if(res.status){ - return {res}; + if(res.code){ + data = res.data; + msg = res.msg || ""; + // return {data, msg}; + return res; } else { - msg = res.Msg || ""; - return Promise.reject(new Error(msg)) + msg = res.msg || ""; + // return Promise.reject(new Error(msg)) + return res; } -},err => { +}, err => { + // console.log(err) + // TODO:具体的code对应的处理可继续添加修改 return Promise.reject(err); }) -export default httpService - +export const getMethod = (api,params) => { + return httpService({ + url: api, + method: 'get', + params: params + }) +} +export const postMethod = (api, data) => { + return httpService({ + url: api, + method: 'post', + // headers: { + // 'Content-Type': 'application/json' + // }, + data: data + }) +} diff --git a/src/static/images/seats/0.png b/src/static/images/seats/0.png new file mode 100644 index 0000000..81e1e5b Binary files /dev/null and b/src/static/images/seats/0.png differ diff --git a/src/static/images/seats/00.png b/src/static/images/seats/00.png new file mode 100644 index 0000000..390bbf8 Binary files /dev/null and b/src/static/images/seats/00.png differ diff --git a/src/static/images/seats/01.png b/src/static/images/seats/01.png new file mode 100644 index 0000000..25e0e69 Binary files /dev/null and b/src/static/images/seats/01.png differ diff --git a/src/static/images/seats/A.png b/src/static/images/seats/A.png new file mode 100644 index 0000000..e4c187c Binary files /dev/null and b/src/static/images/seats/A.png differ diff --git a/src/static/images/seats/B.png b/src/static/images/seats/B.png new file mode 100644 index 0000000..58eaa1d Binary files /dev/null and b/src/static/images/seats/B.png differ diff --git a/src/static/images/seats/C.png b/src/static/images/seats/C.png new file mode 100644 index 0000000..bfdcf04 Binary files /dev/null and b/src/static/images/seats/C.png differ diff --git a/src/static/images/seats/D.png b/src/static/images/seats/D.png new file mode 100644 index 0000000..14a10d9 Binary files /dev/null and b/src/static/images/seats/D.png differ diff --git a/src/static/images/seats/E.png b/src/static/images/seats/E.png new file mode 100644 index 0000000..a6e7deb Binary files /dev/null and b/src/static/images/seats/E.png differ diff --git a/src/static/images/seats/F.png b/src/static/images/seats/F.png new file mode 100644 index 0000000..85ce5d7 Binary files /dev/null and b/src/static/images/seats/F.png differ diff --git a/src/static/images/seats/G.png b/src/static/images/seats/G.png new file mode 100644 index 0000000..aa5be14 Binary files /dev/null and b/src/static/images/seats/G.png differ diff --git a/src/static/images/seats/H.png b/src/static/images/seats/H.png new file mode 100644 index 0000000..b45d4ee Binary files /dev/null and b/src/static/images/seats/H.png differ diff --git a/src/static/images/seats/I.png b/src/static/images/seats/I.png new file mode 100644 index 0000000..19080a6 Binary files /dev/null and b/src/static/images/seats/I.png differ diff --git a/src/static/images/seats/J.png b/src/static/images/seats/J.png new file mode 100644 index 0000000..3ad78c7 Binary files /dev/null and b/src/static/images/seats/J.png differ diff --git a/src/static/images/seats/K.png b/src/static/images/seats/K.png new file mode 100644 index 0000000..e77ddde Binary files /dev/null and b/src/static/images/seats/K.png differ diff --git a/src/static/images/seats/L.png b/src/static/images/seats/L.png new file mode 100644 index 0000000..a94c845 Binary files /dev/null and b/src/static/images/seats/L.png differ diff --git a/src/static/images/seats/M.png b/src/static/images/seats/M.png new file mode 100644 index 0000000..7c2a427 Binary files /dev/null and b/src/static/images/seats/M.png differ diff --git a/src/static/images/seats/N.png b/src/static/images/seats/N.png new file mode 100644 index 0000000..c6b7323 Binary files /dev/null and b/src/static/images/seats/N.png differ diff --git a/src/static/images/seats/O.png b/src/static/images/seats/O.png new file mode 100644 index 0000000..e8a1e52 Binary files /dev/null and b/src/static/images/seats/O.png differ diff --git a/src/static/images/seats/P.png b/src/static/images/seats/P.png new file mode 100644 index 0000000..5f3479e Binary files /dev/null and b/src/static/images/seats/P.png differ diff --git a/src/static/images/seats/Q.png b/src/static/images/seats/Q.png new file mode 100644 index 0000000..0afeeaf Binary files /dev/null and b/src/static/images/seats/Q.png differ diff --git a/src/static/images/seats/R.png b/src/static/images/seats/R.png new file mode 100644 index 0000000..a61724a Binary files /dev/null and b/src/static/images/seats/R.png differ diff --git a/src/static/images/seats/S.png b/src/static/images/seats/S.png new file mode 100644 index 0000000..de07b84 Binary files /dev/null and b/src/static/images/seats/S.png differ diff --git a/src/static/images/seats/T.png b/src/static/images/seats/T.png new file mode 100644 index 0000000..5a433dd Binary files /dev/null and b/src/static/images/seats/T.png differ diff --git a/src/static/images/seats/U.png b/src/static/images/seats/U.png new file mode 100644 index 0000000..6306b3e Binary files /dev/null and b/src/static/images/seats/U.png differ diff --git a/src/static/images/seats/V.png b/src/static/images/seats/V.png new file mode 100644 index 0000000..f5ef6f0 Binary files /dev/null and b/src/static/images/seats/V.png differ diff --git a/src/static/images/seats/W.png b/src/static/images/seats/W.png new file mode 100644 index 0000000..73e68f5 Binary files /dev/null and b/src/static/images/seats/W.png differ diff --git a/src/static/images/seats/X.png b/src/static/images/seats/X.png new file mode 100644 index 0000000..e57efee Binary files /dev/null and b/src/static/images/seats/X.png differ diff --git a/src/static/images/seats/Y.png b/src/static/images/seats/Y.png new file mode 100644 index 0000000..0855ec9 Binary files /dev/null and b/src/static/images/seats/Y.png differ diff --git a/src/static/images/seats/Z.png b/src/static/images/seats/Z.png new file mode 100644 index 0000000..6cfcffe Binary files /dev/null and b/src/static/images/seats/Z.png differ