index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view>
  3. <index ref="首页" v-show="page == '首页'" :sa_storeid="sa_storeid" />
  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. sa_storeid: 0
  37. }
  38. },
  39. onLoad(options) {
  40. if (options.wechatBindUserid) {
  41. this.user.wechatBindUserid = options.wechatBindUserid;
  42. this.user.userName = options.userName;
  43. } else if (options.sa_storeid) {
  44. this.sa_storeid = options.sa_storeid;
  45. }
  46. if (options.q) {
  47. let data = this.getUrlParams(options.q);
  48. if (data.wechatBindUserid) this.user = data;//绑定账号
  49. if (data.sa_storeid) this.sa_storeid = data.sa_storeid;//锁定门店
  50. }
  51. },
  52. onShow() {
  53. this.isInitializeLogin(render.bind(this))
  54. function render() {
  55. let that = this;
  56. this.$Http.changePage = function (itemId, page, params) {
  57. this.$refs.pages.onClick(itemId, page, false, params)
  58. }.bind(this)
  59. // #ifdef MP-WEIXIN
  60. this.updatePageData(this.swiperItemID, this.page)
  61. // #endif
  62. if (this.user.wechatBindUserid) {
  63. console.log("被邀请绑定账号", this.user);
  64. uni.showModal({
  65. title: '提醒',
  66. content: `账号"${this.user.userName}"是否与当前微信号绑定`,
  67. confirmText: '确定绑定',
  68. success: function ({ confirm }) {
  69. if (confirm) uni.login({
  70. success(res) {
  71. that.$Http.basic({
  72. "id": 20240516090402,
  73. "content": {
  74. "wechat_code": res.code,
  75. "isbinging": 1,
  76. "wechatuserinfo": "",
  77. "sys_enterprise_hrid": that.user.wechatBindUserid
  78. }
  79. }).then(s => {
  80. console.log("绑定账号", s)
  81. uni.showModal({
  82. title: '提示',
  83. content: s.msg == '成功' ? '绑定成功' : s.msg,
  84. showCancel: false,
  85. success: function ({ confirm }) {
  86. if (confirm) {
  87. if (s.msg == '成功') that.$Login.wechatLogin().then(() => {
  88. uni.reLaunch({
  89. url: '/pages/index/index'
  90. })
  91. that.user = {
  92. wechatBindUserid: 0,
  93. userName: ""
  94. }
  95. })
  96. }
  97. }
  98. });
  99. })
  100. }
  101. })
  102. }
  103. });
  104. } else {
  105. console.log("this.user", this.user)
  106. }
  107. }
  108. },
  109. methods: {
  110. updatePageData(itemId, page) {
  111. if (this.$refs[this.page].updatePage) this.$refs.pages.onClick(itemId, page)
  112. },
  113. pageChange(detail) {
  114. uni.setNavigationBarTitle({
  115. title: detail.name,
  116. })
  117. this.page = detail.name;
  118. try {
  119. console.log(this.$refs[detail.name].updatePage)
  120. if (this.$refs[detail.name].updatePage) uni.pageScrollTo({
  121. scrollTop: 0,
  122. duration: 0,
  123. })
  124. this.$refs[detail.name].init(detail.callBack, detail.params)
  125. } catch (error) {
  126. detail.callBack()
  127. }
  128. console.log("切换页面", detail)
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="scss"></style>