main.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * @Author: your name
  3. * @Date: 2021-01-25 11:32:04
  4. * @LastEditTime: 2021-03-19 09:40:02
  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. Vue.config.productionTip = false
  17. App.mpType = 'app'
  18. Vue.prototype.$store = store
  19. Vue.prototype.$dayjs = dayjs
  20. Vue.use(uView)
  21. Vue.filter('imgFilter', (fileItem, type) => {
  22. return dealImgUrl(fileItem, type)
  23. })
  24. Vue.filter('imgListFilter', (fileList, type) => {
  25. fileList.forEach(item => {
  26. item.url = dealImgUrl(item, type)
  27. })
  28. return fileList
  29. })
  30. Vue.mixin({
  31. onLoad (options) {
  32. options = this.dealOptions(options)
  33. const inviteId = options.INVITE_ID
  34. if (inviteId && !this.$store.state.INVITE_ID) {
  35. this.$store.commit('saveInviteId', inviteId)
  36. }
  37. },
  38. methods: {
  39. dealOptions (options) {
  40. let option = options
  41. if (Object.prototype.hasOwnProperty.call(option, 'scene')) {
  42. const str = decodeURIComponent(option.scene).split('&')
  43. const json = {}
  44. str.forEach(item => {
  45. const index = item.indexOf('=')
  46. json[item.slice(0, index)] = item.slice(index + 1)
  47. })
  48. option = json
  49. }
  50. for (const key in option) {
  51. option[key.toUpperCase()] = option[key]
  52. }
  53. return option
  54. }
  55. },
  56. onShareAppMessage (res) {
  57. const title = '请你趣吃霸王餐'
  58. let url = '/pages/index'
  59. if (this.$store.userInfo) {
  60. url += '?invite_id=' + this.$store.userInfo.id
  61. }
  62. return {
  63. title: title,
  64. path: url
  65. }
  66. },
  67. onShareTimeline (res) {
  68. const title = '请你趣吃霸王餐'
  69. let url = '/pages/index'
  70. if (this.$store.userInfo) {
  71. url += '?invite_id=' + this.$store.userInfo.id
  72. }
  73. return {
  74. title: title,
  75. path: url
  76. }
  77. }
  78. })
  79. Vue.component('network-error', networkError)
  80. const app = new Vue({
  81. ...App
  82. })
  83. app.$mount()