index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view>
  3. <view class="Tabbar savepadding">
  4. <view v-for="(item, index) in list" :key="index" class="tab-item" @tap="goUrl(item.click)">
  5. <image class="nav_icon11 image" :src="channel===item.channel ?item.selectedIconPath:item.iconPath">
  6. </image>
  7. <view :class="channel===item.channel?'active':''">{{item.text}}<text class="dots"
  8. v-if="count > 0&&item.channel==='cart'">{{count}}</text></view>
  9. </view>
  10. </view>
  11. <view class="savepadding" style="height:115rpx"></view>
  12. </view>
  13. </template>
  14. <script>
  15. const app = getApp();
  16. const req = require("../../utils/request.js");
  17. import foot from "./index";
  18. export default {
  19. data() {
  20. return {
  21. bottomBlankHeignt: app.globalData.isIPhoneX ? 68 : 0,
  22. iconSrc: req.public.iconSrc,
  23. about: {},
  24. list: [],
  25. count: ""
  26. };
  27. },
  28. components: {
  29. foot
  30. },
  31. props: {
  32. channel: {
  33. type: String,
  34. default: 'home'
  35. },
  36. isUpdate: {
  37. type: Boolean,
  38. default: false
  39. },
  40. productType: {
  41. type: Number,
  42. default: 0
  43. }
  44. },
  45. watch: {
  46. "isUpdate": function(isUpdate) {
  47. // console.log('需要更新消息', isUpdate);
  48. if (!this.isReady) return;
  49. this.getCount();
  50. }
  51. },
  52. mounted() {
  53. // console.log('ready');
  54. this.isReady = true;
  55. this.getCount();
  56. this.getTab();
  57. },
  58. methods: {
  59. getCount() {
  60. // console.log(this.productType);
  61. let from = {};
  62. if (this.productType == 2) {
  63. from.purchaseType = 2;
  64. } else {
  65. from.purchaseType = 1;
  66. }
  67. // req.getRequest('/api/purchase/count', from, res => {
  68. // this.setData({
  69. // count: res
  70. // });
  71. // });
  72. },
  73. // 获取tab导航
  74. getTab() {
  75. // console.log(req.tab); // 过滤关闭的tab
  76. let data = req.tab.filter(it => it.show == true); // 排序更换位置
  77. // console.log(data.sort(this.compare('index')))
  78. this.setData({
  79. list: data.sort(this.compare('index'))
  80. }); // console.log(data.sort(this.compare('index')))
  81. },
  82. // 排序
  83. compare(property) {
  84. return function(a, b) {
  85. var value1 = a[property];
  86. var value2 = b[property];
  87. return value1 - value2;
  88. };
  89. },
  90. /**
  91. * 跳转
  92. */
  93. goUrl: function(e) {
  94. // console.log(e)
  95. if (e == "goShop") {
  96. this.goShop()
  97. }
  98. if (e == "goHome") {
  99. this.goHome()
  100. }
  101. if (e == "goSort") {
  102. this.goSort()
  103. }
  104. if (e == "goInteractive") {
  105. this.goInteractive()
  106. }
  107. if (e == "goLive") {
  108. this.goLive()
  109. }
  110. if (e == "goCart") {
  111. this.goCart()
  112. }
  113. if (e == "goUser") {
  114. this.goUser()
  115. }
  116. if (e == "goMatch") {
  117. this.goMatch()
  118. }
  119. if (e == "goFound"){
  120. this.goFound()
  121. }
  122. },
  123. goHome: function() {
  124. if (this.channel === "home") return;
  125. app.globalData.switchTab('pages/index/index');
  126. },
  127. goSort: function() {
  128. if (this.channel === "sort") return;
  129. app.globalData.switchTab('pages/sort/sort');
  130. },
  131. goInteractive: function() {
  132. if (this.channel === "interactive") return;
  133. app.globalData.switchTab('pages/interactive/index');
  134. },
  135. goLive: function() {
  136. if (this.channel === "live") return;
  137. app.globalData.switchTab('pages/live/live');
  138. },
  139. goCart: function() {
  140. if (this.channel === "cart") return;
  141. app.globalData.switchTab('pages/cart/cart');
  142. },
  143. goUser: function() {
  144. if (this.channel === "user") return;
  145. app.globalData.switchTab('pages/user/user');
  146. },
  147. goShop: function() {
  148. if (this.channel === "shop") return;
  149. app.globalData.switchTab('pages/timelyDelivery/index');
  150. },
  151. goMatch: function() {
  152. if (this.channel === "match") return;
  153. app.globalData.switchTab('pages/matchList/index');
  154. },
  155. goFound: function() {
  156. if (this.channel === "found") return;
  157. app.globalData.switchTab('pages/found/found');
  158. }
  159. }
  160. };
  161. </script>
  162. <style>
  163. @import "./index.css";
  164. </style>