index.vue 4.9 KB

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