index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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. this.getDict();
  79. },
  80. mounted() {
  81. getTicketFun(['showMenuItems', 'hideMenuItems', 'onMenuShareAppMessage']).then((res) => {
  82. this.wx.ready(() => {
  83. console.log(this.wx);
  84. this.wx.hideMenuItems({
  85. menuList: ['menuItem:favorite'], // 要显示的菜单项
  86. });
  87. this.wx.showMenuItems({
  88. menuList: ['menuItem:share:appMessage'], // 要显示的菜单项
  89. });
  90. this.wx.onMenuShareAppMessage({
  91. title: '企业微信',
  92. desc: '让每个企业都有自己的微信',
  93. link: 'https://work.weixin.qq.com/',
  94. imgUrl:
  95. 'https://res.mail.qq.com/node/ww/wwmng/style/images/index_share_logo$13c64306.png',
  96. enableIdTrans: 0,
  97. success: () => {
  98. // 用户确认分享后回调
  99. console.log('用户确认分享后回调');
  100. },
  101. error: () => {
  102. console.log('error');
  103. if (res.errMsg.indexOf('no permission') > 0) {
  104. alert('未agentConfig');
  105. }
  106. },
  107. cancel: () => {
  108. // 用户取消分享后回调
  109. console.log('用户取消分享后回调');
  110. },
  111. });
  112. });
  113. });
  114. },
  115. methods: {
  116. onRefresh() {
  117. this.getDict(true);
  118. this.isLoading = false;
  119. },
  120. async getDict(isRefresh) {
  121. this.toastLoading(0, '加载中...', true);
  122. let gz_Option = await getDictOption({}, 'gz_customer_post'); //公装业务员岗位
  123. let jz_Option = await getDictOption({}, 'jz_post_name'); //家装业务员岗位
  124. this.toastLoading().clear();
  125. let postName = this.userInfo.postName;
  126. let is_gz = gz_Option.data.find((res) => res.dictLabel == postName);
  127. let is_jz = jz_Option.data.find((res) => res.dictLabel == postName);
  128. if (is_gz || is_jz) {
  129. localStorage.setItem('isGZorJZ', 'true');
  130. this.isGZorJZ = 'true';
  131. } else {
  132. localStorage.setItem('isGZorJZ', 'false');
  133. this.isGZorJZ = 'false';
  134. }
  135. // 家装或工装不显示提示类tab
  136. this.$nextTick(() => {
  137. // 刷新状态
  138. if (!isRefresh) {
  139. if (this.isGZorJZ == 'true') {
  140. this.tabVal = '0';
  141. } else {
  142. this.tabVal = '-1';
  143. }
  144. }
  145. if (this.tabVal == '-1') {
  146. if (this.$refs.hintTabPage) this.$refs.hintTabPage.initData();
  147. } else if (this.tabVal == '0') {
  148. if (this.$refs.Atarget) this.$refs.Atarget.initData();
  149. } else if (this.tabVal == '1') {
  150. if (this.$refs.Btarget) this.$refs.Btarget.initData();
  151. }
  152. if (this.$refs.bottomBtn) this.$refs.bottomBtn.getReportInfo();
  153. });
  154. },
  155. onClickTabs(val) {
  156. this.$nextTick(() => {
  157. // this.tabVal == '-1' 有watch监听不需要在触发
  158. // if (this.tabVal == '0') {
  159. // if (this.$refs.Atarget) this.$refs.Atarget.initData();
  160. // } else
  161. if (this.tabVal == '1') {
  162. if (this.$refs.Btarget) this.$refs.Btarget.initData();
  163. }
  164. });
  165. },
  166. onClickLeft() {
  167. this.$router.go(-1);
  168. // window.location.href = process.env.VUE_APP_SSB_LINK + "/homeIndex"
  169. },
  170. getReportInfo() {
  171. getReportInfo({ isContent: false }).then((res) => {
  172. if (res.code == 200) {
  173. localStorage.setItem('powerGrade', res.data.positionId);
  174. localStorage.setItem('isDiy', res.data.diy);
  175. localStorage.setItem('uType', res.data.userType);
  176. localStorage.setItem('jzType', res.data.jzType);
  177. localStorage.setItem('customerVisits', res.data.customerManagerVisits);
  178. localStorage.setItem('postType', res.data.postType);
  179. } else {
  180. this.$toast(res.msg);
  181. }
  182. });
  183. },
  184. },
  185. };
  186. </script>
  187. <style scoped lang="scss">
  188. #app {
  189. width: 100%;
  190. height: 100%;
  191. overflow: hidden;
  192. .bgcolor {
  193. width: 100%;
  194. height: 100%;
  195. .homePage {
  196. height: 100%;
  197. width: 100%;
  198. display: flex;
  199. flex-direction: column;
  200. overflow: hidden;
  201. .content {
  202. flex: 1;
  203. overflow-y: auto;
  204. }
  205. .tabBar {
  206. height: 50px;
  207. }
  208. }
  209. }
  210. }
  211. </style>
  212. <style lang="scss">
  213. .homePage {
  214. display: flex;
  215. flex-direction: column;
  216. .myTab {
  217. /* flex: 1; */
  218. display: flex;
  219. flex-direction: column;
  220. /* position: sticky; */
  221. /* top: 0px; */
  222. .van-tabs__wrap {
  223. position: sticky;
  224. top: 0px;
  225. z-index: 10;
  226. }
  227. .van-tabs__content {
  228. flex: 1;
  229. /* margin-bottom: 50px; */
  230. }
  231. }
  232. .myTab .van-tabs__nav--card {
  233. margin: 0 !important;
  234. border-left: 0;
  235. border-right: 0;
  236. }
  237. .myTab .van-tabs__wrap,
  238. .van-tabs__nav--card {
  239. height: 39px;
  240. }
  241. .myTab .van-tab {
  242. line-height: 40px;
  243. }
  244. .bottomBtn {
  245. margin-bottom: 55px;
  246. }
  247. }
  248. </style>