empty-box.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <view class="max-empty" :style="{backgroundColor: backgroundColor}">
  3. <view v-if="type==='cart'" class="cart column center">
  4. <image class="icon" :src="static+'/empty/cart.png'"></image>
  5. <text class="title">空空如也</text>
  6. <text class="text">别忘了买点什么犒赏一下自己哦</text>
  7. <view class="btn center" @click="jump">
  8. <text>随便逛逛</text>
  9. </view>
  10. </view>
  11. <view v-else-if="type==='address'" class="address column center">
  12. <image class="icon" :src="static+'/empty/address.png'"></image>
  13. <text class="text">您还没有收货地址哦~</text>
  14. <view class="btn center" @click="jump">
  15. <text>添加地址</text>
  16. </view>
  17. </view>
  18. <view v-else-if="type==='favorite'" class="favorite column center">
  19. <image class="icon" :src="static+'/empty/favorite.png'"></image>
  20. <text class="text">收藏夹空空的,先去逛逛吧~</text>
  21. <view class="btn center" @click="jump">
  22. <text>随便逛逛</text>
  23. </view>
  24. </view>
  25. <view v-else-if="type==='order'" class="order column center">
  26. <image class="icon" :src="static+'/empty/order.png'"></image>
  27. <text class="text">加载订单失败,请稍后在试</text>
  28. <view class="btn center" @click="jump">
  29. <text>返回</text>
  30. </view>
  31. </view>
  32. <view v-else-if="type==='service'" class="service column center">
  33. <image class="icon" :src="static+'/empty/service.png'"></image>
  34. <text class="text">请求出错,请稍在试</text>
  35. <view class="btn center" @click="jump">
  36. <text>{{ btnText }}</text>
  37. </view>
  38. </view>
  39. <view v-else class="default column center">
  40. <image class="icon" :src="static+'/empty/default.png'"></image>
  41. <text class="text" @click="jump">{{ text }}</text>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. /**
  47. * 缺省显示
  48. * @prop text 缺省文字提示
  49. * @prop type 缺省类型
  50. * @prop backgroundColor 缺省页面背景色
  51. */
  52. export default {
  53. props: {
  54. text: {
  55. type: String,
  56. default: '暂时没有数据'
  57. },
  58. btnText: {
  59. type: String,
  60. default: '刷新'
  61. },
  62. type: {
  63. type: String,
  64. default: ''
  65. },
  66. backgroundColor: {
  67. type: String,
  68. default: 'rgba(0,0,0,0)'
  69. }
  70. },
  71. data(){
  72. return {
  73. static: ""
  74. };
  75. },
  76. mounted() {
  77. this.static = this.$static;
  78. },
  79. methods: {
  80. jump(){
  81. this.$emit("onEvents",{});
  82. },
  83. onCartBtnClick(){
  84. uni.switchTab({
  85. url: '/pages/index/index'
  86. })
  87. },
  88. switchTab(url){
  89. uni.switchTab({
  90. url
  91. })
  92. }
  93. }
  94. }
  95. </script>
  96. <style scoped lang="scss">
  97. .column{
  98. /* #ifndef APP-PLUS-NVUE */
  99. display:flex;
  100. /* #endif */
  101. flex-direction: column;
  102. }
  103. .center{
  104. /* #ifndef APP-PLUS-NVUE */
  105. display:flex;
  106. /* #endif */
  107. align-items: center;
  108. justify-content: center;
  109. }
  110. .max-empty{
  111. position: fixed;
  112. left: 0;
  113. right: 0;
  114. top: 0;
  115. bottom: 0;
  116. display: flex;
  117. flex-direction: column;
  118. align-items: center;
  119. animation: show .5s 1;
  120. }
  121. @keyframes show{
  122. from {
  123. opacity: 0;
  124. }
  125. to {
  126. opacity: 1;
  127. }
  128. }
  129. .default{
  130. padding-top: 26vh;
  131. /* #ifdef H5 */
  132. padding-top: 30vh;
  133. /* #endif */
  134. .icon{
  135. width: 350rpx;
  136. height: 350rpx;
  137. }
  138. .text{
  139. margin-top: 10rpx;
  140. font-size: 28rpx;
  141. color: #999;
  142. }
  143. }
  144. .cart{
  145. padding-top: 14vh;
  146. /* #ifdef H5 */
  147. padding-top: 18vh;
  148. /* #endif */
  149. .icon{
  150. width: 350rpx;
  151. height: 350rpx;
  152. }
  153. .title{
  154. margin: 50rpx 0 26rpx;
  155. font-size: 34rpx;
  156. color: #333;
  157. }
  158. .text{
  159. font-size: 28rpx;
  160. color: #aaa;
  161. }
  162. .btn{
  163. width: 320rpx;
  164. height: 80rpx;
  165. margin-top: 80rpx;
  166. text-indent: 2rpx;
  167. letter-spacing: 2rpx;
  168. font-size: 32rpx;
  169. color: #fff;
  170. border-radius: 100rpx;
  171. background: linear-gradient(to bottom right, #1b43c4, #1b43c4);
  172. }
  173. }
  174. .address{
  175. padding-top: 6vh;
  176. /* #ifdef H5 */
  177. padding-top: 10vh;
  178. /* #endif */
  179. .icon{
  180. width: 350rpx;
  181. height: 350rpx;
  182. }
  183. .text{
  184. width: 400rpx;
  185. margin-top: 40rpx;
  186. font-size: 30rpx;
  187. color: #999;
  188. text-align: center;
  189. line-height: 1.6;
  190. }
  191. .btn{
  192. width: 320rpx;
  193. height: 80rpx;
  194. margin-top: 80rpx;
  195. text-indent: 2rpx;
  196. letter-spacing: 2rpx;
  197. font-size: 32rpx;
  198. color: #fff;
  199. border-radius: 100rpx;
  200. background: linear-gradient(to bottom right, #1b43c4, #1b43c4);
  201. }
  202. }
  203. .favorite{
  204. padding-top: 6vh;
  205. /* #ifdef H5 */
  206. padding-top: 10vh;
  207. /* #endif */
  208. .icon{
  209. width: 360rpx;
  210. height: 360rpx;
  211. }
  212. .text{
  213. width: 400rpx;
  214. margin-top: 40rpx;
  215. font-size: 30rpx;
  216. color: #999;
  217. text-align: center;
  218. line-height: 1.6;
  219. }
  220. .btn{
  221. width: 320rpx;
  222. height: 80rpx;
  223. margin-top: 80rpx;
  224. text-indent: 2rpx;
  225. letter-spacing: 2rpx;
  226. font-size: 32rpx;
  227. color: #fff;
  228. border-radius: 100rpx;
  229. background: linear-gradient(to bottom right, #1b43c4, #1b43c4);
  230. }
  231. }
  232. .order{
  233. padding-top: 6vh;
  234. /* #ifdef H5 */
  235. padding-top: 10vh;
  236. /* #endif */
  237. .icon{
  238. width: 360rpx;
  239. height: 360rpx;
  240. }
  241. .text{
  242. width: 400rpx;
  243. margin-top: 40rpx;
  244. font-size: 30rpx;
  245. color: #999;
  246. text-align: center;
  247. line-height: 1.6;
  248. }
  249. .btn{
  250. width: 320rpx;
  251. height: 80rpx;
  252. margin-top: 80rpx;
  253. text-indent: 2rpx;
  254. letter-spacing: 2rpx;
  255. font-size: 32rpx;
  256. color: #fff;
  257. border-radius: 100rpx;
  258. background: linear-gradient(to bottom right, #1b43c4, #1b43c4);
  259. }
  260. }
  261. .service{
  262. padding-top: 6vh;
  263. /* #ifdef H5 */
  264. padding-top: 10vh;
  265. /* #endif */
  266. .icon{
  267. width: 360rpx;
  268. height: 360rpx;
  269. }
  270. .text{
  271. width: 400rpx;
  272. margin-top: 40rpx;
  273. font-size: 30rpx;
  274. color: #999;
  275. text-align: center;
  276. line-height: 1.6;
  277. }
  278. .btn{
  279. width: 320rpx;
  280. height: 80rpx;
  281. margin-top: 80rpx;
  282. text-indent: 2rpx;
  283. letter-spacing: 2rpx;
  284. font-size: 32rpx;
  285. color: #fff;
  286. border-radius: 100rpx;
  287. background: linear-gradient(to bottom right, #1b43c4, #1b43c4);
  288. }
  289. }
  290. </style>