index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <view class="content">
  3. <image class="logo" src="/static/logo.png"></image>
  4. <view class="text-area">
  5. <text class="title">{{title}}</text>
  6. </view>
  7. <button @click="cb"> {{data.user_name}}
  8. </button>
  9. <view v-for="(v,k,i) in obj" key="k">
  10. <text> {{v}}{{i}}</text>
  11. </view>
  12. <alertDialog v-if="isOpenDialog" :titleName="titleName" contentText="你好呀!" @dialogConfirm ="onDialogConfirm" @dialogClose = "onDialogClose" />
  13. <button @click="isOpenDialog=true">显示对话框</button>
  14. <button @click="isOpenMessage=true">显示消息提示</button>
  15. <MessageVue v-if="isOpenMessage" :messageText="tip_message" @onFinish="isOpenMessage=false"> </MessageVue>
  16. </view>
  17. </template>
  18. <script setup lang="ts">
  19. import { ref,reactive ,onMounted,onUnmounted,watch} from 'vue';
  20. import { UserData } from '../../stores/userDataManager';
  21. import { user_data } from '../../data/data';
  22. import {storeToRefs} from 'pinia';
  23. import { util } from '../../framework/util';
  24. import MessageVue from '../../components/public/Message.vue';
  25. import alertDialog from '../../components/public/alertDialog.vue';
  26. import { log } from '../../framework/log';
  27. import { http } from '../../framework/http';
  28. import { config } from '../../config/config';
  29. let udata = new user_data()
  30. udata.token = "123"
  31. udata.user_id = "1"
  32. udata.user_name = "大靓仔"
  33. let tip_message = ref("")
  34. UserData().updateUserData(udata)
  35. const {data} = storeToRefs(UserData())
  36. let title = ref("123")
  37. let obj = reactive({a:"12",b:"123"});
  38. let cb = function(){
  39. util.alert("你有点呆呆的!")
  40. title.value = "fuck!"
  41. obj.a = "world";
  42. }
  43. // Dialog 使用用例 给组件传递参数和回调 start
  44. let isOpenDialog = ref(false)
  45. let titleName = ref("fuck u!")
  46. function onDialogClose(){
  47. log.Debug("onDialogClose!")
  48. isOpenDialog.value = false
  49. }
  50. function onDialogConfirm(){
  51. log.Debug("onDialogConfirm!")
  52. isOpenDialog.value = false
  53. http.StaticRequest("https://static.hainanmlwl.com/test_books/book_list.json",(err,data)=>{
  54. if(err){
  55. tip_message = err
  56. isOpenMessage.value = true
  57. return
  58. }
  59. log.Debug("data.code", typeof config.url_confg.StatesCode.SUCCESS)
  60. if(data.code==config.url_confg.StatesCode.SUCCESS){
  61. log.Debug("book_list",data)
  62. }else{
  63. tip_message = data.message
  64. isOpenMessage.value = true
  65. }
  66. })
  67. }
  68. //end
  69. //消息
  70. let isOpenMessage = ref(false)
  71. //end
  72. onMounted(()=>{
  73. })
  74. onUnmounted(()=>{
  75. })
  76. watch(obj,async (new_v,old_v)=>{
  77. console.log(new_v,old_v)
  78. })
  79. </script>
  80. <style scoped>
  81. .content {
  82. display: flex;
  83. flex-direction: column;
  84. align-items: center;
  85. justify-content: center;
  86. }
  87. .logo {
  88. height: 200rpx;
  89. width: 200rpx;
  90. margin-top: 200rpx;
  91. margin-left: auto;
  92. margin-right: auto;
  93. margin-bottom: 50rpx;
  94. }
  95. .text-area {
  96. display: flex;
  97. justify-content: center;
  98. }
  99. .title {
  100. font-size: 36rpx;
  101. color: #8f8f94;
  102. }
  103. </style>