You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1811 lines
33 KiB

3 years ago
  1. /**
  2. * BaseCloud APP更新检测组件
  3. v1.0.4
  4. */
  5. <template>
  6. <view class="base-cloud" style="display: inline-block;">
  7. <view class="father" style="display: flex;align-items: center;" v-if="showVersion" @click.stop.prevent="checkVersion">
  8. <text class="version-text">版本{{version}}</text>
  9. <view class="abs top right" v-if="updateData.updated" style="top: -3px;right: -7px;">
  10. <view class="w7 h7 rds redBg"></view>
  11. </view>
  12. </view>
  13. <view class="fixed z20 wp6 flex ct plr50 pb50 " v-if="show">
  14. <view class="w100p showIn" :animation="inData" style="max-width: 300px;">
  15. <view class="rds12" :style="{'background-color':color}">
  16. <view class="father">
  17. <view class="h120 father hidden">
  18. <view class="abs top left50p">
  19. <image src="./static/cloudRight.png" mode="widthFix" class="w500 h120 animated goAway infinite"></image>
  20. </view>
  21. <view class="abs top right50p">
  22. <image src="./static/cloudLeft.png" mode="widthFix" class="w500 h120 animated goAwayLeft infinite"></image>
  23. </view>
  24. <image class="abs top30 left30 w10 h10 animated infinite fadeOut slow" src="./static/star.png" mode="widthFix"></image>
  25. <image class="abs top60 left80 w10 h10 animated infinite fadeOut slowest delay-1s" src="./static/star.png" mode="widthFix"></image>
  26. <image class="abs top20 right20 w10 h10 animated infinite fadeOut slower delay-2s" src="./static/star.png" mode="widthFix"></image>
  27. <image class="abs top20 right50 w30 h30 animated fadeOutRight infinite slowest" src="./static/smallCloud.png"
  28. mode="widthFix"></image>
  29. <image class="abs top30 left50 w30 h30 animated fadeOutRight infinite slow8 " src="./static/smallCloud.png" mode="widthFix"></image>
  30. </view>
  31. <view class="abs bottom animated bounceUp infinite">
  32. <view class="animated goUp delay-06s">
  33. <image src="./static/airship.png" mode="widthFix" class="w80 h75 center-block father z3"></image>
  34. <view class="father" style="top: -5px;">
  35. <image src="./static/shipAir.png" mode="widthFix" class="w40 h85 center-block animated infinite splashOut"></image>
  36. <view class="abs">
  37. <image src="./static/shipAir.png" mode="widthFix" class="w40 h85 center-block animated infinite splashOut delay-03s"></image>
  38. </view>
  39. <view class="abs">
  40. <image src="./static/shipAir.png" mode="widthFix" class="w40 h85 center-block animated infinite splashOut delay-06s"></image>
  41. </view>
  42. <view class="abs bottom" style="bottom: -80upx;">
  43. <image src="./static/shipGas.png" mode="widthFix" class="w40 h85 center-block animated infinite splash"></image>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class=" whiteBg hidden plr20 father z3 rdsBr12 rdsBl12" :class="{'pb100':progress <= 0 || progress >= 100 || completed}">
  50. <view class="ptb10 fz16 bold">
  51. <block v-if="progress == 0">
  52. {{title}} {{ updateData.version ? 'v' + updateData.version : ''}}
  53. </block>
  54. <block v-else-if="progress <=100 && !completed">
  55. <view>
  56. <view class="fz30 normal avanti pt15 text-center">
  57. {{ progress }}
  58. <text class="fz12 ml2">
  59. %
  60. </text>
  61. </view>
  62. <view class="text-center pb40 op8 gray fz14 normal">
  63. 版本更新中不要离开...
  64. </view>
  65. </view>
  66. </block>
  67. <view class="text-center pt15" v-else-if="completed">
  68. 版本升级成功
  69. <view class="pb40 op8 gray fz14 normal pt5">
  70. 更新已完成请重启应用体验新版
  71. </view>
  72. </view>
  73. </view>
  74. <scroll-view scroll-y="true" class="scroll-view h60 autoY pb20" v-if="progress == 0">
  75. <view class="column">
  76. <text v-if="updateData.description.length === 0">
  77. {{ defaultContent }}
  78. </text>
  79. <text v-for="(item, index) in updateData.description" :key="index">
  80. {{ index + 1 }}.{{ item }}
  81. </text>
  82. </view>
  83. </scroll-view>
  84. <view class="pd50 pt25" v-else-if="progress < 100">
  85. <view class="grayBg bd rds23">
  86. <view class="grayBg rds23">
  87. <view class="ptb3 rds23" :style="{width:progress+'%','background-color':color}"></view>
  88. </view>
  89. </view>
  90. </view>
  91. <view class="father">
  92. <view class="abs top left50p roundBox rds text-center" :style="{'background-color':color}">
  93. <view class="pt30" v-if="!completed">
  94. <button hover-class="op9" @tap.stop="download" class="btn bd2 whiteBg line rds23 inline plr50 ptb10 fz16">
  95. 立即升级
  96. </button>
  97. </view>
  98. <view class="pt30" v-else>
  99. <button hover-class="op8" @tap.stop="restart" class="btn bd2 whiteBg line rds23 inline plr50 ptb10 fz16">
  100. 立即重启
  101. </button>
  102. </view>
  103. </view>
  104. </view>
  105. </view>
  106. </view>
  107. <view class="op9 father" v-if="progress == 0">
  108. <view class="abs">
  109. <view class="flex ct ">
  110. <view class="h30 bl3 whiteBd"></view>
  111. </view>
  112. <view class="close-btn" @click="hide">
  113. <text class="mix-icon icon-close"></text>
  114. </view>
  115. </view>
  116. </view>
  117. </view>
  118. </view>
  119. <mix-loading v-if="isLoading"></mix-loading>
  120. </view>
  121. </template>
  122. <script>
  123. export default {
  124. name: "version-update",
  125. props: {
  126. title: {
  127. default: "发现新版本"
  128. },
  129. defaultContent: {
  130. default: "快来升级,体验最新的功能吧!"
  131. },
  132. showVersion: {
  133. default: true
  134. },
  135. autoShow: {
  136. default: false
  137. },
  138. isCache: {
  139. default: true
  140. },
  141. updateUrl: {
  142. default: "api/base-app-version"
  143. },
  144. color: {
  145. default: "#ff536f"
  146. }
  147. },
  148. data() {
  149. return {
  150. show: false,
  151. version: "1.0.0",
  152. updateData: {
  153. description: []
  154. },
  155. progress: 0,
  156. completed: false,
  157. inData: null
  158. };
  159. },
  160. created() {
  161. // #ifdef APP-PLUS
  162. plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
  163. this.version = widgetInfo.version;
  164. });
  165. // #endif
  166. },
  167. methods: {
  168. async checkVersion(e) {
  169. console.log(e);
  170. const res = await this.$request('version', 'check', {
  171. version: this.version
  172. }, {
  173. showLoading: true
  174. })
  175. if (res.status === 0) {
  176. this.$util.msg(res.msg);
  177. } else {
  178. res.data.description = res.data.description.split(';');
  179. this.updateData = res.data;
  180. this.show = true;
  181. }
  182. },
  183. download(e) {
  184. if(this.isDownloading){
  185. return;
  186. }
  187. this.isDownloading = true;
  188. const task = uni.downloadFile({
  189. url: this.updateData.downloadLink,
  190. success: (downloadResult) => {
  191. this.isDownloading =false;
  192. uni.hideLoading();
  193. if (downloadResult.statusCode === 200) {
  194. plus.runtime.install(downloadResult.tempFilePath, {
  195. force: false
  196. }, (e) => {
  197. this.downloadSuccess(e);
  198. }, (err) => {
  199. this.downloadError(err);
  200. });
  201. }
  202. },
  203. fail: err => {
  204. this.isDownloading =false;
  205. this.downloadError(err);
  206. }
  207. });
  208. task.onProgressUpdate((e) => {
  209. console.log(e.progress);
  210. this.progress = e.progress;
  211. });
  212. },
  213. downloadError(e) {
  214. this.show = false;
  215. this.progress = 0;
  216. uni.showModal({
  217. title: '提示',
  218. content: '更新失败,请稍后再试',
  219. showCancel: false,
  220. confirmColor: '#414cd9'
  221. });
  222. },
  223. downloadSuccess(e) {
  224. this.completed = true;
  225. },
  226. restart(e) {
  227. this.show = false;
  228. this.completed = false;
  229. this.progress = 0;
  230. // #ifdef APP-PLUS
  231. plus.runtime.restart();
  232. // #endif
  233. },
  234. hide(e) {
  235. var animation = uni.createAnimation({
  236. duration: 300,
  237. timingFunction: 'ease',
  238. });
  239. animation.scale(0).opacity(0).step();
  240. this.inData = animation.export();
  241. setTimeout((e) => {
  242. this.show = false;
  243. this.inData = null;
  244. }, 420);
  245. },
  246. },
  247. }
  248. </script>
  249. <style scoped lang="scss">
  250. .version-text{
  251. margin-right: 10rpx;
  252. font-size: 26rpx;
  253. color: #999;
  254. position: relative;
  255. z-index: -2rpx;
  256. }
  257. .close-btn{
  258. display: flex;
  259. justify-content: center;
  260. color: #fff;
  261. .mix-icon{
  262. margin-top: -20rpx;
  263. padding: 20rpx;
  264. font-size: 48rpx;
  265. }
  266. }
  267. .scroll-view{
  268. height: auto !important;
  269. min-height: 120rpx;
  270. max-height: 17vh;
  271. text{
  272. margin-bottom: 16rpx;
  273. line-height: 1.5;
  274. font-size: 28rpx;
  275. }
  276. }
  277. .roundBox {
  278. width: 5000upx;
  279. height: 5000upx;
  280. margin-left: -2500upx;
  281. }
  282. .animated {
  283. -webkit-animation-duration: 1s;
  284. animation-duration: 1s;
  285. -webkit-animation-fill-mode: both;
  286. animation-fill-mode: both;
  287. animation-timing-function: linear;
  288. }
  289. .animated.infinite {
  290. -webkit-animation-iteration-count: infinite;
  291. animation-iteration-count: infinite;
  292. }
  293. @keyframes goUp {
  294. from {
  295. -webkit-transform: translate3d(0, 70%, 0);
  296. transform: translate3d(0, 70%, 0);
  297. }
  298. to {
  299. -webkit-transform: translate3d(0, 0, 0);
  300. transform: translate3d(0, 0, 0);
  301. }
  302. }
  303. .goUp {
  304. -webkit-animation-name: goUp;
  305. animation-name: goUp;
  306. -webkit-animation-duration: 600ms;
  307. animation-duration: 600ms;
  308. animation-timing-function: ease-in;
  309. }
  310. @keyframes splash {
  311. 0,
  312. 100% {
  313. transform: scaleX(0.9);
  314. }
  315. 5%,
  316. 95% {
  317. transform: scaleX(1.02);
  318. }
  319. 10%,
  320. 80% {
  321. transform: scaleX(1.05);
  322. }
  323. 25%,
  324. 75% {
  325. transform: scaleX(1.08);
  326. }
  327. 50% {
  328. transform: scaleX(1.1);
  329. }
  330. }
  331. .splash {
  332. -webkit-animation-name: splash;
  333. animation-name: splash;
  334. -webkit-animation-duration: 0.6s;
  335. animation-duration: 0.6s;
  336. animation-timing-function: linear;
  337. }
  338. @-webkit-keyframes splashOut {
  339. from {
  340. opacity: 1;
  341. transform: scaleX(0);
  342. }
  343. to {
  344. opacity: 0;
  345. transform: scaleX(2);
  346. }
  347. }
  348. .splashOut {
  349. -webkit-animation-name: splashOut;
  350. animation-name: splashOut;
  351. -webkit-animation-duration: 1s;
  352. animation-duration: 1s;
  353. }
  354. @keyframes bounceUp {
  355. 0% {
  356. transform: translate3d(0, 0, 0);
  357. }
  358. 50% {
  359. transform: translate3d(0, -30rpx, 0);
  360. }
  361. }
  362. .bounceUp {
  363. -webkit-animation-name: bounceUp;
  364. animation-name: bounceUp;
  365. -webkit-animation-duration: 1.6s;
  366. animation-duration: 1.6s;
  367. animation-timing-function: linear;
  368. }
  369. @keyframes fadeOut {
  370. 0,
  371. 100% {
  372. opacity: 1;
  373. }
  374. 50% {
  375. opacity: 0;
  376. }
  377. }
  378. .fadeOut {
  379. -webkit-animation-name: fadeOut;
  380. animation-name: fadeOut;
  381. }
  382. @keyframes fadeOutRight {
  383. 0% {
  384. opacity: 0;
  385. transform: translate3d(-200%, 0, 0);
  386. }
  387. 50% {
  388. opacity: 1;
  389. transform: translate3d(0, 0, 0);
  390. }
  391. 100% {
  392. opacity: 0;
  393. transform: translate3d(200%, 0, 0);
  394. }
  395. }
  396. .fadeOutRight {
  397. -webkit-animation-name: fadeOutRight;
  398. animation-name: fadeOutRight;
  399. }
  400. .animated.delay-03s {
  401. -webkit-animation-delay: 0.3s;
  402. animation-delay: 0.3s;
  403. }
  404. .animated.delay-06s {
  405. -webkit-animation-delay: 0.6s;
  406. animation-delay: 0.6s;
  407. }
  408. .animated.delay-1s {
  409. -webkit-animation-delay: 1s;
  410. animation-delay: 1s;
  411. }
  412. .animated.delay-2s {
  413. -webkit-animation-delay: 2s;
  414. animation-delay: 2s;
  415. }
  416. .animated.delay-3s {
  417. -webkit-animation-delay: 3s;
  418. animation-delay: 3s;
  419. }
  420. .animated.fast {
  421. -webkit-animation-duration: 800ms;
  422. animation-duration: 800ms;
  423. }
  424. .animated.faster {
  425. -webkit-animation-duration: 500ms;
  426. animation-duration: 500ms;
  427. }
  428. .animated.fastest {
  429. -webkit-animation-duration: 200ms;
  430. animation-duration: 200ms;
  431. }
  432. .animated.slow {
  433. -webkit-animation-duration: 2s;
  434. animation-duration: 2s;
  435. }
  436. .animated.slower {
  437. -webkit-animation-duration: 3s;
  438. animation-duration: 3s;
  439. }
  440. .animated.slowest {
  441. -webkit-animation-duration: 10s;
  442. animation-duration: 10s;
  443. }
  444. .animated.slow4 {
  445. -webkit-animation-duration: 5s;
  446. animation-duration: 5s;
  447. }
  448. .animated.slow5 {
  449. -webkit-animation-duration: 5s;
  450. animation-duration: 5s;
  451. }
  452. .animated.slow8 {
  453. -webkit-animation-duration: 8s;
  454. animation-duration: 8s;
  455. }
  456. .goAway {
  457. transform: translate3d(-50%, 10%, 0);
  458. -webkit-animation-name: goAway;
  459. animation-name: goAway;
  460. -webkit-animation-duration: 2s;
  461. animation-duration: 2s;
  462. }
  463. @keyframes goAway {
  464. from {
  465. transform: translate3d(-50%, 10%, 0);
  466. }
  467. to {
  468. transform: translate3d(-1.3%, -17.6%, 0);
  469. }
  470. }
  471. .goAwayLeft {
  472. transform: translate3d(50%, 10%, 0);
  473. -webkit-animation-name: goAwayLeft;
  474. animation-name: goAwayLeft;
  475. -webkit-animation-duration: 2s;
  476. animation-duration: 2s;
  477. }
  478. @keyframes goAwayLeft {
  479. from {
  480. transform: translate3d(50%, 10%, 0);
  481. }
  482. to {
  483. transform: translate3d(2%, -17%, 0);
  484. }
  485. }
  486. @keyframes showIn {
  487. 0% {
  488. opacity: 0;
  489. transform: scale3d(0.5, 0.5, 0.5);
  490. }
  491. 100% {
  492. opacity: 1;
  493. transform: scale3d(1, 1, 1);
  494. }
  495. }
  496. .showIn {
  497. animation-duration: 0.4s;
  498. animation-name: showIn;
  499. }
  500. div,a,img,span,page,view,navigator,image,text,input,textarea,button,form{
  501. box-sizing: border-box;
  502. }
  503. a{
  504. text-decoration: none;
  505. color: $main;
  506. }
  507. form{
  508. display: block;
  509. width: 100%;
  510. }
  511. image{will-change: transform}
  512. input,textarea,form{
  513. width: 100%;
  514. height: auto;
  515. min-height: 10px;
  516. display: block;
  517. font-size: inherit;
  518. }
  519. button{
  520. color: inherit;
  521. line-height: inherit;
  522. margin: 0;
  523. background-color: transparent;
  524. padding: 0;
  525. -webkit-border-radius: 0;
  526. -moz-border-radius: 0;
  527. border-radius: 0;
  528. &:after{
  529. display: none;
  530. }
  531. }
  532. switch .uni-switch-input{
  533. margin-right: 0;
  534. }
  535. .wx-switch-input,.uni-switch-input{width:42px !important;height:22px !important;}
  536. .wx-switch-input::before,.uni-switch-input::before{width:40px !important;height: 20px !important;}
  537. .wx-switch-input::after,.uni-switch-input::after{width: 20px !important;height: 20px !important;}
  538. /**背景颜色**/
  539. .bg{
  540. background-color: $main;
  541. color: $mainInverse;
  542. }
  543. .gradualBg{
  544. background-image: $mainGradual;
  545. color: $mainGradualInverse ;
  546. }
  547. .grayBg{
  548. background-color: #f7f7f7;
  549. color: #30302f;
  550. }
  551. .whiteBg{
  552. background-color: #fff;
  553. color: #000;
  554. }
  555. .blackBg{
  556. background-color: #000;
  557. color: #fff;
  558. }
  559. .orangeBg{
  560. background-color: $orange;
  561. color: #fff;
  562. }
  563. .redBg{
  564. background-color: $red;
  565. color: #fff;
  566. }
  567. .yellowBg{
  568. background-color: $yellow;
  569. color: #000;
  570. }
  571. .greenBg{
  572. background-color: $green;
  573. color: #fff;
  574. }
  575. .brownBg{
  576. background-color: $brown;
  577. color: #fff;
  578. }
  579. .blueBg{
  580. background-color: $blue;
  581. color: #fff;
  582. }
  583. .purpleBg{
  584. background-color: $purple;
  585. color: #fff;
  586. }
  587. /* 文字颜色 */
  588. .main{
  589. color: $main;
  590. }
  591. .green{
  592. color: $green;
  593. }
  594. .red{
  595. color: $red;
  596. }
  597. .yellow{
  598. color: $yellow;
  599. }
  600. .black{
  601. color: $black;
  602. }
  603. .white{
  604. color: $white;
  605. }
  606. .gray{
  607. color: $gray;
  608. }
  609. .grey{
  610. color: $grey;
  611. }
  612. .orange{
  613. color: $orange;
  614. }
  615. .brown{
  616. color: $brown;
  617. }
  618. .blue{
  619. color: $blue;
  620. }
  621. .purple{
  622. color: $purple;
  623. }
  624. .hoverMain{
  625. &:hover{
  626. color: $main;
  627. }
  628. }
  629. .hoverGreen{
  630. &:hover{
  631. color: $green;
  632. }
  633. }
  634. .hoverRed{
  635. &:hover{
  636. color: $red;
  637. }
  638. }
  639. .hoverBlue{
  640. &:hover{
  641. color: $blue;
  642. }
  643. }
  644. .hoverGray{
  645. &:hover{
  646. color: $gray;
  647. }
  648. }
  649. .hoverWhite{
  650. &:hover{
  651. color: $white;
  652. }
  653. }
  654. .hoverBlack{
  655. &:hover{
  656. color: $black;
  657. }
  658. }
  659. .hoverOrange{
  660. &:hover{
  661. color: $orange;
  662. }
  663. }
  664. .hoverYellow{
  665. &:hover{
  666. color: $yellow;
  667. }
  668. }
  669. .hoverBrown{
  670. &:hover{
  671. color: $brown;
  672. }
  673. }
  674. .hoverPurple{
  675. &:hover{
  676. color: $purple;
  677. }
  678. }
  679. /* 宽度 高度 */
  680. $w:0;
  681. @while $w <= 500 {
  682. @if $w <= 100 {
  683. .w#{$w}p{
  684. width: $w*1%;
  685. }
  686. .h#{$w}p{
  687. height: $w*1%;
  688. }
  689. @if $w == 100 {
  690. .100p{
  691. width: 100%;
  692. height: 100%;
  693. }
  694. .ww{
  695. width: 100vw;
  696. }
  697. .hh{
  698. height: 100vh;
  699. }
  700. }
  701. }
  702. .w#{$w}{
  703. width: $w*2upx;
  704. }
  705. .h#{$w}{
  706. height: $w*2upx;
  707. }
  708. @if $w < 10 {
  709. $w : $w + 1 ;
  710. } @else{
  711. $w : $w + 5 ;
  712. }
  713. }
  714. /* 字号 */
  715. @for $fz from 12 through 100 {
  716. .fz#{$fz}{
  717. font-size: $fz*2upx !important;
  718. }
  719. }
  720. /* 边距 - 覆盖顺序是小的尺寸覆盖大的尺寸 少的方向覆盖多的方向 */
  721. $s : 0 ;
  722. @while $s <= 500 {
  723. .pd#{$s}{
  724. padding: $s*2upx!important;
  725. }
  726. .m#{$s}{
  727. margin: $s*2upx!important;
  728. }
  729. @if $s == 15 {
  730. .pd{
  731. padding: 30upx!important;
  732. }
  733. .m{
  734. margin: 30upx!important;
  735. }
  736. }
  737. @if $s < 10 {
  738. $s : $s + 1 ;
  739. } @else if($s < 100){
  740. $s : $s + 5 ;
  741. } @else if($s < 300){
  742. $s : $s + 10 ;
  743. } @else{
  744. $s : $s + 50 ;
  745. }
  746. }
  747. $s : 0 ;
  748. @while $s <= 500 {
  749. .ptb#{$s}{
  750. padding-top: $s*2upx!important;
  751. padding-bottom: $s*2upx!important;
  752. }
  753. .plr#{$s}{
  754. padding-left: $s*2upx!important;
  755. padding-right: $s*2upx!important;
  756. }
  757. .mtb#{$s}{
  758. margin-top: $s*2upx!important;
  759. margin-bottom: $s*2upx!important;
  760. }
  761. .mlr#{$s}{
  762. margin-left: $s*2upx!important;
  763. margin-right: $s*2upx!important;
  764. }
  765. @if $s == 15 {
  766. .ptb{
  767. padding-top: 30upx!important;
  768. padding-bottom: 30upx!important;
  769. }
  770. .plr{
  771. padding-left: 30upx!important;
  772. padding-right: 30upx!important;
  773. }
  774. .mlr{
  775. margin-left: 30upx!important;
  776. margin-right: 30upx!important;
  777. }
  778. .mtb{
  779. margin-top: 30upx!important;
  780. margin-bottom: 30upx!important;
  781. }
  782. }
  783. @if $s < 10 {
  784. $s : $s + 1 ;
  785. } @else if($s < 100){
  786. $s : $s + 5 ;
  787. } @else if($s < 300){
  788. $s : $s + 10 ;
  789. } @else{
  790. $s : $s + 50 ;
  791. }
  792. }
  793. $s : 0 ;
  794. @while $s <= 500 {
  795. .pl#{$s}{
  796. padding-left: $s*2upx!important;
  797. }
  798. .pr#{$s}{
  799. padding-right: $s*2upx!important;
  800. }
  801. .pt#{$s}{
  802. padding-top: $s*2upx!important;
  803. }
  804. .pb#{$s}{
  805. padding-bottom: $s*2upx!important;
  806. }
  807. .ml#{$s}{
  808. margin-left: $s*2upx!important;
  809. }
  810. .mr#{$s}{
  811. margin-right: $s*2upx!important;
  812. }
  813. .mt#{$s}{
  814. margin-top: $s*2upx!important;
  815. }
  816. .mb#{$s}{
  817. margin-bottom: $s*2upx!important;
  818. }
  819. @if $s == 15 {
  820. .pt{
  821. padding-top: 30upx!important;
  822. }
  823. .pb{
  824. padding-bottom: 30upx!important;
  825. }
  826. .pl{
  827. padding-left: 30upx!important;
  828. }
  829. .pr{
  830. padding-right: 30upx!important;
  831. }
  832. .mt{
  833. margin-top: 30upx!important;
  834. }
  835. .mr{
  836. margin-right: 30upx!important;
  837. }
  838. .ml{
  839. margin-left: 30upx!important;
  840. }
  841. .mb{
  842. margin-bottom: 30upx!important;
  843. }
  844. }
  845. @if $s < 10 {
  846. $s : $s + 1 ;
  847. } @else if($s < 100){
  848. $s : $s + 5 ;
  849. } @else if($s < 300){
  850. $s : $s + 10 ;
  851. } @else{
  852. $s : $s + 50 ;
  853. }
  854. }
  855. /* 文字溢出隐藏 */
  856. .clip{
  857. width: 100%;
  858. display: -webkit-box;
  859. overflow: hidden;
  860. -webkit-line-clamp: 1;
  861. -webkit-box-orient: vertical;
  862. @for $i from 2 through 10{
  863. &.c#{$i}{
  864. -webkit-line-clamp: $i;
  865. }
  866. }
  867. }
  868. .cut{
  869. display: block;
  870. width: 100%;
  871. overflow: hidden;
  872. text-overflow: ellipsis;
  873. white-space: nowrap;
  874. }
  875. /* 价格 */
  876. .price{
  877. font-size: inherit ;
  878. &:before{
  879. content: "¥";
  880. font-size: 70%;
  881. color: inherit;
  882. font-weight: normal;
  883. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif ;
  884. }
  885. .point{
  886. display: inline-block;
  887. font-size: 70%;
  888. font-weight: inherit;
  889. letter-spacing: 1px;
  890. color: inherit;
  891. }
  892. &.noPrefix{
  893. &:before{
  894. content: '';
  895. }
  896. }
  897. }
  898. /* 布局 */
  899. .grid,.gridNoPd,.gridSmPd,.gridNoMb{
  900. display: -webkit-box;
  901. display: -webkit-flex;
  902. display: -ms-flexbox;
  903. display: flex;
  904. -webkit-flex-wrap: wrap;
  905. -ms-flex-wrap: wrap;
  906. flex-wrap: wrap;
  907. width: 100%;
  908. padding: 20upx 20upx 0 20upx;
  909. >.item,>image,>view,>navigator,>text,>button{
  910. width: 50%;
  911. padding: 0 10upx;
  912. margin-bottom: 20upx;
  913. }
  914. @for $i from 1 through 50{
  915. &.g#{$i}{
  916. >.item,>image,>view,>navigator,>text,>button{
  917. width: 100%/$i;
  918. }
  919. }
  920. }
  921. }
  922. .gridNoMb{
  923. >.item,>image,>view,>navigator,>text,>button{
  924. margin-bottom: 0;
  925. }
  926. }
  927. .gridNoPd{
  928. padding: 0;
  929. >.item,>image,>view,>navigator,>text,>button{
  930. padding: 0;
  931. margin-bottom: 0;
  932. }
  933. }
  934. .gridSmPd{
  935. padding: 0;
  936. >.item,>image,>view,>navigator,>text,>button{
  937. padding-right: 0;
  938. &:first-child{
  939. padding-left: 0;
  940. padding-right: 10upx;
  941. }
  942. }
  943. }
  944. /* flex布局 */
  945. .flex{
  946. display: flex;
  947. align-items: center;
  948. justify-content: space-between;
  949. &.t{
  950. align-items: flex-start;
  951. }
  952. &.b{
  953. align-items: flex-end;
  954. }
  955. &.cv{ //垂直方向铺满
  956. align-items: stretch;
  957. }
  958. &.bk{ //水平方向铺满
  959. flex-direction: column;
  960. }
  961. &.lt{
  962. justify-content: flex-start;
  963. }
  964. &.ct{
  965. justify-content: center;
  966. }
  967. &.rt{
  968. justify-content: flex-end;
  969. }
  970. &.ar{
  971. justify-content: space-around;
  972. }
  973. &.av{
  974. >.item,view,button,navigator,image,text{
  975. flex:1;
  976. }
  977. }
  978. }
  979. /* 定位布局 */
  980. .father{
  981. position: relative;
  982. }
  983. .abs,.fixed{
  984. position: absolute;
  985. top: 0;
  986. left: 0;
  987. right: 0;
  988. bottom: 0;
  989. z-index: 1;
  990. &image{
  991. width: 100%;
  992. height: 100%;
  993. }
  994. &.top{
  995. bottom: auto;
  996. }
  997. &.bottom{
  998. top: auto;
  999. }
  1000. &.left{
  1001. right: auto;
  1002. }
  1003. &.right{
  1004. left: auto;
  1005. }
  1006. }
  1007. @for $i from 0 through 20 {
  1008. .z#{$i}{
  1009. z-index: $i !important;
  1010. }
  1011. }
  1012. @for $i from 1 through 200 {
  1013. .top-#{$i}{
  1014. bottom: auto;
  1015. top: $i * -2upx;
  1016. }
  1017. .left-#{$i}{
  1018. right: auto;
  1019. left: $i * -2upx;
  1020. }
  1021. .bottom-#{$i}{
  1022. top: auto;
  1023. bottom: $i * -2upx;
  1024. }
  1025. .right-#{$i}{
  1026. left: auto;
  1027. right: $i * -2upx;
  1028. }
  1029. .top#{$i}{
  1030. bottom: auto;
  1031. top: $i * 2upx;
  1032. }
  1033. .left#{$i}{
  1034. right: auto;
  1035. left: $i * 2upx;
  1036. }
  1037. .bottom#{$i}{
  1038. top: auto;
  1039. bottom: $i * 2upx;
  1040. }
  1041. .right#{$i}{
  1042. left: auto;
  1043. right: $i * 2upx;
  1044. }
  1045. .top-#{$i}p{
  1046. bottom: auto;
  1047. top: $i * -1%;
  1048. }
  1049. .left-#{$i}p{
  1050. right: auto;
  1051. left: $i * -1%;
  1052. }
  1053. .bottom-#{$i}p{
  1054. top: auto;
  1055. bottom: $i * -1%;
  1056. }
  1057. .right-#{$i}p{
  1058. left: auto;
  1059. right: $i * -1%;
  1060. }
  1061. .top#{$i}p{
  1062. bottom: auto;
  1063. top: $i * 1%;
  1064. }
  1065. .left#{$i}p{
  1066. right: auto;
  1067. left: $i * 1%;
  1068. }
  1069. .bottom#{$i}p{
  1070. top: auto;
  1071. bottom: $i * 1%;
  1072. }
  1073. .right#{$i}p{
  1074. left: auto;
  1075. right: $i * 1%;
  1076. }
  1077. }
  1078. .fixed{
  1079. position: fixed;
  1080. }
  1081. /* fix-auto布局 */
  1082. .fixAuto,.fixAutoNoPd,.fixAutoSmPd{
  1083. display: table;
  1084. width: 100%;
  1085. padding: 20upx 10upx;
  1086. >.item,>view,>image,>navigator,>text,>button{
  1087. vertical-align: top;
  1088. padding: 0 10upx;
  1089. display: table-cell ;
  1090. }
  1091. &.middle{
  1092. >.item,>view,>image,>navigator,>text{
  1093. vertical-align: middle;
  1094. }
  1095. }
  1096. &.bottom{
  1097. >.item,>view,>image,>navigator,>text{
  1098. vertical-align: bottom;
  1099. }
  1100. }
  1101. }
  1102. .fixAutoSmPd{
  1103. padding: 0;
  1104. >.item,>view,>image,>navigator,>text{
  1105. padding-right: 0;
  1106. &:first-child{
  1107. padding-left: 0;
  1108. padding-right: 10upx;
  1109. }
  1110. }
  1111. }
  1112. .fixAutoNoPd{
  1113. padding: 0;
  1114. >.item,>view,>image,>navigator,>text{
  1115. padding: 0;
  1116. }
  1117. }
  1118. /* 浮动组件 */
  1119. .clear{
  1120. &:after{
  1121. content: "";
  1122. clear: both;
  1123. height: 0;
  1124. display: block;
  1125. visibility: hidden;
  1126. }
  1127. }
  1128. .fl{
  1129. float: left;
  1130. }
  1131. .fr{
  1132. float: right;
  1133. }
  1134. /* 按钮样式类 */
  1135. .btn,.roundBtn{
  1136. cursor: pointer;
  1137. display: inline-block;
  1138. text-align: center;
  1139. padding: 8upx 24upx;
  1140. background-color: $main;
  1141. color: $mainInverse ;
  1142. font-size: 28upx;
  1143. border: 1px solid $main;
  1144. -webkit-border-radius: 8upx;
  1145. -moz-border-radius: 8upx;
  1146. border-radius: 8upx;
  1147. transition: 0.4s;
  1148. white-space: nowrap;
  1149. text-overflow: ellipsis;
  1150. &.gradualBg{
  1151. border-color: transparent;
  1152. background-image: $mainGradual;
  1153. color: $mainGradualInverse;
  1154. }
  1155. &.blackBg{
  1156. background-color: $black;
  1157. border-color: $black;
  1158. color: #fff;
  1159. &.shadow{
  1160. box-shadow: 0px 2px 9px -1px rgba($black , 0.4);
  1161. }
  1162. }
  1163. &.greenBg{
  1164. background-color: $green;
  1165. border-color: $green;
  1166. color: #fff;
  1167. &.shadow{
  1168. box-shadow: 0px 2px 9px -1px rgba($green , 0.4);
  1169. }
  1170. }
  1171. &.grayBg{
  1172. border-color: rgba(#30302f,0.2);
  1173. background-color: #f7f7f7;
  1174. color: #30302f;
  1175. &.shadow{
  1176. box-shadow: 0px 2px 9px -1px rgba( #30302f , 0.2);
  1177. }
  1178. }
  1179. &.whiteBg{
  1180. border-color: rgba(#fff,0.2);
  1181. background-color: #fff;
  1182. color: #000;
  1183. }
  1184. &.orangeBg{
  1185. border-color: $orange;
  1186. background-color: $orange;
  1187. color: #fff;
  1188. &.shadow{
  1189. box-shadow: 0px 2px 9px -1px rgba( $orange , 0.4);
  1190. }
  1191. }
  1192. &.redBg{
  1193. border-color: $red;
  1194. background-color: $red;
  1195. color: #fff;
  1196. &.shadow{
  1197. box-shadow: 0px 2px 9px -1px rgba( $red , 0.4);
  1198. }
  1199. }
  1200. &.yellowBg{
  1201. border-color: $yellow;
  1202. background-color: $yellow;
  1203. color: #000;
  1204. &.shadow{
  1205. box-shadow: 0px 2px 9px -1px rgba( $yellow , 0.4);
  1206. }
  1207. }
  1208. &.line{
  1209. background-color: transparent;
  1210. background-image: none;
  1211. color: $main;
  1212. &.blackBg{
  1213. color: $black;
  1214. }
  1215. &.greenBg{
  1216. color: $green;
  1217. }
  1218. &.yellowBg{
  1219. color: $yellow;
  1220. }
  1221. &.grayBg{
  1222. color: #30302f;
  1223. }
  1224. &.whiteBg{
  1225. border-color: rgba(#fff,0.7);
  1226. color: #fff;
  1227. }
  1228. &.orangeBg{
  1229. color: $orange;
  1230. }
  1231. &.redBg{
  1232. color: $red;
  1233. }
  1234. }
  1235. &+.btn,&+.roundBtn{
  1236. margin-left: 20upx;
  1237. }
  1238. &.block{
  1239. margin: 0;
  1240. padding: 20upx 24upx;
  1241. display: block;
  1242. width: 100%;
  1243. &+.btn{
  1244. margin-left: 0;
  1245. }
  1246. }
  1247. &:hover{
  1248. -webkit-transform: scale(0.99);
  1249. -moz-transform: scale(0.99);
  1250. -ms-transform: scale(0.99);
  1251. -o-transform: scale(0.99);
  1252. transform: scale(0.99);
  1253. opacity: 0.8;
  1254. }
  1255. &.disabled{
  1256. -webkit-transform: scale(1);
  1257. -moz-transform: scale(1);
  1258. -ms-transform: scale(1);
  1259. -o-transform: scale(1);
  1260. transform: scale(1);
  1261. opacity: 0.4;
  1262. cursor: not-allowed;
  1263. }
  1264. }
  1265. [class^="tag"] , [class*=" tag"]{
  1266. display: inline-block;
  1267. font-size: 24upx;
  1268. padding: 4upx 14upx;
  1269. border-radius: 4upx;
  1270. margin-right: 6upx;
  1271. margin-left: 6upx;
  1272. }
  1273. .tag{
  1274. background-color: rgba($main,0.2);
  1275. color: $main;
  1276. }
  1277. .tagBlue{
  1278. background-color: rgba($blue,0.2);
  1279. color: $blue;
  1280. }
  1281. .tagGray{
  1282. background-color: rgba($gray,0.2);
  1283. color: $gray;
  1284. }
  1285. .tagGradual{
  1286. background-image: linear-gradient(to top right,rgba($main,0.2),rgba($main,0.1));
  1287. color: $main;
  1288. }
  1289. .tagBlack{
  1290. background-color: rgba($black,0.2);
  1291. color: $black;
  1292. }
  1293. .tagGreen{
  1294. background-color: rgba($green,0.2);
  1295. color: $green;
  1296. }
  1297. .tagWhite{
  1298. background-color: rgba($white,0.2);
  1299. color: $white;
  1300. }
  1301. .tagOrange{
  1302. background-color: rgba($orange,0.2);
  1303. color: $orange;
  1304. }
  1305. .tagRed{
  1306. background-color: rgba($red,0.2);
  1307. color: $red;
  1308. }
  1309. .tagYellow{
  1310. background-color: rgba($yellow,0.2);
  1311. color: $yellow;
  1312. }
  1313. /* 边线(实线、虚线) */
  1314. .bdn{
  1315. border: none;
  1316. }
  1317. .bd{
  1318. border: 1px solid $borderColor;
  1319. &.dashed{
  1320. border-style: dashed;
  1321. }
  1322. }
  1323. .bt{
  1324. border-top:1px solid $borderColor;
  1325. &.dashed{
  1326. border-top-style: dashed;
  1327. }
  1328. }
  1329. .bb{
  1330. border-bottom:1px solid $borderColor;
  1331. &.dashed{
  1332. border-bottom-style: dashed;
  1333. }
  1334. }
  1335. .bl{
  1336. border-left:1px solid $borderColor;
  1337. &.dashed{
  1338. border-left-style: dashed;
  1339. }
  1340. }
  1341. .br{
  1342. border-right: 1px solid $borderColor;
  1343. &.dashed{
  1344. border-right-style: dashed;
  1345. }
  1346. }
  1347. $b:2;
  1348. @while $b <= 10 {
  1349. .bd#{$b}{
  1350. border: #{$b}px solid $borderColor;
  1351. &.dashed{
  1352. border-style: dashed;
  1353. }
  1354. }
  1355. .bt#{$b}{
  1356. border-top:#{$b}px solid $borderColor;
  1357. &.dashed{
  1358. border-top-style: dashed;
  1359. }
  1360. }
  1361. .bb#{$b}{
  1362. border-bottom:#{$b}px solid $borderColor;
  1363. &.dashed{
  1364. border-bottom-style: dashed;
  1365. }
  1366. }
  1367. .bl#{$b}{
  1368. border-left:#{$b}px solid $borderColor;
  1369. &.dashed{
  1370. border-left-style: dashed;
  1371. }
  1372. }
  1373. .br#{$b}{
  1374. border-right: #{$b}px solid $borderColor;
  1375. &.dashed{
  1376. border-right-style: dashed;
  1377. }
  1378. }
  1379. $b : $b + 1 ;
  1380. }
  1381. /* 边线颜色 */
  1382. .mainBd{
  1383. border-color: $main;
  1384. }
  1385. .greenBd{
  1386. border-color: $green;
  1387. }
  1388. .redBd{
  1389. border-color: $red;
  1390. }
  1391. .yellowBd{
  1392. border-color:$yellow ;
  1393. }
  1394. .blackBd{
  1395. border-color: $black;
  1396. }
  1397. .whiteBd{
  1398. border-color:$white ;
  1399. }
  1400. .grayBd{
  1401. border-color:$gray;
  1402. }
  1403. .greyBd{
  1404. border-color:$grey;
  1405. }
  1406. .orangeBd{
  1407. border-color:$orange;
  1408. }
  1409. /* 圆角 */
  1410. .radius,.rds{
  1411. -webkit-border-radius: 100%!important;
  1412. -moz-border-radius: 100%!important;
  1413. border-radius: 100%!important;
  1414. }
  1415. $r:0;
  1416. @while $r <= 50{
  1417. .rds#{$r},&.radius#{$r}{
  1418. -webkit-border-radius:$r*2upx!important;
  1419. -moz-border-radius:$r*2upx!important;
  1420. border-radius:$r*2upx!important;
  1421. }
  1422. $r : $r + 1;
  1423. }
  1424. .rdsTl,.radiusTopLeft{
  1425. border-top-left-radius:100%!important;
  1426. }
  1427. .rdsTr,.radiusTopRight{
  1428. border-top-right-radius: 100%!important;
  1429. }
  1430. .rdsBl,.radiusBottomLeft{
  1431. border-bottom-left-radius: 100%!important;
  1432. }
  1433. .rdsBr,.radiusBottomRight{
  1434. border-bottom-right-radius: 100%!important;
  1435. }
  1436. $r:0;
  1437. @while $r <= 50{
  1438. .rdsTl#{$r},.radiusTopLeft#{$r}{
  1439. border-top-left-radius: $r*2upx!important;
  1440. }
  1441. .rdsTr#{$r},.radiusTopRight#{$r}{
  1442. border-top-right-radius: $r*2upx!important;
  1443. }
  1444. .rdsBl#{$r},.radiusBottomLeft#{$r}{
  1445. border-bottom-left-radius: $r*2upx!important;
  1446. }
  1447. .rdsBr#{$r},.radiusBottomRight#{$r}{
  1448. border-bottom-right-radius: $r*2upx!important;
  1449. }
  1450. $r : $r + 1;
  1451. }
  1452. /* 正方形&长方形 */
  1453. [class^="square"] , [class*=" square"]{
  1454. width: 100%;
  1455. position: relative;
  1456. height: auto;
  1457. >.item,>image,>view,>navigator,>text,>button{
  1458. position: absolute;
  1459. top: 0;
  1460. left: 0;
  1461. width: 100%;
  1462. height: 100%;
  1463. }
  1464. }
  1465. $p : 200 ;
  1466. @while $p > 0 {
  1467. .square#{$p}{
  1468. padding-top: $p*1%;
  1469. }
  1470. @if $p == 100 {
  1471. .square{
  1472. padding-top: 100%;
  1473. }
  1474. }
  1475. $p : $p - 5 ;
  1476. }
  1477. /* 阴影 */
  1478. .shadow{
  1479. box-shadow: 0px 2px 9px -1px rgba(0, 0, 0, 0.1);
  1480. }
  1481. /* 遮罩层 */
  1482. .wrapper-top,.wt{
  1483. background-image: linear-gradient(rgba(0,0,0,0.3) , rgba(0,0,0,0.02));
  1484. }
  1485. .wrapper-bottom,.wb{
  1486. background-image: linear-gradient( rgba(0,0,0,0.02) , rgba(0,0,0,0.3) );
  1487. }
  1488. [class^="wp"],[class*=" wp"] {
  1489. z-index: 10;
  1490. }
  1491. /* 透明度 */
  1492. @for $op from 0 through 10 {
  1493. .op#{$op}{
  1494. opacity: $op * 0.1!important;
  1495. }
  1496. .wp#{$op}{
  1497. background-color: rgba(#000,$op*0.1);
  1498. }
  1499. @if $op == 5 {
  1500. .wp{
  1501. background-color: rgba(#000,0.5);
  1502. }
  1503. }
  1504. }
  1505. /* 分割线 */
  1506. [class*=" split"],[class^="split"] {
  1507. position: relative;
  1508. &:before{
  1509. content:"";
  1510. display: block;
  1511. position: absolute;
  1512. left: 0;
  1513. top: 50%;
  1514. border-left: 1px solid $borderColor;
  1515. }
  1516. }
  1517. $s:10;
  1518. @while $s <= 100 {
  1519. .split#{$s}{
  1520. &:before{
  1521. height: #{$s*2}upx;
  1522. margin-top: -#{$s}upx;
  1523. }
  1524. }
  1525. @if $s == 10 {
  1526. .split{
  1527. &:before{
  1528. height: 20upx;
  1529. margin-top: -10upx;
  1530. }
  1531. }
  1532. }
  1533. $s:$s+2;
  1534. }
  1535. .hover,[class^="hover"],[class*=" hover"]{
  1536. transition: all 0.4s;
  1537. cursor: pointer;
  1538. &:hover{
  1539. opacity: 0.8 !important;
  1540. }
  1541. }
  1542. .statusBar{
  1543. height: var(--status-bar-height);
  1544. }
  1545. .winBottom{
  1546. height: var(--windown-bottom);
  1547. }
  1548. .safeBottom{
  1549. padding-bottom: constant(safe-area-inset-bottom);
  1550. padding-bottom: env(safe-area-inset-bottom);
  1551. }
  1552. .disabled{
  1553. opacity:0.8;
  1554. cursor: not-allowed;
  1555. }
  1556. .grid,.gridNoMb,.gridNoPd{
  1557. >.btn,>.roundBtn{
  1558. &+.btn,&+.roundBtn{
  1559. margin-left: 0 ;
  1560. }
  1561. }
  1562. }
  1563. .roundBtn{
  1564. -webkit-border-radius: 100upx;
  1565. -moz-border-radius: 100upx;
  1566. border-radius: 100upx;
  1567. }
  1568. /* 位置 */
  1569. .text-center,.tc{
  1570. text-align: center!important;
  1571. }
  1572. .text-left,.tl{
  1573. text-align: left!important;
  1574. }
  1575. .text-right,.tr{
  1576. text-align: right!important;
  1577. }
  1578. .text-justify,.tj{
  1579. text-align: justify!important;
  1580. }
  1581. .text-bold,.bold{
  1582. font-weight: bold!important;
  1583. }
  1584. .text-normal,.normal{
  1585. font-weight: normal!important;
  1586. }
  1587. .break{
  1588. white-space: normal;
  1589. word-break: break-all;
  1590. }
  1591. .noBreak{
  1592. white-space: nowrap;
  1593. word-break: keep-all;
  1594. }
  1595. .inline{
  1596. display: inline-block;
  1597. }
  1598. .block{
  1599. display: block;
  1600. width: 100%;
  1601. }
  1602. .none{
  1603. display: none;
  1604. }
  1605. .center-block{
  1606. margin: 0 auto;
  1607. display: block;
  1608. }
  1609. .hidden{
  1610. overflow: hidden;
  1611. }
  1612. .hiddenX{
  1613. overflow-x: hidden;
  1614. }
  1615. .hiddenY{
  1616. overflow-y: hidden;
  1617. }
  1618. .auto{
  1619. overflow: auto;
  1620. }
  1621. .autoX{
  1622. overflow-x: auto;
  1623. }
  1624. .autoY{
  1625. overflow-y: auto;
  1626. }
  1627. .showInMb{
  1628. display: block;
  1629. }
  1630. .showInPc{
  1631. display: none;
  1632. }
  1633. table{
  1634. width: 100%;
  1635. border-collapse: collapse;
  1636. border-spacing: 0;
  1637. border: 1px solid #e6e6e6;
  1638. thead{
  1639. tr{
  1640. background-color: #f2f2f2;
  1641. th{
  1642. color: #8799a3;
  1643. width: 1%;
  1644. }
  1645. }
  1646. }
  1647. tr{
  1648. background-color: #fff;
  1649. transition: all 0.4s;
  1650. td,th{
  1651. border: 1px solid #e6e6e6;
  1652. overflow: hidden;
  1653. -o-text-overflow: ellipsis;
  1654. text-overflow: ellipsis;
  1655. white-space: nowrap;
  1656. word-wrap: break-word;
  1657. padding: 5px 10px;
  1658. height: 28px;
  1659. line-height: 28px;
  1660. &.autoWidth{
  1661. width: auto;
  1662. }
  1663. }
  1664. &:hover{
  1665. background-color: #f2f2f2;
  1666. }
  1667. }
  1668. }
  1669. </style>