index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <view :style="[mainStyle]">
  3. <view class="Tabbar savepadding">
  4. <!-- v-if="distribution.distributionIsOpen == 1" -->
  5. <view v-for="(item, index) in list" :key="index"
  6. :class="'tab-item fflex' + (list.length == 3?' tab-item3':'')" @tap="jumpUrl(item)">
  7. <!-- @tap="goUrl(item.click)" -->
  8. <image class="nav_icon11 image" v-if="channel === item.channel"
  9. :src="item.selectedIconPathOn?(picUrlss+about.mainIconPath+item.selectedIconPathOn): item.selectedIconPath">
  10. </image>
  11. <image class="nav_icon11 image" v-else
  12. :src="item.iconPathOn?(picUrlss+about.mainIconPath+item.iconPathOn): item.iconPath"></image>
  13. <view :class="channel === item.channel ? 'active' : ''">
  14. {{ item.text }}
  15. <text class="dots-cart" v-if="count > 0 && item.channel === 'cart'">{{ count }}</text>
  16. </view>
  17. </view>
  18. <!-- <view v-else v-for="(item, indx) in listNHH" :key="indx" class="tab-item" @tap="goUrl(item.click)">
  19. <image class="nav_icon11 image" :src="channel === item.channel ? item.selectedIconPath : item.iconPath"></image>
  20. <view :class="channel === item.channel ? 'active' : ''">
  21. {{ item.text }}
  22. <text class="dots-cart" v-if="count > 0 && item.channel === 'cart'">{{ count }}</text>
  23. </view>
  24. </view> -->
  25. </view>
  26. <view class="savepadding" style="height:115rpx"></view>
  27. <update-userinfo :update-info="isUpdateInfo" :update-mobile="isUpdateMobile" v-if="isShowUpdate"
  28. @closeUpdate="closeUpdate"></update-userinfo>
  29. </view>
  30. </template>
  31. <script>
  32. const app = getApp();
  33. const req = require('../../utils/request.js');
  34. import foot from './index';
  35. export default {
  36. data() {
  37. return {
  38. mainStyle: app.globalData.mainStyle,
  39. picUrlss: req.public.picUrls,
  40. bottomBlankHeignt: app.globalData.isIPhoneX ? 68 : 0,
  41. iconSrc: req.public.iconSrc,
  42. about: {},
  43. distribution: '', //分销配置
  44. list: [], //有合伙人
  45. listNHH: [], //无合伙人
  46. count: '',
  47. isShowUpdate: false,
  48. isUpdateInfo: false,
  49. isUpdateMobile: false
  50. };
  51. },
  52. components: {
  53. foot
  54. },
  55. props: {
  56. channel: {
  57. type: String,
  58. default: 'home'
  59. },
  60. isUpdate: {
  61. type: Boolean,
  62. default: false
  63. },
  64. productType: {
  65. type: Number,
  66. default: 0
  67. }
  68. },
  69. watch: {
  70. isUpdate: function(isUpdate) {
  71. // console.log('需要更新消息', isUpdate);
  72. if (!this.isReady) return;
  73. // this.getCount();
  74. }
  75. },
  76. async mounted() {
  77. this.distribution = req.getStorage('distribution');
  78. if (req.getStorage('configRes')) {
  79. this.about = JSON.parse(req.getStorage('configRes'));
  80. }
  81. console.log('mounted', this.about)
  82. this.isReady = true;
  83. await this.getTab();
  84. await this.getCount();
  85. },
  86. methods: {
  87. getCount() {
  88. let from = {};
  89. from.purchaseType = 1;
  90. return new Promise((resolve, reject) => {
  91. req.getRequest('/api/purchase/count', from, res => {
  92. this.count = res;
  93. this.$forceUpdate();
  94. resolve();
  95. });
  96. })
  97. },
  98. // 获取tab导航
  99. getTab() {
  100. req.setStorage('cartTab', false);
  101. console.log('数据>>>>>>>getTab>>>>>>>>>>');
  102. return new Promise((resolve, reject) => {
  103. req.tab.map((it) => {
  104. if (this.about.solution_name && this.about.solution_name != ' ') {
  105. if (it.name == this.about.solution_name) {
  106. this.list = it.list.filter(it => it.show == true);
  107. this.list.map(ittx => {
  108. if (ittx.channel == 'cart') {
  109. req.setStorage('cartTab', true);
  110. }
  111. });
  112. }
  113. } else {
  114. if (it.name == 'default') {
  115. this.list = it.list.filter(it => it.show == true);
  116. }
  117. }
  118. })
  119. this.$forceUpdate();
  120. resolve();
  121. })
  122. },
  123. // 排序
  124. compare(property) {
  125. return function(a, b) {
  126. var value1 = a[property];
  127. var value2 = b[property];
  128. return value1 - value2;
  129. };
  130. },
  131. jumpUrl(item) {
  132. if (this.channel == item.channel) {
  133. return false;
  134. }
  135. // #ifdef MP-WEIXIN
  136. if (req.getStorage('isShowUpdateMobile') && req.getStorage('isShowUpdateInfo')) {
  137. uni.$emit('tabClick', item.channel)
  138. } else if (this.getUpdate()) {
  139. uni.$emit('tabClick', item.channel)
  140. }
  141. // #endif
  142. // #ifndef MP-WEIXIN
  143. uni.$emit('tabClick', item.channel)
  144. // #endif
  145. },
  146. getUpdate() {
  147. let userInfos = req.getStorage('userInfo')
  148. if (!req.getStorage('isShowUpdateMobile') && !userInfos.mobile) {
  149. console.log('没有手机号')
  150. this.isShowUpdate = true;
  151. this.isUpdateMobile = true;
  152. req.setStorage('isShowUpdateMobile', true)
  153. return false;
  154. }
  155. if (!req.getStorage('isShowUpdateInfo') && (!userInfos.avatar || userInfos.avatar.indexOf(
  156. 'thirdwx.qlogo') > -1 || userInfos.nickName.indexOf('用户') > -1)) {
  157. console.log('没有昵称')
  158. this.isShowUpdate = true;
  159. this.isUpdateInfo = true;
  160. req.setStorage('isShowUpdateInfo', true)
  161. return false;
  162. }
  163. return true;
  164. },
  165. closeUpdate() {
  166. this.isShowUpdate = false
  167. this.isUpdateInfo = false;
  168. this.isUpdateMobile = false;
  169. },
  170. /**
  171. * 跳转
  172. */
  173. goUrl: function(e) {
  174. // console.log(e)
  175. if (e == 'goShop') {
  176. this.goShop();
  177. }
  178. if (e == 'goHome') {
  179. this.goHome();
  180. }
  181. if (e == 'goSort') {
  182. this.goSort();
  183. }
  184. if (e == 'goLive') {
  185. this.goLive();
  186. }
  187. if (e == 'goCart') {
  188. this.goCart();
  189. }
  190. if (e == 'goMerchant') {
  191. this.goMerchant();
  192. }
  193. if (e == 'goPartner') {
  194. this.goPartner();
  195. }
  196. if (e == 'goService') {
  197. this.goService();
  198. }
  199. if (e == 'goUser') {
  200. this.goUser();
  201. }
  202. },
  203. goHome: function() {
  204. if (this.channel === 'home') return;
  205. app.globalData.switchTab('pages/index/index_zehuiyun');
  206. },
  207. goSort: function() {
  208. if (this.channel === 'sort') return;
  209. app.globalData.switchTab('pages/sort/sort');
  210. },
  211. goLive: function() {
  212. if (this.channel === 'live') return;
  213. app.globalData.switchTab('service/live/live');
  214. },
  215. goCart: function() {
  216. if (this.channel === 'cart') return;
  217. app.globalData.switchTab('pages/cart/cart');
  218. },
  219. goMerchant: function() {
  220. if (this.channel === 'merchant') return;
  221. app.globalData.switchTab('pages/merchant/index');
  222. },
  223. goPartner: function() {
  224. if (this.channel === 'partner') return;
  225. app.globalData.switchTab('pages/partner/index');
  226. },
  227. goService: function() {
  228. if (this.channel === 'service') return;
  229. app.globalData.switchTab('pages/service/index');
  230. },
  231. goUser: function() {
  232. if (this.channel === 'user') return;
  233. app.globalData.switchTab('pages/user/user');
  234. },
  235. goShop: function() {
  236. if (this.channel === 'shop') return;
  237. app.globalData.switchTab('pages/timelyDelivery/index');
  238. }
  239. }
  240. };
  241. </script>
  242. <style>
  243. @import './index.css';
  244. </style>