load-toast.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <view>
  3. <view v-if="showLoading2" :style="{top:topPadding+'px'}" class="load-container">
  4. <image class="load-image" src="./img/loading.png"></image>
  5. </view>
  6. <view v-if="showSelect" class="pop-container">
  7. <view class="delay-con">
  8. <view class="delay-title row-center">
  9. {{selectTip}}
  10. </view>
  11. <view class="delay-content column-center">
  12. <text>{{selectContent}}</text>
  13. </view>
  14. <view class="delay-bottom row-center">
  15. <view class="delay-view" data-state="cancel" @click="hiddeenSelectDialog" style="border-right:1px solid #d6d6d6">{{cancelText}}</view>
  16. <view class="delay-view" data-state="confirm" @click="hiddeenSelectDialog">{{confirmText}}</view>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. let systemInfo, selectCallBack, confirmCallback;
  24. import {
  25. selectLabel
  26. } from '../../static/js/config.js'
  27. export default {
  28. name: 'loadToast',
  29. ready: function() {
  30. let that = this;
  31. that.initData();
  32. },
  33. data() {
  34. return {
  35. showTitleCon: false,
  36. showBackBtn: false,
  37. titleName: '',
  38. statusBarHeight: 0,
  39. showLoading2: false,
  40. toastContent: '',
  41. topPadding: 0,
  42. showSelect: false,
  43. isCenter: true,
  44. selectTip: '',
  45. selectContent: '',
  46. confirmText: '',
  47. cancelText: '',
  48. dialogContent: '',
  49. confirmText: ''
  50. }
  51. },
  52. methods: {
  53. showDialog: function(params, callBack) {
  54. let that = this;
  55. confirmCallback = callBack;
  56. that.dialogContent = params.content != undefined ? params.content : '';
  57. that.confirmText = params.confirmText != undefined ? params.confirmText : selectLabel[systemInfo.lang][
  58. 'confirmText'
  59. ];
  60. },
  61. hiddenDialog: function(e) {
  62. let that = this;
  63. if (confirmCallback != undefined)
  64. confirmCallback();
  65. },
  66. initData: function() {
  67. let that = this;
  68. uni.getSystemInfo({
  69. success: function(res) {
  70. console.log(res, 'system');
  71. if (res.errMsg === 'getSystemInfo:ok') {
  72. that.statusBarHeight = res.statusBarHeight;
  73. that.topPadding = res.statusBarHeight + 45
  74. res.lang = res.language.indexOf('zh') !== -1 ? 'zh' : 'en';
  75. systemInfo = res;
  76. that.selectTip = selectLabel[systemInfo.lang]['selectTip'];
  77. that.confirmText = selectLabel[systemInfo.lang]['confirmText']
  78. }
  79. },
  80. });
  81. },
  82. /* 展示选择对话框
  83. */
  84. showSelectDailog: function(params, callBack) {
  85. let that = this;
  86. that.showSelect = true;
  87. that.isCenter = params.isCenter != undefined ? params.isCenter : true;
  88. that.selectTip = params.selectTip != undefined ? params.selectTip : selectLabel[systemInfo.lang]['selectTip'];
  89. that.selectContent = params.selectContent != undefined ? params.selectContent : selectLabel[systemInfo.lang][
  90. 'content'
  91. ];
  92. that.confirmText = params.confirmText != undefined ? params.confirmText : selectLabel[systemInfo.lang][
  93. 'confirmText'
  94. ];
  95. that.cancelText = params.cancelText != undefined ? params.cancelText : selectLabel[systemInfo.lang]['cancelText'];
  96. selectCallBack = callBack;
  97. },
  98. hiddeenSelectDialog: function(e) {
  99. let that = this;
  100. that.showSelect = false;
  101. selectCallBack(e.currentTarget.dataset.state);
  102. }
  103. }
  104. }
  105. </script>
  106. <style>
  107. .load-container {
  108. pointer-events: auto;
  109. color: #000;
  110. font-size: 20px;
  111. z-index: 9999;
  112. position: absolute;
  113. top: 0;
  114. left: 0;
  115. right: 0;
  116. bottom: 0;
  117. background: rgba(0, 0, 0, 0.3);
  118. display: flex;
  119. flex-direction: column;
  120. align-items: center;
  121. justify-content: center;
  122. }
  123. .load-image {
  124. width: 50px;
  125. height: 50px;
  126. animation: loading-rotate 1s linear infinite;
  127. }
  128. @keyframes loading-rotate {
  129. 0% {
  130. transform: rotate(0deg);
  131. }
  132. 100% {
  133. transform: rotate(360deg);
  134. }
  135. }
  136. .pop-container {
  137. pointer-events: auto;
  138. color: #000;
  139. font-size: 20px;
  140. z-index: 9999;
  141. position: absolute;
  142. top: 0;
  143. left: 0;
  144. right: 0;
  145. bottom: 0;
  146. background: rgba(0, 0, 0, 0.3);
  147. display: flex;
  148. flex-direction: column;
  149. align-items: center;
  150. justify-content: center;
  151. }
  152. .row-center {
  153. display: flex;
  154. flex-direction: row;
  155. align-items: center;
  156. justify-content: center;
  157. }
  158. .delay-con {
  159. width: 80%;
  160. border-radius: 25rpx;
  161. background: white;
  162. font-size: 32rpx;
  163. margin-bottom: 100rpx;
  164. -webkit-animation: fadeleftIn .4s;
  165. animation: fadeleftIn .4s;
  166. -webkit-animation-name: popIn;
  167. animation-name: popIn;
  168. }
  169. .delay-title {
  170. padding-top: 30rpx;
  171. padding-bottom: 20rpx;
  172. }
  173. .column-center {
  174. display: flex;
  175. flex-direction: column;
  176. align-items: center;
  177. justify-content: center;
  178. }
  179. .delay-content {
  180. padding-bottom: 30rpx;
  181. line-height: 45rpx;
  182. text-align: center;
  183. padding-left: 20px;
  184. padding-right: 20px;
  185. }
  186. .delay-bottom {
  187. width: 100%;
  188. border-top: 1px solid #d6d6d6;
  189. color: #027bfe;
  190. }
  191. .delay-view {
  192. width: 50%;
  193. padding-top: 25rpx;
  194. padding-bottom: 25rpx;
  195. text-align: center;
  196. }
  197. .toast-con {
  198. position: absolute;
  199. z-index: 9999;
  200. left: 0;
  201. top: 200px;
  202. width: calc(100% - 100px);
  203. padding-top: 15px;
  204. padding-bottom: 15px;
  205. margin-left: 50px;
  206. margin-right: 50px;
  207. border-radius: 10px;
  208. background: rgba(0, 0, 0, 0.8);
  209. color: white;
  210. text-align: center;
  211. font-size: 15px;
  212. -webkit-animation: fadelogIn .2s;
  213. animation: fadelogIn .2s;
  214. }
  215. @-webkit-keyframes popIn {
  216. 0% {
  217. -webkit-transform: scale3d(0, 0, 0);
  218. transform: scale3d(0.5, 0.5, 0.5);
  219. opacity: 0;
  220. }
  221. 50% {
  222. -webkit-animation-timing-function: cubic-bezier(0.47, 0, 0.745, 0.715);
  223. animation-timing-function: cubic-bezier(0.47, 0, 0.745, 0.715);
  224. }
  225. 100% {
  226. -webkit-transform: scale3d(1, 1, 1);
  227. transform: scale3d(1, 1, 1);
  228. -webkit-animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  229. animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  230. opacity: 1;
  231. }
  232. }
  233. @keyframes popIn {
  234. 0% {
  235. -webkit-transform: scale3d(0, 0, 0);
  236. transform: scale3d(0.5, 0.5, 0.5);
  237. opacity: 0;
  238. }
  239. 50% {
  240. -webkit-animation-timing-function: cubic-bezier(0.47, 0, 0.745, 0.715);
  241. animation-timing-function: cubic-bezier(0.47, 0, 0.745, 0.715);
  242. }
  243. 100% {
  244. -webkit-transform: scale3d(1, 1, 1);
  245. transform: scale3d(1, 1, 1);
  246. -webkit-animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  247. animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  248. opacity: 1;
  249. }
  250. }
  251. @keyframes fadelogIn {
  252. 0% {
  253. -webkit-transform: translate3d(0, 100%, 0);
  254. -webkit-transform: translate3d(0, 100%, 0);
  255. transform: translate3d(0, 100%, 0);
  256. transform: translate3d(0, 100%, 0);
  257. }
  258. 100% {
  259. -webkit-transform: none;
  260. transform: none;
  261. }
  262. }
  263. @-webkit-keyframes fadelogIn {
  264. 0% {
  265. -webkit-transform: translate3d(0, 100%, 0);
  266. }
  267. 100% {
  268. -webkit-transform: none;
  269. }
  270. }
  271. .top-con {
  272. background: linear-gradient(to right, #57bce8, #275fd0);
  273. width: 100%;
  274. color: white;
  275. position: relative;
  276. }
  277. .top-view {
  278. height: 45px;
  279. width: 100%;
  280. display: flex;
  281. flex-direction: column;
  282. justify-content: center;
  283. align-items: center;
  284. position: relative;
  285. font-size: 16px;
  286. }
  287. .top-view-img {
  288. position: absolute;
  289. left: 16px;
  290. top: 12px;
  291. width: 20px;
  292. height: 20px;
  293. }
  294. .top-view-img:active {
  295. top: 13px;
  296. }
  297. </style>