help.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view>
  3. <view class="edgeInsetTop"></view>
  4. <view class="help-service bg-white padding-lr">
  5. <view @tap="goService">
  6. <view class="cu-avatar lg round bg-white solid">
  7. <text class="wlIcon-unie737 text-cyan"></text>
  8. </view>
  9. <view class="margin-top-xs text-df">
  10. {{ $t('help.onlineService') }}
  11. </view>
  12. </view>
  13. <view @tap="callPhone">
  14. <view class="cu-avatar lg round bg-white solid">
  15. <text class="wlIcon-31guanzhuxuanzhong text-blue"></text>
  16. </view>
  17. <view class="margin-top-xs text-df">
  18. {{ $t('help.salesHotline') }}
  19. </view>
  20. </view>
  21. <view @tap="callPhone">
  22. <view class="cu-avatar lg round bg-white solid">
  23. <text class="wlIcon-dianhua text-purple"></text>
  24. </view>
  25. <view class="margin-top-xs text-df">
  26. {{ $t('help.serviceHotline') }}
  27. </view>
  28. </view>
  29. </view>
  30. <view class="bg-white text-center padding-bottom-sm">
  31. <text class="text-gray text-sm">{{ $t('help.workingHours') }}: {{ workingHours }}</text>
  32. </view>
  33. <view class="cu-bar bg-white solid-bottom margin-top" v-if="dataList.length !== 0">
  34. <view class="action">
  35. {{ $t('help.commonQuestions') }}
  36. </view>
  37. </view>
  38. <empty v-else-if="!loading" :text="$t('help.empty')" />
  39. <view class="cu-list menu">
  40. <view class="cu-item arrow" v-for="item in dataList" :key="item.id" @tap="onDetails(item)">
  41. <view class="content text-cut">
  42. <text class="text-gray-2">{{ item.title }}</text>
  43. </view>
  44. </view>
  45. </view>
  46. <uni-load-more :status="status" :content-text="contentText" />
  47. </view>
  48. </template>
  49. <script>
  50. import { mapState } from 'vuex'
  51. import Empty from '@/components/empty/empty.vue'
  52. import { fetchArticleListPage } from '@/features/article/article-gateway'
  53. export default {
  54. components: { Empty },
  55. data() {
  56. return {
  57. dataList: [],
  58. reload: false,
  59. current_page: 1,
  60. last_page: 1,
  61. status: 'more',
  62. loading: false,
  63. contentText: {
  64. contentdown: ' ',
  65. contentrefresh: this.$t('help.loading'),
  66. contentnomore: this.$t('help.noMore')
  67. }
  68. }
  69. },
  70. computed: {
  71. ...mapState({
  72. appConfig: state => state.shell.appConfig || {}
  73. }),
  74. workingHours() {
  75. return this.appConfig.working_hours || '09:00-18:00'
  76. },
  77. phoneNumber() {
  78. return this.appConfig.tel_phone || ''
  79. }
  80. },
  81. onLoad() {
  82. this.loadData()
  83. },
  84. onPullDownRefresh() {
  85. this.current_page = 1
  86. this.reload = true
  87. this.loadData()
  88. },
  89. onReachBottom() {
  90. if (this.current_page >= this.last_page) {
  91. this.status = 'noMore'
  92. } else {
  93. this.reload = false
  94. this.current_page++
  95. this.status = 'loading'
  96. this.loadData()
  97. }
  98. },
  99. methods: {
  100. async loadData() {
  101. this.loading = true
  102. try {
  103. const res = await fetchArticleListPage(this.current_page, 'help')
  104. uni.stopPullDownRefresh()
  105. this.dataList = this.reload ? res.rows : this.dataList.concat(res.rows)
  106. this.current_page = res.currentPage
  107. this.last_page = res.lastPage
  108. this.status = res.total === 0 ? 'noMore' : 'more'
  109. } catch (e) {
  110. uni.stopPullDownRefresh()
  111. this.status = 'noMore'
  112. }
  113. this.loading = false
  114. },
  115. goService() {
  116. uni.navigateTo({ url: '/pages/user/service' })
  117. },
  118. callPhone() {
  119. if (this.phoneNumber) {
  120. uni.makePhoneCall({ phoneNumber: this.phoneNumber })
  121. } else {
  122. uni.showToast({ title: this.$t('help.noPhone'), icon: 'none' })
  123. }
  124. },
  125. onDetails(item) {
  126. const title = encodeURIComponent(item.title || '')
  127. uni.navigateTo({ url: `/pages/article/details?id=${item.id}&title=${title}` })
  128. }
  129. }
  130. }
  131. </script>
  132. <style>
  133. .help-service {
  134. display: flex;
  135. justify-content: space-around;
  136. padding-top: 40rpx;
  137. padding-bottom: 30rpx;
  138. text-align: center;
  139. }
  140. .help-service > view {
  141. display: flex;
  142. flex-direction: column;
  143. align-items: center;
  144. }
  145. .solid::after {
  146. border: 1px solid rgba(0, 0, 0, 0.12);
  147. }
  148. </style>