main.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * @Author: your name
  3. * @Date: 2021-01-25 11:32:04
  4. * @LastEditTime: 2021-04-02 16:29:26
  5. * @LastEditors: Please set LastEditors
  6. * @Description: In User Settings Edit
  7. * @FilePath: \rebatedine-mini\src\main.js
  8. */
  9. import Vue from 'vue'
  10. import App from './App'
  11. import store from './store/index'
  12. // import uView from 'uview-ui'
  13. import dayjs from './utils/dayjs.min.js'
  14. import dealImgUrl from '@/utils/dealImgUrl'
  15. import networkError from '@/components/networkError'
  16. import * as commonApi from '@/api/commonApi'
  17. Vue.config.productionTip = false
  18. App.mpType = 'app'
  19. Vue.prototype.$store = store
  20. Vue.prototype.$dayjs = dayjs
  21. // Vue.use(uView)
  22. Vue.filter('imgFilter', (fileItem, type) => {
  23. return dealImgUrl(fileItem, type)
  24. })
  25. Vue.filter('imgListFilter', (fileList, type) => {
  26. fileList.forEach(item => {
  27. item.url = dealImgUrl(item, type)
  28. })
  29. return fileList
  30. })
  31. Vue.mixin({
  32. onLoad (options) {
  33. console.log(111)
  34. options = this.dealOptions(options)
  35. const inviteId = options.INVITE_ID
  36. if (inviteId && !this.$store.state.INVITE_ID) {
  37. this.$store.commit('saveInviteId', inviteId)
  38. }
  39. // #ifdef H5
  40. const url = window.location.href.substring(
  41. 0,
  42. window.location.href.indexOf('#')
  43. )
  44. console.log(wx)
  45. console.log(wx.agentConfig)
  46. console.log(jWeixin)
  47. commonApi.signUrl({ url }).then(({ code, data }) => {
  48. if (code === 200) {
  49. jWeixin.agentConfig({
  50. corpid: data.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
  51. agentid: data.agentid, // 必填,企业微信的应用id (e.g. 1000247)
  52. timestamp: data.timestamp, // 必填,生成签名的时间戳
  53. nonceStr: data.noncestr, // 必填,生成签名的随机串
  54. signature: data.sign, // 必填,签名,见附录-JS-SDK使用权限签名算法
  55. jsApiList: data.jsApiList, // 必填,传入需要使用的接口名称
  56. success: function (res) {
  57. // 回调
  58. console.log('success')
  59. },
  60. fail: function (res) {
  61. if (res.errMsg.indexOf('function not exist') > -1) {
  62. alert('版本过低请升级')
  63. } else {
  64. console.log(res.errMsg)
  65. }
  66. }
  67. })
  68. }
  69. })
  70. // #endif
  71. },
  72. methods: {
  73. dealJumpInfo (banner) {
  74. switch (banner.jump_type * 1) {
  75. case 1:
  76. uni.navigateTo({
  77. url: `/pagesSub/other/webView?url=${banner.jump_content}`
  78. })
  79. break
  80. case 2:
  81. this.$store.dispatch('toOtherApplte', banner.jump_content)
  82. break
  83. case 3:
  84. uni.navigateTo({
  85. url: `/pagesSub/activity/activityDetail?id=${banner.jump_content}`
  86. })
  87. break
  88. case 4:
  89. console.log('jump_content', banner.jump_content)
  90. this.$store.commit('changeCateId', banner.jump_content)
  91. uni.switchTab({
  92. url: '/pages/classification'
  93. })
  94. break
  95. case 5:
  96. this.$store.commit('changeCateId', banner.jump_content)
  97. uni.navigateTo({
  98. url: '/pagesSub/other/noviceStrategy'
  99. })
  100. break
  101. default:
  102. }
  103. },
  104. dealOptions (options) {
  105. let option = options
  106. if (Object.prototype.hasOwnProperty.call(option, 'scene')) {
  107. const str = decodeURIComponent(option.scene).split('&')
  108. const json = {}
  109. str.forEach(item => {
  110. const index = item.indexOf('=')
  111. json[item.slice(0, index)] = item.slice(index + 1)
  112. })
  113. option = json
  114. }
  115. for (const key in option) {
  116. option[key.toUpperCase()] = option[key]
  117. }
  118. return option
  119. }
  120. },
  121. onShareAppMessage (res) {
  122. const title = '请你趣吃霸王餐'
  123. let url = '/pages/index'
  124. if (this.$store.userInfo) {
  125. url += '?invite_id=' + this.$store.userInfo.id
  126. }
  127. return {
  128. title: title,
  129. path: url
  130. }
  131. },
  132. onShareTimeline (res) {
  133. const title = '请你趣吃霸王餐'
  134. let url = '/pages/index'
  135. if (this.$store.userInfo) {
  136. url += '?invite_id=' + this.$store.userInfo.id
  137. }
  138. return {
  139. title: title,
  140. path: url
  141. }
  142. }
  143. })
  144. Vue.component('network-error', networkError)
  145. const app = new Vue({
  146. ...App
  147. })
  148. app.$mount()