cu-progress.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. <template>
  2. <view>
  3. <view class="cu-progress-main" :style="{'border-radius':bgBR,'width': progressMainW,'height':progressMainH,'background-color': backgroundColor}">
  4. <view class="cu-progress" :style="{'left':areaLeft, 'flex-direction':flexDirection,'width':areaW,height:areaH}">
  5. <view class="cu-progress-bar" :style="{'bottom':pgBarBottom,'background':pgBarBg,'margin-left':pgBarML, 'margin-bottom':pgBarMB,'width': pgBarW,'height':pgBarH,'border-radius':pgBarBR,'background-color':noActiveColor}"></view>
  6. <movable-area class="cu-area" :style="{'flex-direction':flexDirection,'width':areaW,height:areaH}" @touchcancel="touchCancel" @touchstart="areaTouchStart"
  7. @touchmove="areaTouchMove" @touchend="touchEnd">
  8. <text style="position: relative;left:280rpx;font-size:35rpx;color: #FFFFFF;">滑动接单</text>
  9. <movable-view class="cu-handle" disabled="disabled" :animation="false" :style="{ 'top':handleT, 'width':handleS,'height':handleS,'border-radius': handleBR,'background-color':handleColor}"
  10. @change="change" :damping="damping" :x="handleX" :y="handleY" :direction="direction == 'vertical' ? 'vertical' : 'horizontal'">
  11. <text :class="handleIcon" :style="{'backgroundColor':iconColor,'font-size':iconS,'border-radius':iconBR}"></text>
  12. </movable-view>
  13. </movable-area>
  14. </view>
  15. <text v-if="getShowInfoStatus2view" class="cu-showInfo" :style="{'right':infoRt, 'left':infoLt, 'color':infoColor,'font-size':infoS,width:infoW}">{{showValue}}{{infoEndText}}</text>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. export default {
  21. data() {
  22. return {
  23. scale: 1,
  24. percent: 0, // progress进度
  25. // pgbw: '10px', // progress-bar width
  26. showValue: 0, //显示进度
  27. showVL: 0, // showValue 最大长度
  28. handleMoveStatus: false,
  29. handleX: 0, // 拖柄位置
  30. handleY: 0,
  31. progressBarInfo: {
  32. left: 0,
  33. bottom: 0,
  34. width: 0,
  35. height: 0
  36. },
  37. area: {
  38. left: 0,
  39. bottom: 0,
  40. width: 0,
  41. height: 0,
  42. top: 0
  43. },
  44. handle: {
  45. height: 0
  46. }
  47. };
  48. },
  49. beforeMount: function() {
  50. const res = uni.getSystemInfoSync()
  51. this.scale = 750 / res.windowWidth;
  52. // 0 为 false
  53. if (this.maxValue - this.minValue == 0) {
  54. console.error("min不能等于max:" + this.minValue + "->" + this.maxValue)
  55. return
  56. }
  57. else{
  58. this.showValue = this.valueFormat(this.value)
  59. }
  60. this.percent = Math.abs(this.showValue - this.minValue) / Math.abs(this.maxValue - this.minValue) * 100
  61. let minl = this.textLength(this.minValue + this.infoEndText)
  62. let maxl = this.textLength(this.maxValue + this.infoEndText)
  63. this.showVL = maxl > minl ? maxl : minl
  64. },
  65. mounted: function() {
  66. this.$nextTick(function() {
  67. const query = uni.createSelectorQuery().in(this)
  68. query.select(".cu-progress-bar").boundingClientRect(data => {
  69. this.progressBarInfo.width = data.width
  70. this.progressBarInfo.left = data.left
  71. this.progressBarInfo.bottom = data.bottom
  72. this.progressBarInfo.height = data.height
  73. if (this.direction == 'vertical'){
  74. this.handleY = this.progressBarInfo.height * (100 - this.percent) / 100
  75. }
  76. else{
  77. this.handleX = this.progressBarInfo.width * this.percent / 100
  78. }
  79. }).exec()
  80. query.select(".cu-area").boundingClientRect(data => {
  81. this.area.width = data.width
  82. this.area.left = data.left
  83. this.area.height = data.height
  84. this.area.bottom = data.bottom
  85. this.area.top = data.top
  86. }).exec()
  87. query.select(".cu-handle").boundingClientRect(data => {
  88. this.handle.height = data.height
  89. }).exec()
  90. })
  91. },
  92. props: {
  93. infoAlign: {
  94. default: 'right',
  95. type: String
  96. },
  97. step: {
  98. default: 1,
  99. type: [String, Number]
  100. },
  101. direction: {
  102. default: 'horizontal', //vertical 方向
  103. type: String
  104. },
  105. disabled: {
  106. default: false,
  107. type: [String, Boolean]
  108. },
  109. bgBorderRadius: {
  110. default: 0,
  111. type: [Number, String]
  112. },
  113. iconBorderRadius: {
  114. default: '8px',
  115. type: [Number, String]
  116. },
  117. iconColor: {
  118. default: 'inherit',
  119. type: String
  120. },
  121. iconSize: {
  122. default: '8px',
  123. type: [Number, String]
  124. },
  125. handleIcon: {
  126. default: '',
  127. type: String
  128. },
  129. backgroundColor: {
  130. default: 'inherit',
  131. type: String
  132. },
  133. max: {
  134. default: 100,
  135. type: [String, Number]
  136. },
  137. min: {
  138. default: 0,
  139. type: [String, Number]
  140. },
  141. value: {
  142. default: null, // 设置进度条进度
  143. type: [String, Number]
  144. },
  145. activeColor: {
  146. default: '#ffa673', // 已经过区域颜色
  147. type: String
  148. },
  149. noActiveColor: {
  150. default: '#ffd2ac', // 为经过区域颜色
  151. type: String
  152. },
  153. strokeWidth: {
  154. default: '3', // 行程宽度
  155. type: [String, Number]
  156. },
  157. damping: {
  158. default: 100, // 阻尼系数,越大移动越快
  159. type: [String, Number]
  160. },
  161. handleColor: {
  162. default: '#ff6a14', // 拖柄颜色
  163. type: String
  164. },
  165. handleSize: {
  166. default: '8px', // 拖柄尺寸
  167. type: [String, Number]
  168. },
  169. handleBorderRadius: {
  170. default: '8px', // 拖柄圆角半径
  171. type: [String, Number]
  172. },
  173. showInfo: {
  174. default: false, // 是否在进度条右侧显示百分比
  175. type: [Boolean, String]
  176. },
  177. infoSize: {
  178. default: '16px', // 百分比显示字体尺寸
  179. type: [String, Number]
  180. },
  181. infoColor: {
  182. default: '#000000', // 百分比显示字体颜色
  183. type: String
  184. },
  185. infoEndText: {
  186. default: '',
  187. type: String
  188. },
  189. borderRadius: {
  190. default: 0, // 进度条圆角半径
  191. type: [String, Number]
  192. },
  193. width: {
  194. default: '200px', // 进度条总宽,如果显示百分比,则包括百分比在内的宽度
  195. type: [String, Number]
  196. },
  197. },
  198. computed: {
  199. getShowInfoStatus2view(){
  200. if ((this.showInfo == true || this.showInfo == 'true') && this.direction != "vertical"){
  201. return true
  202. }
  203. else{
  204. return false
  205. }
  206. },
  207. showVLC (){
  208. let minl = this.textLength(this.minValue.toFixed(0) + this.infoEndText)
  209. let maxl = this.textLength(this.maxValue.toFixed(0) + this.infoEndText)
  210. let L = maxl > minl ? maxl : minl
  211. return L
  212. },
  213. flexDirection (){
  214. if (this.direction == 'vertical'){
  215. return 'column'
  216. }
  217. else{
  218. return 'row'
  219. }
  220. },
  221. pgBarBottom (){
  222. // progress-
  223. if (this.direction == 'vertical'){
  224. return '0px'
  225. }
  226. else{
  227. return 'unset'
  228. }
  229. },
  230. showInfoStatus (){
  231. if (this.getShowInfoStatus() && this.direction != "vertical"){
  232. return true
  233. }
  234. else{
  235. return false
  236. }
  237. },
  238. pgBarBg(){
  239. let bg1
  240. if (this.direction == 'vertical'){
  241. bg1 = "linear-gradient(to top," + this.activeColor + ' ' + this.percent + "%," + this.noActiveColor + ' ' + this.percent + "%)"
  242. }
  243. else{
  244. bg1 = "linear-gradient(to right," + this.activeColor + ' ' + this.percent + "%," + this.noActiveColor + ' ' + this.percent + "%)"
  245. // qq
  246. let bg2 = "-webkit-linear-gradient(left," + this.activeColor + ' ' + this.percent + "%," + this.noActiveColor + ' ' + this.percent + "%)"
  247. let bg3 = "-o-linear-gradient(right," + this.activeColor + ' ' + this.percent + "%," + this.noActiveColor + ' ' + this.percent + "%)"
  248. let bg4 = "-moz-linear-gradient(right," + this.activeColor + ' ' + this.percent + "%," + this.noActiveColor + ' ' + this.percent + "%)"
  249. }
  250. return bg1
  251. },
  252. pgBarBR(){
  253. return this.sizeDeal(this.borderRadius)[2]
  254. },
  255. bgBR() {
  256. return this.sizeDeal(this.bgBorderRadius)[2]
  257. },
  258. iconBR() {
  259. return this.sizeDeal(this.iconBorderRadius)[2]
  260. },
  261. iconS() {
  262. return this.sizeDeal(this.iconSize)[2]
  263. },
  264. infoW() {
  265. const s = this.sizeDeal(this.infoSize)
  266. const size = s[0] * this.showVL + s[1]
  267. return size
  268. },
  269. infoS() {
  270. return this.sizeDeal(this.infoSize)[2]
  271. },
  272. infoRt(){
  273. // showinfo right
  274. if (this.infoAlign == 'left' && this.direction != 'vertical'){
  275. return 'unset'
  276. }
  277. else{ return 0 }
  278. },
  279. infoLt(){
  280. if (this.infoAlign == 'left' && this.direction != 'vertical'){
  281. return 0
  282. }
  283. else if (this.infoAlign == 'center' && this.direction != 'vertical'){
  284. let aw = this.area.width / 2
  285. const s = this.sizeDeal(this.infoSize)
  286. const size = aw - (s[0] * this.showVL) / 2 + 'px'
  287. return size
  288. }
  289. else{ return 'unset' }
  290. },
  291. areaW: {
  292. get (){
  293. if (this.direction == 'vertical'){
  294. return this.maxHeight(true)[2]
  295. }
  296. else{
  297. const s = this.sizeDeal(this.infoSize)
  298. const h = this.maxHeight()
  299. let w
  300. if (this.getShowInfoStatus()) {
  301. w = 'calc(' + this.width + ' - ' + s[0] * this.showVL + s[1] + ')'
  302. } else { w = this.width }
  303. return w
  304. }
  305. },
  306. set (w){ return w }
  307. },
  308. areaH: {
  309. get(){
  310. if (this.direction == 'vertical'){ return this.width }
  311. else{ return this.maxHeight()[2] }
  312. },
  313. set (v){ return v }
  314. },
  315. areaLeft() {
  316. if (this.infoAlign == 'left' && this.direction != 'vertical'){
  317. const s = this.sizeDeal(this.infoSize)
  318. const size = s[0] * this.showVL + s[1]
  319. return size
  320. }
  321. else{ return 0 }
  322. },
  323. pgBarW() {
  324. // width
  325. if (this.direction == 'vertical'){
  326. return this.sizeDeal(this.strokeWidth)[2]
  327. }
  328. else{
  329. const s = this.sizeDeal(this.infoSize)
  330. const w = this.sizeDeal(this.width)
  331. const s2 = this.sizeDeal(this.handleSize)
  332. let w2
  333. if (this.getShowInfoStatus()) {
  334. w2 = 'calc(' + w[2] + ' - ' + s[0] * this.showVL + s[1] + ' - ' + s2[2] + ')'
  335. } else {
  336. w2 = 'calc(' + w[2] + ' - ' + s2[2] + ')'
  337. }
  338. return w2
  339. }
  340. },
  341. pgBarH() {
  342. // height
  343. if (this.direction == 'vertical'){
  344. const w = this.sizeDeal(this.width)
  345. const s2 = this.sizeDeal(this.handleSize)
  346. let w2 = 'calc(' + w[2] + ' - ' + s2[2] + ')'
  347. return w2
  348. }
  349. else{ return this.sizeDeal(this.strokeWidth)[2] }
  350. },
  351. pgBarML() {
  352. // margin-left
  353. if (this.direction == 'vertical'){
  354. const s = this.sizeDeal(this.progressBarInfo.width)
  355. const ah = Number(this.area.width) / 2
  356. const t = ah - s[0] / 2 + 'px'
  357. return t
  358. }
  359. else{
  360. const s2 = this.sizeDeal(this.handleSize)
  361. return s2[0] / 2 + s2[1]
  362. }
  363. },
  364. pgBarMB() {
  365. // margin-bottom
  366. if (this.direction == 'vertical'){
  367. const s2 = this.sizeDeal(this.handleSize)
  368. return s2[0] / 2 + s2[1]
  369. }
  370. else{ return 0 }
  371. },
  372. handleS() {
  373. const s = this.sizeDeal(this.handleSize)
  374. return s[2]
  375. },
  376. handleL (){
  377. if (this.direction == 'vertical') {
  378. const s = this.sizeDeal(this.handleSize)
  379. const ah = Number(this.area.width) / 2
  380. const t = ah - s[0] / 2 + 'px'
  381. return t
  382. }
  383. else{
  384. return 'unset'
  385. }
  386. },
  387. handleT() {
  388. if (this.area.height && this.direction != 'vertical') {
  389. const s = this.sizeDeal(this.handleSize)
  390. const ah = Number(this.area.height) / 2
  391. const t = ah - s[0] / 2 + 'px'
  392. return t
  393. }
  394. else{
  395. return 'unset'
  396. }
  397. },
  398. handleBR() {
  399. const r = this.sizeDeal(this.handleBorderRadius)
  400. return r[2]
  401. },
  402. progressMainW() {
  403. let w
  404. if (this.direction == 'vertical'){
  405. w = this.maxHeight(true)[2]
  406. }
  407. else{
  408. w = this.width
  409. }
  410. return w
  411. },
  412. progressMainH() {
  413. let h
  414. if (this.direction == 'vertical'){
  415. h = this.width
  416. }
  417. else{
  418. h = this.maxHeight()[2]
  419. }
  420. return h
  421. },
  422. maxValue() {
  423. let max = Number.isNaN(parseFloat(this.max)) ? 100 : parseFloat(this.max)
  424. return this.valueFormat(max)
  425. },
  426. minValue() {
  427. let min = Number.isNaN(parseFloat(this.min)) ? 0 : parseFloat(this.min)
  428. let si = this.getStepInfo()
  429. return Number(min.toFixed(si[1]))
  430. // return this.valueFormat(min)
  431. },
  432. },
  433. watch: {
  434. showVLC (v){
  435. this.showVL = v
  436. if (this.direction != 'vertical'){
  437. const s = this.sizeDeal(this.infoSize)
  438. const h = this.maxHeight()
  439. let w
  440. if (this.getShowInfoStatus()) {
  441. w = 'calc(' + this.width + ' - ' + s[0] * this.showVL + s[1] + ')'
  442. } else {
  443. w = this.width
  444. }
  445. this.areaW = w
  446. this.areaH = h[2]
  447. }
  448. this.clientInit()
  449. },
  450. value(v) {
  451. // 当处于拖动状态时,禁止进度条外部触发变化
  452. if (!this.handleMoveStatus) {
  453. this.showValue = this.valueFormat(v)
  454. this.percent = (this.showValue - this.minValue) / Math.abs(this.maxValue - this.minValue) * 100
  455. if (this.direction == 'vertical'){
  456. this.handleY = this.progressBarInfo.height * this.percent / 100
  457. }
  458. else{
  459. this.handleX = this.progressBarInfo.width * this.percent / 100
  460. }
  461. }
  462. },
  463. },
  464. methods: {
  465. valueFormat (v){
  466. // set step
  467. v = Number(v - this.minValue).toFixed(7)
  468. let stepInfo = this.getStepInfo()
  469. let valueE = v * 10 ** stepInfo[1]
  470. let remainder = valueE % (stepInfo[0] * 10 ** stepInfo[1])
  471. let remainderInt = Math.floor(remainder)
  472. let value = (Math.floor(valueE) - remainderInt) / (10 ** stepInfo[1])
  473. return Number((value + this.minValue).toFixed(6))
  474. },
  475. getStepInfo() {
  476. // return step, decimal位数
  477. let step = Number(this.step)
  478. if (step <= 0 || !step){
  479. return [1, 0]
  480. }
  481. else{
  482. let steps = step.toString().split('.')
  483. if (steps.length == 1){
  484. return [step,0]
  485. }
  486. else {
  487. return [step,steps[1].length]
  488. }
  489. }
  490. },
  491. clientInit() {
  492. this.$nextTick(function() {
  493. const query = uni.createSelectorQuery().in(this)
  494. query.select(".cu-progress-bar").boundingClientRect(data => {
  495. this.progressBarInfo.width = data.width
  496. this.progressBarInfo.left = data.left
  497. this.progressBarInfo.bottom = data.bottom
  498. this.progressBarInfo.height = data.height
  499. if (this.direction == 'vertical'){
  500. this.handleY = this.progressBarInfo.height * this.percent / 100
  501. }
  502. else{
  503. this.handleX = this.progressBarInfo.width * this.percent / 100
  504. }
  505. }).exec()
  506. query.select(".cu-area").boundingClientRect(data => {
  507. this.area.width = data.width
  508. this.area.left = data.left
  509. this.area.height = data.height
  510. this.area.bottom = data.bottom
  511. this.area.top = data.top
  512. }).exec()
  513. if (this.maxValue - this.minValue == 0) {
  514. console.error("min不能等于max:" + this.minValue + "->" + this.maxValue)
  515. }
  516. else{
  517. let stepInfo = this.getStepInfo()
  518. let v = this.percent * (this.maxValue - this.minValue) / 100
  519. let valueE = v * 10 ** stepInfo[1]
  520. let remainder = valueE % (stepInfo[0] * 10 ** stepInfo[1])
  521. let remainderInt = Math.floor(remainder)
  522. let sv = (Math.floor(valueE) - remainderInt) / (10 ** stepInfo[1])
  523. this.showValue = sv
  524. }
  525. })
  526. },
  527. getShowInfoStatus(){
  528. if ((this.showInfo == true || this.showInfo == 'true') && this.direction != "vertical" && this.infoAlign !== 'center'){
  529. return true
  530. }
  531. else{
  532. return false
  533. }
  534. },
  535. textLength(t) {
  536. t = t.toString()
  537. let int = t.split('.')[0]
  538. let subt = t.match(/[^\x00-\xff]/g)
  539. let subl = 0
  540. if (subt) {
  541. subl = subt.length
  542. }
  543. let l = (int.length - subl + this.getStepInfo()[1]) / 3 * 2 + subl + 0.2
  544. return Number(l.toFixed(2))
  545. },
  546. maxHeight(vertical) {
  547. let h = []
  548. if (!vertical){ // direction 为 vertical 时不显示info
  549. let subt = this.infoEndText.match(/[^\x00-\xff]/g)
  550. if (subt){
  551. h.push(this.sizeDeal(this.infoSize)[0] * 1.1)
  552. }
  553. else{
  554. h.push(this.sizeDeal(this.infoSize)[0])
  555. }
  556. }
  557. h.push(this.sizeDeal(this.strokeWidth)[0])
  558. h.push(this.sizeDeal(this.handleSize)[0])
  559. h.sort(function(a, b) {
  560. return b - a
  561. }) // 降序
  562. return [h[0], 'px', h[0] + 'px']
  563. },
  564. sizeDeal(size) {
  565. // 分离字体大小和单位,rpx 转 px
  566. let s = Number.isNaN(parseFloat(size)) ? 0 : parseFloat(size)
  567. let u = size.toString().replace(/[0-9]/g, '')
  568. if (u == 'rpx') {
  569. s /= this.scale
  570. u = 'px'
  571. } else if (u == '') {
  572. u = 'px'
  573. }else if (u == 'vw') {
  574. u = 'px'
  575. s = s / 100 * 750 / this.scale
  576. }
  577. return [s, u, s + u]
  578. },
  579. change (){
  580. this.$emit('change', {
  581. type: 'change',
  582. value: this.showValue,
  583. })
  584. },
  585. handleMove(x_) {
  586. let x = x_
  587. x = x >= 0 ? x : 0
  588. let s = this.sizeDeal(this.handleSize)
  589. let cp
  590. let sv
  591. if (this.direction == 'vertical'){
  592. // #ifdef H5
  593. x = x - s[0] / 2 - this.area.bottom // ?
  594. cp = x / (this.area.height - s[0] - 1)
  595. // #endif
  596. // #ifndef H5
  597. x = x - this.area.top - s[0] / 2
  598. cp = x / (this.area.height - s[0] - 1)
  599. // #endif
  600. cp = cp <= 1 ? cp : 1
  601. cp = cp > 0 ? cp : 0
  602. let value = Number(((1 - cp) * (this.maxValue - this.minValue))) + this.minValue
  603. this.percent = (1 - cp) * 100
  604. this.showValue = this.valueFormat(value)
  605. this.handleY = x
  606. }
  607. else{
  608. cp = x / (this.area.width - s[0] - 1) // 多减 1 避免达不到maxValue
  609. cp = cp <= 1 ? cp : 1
  610. cp = cp > 0 ? cp : 0
  611. let value = Number((cp * (this.maxValue - this.minValue))) + this.minValue
  612. this.percent = cp * 100
  613. this.showValue = this.valueFormat(value)
  614. this.handleX = x
  615. }
  616. this.$emit('dragging', {
  617. type: 'dragging',
  618. value: this.showValue
  619. })
  620. },
  621. touchEnd() {
  622. if (!this.disabled){
  623. this.handleMoveStatus = false
  624. this.$emit('dragged', {
  625. type: 'dragged',
  626. value: this.showValue
  627. })
  628. }
  629. },
  630. areaTouchStart(e) {
  631. if (!this.disabled){
  632. this.handleMoveStatus = true
  633. let s = this.sizeDeal(this.handleSize)
  634. let tapX
  635. if (this.direction == 'vertical'){
  636. // #ifdef H5
  637. tapX = this.area.height + e.changedTouches[0].pageY
  638. // #endif
  639. // #ifndef H5
  640. tapX = e.changedTouches[0].pageY
  641. // #endif
  642. }
  643. else{
  644. tapX = e.changedTouches[0].pageX - this.area.left - s[0] / 2 // 拖柄中心与鼠标箭头一致
  645. }
  646. tapX = tapX >= 0 ? tapX : 0
  647. this.handleMove(tapX)
  648. this.$emit('dragstart', {
  649. type: 'dragstart',
  650. value: this.showValue
  651. })
  652. }
  653. },
  654. areaTouchMove(e) {
  655. if (!this.disabled){
  656. let s = this.sizeDeal(this.handleSize)
  657. let tapX
  658. if (this.direction == 'vertical'){
  659. // #ifdef H5
  660. tapX = this.area.height + e.changedTouches[0].pageY
  661. // #endif
  662. // #ifndef H5
  663. tapX = e.changedTouches[0].pageY
  664. // #endif
  665. }
  666. else{
  667. tapX = e.changedTouches[0].pageX - this.area.left - s[0] / 2
  668. }
  669. tapX = tapX >= 0 ? tapX : 0
  670. this.handleMove(tapX)
  671. }
  672. },
  673. touchCancel() {
  674. if (!this.disabled){
  675. this.touchEnd()
  676. this.$emit('dragcancel', {
  677. type: 'dragcancel',
  678. value: this.showValue
  679. })
  680. }
  681. },
  682. }
  683. }
  684. </script>
  685. <style scoped>
  686. @import 'cu-progress.css'
  687. </style>