index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. sa_storeid: 0,
  33. funs: [],
  34. }
  35. },
  36. onLoad(options) {
  37. if (options.wechatBindUserid) {
  38. this.funs.push({
  39. fun: this.wechatBind.bind(this),
  40. value: {
  41. wechatBindUserid: options.wechatBindUserid,
  42. userName: options.userName,
  43. }
  44. })
  45. } else if (options.sa_storeid) {
  46. this.sa_storeid = options.sa_storeid;
  47. }
  48. if (options.q) {
  49. let data = this.getUrlParams(options.q);
  50. switch (data.funName) {
  51. case 'wechatBind':
  52. this.funs.push({
  53. fun: this.wechatBind.bind(this),
  54. value: data
  55. })
  56. break;
  57. case 'getStore':
  58. this.sa_storeid = data.sa_storeid;
  59. break;
  60. case 'BindSalesman':
  61. this.funs.push({
  62. fun: this.bindSalesman.bind(this),
  63. value: data
  64. })
  65. break;
  66. }
  67. }
  68. },
  69. onShow() {
  70. this.isInitializeLogin(render.bind(this))
  71. function render() {
  72. if (this.funs.length) this.funs.forEach(v => v.fun(v.value));
  73. this.$Http.changePage = function (itemId, page, params) {
  74. this.$refs.pages.onClick(itemId, page, false, params)
  75. }.bind(this)
  76. // #ifdef MP-WEIXIN
  77. this.updatePageData(this.swiperItemID, this.page)
  78. // #endif
  79. }
  80. },
  81. methods: {
  82. updatePageData(itemId, page) {
  83. if (this.$refs[this.page].updatePage) this.$refs.pages.onClick(itemId, page)
  84. },
  85. pageChange(detail) {
  86. uni.setNavigationBarTitle({
  87. title: detail.name,
  88. })
  89. this.page = detail.name;
  90. try {
  91. console.log(this.$refs[detail.name].updatePage)
  92. if (this.$refs[detail.name].updatePage) uni.pageScrollTo({
  93. scrollTop: 0,
  94. duration: 0,
  95. })
  96. this.$refs[detail.name].init(detail.callBack, detail.params)
  97. } catch (error) {
  98. detail.callBack()
  99. }
  100. console.log("切换页面", detail)
  101. },
  102. wechatBind(user) {
  103. console.log("被邀请绑定账号", user);
  104. let that = this;
  105. uni.showModal({
  106. title: '提醒',
  107. content: `账号"${user.userName}"是否与当前微信号绑定`,
  108. confirmText: '确定绑定',
  109. success: function ({ confirm }) {
  110. if (confirm) uni.login({
  111. success(res) {
  112. that.$Http.basic({
  113. "id": 20240516090402,
  114. "content": {
  115. "wechat_code": res.code,
  116. "isbinging": 1,
  117. "wechatuserinfo": "",
  118. "sys_enterprise_hrid": user.wechatBindUserid
  119. }
  120. }).then(s => {
  121. console.log("绑定账号", s)
  122. uni.showModal({
  123. title: '提示',
  124. content: s.msg == '成功' ? '绑定成功' : s.msg,
  125. showCancel: false,
  126. success: function () {
  127. that.$Login.wechatLogin().then(() => uni.reLaunch({
  128. url: '/pages/index/index'
  129. }))
  130. }
  131. });
  132. })
  133. }
  134. })
  135. }
  136. });
  137. },
  138. bindSalesman(user) {
  139. console.log("被邀请绑定业务员", user);
  140. let that = this;
  141. uni.showModal({
  142. title: '提醒',
  143. content: `业务员账号"${user.username}"是否与当前微信号绑定`,
  144. confirmText: '确定绑定',
  145. success: function ({ confirm }) {
  146. if (confirm) that.$Http.basic({
  147. "id": 20240524090002,
  148. "content": {
  149. "hrid": user.hrid
  150. }
  151. }).then(s => {
  152. console.log("绑定账号", s)
  153. uni.showModal({
  154. title: '提示',
  155. content: s.msg == '成功' ? '绑定成功' : s.msg,
  156. showCancel: false,
  157. success: function () {
  158. that.$Login.wechatLogin().then(() => uni.reLaunch({
  159. url: '/pages/index/index'
  160. }))
  161. }
  162. });
  163. })
  164. }
  165. });
  166. }
  167. }
  168. }
  169. </script>
  170. <style lang="scss"></style>