index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. type: 'link', // 分享类型,默认为link(链接)
  97. dataUrl: '', // 数据链接
  98. thumbUrl:
  99. 'https://cdn-svs-test.nipponpaint.com.cn/%E5%90%B4%E5%BA%B7-%E9%97%A8%E5%BA%97%E7%85%A7-%E5%A4%A9%E5%BB%B6%E7%BB%BC%E5%90%88%E7%BB%8F%E8%90%A5%E9%83%A8-20250109033940.jpg?Expires=2051941182&OSSAccessKeyId=LTAI5tG1DTJFA16BHkzHVxjz&Signature=T7%2FszxqrMyc%2FZWQV955BOGMYFgc%3D', // 缩略图链接
  100. mediaId: '', // 如果type为media则必填,需提供媒体ID
  101. success: () => {
  102. // 用户确认分享后回调
  103. console.log('用户确认分享后回调');
  104. },
  105. error: () => {
  106. console.log('error');
  107. if (res.errMsg.indexOf('no permission') > 0) {
  108. alert('未agentConfig');
  109. }
  110. },
  111. cancel: () => {
  112. // 用户取消分享后回调
  113. console.log('用户取消分享后回调');
  114. },
  115. });
  116. });
  117. });
  118. },
  119. methods: {
  120. onRefresh() {
  121. this.getDict(true);
  122. this.isLoading = false;
  123. },
  124. async getDict(isRefresh) {
  125. this.toastLoading(0, '加载中...', true);
  126. let gz_Option = await getDictOption({}, 'gz_customer_post'); //公装业务员岗位
  127. let jz_Option = await getDictOption({}, 'jz_post_name'); //家装业务员岗位
  128. this.toastLoading().clear();
  129. let postName = this.userInfo.postName;
  130. let is_gz = gz_Option.data.find((res) => res.dictLabel == postName);
  131. let is_jz = jz_Option.data.find((res) => res.dictLabel == postName);
  132. if (is_gz || is_jz) {
  133. localStorage.setItem('isGZorJZ', 'true');
  134. this.isGZorJZ = 'true';
  135. } else {
  136. localStorage.setItem('isGZorJZ', 'false');
  137. this.isGZorJZ = 'false';
  138. }
  139. // 家装或工装不显示提示类tab
  140. this.$nextTick(() => {
  141. // 刷新状态
  142. if (!isRefresh) {
  143. if (this.isGZorJZ == 'true') {
  144. this.tabVal = '0';
  145. } else {
  146. this.tabVal = '-1';
  147. }
  148. }
  149. if (this.tabVal == '-1') {
  150. if (this.$refs.hintTabPage) this.$refs.hintTabPage.initData();
  151. } else if (this.tabVal == '0') {
  152. if (this.$refs.Atarget) this.$refs.Atarget.initData();
  153. } else if (this.tabVal == '1') {
  154. if (this.$refs.Btarget) this.$refs.Btarget.initData();
  155. }
  156. if (this.$refs.bottomBtn) this.$refs.bottomBtn.getReportInfo();
  157. });
  158. },
  159. onClickTabs(val) {
  160. this.$nextTick(() => {
  161. // this.tabVal == '-1' 有watch监听不需要在触发
  162. // if (this.tabVal == '0') {
  163. // if (this.$refs.Atarget) this.$refs.Atarget.initData();
  164. // } else
  165. if (this.tabVal == '1') {
  166. if (this.$refs.Btarget) this.$refs.Btarget.initData();
  167. }
  168. });
  169. },
  170. onClickLeft() {
  171. this.$router.go(-1);
  172. // window.location.href = process.env.VUE_APP_SSB_LINK + "/homeIndex"
  173. },
  174. getReportInfo() {
  175. getReportInfo({ isContent: false }).then((res) => {
  176. if (res.code == 200) {
  177. localStorage.setItem('powerGrade', res.data.positionId);
  178. localStorage.setItem('isDiy', res.data.diy);
  179. localStorage.setItem('uType', res.data.userType);
  180. localStorage.setItem('jzType', res.data.jzType);
  181. localStorage.setItem('customerVisits', res.data.customerManagerVisits);
  182. localStorage.setItem('postType', res.data.postType);
  183. } else {
  184. this.$toast(res.msg);
  185. }
  186. });
  187. },
  188. },
  189. };
  190. </script>
  191. <style scoped lang="scss">
  192. #app {
  193. width: 100%;
  194. height: 100%;
  195. overflow: hidden;
  196. .bgcolor {
  197. width: 100%;
  198. height: 100%;
  199. .homePage {
  200. height: 100%;
  201. width: 100%;
  202. display: flex;
  203. flex-direction: column;
  204. overflow: hidden;
  205. .content {
  206. flex: 1;
  207. overflow-y: auto;
  208. }
  209. .tabBar {
  210. height: 50px;
  211. }
  212. }
  213. }
  214. }
  215. </style>
  216. <style lang="scss">
  217. .homePage {
  218. display: flex;
  219. flex-direction: column;
  220. .myTab {
  221. /* flex: 1; */
  222. display: flex;
  223. flex-direction: column;
  224. /* position: sticky; */
  225. /* top: 0px; */
  226. .van-tabs__wrap {
  227. position: sticky;
  228. top: 0px;
  229. z-index: 10;
  230. }
  231. .van-tabs__content {
  232. flex: 1;
  233. /* margin-bottom: 50px; */
  234. }
  235. }
  236. .myTab .van-tabs__nav--card {
  237. margin: 0 !important;
  238. border-left: 0;
  239. border-right: 0;
  240. }
  241. .myTab .van-tabs__wrap,
  242. .van-tabs__nav--card {
  243. height: 39px;
  244. }
  245. .myTab .van-tab {
  246. line-height: 40px;
  247. }
  248. .bottomBtn {
  249. margin-bottom: 55px;
  250. }
  251. }
  252. </style>