index.vue 4.6 KB

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