選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import App from './App'
  2. // #ifndef VUE3
  3. import Vue from 'vue'
  4. import uView from 'uview-ui'
  5. Vue.use(uView)
  6. Vue.config.productionTip = false
  7. App.mpType = 'app'
  8. import tabBar from './components/tabbar/index.vue'
  9. Vue.component('tab-bar', tabBar)
  10. import request from'./utils/request.js'
  11. Vue.prototype.$request = request
  12. // 封装全局登录函数
  13. // backpage, backtype 2个参数分别代表:
  14. // backpage : 登录后返回的页面
  15. // backtype : 打开页面的类型[1 : redirectTo 2 : switchTab]
  16. Vue.prototype.checkLogin = function(backpage, backtype) {
  17. // 同步获取本地数据(uid、随机码、用户名、头像)
  18. var user_id = uni.getStorageSync('user_id');
  19. var user_nu = uni.getStorageSync('user_nu');
  20. var user_nm = uni.getStorageSync('user_nm');
  21. var user_fa = uni.getStorageSync('user_fa');
  22. if (user_id == '' || user_nu == '' || user_fa == '') {
  23. // 使用重定向的方式跳转至登录页面
  24. debugger;
  25. uni.redirectTo({
  26. url: '../login/login?backpage=' + backpage + '&backtype=' + backtype
  27. });
  28. return false;
  29. }
  30. // 登录成功、已经登录返回数组 [用户 id, 用户随机码, 用户昵称, 用户表情]
  31. return [user_id, user_nu, user_nm, user_fa];
  32. }
  33. Vue.mixin({
  34. data(){
  35. return {
  36. $theme:'#F34B16'
  37. }
  38. }
  39. })
  40. // 定义一个全局的请求地址
  41. Vue.prototype.apiServer = 'http://dianping.vtor.xyz/'
  42. // Vue.prototype.apiServer = 'http://192.168.1.50:8066/'
  43. // uni.addInterceptor('request', {
  44. // invoke(arg:WechatMiniprogram.RequestOption) {
  45. // // 对请求头处理事情
  46. // arg.header = {
  47. // ...arg.header,
  48. // Authorization: 'xxx'
  49. // }
  50. // return arg
  51. // },
  52. // success(args) {
  53. // debugger;
  54. // console.log('interceptor-complete', res)
  55. // // 请求成功后,修改code值为1
  56. // args.data.code = 1
  57. // },
  58. // fail(err) {
  59. // console.log('interceptor-fail', err)
  60. // },
  61. // complete(res) {
  62. // console.log('interceptor-complete', res)
  63. // }
  64. // })
  65. const app = new Vue({
  66. ...App
  67. })
  68. app.$mount()
  69. // #endif
  70. // #ifdef VUE3
  71. import {
  72. createSSRApp
  73. } from 'vue'
  74. export function createApp() {
  75. const app = createSSRApp(App)
  76. return {
  77. app
  78. }
  79. }
  80. // #endif