kevy-result-page.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <view class="t-wrap">
  3. <view class="t-krp-header">
  4. <image class="t-icon" :src="icon"></image>
  5. <view class="t-title">{{title}}</view>
  6. <uv-count-down :time="time" format="HH时mm分ss秒后失效" v-if="type === 'warning'" @finish="finish">
  7. </uv-count-down>
  8. <view class="t-description">{{description}}</view>
  9. <view class="t-detail-con" v-if="detailData && detailData.length>0">
  10. <view class="t-detail" v-for="(item,index) in detailData" :key="index">
  11. <text :style="{'font-weight':item['bold']?'600':'unset'}">{{item.label}}</text>
  12. <text :style="{'font-weight':item['bold']?'600':'unset'}">{{item.value}}</text>
  13. </view>
  14. <view class="t-collapse" @click="changeExpand" v-if="details.length>2">
  15. <view class="t-collapse-box" :style="{'transform': isExpand?'rotate(-45deg)':'rotate(135deg)'}">
  16. </view>
  17. </view>
  18. </view>
  19. <view class="t-bg-wrap">
  20. <view class="t-bg" :style="{'background-color':primarColor}"></view>
  21. </view>
  22. </view>
  23. <view class="t-krp-footer" v-if="primaryBtnText || secondaryBtnText"
  24. :style="{'justify-content': primaryBtnText && secondaryBtnText?'space-between':'center'}">
  25. <view v-if="secondaryBtnText" hover-class="t-hover" class="t-btn t-secondary" @click="secondaryBtnClick">
  26. {{secondaryBtnText}}
  27. </view>
  28. <view v-if="primaryBtnText" hover-class="t-hover" class="t-btn t-primary" @click="primaryBtnClick"
  29. :style="{'background-color':primarColor}">{{primaryBtnText}}</view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. name: "kevyResultPage",
  36. props: {
  37. /**
  38. * 类型
  39. */
  40. type: {
  41. type: String,
  42. default: 'success'
  43. },
  44. /**
  45. * 标题
  46. */
  47. title: {
  48. type: String,
  49. default: ''
  50. },
  51. /**
  52. * 描述
  53. */
  54. description: {
  55. type: String,
  56. default: ''
  57. },
  58. /**
  59. * 详细数量列表,超过三条自动折叠
  60. */
  61. details: {
  62. type: Array,
  63. default: []
  64. },
  65. /**
  66. * 主背景色
  67. */
  68. primarColor: {
  69. type: String,
  70. default: '#4fc08d'
  71. },
  72. /**
  73. * 主要按钮文字,不填不显示主要按钮
  74. */
  75. primaryBtnText: {
  76. type: String,
  77. default: ''
  78. },
  79. /**
  80. * 次要按钮文字,不填不显示次要按钮
  81. */
  82. secondaryBtnText: {
  83. type: String,
  84. default: ''
  85. },
  86. /**
  87. * 倒计时
  88. */
  89. codeUrlFailureTime: {
  90. type: String,
  91. default: ''
  92. }
  93. },
  94. data() {
  95. return {
  96. //是否展开
  97. isExpand: false,
  98. };
  99. },
  100. created() {
  101. },
  102. computed: {
  103. //状态图标
  104. icon: function() {
  105. return '/uni_modules/kevy-result-page/static/icon/icon_' + this.type + '.png';
  106. },
  107. //详情数据
  108. detailData: function() {
  109. if (this.isExpand) {
  110. return this.details;
  111. } else {
  112. return this.details.length > 2 ? this.details.slice(0, 2) : this.details;
  113. }
  114. },
  115. //时间
  116. time() {
  117. let date = this.codeUrlFailureTime.replaceAll('-', '/');
  118. return (new Date(date).getTime() - new Date().getTime());
  119. }
  120. },
  121. methods: {
  122. //切换展开状态
  123. changeExpand() {
  124. this.isExpand = !this.isExpand;
  125. },
  126. //主按钮点击
  127. primaryBtnClick() {
  128. this.$emit('primaryBtnClick');
  129. },
  130. //辅助按钮点击
  131. secondaryBtnClick() {
  132. this.$emit('secondaryBtnClick');
  133. },
  134. //倒计时结束
  135. finish() {
  136. this.$emit('finish');
  137. }
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. .t-wrap {
  143. width: 100%;
  144. box-sizing: border-box;
  145. position: relative;
  146. background-color: rgb(245, 245, 245);
  147. height: 100vh;
  148. }
  149. .t-krp-header {
  150. display: flex;
  151. align-items: center;
  152. flex-direction: column;
  153. background-color: transparent;
  154. position: relative;
  155. padding: 40rpx 40rpx 200rpx;
  156. z-index: 1;
  157. overflow: hidden;
  158. .t-icon {
  159. width: 64rpx;
  160. height: 64rpx;
  161. }
  162. .t-title {
  163. font-size: 36rpx;
  164. color: #ffffff;
  165. text-align: center;
  166. line-height: 1.4;
  167. margin-top: 20rpx;
  168. }
  169. .t-description {
  170. margin-top: 16rpx;
  171. margin-bottom: 48rpx;
  172. font-size: 28rpx;
  173. color: hsla(0, 0%, 100%, .6);
  174. line-height: 1.4;
  175. text-align: center;
  176. }
  177. .t-detail-con {
  178. width: 100%;
  179. box-sizing: border-box;
  180. .t-detail {
  181. width: 100%;
  182. display: flex;
  183. flex-direction: row;
  184. justify-content: space-between;
  185. margin-bottom: 10rpx;
  186. color: #ffffff;
  187. font-size: 28rpx;
  188. }
  189. .t-collapse {
  190. box-sizing: border-box;
  191. padding: 17rpx;
  192. width: 100%;
  193. display: flex;
  194. .t-collapse-box {
  195. opacity: 0.6;
  196. width: 20rpx;
  197. height: 20rpx;
  198. margin: auto auto 20rpx;
  199. border-top: 4rpx solid #ffffff;
  200. border-right: 4rpx solid #ffffff;
  201. transform: rotate(135deg);
  202. }
  203. }
  204. }
  205. .t-bg-wrap {
  206. position: relative;
  207. align-self: flex-start;
  208. top: 54rpx;
  209. .t-bg {
  210. --width: 440vw;
  211. position: absolute;
  212. height: var(--width);
  213. width: var(--width);
  214. left: calc(var(--width)*-1/2 + 50vw - 40rpx);
  215. top: calc(var(--width)*-1 + 1vw);
  216. border-radius: 50%;
  217. z-index: -1;
  218. }
  219. }
  220. }
  221. .t-krp-footer {
  222. display: flex;
  223. flex-direction: row;
  224. justify-content: space-between;
  225. align-items: center;
  226. box-sizing: border-box;
  227. position: fixed;
  228. bottom: 0;
  229. width: 100%;
  230. padding: 24rpx 24rpx 48rpx;
  231. background-color: #f5f5f5;
  232. z-index: 3;
  233. .t-btn {
  234. padding: 22rpx 24rpx;
  235. font-size: 36rpx;
  236. display: flex;
  237. flex-direction: row;
  238. justify-content: center;
  239. align-items: center;
  240. box-sizing: border-box;
  241. border-radius: 8rpx;
  242. flex: 1 1;
  243. max-width: calc(50vw - 36rpx);
  244. }
  245. .t-primary {
  246. color: #ffffff;
  247. }
  248. .t-secondary {
  249. background: #ffffff;
  250. color: rgb(51, 51, 51);
  251. }
  252. .t-hover {
  253. opacity: 0.7;
  254. }
  255. }
  256. </style>