index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <view>
  3. <view :class="'Tabbar savepadding '+(about.greyTheme==1?' grayTheme':'')">
  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. async mounted() {
  53. // console.log('ready');
  54. this.about = await req.getsysConfig()
  55. this.isReady = true;
  56. this.getCount();
  57. this.getTab();
  58. },
  59. methods: {
  60. getCount() {
  61. // console.log(this.productType);
  62. let from = {};
  63. if (this.productType == 2) {
  64. from.purchaseType = 2;
  65. } else {
  66. from.purchaseType = 1;
  67. }
  68. // req.getRequest('/api/purchase/count', from, res => {
  69. // this.setData({
  70. // count: res
  71. // });
  72. // });
  73. },
  74. // 获取tab导航
  75. getTab() {
  76. // console.log(req.tab); // 过滤关闭的tab
  77. let data = req.tab.filter(it => it.show == true); // 排序更换位置
  78. // console.log(data.sort(this.compare('index')))
  79. this.setData({
  80. list: data.sort(this.compare('index'))
  81. }); // console.log(data.sort(this.compare('index')))
  82. },
  83. // 排序
  84. compare(property) {
  85. return function(a, b) {
  86. var value1 = a[property];
  87. var value2 = b[property];
  88. return value1 - value2;
  89. };
  90. },
  91. /**
  92. * 跳转
  93. */
  94. goUrl: function(e) {
  95. // console.log(e)
  96. if (e == "goShop") {
  97. this.goShop()
  98. }
  99. if (e == "goHome") {
  100. this.goHome()
  101. }
  102. if (e == "goSort") {
  103. this.goSort()
  104. }
  105. if (e == "goInteractive") {
  106. this.goInteractive()
  107. }
  108. if (e == "goLive") {
  109. this.goLive()
  110. }
  111. if (e == "goCart") {
  112. this.goCart()
  113. }
  114. if (e == "goUser") {
  115. this.goUser()
  116. }
  117. if (e == "goMatch") {
  118. this.goMatch()
  119. }
  120. if (e == "goFound"){
  121. this.goFound()
  122. }
  123. },
  124. goHome: function() {
  125. if (this.channel === "home") return;
  126. app.globalData.switchTab('pages/index/index');
  127. },
  128. goSort: function() {
  129. if (this.channel === "sort") return;
  130. app.globalData.switchTab('pages/sort/sort');
  131. },
  132. goInteractive: function() {
  133. if (this.channel === "interactive") return;
  134. app.globalData.switchTab('pages/interactive/index');
  135. },
  136. goLive: function() {
  137. if (this.channel === "live") return;
  138. app.globalData.switchTab('pages/live/live');
  139. },
  140. goCart: function() {
  141. if (this.channel === "cart") return;
  142. app.globalData.switchTab('pages/cart/cart');
  143. },
  144. goUser: function() {
  145. if (this.channel === "user") return;
  146. app.globalData.switchTab('pages/user/user');
  147. },
  148. goShop: function() {
  149. if (this.channel === "shop") return;
  150. app.globalData.switchTab('pages/timelyDelivery/index');
  151. },
  152. goMatch: function() {
  153. if (this.channel === "match") return;
  154. app.globalData.switchTab('pages/matchList/index');
  155. },
  156. goFound: function() {
  157. if (this.channel === "found") return;
  158. app.globalData.switchTab('pages/found/found');
  159. }
  160. }
  161. };
  162. </script>
  163. <style>
  164. @import "./index.css";
  165. </style>