index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <div class="homePage" ref="homePage">
  3. <div class="content">
  4. <van-nav-bar class="navBar" left-arrow title="门店拜访" @click-left="onClickLeft" />
  5. <van-tabs
  6. class="myTab"
  7. type="card"
  8. v-model="tabVal"
  9. color="#0057ba"
  10. @click="onClickTabs"
  11. v-if="isGZorJZ">
  12. <van-tab title="提示类" name="-1" v-if="isGZorJZ == 'false'">
  13. <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
  14. <hintTabPage :tabVal="tabVal" ref="hintTabPage"></hintTabPage>
  15. </van-pull-refresh>
  16. </van-tab>
  17. <van-tab title="A类指标" name="0">
  18. <ABtarget :tabVal="tabVal" ref="Atarget"></ABtarget>
  19. </van-tab>
  20. <van-tab title="B类指标" name="1">
  21. <ABtarget :tabVal="tabVal" ref="Btarget"></ABtarget>
  22. </van-tab>
  23. </van-tabs>
  24. <div class="bottomBtn">
  25. <bottomBtn :tabVal="tabVal" ref="bottomBtn"></bottomBtn>
  26. </div>
  27. </div>
  28. <tab-bar></tab-bar>
  29. </div>
  30. </template>
  31. <script>
  32. import { getReportInfo, getDictOption } from '@/api/index';
  33. import hintTabPage from './hintTabPage/index.vue';
  34. import tabBar from '@/components/tabBar';
  35. import ABtarget from './ABtarget.vue';
  36. import { mapState } from 'vuex';
  37. import bottomBtn from './bottomBtn.vue';
  38. import { getTicketFun } from '@/utils/TXApiFun';
  39. export default {
  40. name: 'home',
  41. components: { tabBar, hintTabPage, ABtarget, bottomBtn },
  42. computed: {
  43. ...mapState({
  44. userInfo: (state) => state.user.userInfo,
  45. }),
  46. },
  47. data() {
  48. return {
  49. tabVal: '-1',
  50. hintTabPageIndex: 0,
  51. isGZorJZ: null,
  52. isLoading: false,
  53. };
  54. },
  55. watch: {
  56. // 监听切换用户
  57. 'userInfo.userName': {
  58. handler(val) {
  59. if (val) {
  60. this.getDict();
  61. // this.getReportInfo();
  62. }
  63. },
  64. immediete: true,
  65. },
  66. },
  67. activated() {
  68. if (this.tabVal == '-1') {
  69. // 从其他页面跳转过来如果;要重新获取对应tab数据
  70. // if (this.$refs.hintTabPage) this.$refs.hintTabPage.initData();
  71. } else if (this.tabVal == '0') {
  72. // if (this.$refs.Atarget) this.$refs.Atarget.initData();
  73. } else if (this.tabVal == '1') {
  74. // if (this.$refs.Btarget) this.$refs.Btarget.initData();
  75. }
  76. },
  77. created() {
  78. getTicketFun(['onMenuShareAppMessage']).then((res) => {
  79. this.wx.ready(() => {
  80. console.log('this.wx.ready');
  81. console.log(this.wx);
  82. this.wx.onMenuShareAppMessage({
  83. title: '企业微信',
  84. desc: '让每个企业都有自己的微信',
  85. link: 'https://work.weixin.qq.com/',
  86. imgUrl:
  87. 'https://res.mail.qq.com/node/ww/wwmng/style/images/index_share_logo$13c64306.png',
  88. success() {
  89. // 用户确认分享后回调
  90. console.log('用户确认分享后回调');
  91. },
  92. cancel() {
  93. // 用户取消分享后回调
  94. console.log('用户取消分享后回调');
  95. },
  96. });
  97. });
  98. });
  99. this.getDict();
  100. },
  101. mounted() {},
  102. methods: {
  103. onRefresh() {
  104. this.getDict(true);
  105. this.isLoading = false;
  106. },
  107. async getDict(isRefresh) {
  108. this.toastLoading(0, '加载中...', true);
  109. let gz_Option = await getDictOption({}, 'gz_customer_post'); //公装业务员岗位
  110. let jz_Option = await getDictOption({}, 'jz_post_name'); //家装业务员岗位
  111. this.toastLoading().clear();
  112. let postName = this.userInfo.postName;
  113. let is_gz = gz_Option.data.find((res) => res.dictLabel == postName);
  114. let is_jz = jz_Option.data.find((res) => res.dictLabel == postName);
  115. if (is_gz || is_jz) {
  116. localStorage.setItem('isGZorJZ', 'true');
  117. this.isGZorJZ = 'true';
  118. } else {
  119. localStorage.setItem('isGZorJZ', 'false');
  120. this.isGZorJZ = 'false';
  121. }
  122. // 家装或工装不显示提示类tab
  123. this.$nextTick(() => {
  124. // 刷新状态
  125. if (!isRefresh) {
  126. if (this.isGZorJZ == 'true') {
  127. this.tabVal = '0';
  128. } else {
  129. this.tabVal = '-1';
  130. }
  131. }
  132. if (this.tabVal == '-1') {
  133. if (this.$refs.hintTabPage) this.$refs.hintTabPage.initData();
  134. } else if (this.tabVal == '0') {
  135. if (this.$refs.Atarget) this.$refs.Atarget.initData();
  136. } else if (this.tabVal == '1') {
  137. if (this.$refs.Btarget) this.$refs.Btarget.initData();
  138. }
  139. if (this.$refs.bottomBtn) this.$refs.bottomBtn.getReportInfo();
  140. });
  141. },
  142. onClickTabs(val) {
  143. this.$nextTick(() => {
  144. // this.tabVal == '-1' 有watch监听不需要在触发
  145. // if (this.tabVal == '0') {
  146. // if (this.$refs.Atarget) this.$refs.Atarget.initData();
  147. // } else
  148. if (this.tabVal == '1') {
  149. if (this.$refs.Btarget) this.$refs.Btarget.initData();
  150. }
  151. });
  152. },
  153. onClickLeft() {
  154. this.$router.go(-1);
  155. // window.location.href = process.env.VUE_APP_SSB_LINK + "/homeIndex"
  156. },
  157. getReportInfo() {
  158. getReportInfo({ isContent: false }).then((res) => {
  159. if (res.code == 200) {
  160. localStorage.setItem('powerGrade', res.data.positionId);
  161. localStorage.setItem('isDiy', res.data.diy);
  162. localStorage.setItem('uType', res.data.userType);
  163. localStorage.setItem('jzType', res.data.jzType);
  164. localStorage.setItem('customerVisits', res.data.customerManagerVisits);
  165. localStorage.setItem('postType', res.data.postType);
  166. } else {
  167. this.$toast(res.msg);
  168. }
  169. });
  170. },
  171. },
  172. };
  173. </script>
  174. <style scoped lang="scss">
  175. #app {
  176. width: 100%;
  177. height: 100%;
  178. overflow: hidden;
  179. .bgcolor {
  180. width: 100%;
  181. height: 100%;
  182. .homePage {
  183. height: 100%;
  184. width: 100%;
  185. display: flex;
  186. flex-direction: column;
  187. overflow: hidden;
  188. .content {
  189. flex: 1;
  190. overflow-y: auto;
  191. }
  192. .tabBar {
  193. height: 50px;
  194. }
  195. }
  196. }
  197. }
  198. </style>
  199. <style lang="scss">
  200. .homePage {
  201. display: flex;
  202. flex-direction: column;
  203. .myTab {
  204. /* flex: 1; */
  205. display: flex;
  206. flex-direction: column;
  207. /* position: sticky; */
  208. /* top: 0px; */
  209. .van-tabs__wrap {
  210. position: sticky;
  211. top: 0px;
  212. z-index: 10;
  213. }
  214. .van-tabs__content {
  215. flex: 1;
  216. /* margin-bottom: 50px; */
  217. }
  218. }
  219. .myTab .van-tabs__nav--card {
  220. margin: 0 !important;
  221. border-left: 0;
  222. border-right: 0;
  223. }
  224. .myTab .van-tabs__wrap,
  225. .van-tabs__nav--card {
  226. height: 39px;
  227. }
  228. .myTab .van-tab {
  229. line-height: 40px;
  230. }
  231. .bottomBtn {
  232. margin-bottom: 55px;
  233. }
  234. }
  235. </style>