index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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" style="width: 20rpx;height: 20rpx;min-width: 20rpx;right: 30%;top: 18rpx;"
  8. v-if="count > 0&&item.channel==='found'"></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. const utils = require("../../utils/util.js");
  18. import foot from "./index";
  19. export default {
  20. data() {
  21. return {
  22. bottomBlankHeignt: app.globalData.isIPhoneX ? 68 : 0,
  23. iconSrc: req.public.iconSrc,
  24. about: {},
  25. list: [],
  26. count: ""
  27. };
  28. },
  29. components: {
  30. foot
  31. },
  32. props: {
  33. channel: {
  34. type: String,
  35. default: 'home'
  36. },
  37. isUpdate: {
  38. type: Boolean,
  39. default: false
  40. },
  41. productType: {
  42. type: Number,
  43. default: 0
  44. }
  45. },
  46. watch: {
  47. "isUpdate": function(isUpdate) {
  48. // console.log('需要更新消息', isUpdate);
  49. if (!this.isReady) return;
  50. this.getCount();
  51. }
  52. },
  53. created() {
  54. uni.$on('updataTab',()=>{
  55. this.getCount()
  56. })
  57. },
  58. async mounted() {
  59. // console.log('ready');
  60. this.about = await req.getsysConfig()
  61. this.isReady = true;
  62. this.getCount();
  63. this.getTab();
  64. },
  65. methods: {
  66. getCount() {
  67. // console.log(this.productType);
  68. let from = {};
  69. if (this.productType == 2) {
  70. from.purchaseType = 2;
  71. } else {
  72. from.purchaseType = 1;
  73. }
  74. // req.getRequest('/api/purchase/count', from, res => {
  75. // this.setData({
  76. // count: res
  77. // });
  78. // });
  79. req.getRequest('/api/content/category/list', {
  80. parentCode: req.public.fxCode
  81. }, res => {
  82. console.log('sss',res)
  83. this.count = 0
  84. if(res&&res.length>0){
  85. res.map(item=>{
  86. let s = req.getStorage('readFindCode')
  87. let readObj = {
  88. date:utils.formatTime(new Date()).t2,
  89. readCode:(s && s.date == utils.formatTime(new Date()).t2)?s.readCode:{}
  90. }
  91. if(readObj.readCode[item.code]){
  92. }else{
  93. this.count = this.count + item.addToday
  94. }
  95. console.log(this.count)
  96. })
  97. }
  98. })
  99. },
  100. // 获取tab导航
  101. getTab() {
  102. // console.log(req.tab); // 过滤关闭的tab
  103. let data = req.tab.filter(it => it.show == true); // 排序更换位置
  104. // console.log(data.sort(this.compare('index')))
  105. this.setData({
  106. list: data.sort(this.compare('index'))
  107. }); // console.log(data.sort(this.compare('index')))
  108. },
  109. // 排序
  110. compare(property) {
  111. return function(a, b) {
  112. var value1 = a[property];
  113. var value2 = b[property];
  114. return value1 - value2;
  115. };
  116. },
  117. /**
  118. * 跳转
  119. */
  120. goUrl: function(e) {
  121. // console.log(e)
  122. if (e == "goShop") {
  123. this.goShop()
  124. }
  125. if (e == "goHome") {
  126. this.goHome()
  127. }
  128. if (e == "goSort") {
  129. this.goSort()
  130. }
  131. if (e == "goInteractive") {
  132. this.goInteractive()
  133. }
  134. if (e == "goLive") {
  135. this.goLive()
  136. }
  137. if (e == "goCart") {
  138. this.goCart()
  139. }
  140. if (e == "goUser") {
  141. this.goUser()
  142. }
  143. if (e == "goMatch") {
  144. this.goMatch()
  145. }
  146. if (e == "goFound"){
  147. this.goFound()
  148. }
  149. },
  150. goHome: function() {
  151. if (this.channel === "home") return;
  152. app.globalData.switchTab('pages/index/index');
  153. },
  154. goSort: function() {
  155. if (this.channel === "sort") return;
  156. app.globalData.switchTab('pages/sort/sort');
  157. },
  158. goInteractive: function() {
  159. if (this.channel === "interactive") return;
  160. app.globalData.switchTab('pages/interactive/index');
  161. },
  162. goLive: function() {
  163. if (this.channel === "live") return;
  164. app.globalData.switchTab('pages/live/live');
  165. },
  166. goCart: function() {
  167. if (this.channel === "cart") return;
  168. app.globalData.switchTab('pages/cart/cart');
  169. },
  170. goUser: function() {
  171. if (this.channel === "user") return;
  172. app.globalData.switchTab('pages/user/user');
  173. },
  174. goShop: function() {
  175. if (this.channel === "shop") return;
  176. app.globalData.switchTab('pages/timelyDelivery/index');
  177. },
  178. goMatch: function() {
  179. if (this.channel === "match") return;
  180. app.globalData.switchTab('pages/matchList/index');
  181. },
  182. goFound: function() {
  183. if (this.channel === "found") return;
  184. app.globalData.switchTab('pages/found/found');
  185. }
  186. }
  187. };
  188. </script>
  189. <style>
  190. @import "./index.css";
  191. </style>