index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <route lang="json">
  2. { "style": { "navigationBarTitleText": "关联视频号", "navigationBarBackgroundColor": "#fff" } }
  3. </route>
  4. <script setup lang="ts">
  5. import SectionHeading from '@/components/section-heading.vue'
  6. import { getDesignerInfo, updateDesignerInfo } from '../../../../core/libs/requests'
  7. import { useUserStore } from '../../../../store'
  8. import { storeToRefs } from 'pinia'
  9. import { pick } from 'radash'
  10. import { toContentHtml, validate } from '../../../../core/utils/common'
  11. import BottomAppBar from '@/components/bottom-app-bar.vue'
  12. import { useMessage } from 'wot-design-uni'
  13. import { NetImages } from '../../../../core/libs/net-images'
  14. import { useRouter } from '@/core/utils/router'
  15. import { AgreementType } from '@/core/libs/enums'
  16. const { alert, confirm } = useMessage('wd-message-box-slot')
  17. const userStore = useUserStore()
  18. const { userInfo } = storeToRefs(userStore)
  19. const { back } = useRouter()
  20. const form = ref<{
  21. userId?: number
  22. videoNumber?: string
  23. }>()
  24. const { data, run: setData } = useRequest(() => getDesignerInfo(userInfo.value.userId))
  25. const { loading, run: submiting } = useRequest(() => updateDesignerInfo(form.value))
  26. const handleSubmit = async () => {
  27. if (!validate(form.value, { videoNumber: [{ required: true, message: '请输入视频号ID' }] }))
  28. return
  29. const { action } = await confirm({
  30. title: '温馨提示',
  31. confirmButtonText: '同意并关联',
  32. cancelButtonText: '不同意',
  33. })
  34. console.log(action)
  35. if (action === 'confirm') {
  36. await submiting()
  37. uni.showToast({
  38. title: '视频号关联成功',
  39. icon: 'none',
  40. duration: 2000,
  41. success: () => {
  42. back()
  43. },
  44. })
  45. await setData()
  46. }
  47. // await alert({ title: '关联成功', confirmButtonText: '我知道了' })
  48. }
  49. onMounted(async () => {
  50. await setData()
  51. form.value = pick(data.value, ['id', 'userId', 'videoNumber'])
  52. })
  53. </script>
  54. <template>
  55. <div class="flex-grow flex flex-col gap-5 px-3.5 py-6 bg-white">
  56. <SectionHeading title="视频号ID" size="sm"></SectionHeading>
  57. <div class="bg-[#f6f6f6] rounded-lg px-3.5 py-2.5">
  58. <wd-input
  59. v-model="form.videoNumber"
  60. placeholder="请输入视频号ID"
  61. no-border
  62. custom-class="bg-[#f6f6f6]!"
  63. ></wd-input>
  64. </div>
  65. <SectionHeading title="如何关联视频号?" size="sm"></SectionHeading>
  66. <wd-img class="rounded-2xl" width="100%" mode="widthFix" :src="NetImages.WechatChannelsGuide" />
  67. <SectionHeading title="视频教程" size="sm"></SectionHeading>
  68. <div class="aspect-[1.87/1] rounded-2xl overflow-hidden">
  69. <video class="w-full h-full" :src="NetImages.VideoTutorial"></video>
  70. </div>
  71. <BottomAppBar fixed placeholder :border="false" v-if="(data.videoNumber ?? '') === ''">
  72. <div>
  73. <!-- <div class="text-center mb-5.5">-->
  74. <!-- <span class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-tight">-->
  75. <!-- 点击确认关联即表示同意-->
  76. <!-- </span>-->
  77. <!-- <span class="text-[#0cbe7c] text-xs font-normal font-['PingFang_SC'] leading-tight">-->
  78. <!-- 《个人微信视频号授权使用协议》-->
  79. <!-- </span>-->
  80. <!-- </div>-->
  81. <wd-button :round="false" block :loading="loading" @click="handleSubmit">
  82. 确定关联
  83. </wd-button>
  84. </div>
  85. </BottomAppBar>
  86. <wd-message-box selector="wd-message-box-slot">
  87. <div class="">
  88. <span class="text-black/40 text-base font-normal font-['PingFang_SC'] leading-relaxed">
  89. 关联后,小程序开发者将获取您的视频号相关信息,并为您提供相关服务,请您充分阅读
  90. </span>
  91. <span
  92. class="text-[#3f598f] text-base font-normal font-['PingFang_SC'] leading-relaxed"
  93. @click="
  94. toContentHtml({
  95. title: '个人微信视频号授权使用协议',
  96. type: AgreementType.PersonalWeChatVideoAuthorization,
  97. })
  98. "
  99. >
  100. 《个人微信视频号授权使用协议》
  101. </span>
  102. </div>
  103. </wd-message-box>
  104. </div>
  105. </template>