main.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import App from './App'
  2. import {myRequest} from './utils/request.js'
  3. import {getUserDetail} from '@/api/common.js'
  4. import {getVipLog,mealList,getTmpVip} from '@/api/combo.js'
  5. function GetVip(){
  6. console.log('cesjhio');
  7. if(uni.getStorageSync('token')){
  8. getVipLog().then(res=>{
  9. let createTime = new Date(JSON.parse(uni.getStorageSync('userInfo')).createTime)
  10. if(res.content&&!res.content.length&&createTime>new Date('2024-12-01 00:00:00')){
  11. this.showGetVip = true
  12. // uni.showModal({
  13. // title:'提示',
  14. // content:'免费领取7天会员,畅享专属权益,点击“领取”体验!',
  15. // cancelText:'取消',
  16. // confirmText:'领取',
  17. // success: function (r) {
  18. // if (r.confirm) {
  19. // console.log('用户点击确定');
  20. // mealList({source:2}).then(result=>{
  21. // if(result.content.records.length){
  22. // getTmpVip(result.content.records[0].setMealCode).then(res1=>{
  23. // if(res1.state == 'Success'){
  24. // getUserDetail().then(data => {
  25. // uni.setStorageSync('userInfo', JSON.stringify(data.content))
  26. // })
  27. // uni.showToast({
  28. // title:'领取成功',
  29. // icon:'none'
  30. // })
  31. // }
  32. // })
  33. // }else{
  34. // uni.showToast({
  35. // title:'未配置临时会员',
  36. // icon:'none'
  37. // })
  38. // }
  39. // })
  40. // }
  41. // }
  42. // })
  43. }
  44. })
  45. }
  46. }
  47. function submit(){
  48. mealList({source:2}).then(result=>{
  49. if(result.content.records.length){
  50. getTmpVip(result.content.records[0].setMealCode).then(res1=>{
  51. if(res1.state == 'Success'){
  52. getUserDetail().then(data => {
  53. uni.setStorageSync('userInfo', JSON.stringify(data.content))
  54. })
  55. this.showGetVip = false
  56. uni.showToast({
  57. title:'领取成功',
  58. icon:'none'
  59. })
  60. }
  61. })
  62. }else{
  63. uni.showToast({
  64. title:'未配置临时会员',
  65. icon:'none'
  66. })
  67. }
  68. })
  69. }
  70. // #ifndef VUE3
  71. import Vue from 'vue'
  72. import './uni.promisify.adaptor'
  73. Vue.config.productionTip = false
  74. App.mpType = 'app'
  75. //挂载,让全局可以使用
  76. Vue.prototype.$req = myRequest
  77. Vue.prototype.$GetVip = GetVip
  78. Vue.prototype.$Submit = submit
  79. import uView from '@/uni_modules/uview-ui'
  80. Vue.use(uView)
  81. uni.$u.config.unit = 'rpx'
  82. const app = new Vue({
  83. ...App
  84. })
  85. app.$mount()
  86. // #endif
  87. // #ifdef VUE3
  88. import { createSSRApp } from 'vue'
  89. export function createApp() {
  90. const app = createSSRApp(App)
  91. return {
  92. app
  93. }
  94. }
  95. // #endif