index.vue 3.7 KB

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