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.

209 lines
4.3 KiB

4 years ago
  1. <template>
  2. <view class="mix-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">{{ hasLogin ? '空空如也' : '先去登录嘛' }}</text>
  6. <text class="text">别忘了买点什么犒赏一下自己哦</text>
  7. <view class="btn center" @click="onCartBtnClick">
  8. <text>{{ hasLogin ? '随便逛逛' : '去登录' }}</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="navTo('manage')">
  15. <text class="mix-icon icon-jia2"></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="switchTab('/pages/tabbar/home')">
  22. <text>随便逛逛</text>
  23. </view>
  24. </view>
  25. <view v-else class="default column center">
  26. <image class="icon" src="/static/empty/default.png"></image>
  27. <text class="text">{{ text }}</text>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. /**
  33. * 缺省显示
  34. * @prop text 缺省文字提示
  35. * @prop type 缺省类型
  36. * @prop backgroundColor 缺省页面背景色
  37. */
  38. export default {
  39. computed: {
  40. hasLogin(){
  41. return !!this.$store.getters.hasLogin;
  42. }
  43. },
  44. props: {
  45. text: {
  46. type: String,
  47. default: '暂时没有数据'
  48. },
  49. type: {
  50. type: String,
  51. default: ''
  52. },
  53. backgroundColor: {
  54. type: String,
  55. default: 'rgba(0,0,0,0)'
  56. }
  57. },
  58. methods: {
  59. onCartBtnClick(){
  60. if(this.hasLogin){
  61. uni.switchTab({
  62. url: '/pages/tabbar/home'
  63. })
  64. }else{
  65. this.navTo('/pages/auth/login');
  66. }
  67. },
  68. switchTab(url){
  69. uni.switchTab({
  70. url
  71. })
  72. }
  73. }
  74. }
  75. </script>
  76. <style scoped lang="scss">
  77. .mix-empty{
  78. position: fixed;
  79. left: 0;
  80. right: 0;
  81. top: 0;
  82. bottom: 0;
  83. display: flex;
  84. flex-direction: column;
  85. align-items: center;
  86. animation: show .5s 1;
  87. }
  88. @keyframes show{
  89. from {
  90. opacity: 0;
  91. }
  92. to {
  93. opacity: 1;
  94. }
  95. }
  96. .default{
  97. padding-top: 26vh;
  98. /* #ifdef H5 */
  99. padding-top: 30vh;
  100. /* #endif */
  101. .icon{
  102. width: 460rpx;
  103. height: 342rpx;
  104. }
  105. .text{
  106. margin-top: 10rpx;
  107. font-size: 28rpx;
  108. color: #999;
  109. }
  110. }
  111. .cart{
  112. padding-top: 14vh;
  113. /* #ifdef H5 */
  114. padding-top: 18vh;
  115. /* #endif */
  116. .icon{
  117. width: 320rpx;
  118. height: 320rpx;
  119. }
  120. .title{
  121. margin: 50rpx 0 26rpx;
  122. font-size: 34rpx;
  123. color: #333;
  124. }
  125. .text{
  126. font-size: 28rpx;
  127. color: #aaa;
  128. }
  129. .btn{
  130. width: 320rpx;
  131. height: 80rpx;
  132. margin-top: 80rpx;
  133. text-indent: 2rpx;
  134. letter-spacing: 2rpx;
  135. font-size: 32rpx;
  136. color: #fff;
  137. border-radius: 100rpx;
  138. background: linear-gradient(to bottom right, #ffb2bf, $base-color);
  139. }
  140. }
  141. .address{
  142. padding-top: 6vh;
  143. /* #ifdef H5 */
  144. padding-top: 10vh;
  145. /* #endif */
  146. .icon{
  147. width: 380rpx;
  148. height: 380rpx;
  149. }
  150. .text{
  151. width: 400rpx;
  152. margin-top: 40rpx;
  153. font-size: 30rpx;
  154. color: #999;
  155. text-align: center;
  156. line-height: 1.6;
  157. }
  158. .btn{
  159. position: fixed;
  160. left: 50%;
  161. bottom: 120rpx;
  162. width: 110rpx;
  163. height: 110rpx;
  164. background-color: $base-color;
  165. border-radius: 100rpx;
  166. transform: translateX(-50%);
  167. box-shadow: 2rpx 2rpx 10rpx rgba(255, 83, 111, .5);
  168. }
  169. .icon-jia2{
  170. font-size: 50rpx;
  171. color: #fff;
  172. }
  173. }
  174. .favorite{
  175. padding-top: 6vh;
  176. /* #ifdef H5 */
  177. padding-top: 10vh;
  178. /* #endif */
  179. .icon{
  180. width: 360rpx;
  181. height: 360rpx;
  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: 40rpx;
  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, #ffb2bf, $base-color);
  201. }
  202. }
  203. </style>