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. }
  31. },
  32. onLoad(options) {
  33. let user = {
  34. wechatBindUserid: 0,
  35. userName: ""
  36. },
  37. that = this;
  38. if (options.wechatBindUserid) {
  39. user.wechatBindUserid = options.wechatBindUserid;
  40. user.userName = options.userName;
  41. }
  42. if (options.q) {
  43. let params = this.getUrlParams(options.q);
  44. user.wechatBindUserid = params.wechatBindUserid;
  45. user.userName = params.userName;
  46. }
  47. if (user.wechatBindUserid) {
  48. console.log("被邀请绑定账号", user);
  49. uni.showModal({
  50. title: '提醒',
  51. content: `"${user.userName}"是否与当前微信号绑定`,
  52. confirmText: '确定绑定',
  53. success: function ({ confirm }) {
  54. if (confirm) uni.login({
  55. success(res) {
  56. that.$Http.basic({
  57. "id": 20240516090402,
  58. "content": {
  59. "wechat_code": res.code,
  60. "isbinging": 1,
  61. "wechatuserinfo": "",
  62. "userid": user.wechatBindUserid
  63. }
  64. }).then(res => {
  65. console.log("绑定账号", res)
  66. uni.showModal({
  67. title: '提示',
  68. content: res.msg == '成功' ? '绑定成功' : res.msg,
  69. showCancel: false,
  70. success: function ({ confirm }) {
  71. if (confirm) {
  72. if (res.msg == '成功') that.$Login.wechatLogin().then(s => {
  73. uni.reLaunch({
  74. url: '/pages/index/index'
  75. })
  76. })
  77. }
  78. }
  79. });
  80. if (that.cutoff(res.msg, '绑定成功')) return;
  81. })
  82. }
  83. })
  84. }
  85. });
  86. }
  87. },
  88. onShow() {
  89. const systemInitIsComplete = this.$Http.systemInitIsComplete;
  90. if (!systemInitIsComplete || typeof systemInitIsComplete == 'object') {
  91. this.$Http.HomePageStartRendering = render(this)
  92. } else {
  93. render(this)
  94. }
  95. function render(that) {
  96. that.$Http.changePage = function (itemId, page, params) {
  97. that.$refs.pages.onClick(itemId, page, false, params)
  98. }.bind(that)
  99. // #ifdef MP-WEIXIN
  100. that.updatePageData(that.swiperItemID, that.page)
  101. // #endif
  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>