index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view>
  3. <index ref="首页" v-show="page == '首页'" />
  4. <store ref="活动" v-show="page == '活动'" />
  5. <my-case ref="案例" v-show="page == '案例'" />
  6. <videos ref="视频" v-show="page == '视频'" />
  7. <user-center ref="我的" v-show="page == '我的'" />
  8. <workbench ref="工作台" v-show="page == '工作台'" />
  9. <dataBank ref="资料库" v-show="page == '资料库'" />
  10. <school ref="商学院" v-show="page == '商学院'" />
  11. <product ref="单品" v-show="page == '单品'" />
  12. <bottom-suspension-frame ref="pages" @onChange="pageChange" />
  13. </view>
  14. </template>
  15. <script>
  16. import index from './index/index.vue'
  17. import store from './index/store.vue'
  18. import myCase from './index/myCase.vue'
  19. import userCenter from './index/userCenter.vue'
  20. import videos from './index/videos.vue'
  21. import dataBank from './cloud/dataBank.vue'
  22. import school from './cloud/school.vue'
  23. import product from './cloud/product.vue'
  24. import workbench from './cloud/workbench.vue'
  25. import bottomSuspensionFrame from "./modules/bottomSuspensionFrame.vue";
  26. export default {
  27. components: { bottomSuspensionFrame, index, store, myCase, userCenter, dataBank, school, product, workbench, videos },
  28. data() {
  29. return {
  30. swiperItemID: 'index',
  31. page: '首页',
  32. user: {
  33. wechatBindUserid: 0,
  34. userName: ""
  35. }
  36. }
  37. },
  38. onLoad(options) {
  39. if (options.wechatBindUserid) {
  40. this.user.wechatBindUserid = options.wechatBindUserid;
  41. this.user.userName = options.userName;
  42. }
  43. if (options.q) this.user = this.getUrlParams(options.q);
  44. },
  45. onShow() {
  46. const systemInitIsComplete = this.$Http.systemInitIsComplete;
  47. if (!systemInitIsComplete || typeof systemInitIsComplete == 'object') {
  48. this.$Http.HomePageStartRendering = render(this)
  49. } else {
  50. render(this)
  51. }
  52. function render(that) {
  53. that.$Http.changePage = function (itemId, page, params) {
  54. that.$refs.pages.onClick(itemId, page, false, params)
  55. }.bind(that)
  56. // #ifdef MP-WEIXIN
  57. that.updatePageData(that.swiperItemID, that.page)
  58. // #endif
  59. if (that.user.wechatBindUserid) {
  60. console.log("被邀请绑定账号", that.user);
  61. uni.showModal({
  62. title: '提醒',
  63. content: `账号"${that.user.userName}"是否与当前微信号绑定`,
  64. confirmText: '确定绑定',
  65. success: function ({ confirm }) {
  66. if (confirm) uni.login({
  67. success(res) {
  68. that.$Http.basic({
  69. "id": 20240516090402,
  70. "content": {
  71. "wechat_code": res.code,
  72. "isbinging": 1,
  73. "wechatuserinfo": "",
  74. "sys_enterprise_hrid": that.user.wechatBindUserid
  75. }
  76. }).then(s => {
  77. console.log("绑定账号", s)
  78. uni.showModal({
  79. title: '提示',
  80. content: s.msg == '成功' ? '绑定成功' : s.msg,
  81. showCancel: false,
  82. success: function ({ confirm }) {
  83. if (confirm) {
  84. if (s.msg == '成功') that.$Login.wechatLogin().then(() => {
  85. uni.reLaunch({
  86. url: '/pages/index/index'
  87. })
  88. that.user = {
  89. wechatBindUserid: 0,
  90. userName: ""
  91. }
  92. })
  93. }
  94. }
  95. });
  96. })
  97. }
  98. })
  99. }
  100. });
  101. }
  102. }
  103. },
  104. methods: {
  105. updatePageData(itemId, page) {
  106. if (this.$refs[this.page].updatePage) this.$refs.pages.onClick(itemId, page)
  107. },
  108. pageChange(detail) {
  109. uni.setNavigationBarTitle({
  110. title: detail.name,
  111. })
  112. this.page = detail.name;
  113. try {
  114. console.log(this.$refs[detail.name].updatePage)
  115. if (this.$refs[detail.name].updatePage) uni.pageScrollTo({
  116. scrollTop: 0,
  117. duration: 0,
  118. })
  119. this.$refs[detail.name].init(detail.callBack, detail.params)
  120. } catch (error) {
  121. detail.callBack()
  122. }
  123. console.log("切换页面", detail)
  124. }
  125. }
  126. }
  127. </script>
  128. <style lang="scss"></style>