index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template>
  2. <view class="contanier" :class="{ spread: spread }">
  3. <view class="main-contanier">
  4. <ss-header />
  5. <template v-if="global.networkIsConnected">
  6. <ss-navigation @quick-send="quickSend" @call-hotline="callServiceHotline" @load-service="loadService" />
  7. <view class="main-body" :class="{ show: pagePaddingTop }" :style="bodyStyle">
  8. <view class="main-scroll">
  9. <view class="scroll-content">
  10. <ss-headline />
  11. <ss-chat ref="chat" @edit-message="editMessage" @quick-send="quickSend" @change-chat="changeChat" />
  12. <ss-input-box ref="inputBox" @change-chat="changeChat" @new-message="newMessage" />
  13. <ss-service @load-service="loadService" />
  14. <ss-common-problem @quick-send="quickSend" />
  15. <view class="ss-row ss-flex no-margin-bottom">
  16. <view class="ss-col">
  17. <ss-grid-entrance title="意见反馈" subject="诚谢建言,共筑精品" :image="getStaticImageUrl('/images/bg07.png')" @tap="navigatorToFeedback" />
  18. </view>
  19. <view class="ss-col">
  20. <ss-grid-entrance title="服务热线" :subject="serviceHotline" :image="getStaticImageUrl('/images/bg08.png')" sub-class="yellow" @tap="callServiceHotline" />
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <view v-else class="no-network">
  28. <view class="network-center">
  29. <image class="no-network-image" mode="aspectFit" src="/static/images/no-network.png" />
  30. <view class="no-network-text">哎呀,网络连接失败~</view>
  31. <button class="no-network-button" @tap="checkNetwork">刷新试试</button>
  32. </view>
  33. </view>
  34. </view>
  35. <image class="background-image" mode="aspectFill" :src="getStaticImageUrl('/images/bg-page.png')"></image>
  36. <ss-disclaimer />
  37. </view>
  38. </template>
  39. <script>
  40. import SsHeader from '@/components/SsHeader.vue';
  41. import SsNavigation from '@/components/SsNavigation.vue';
  42. import SsHeadline from '@/components/SsHeadline.vue';
  43. import SsInputBox from '@/components/SsInputBox.vue';
  44. import SsService from '@/components/SsService.vue';
  45. import SsCommonProblem from '@/components/SsCommonProblem.vue';
  46. import SsGridEntrance from '@/components/SsGridEntrance.vue';
  47. import SsChat from '@/components/ss_chat/SsChat.vue';
  48. import SsDisclaimer from '@/components/SsDisclaimer.vue';
  49. import { useGlobalStore } from '@/stores/global';
  50. import { watch } from 'vue';
  51. export default {
  52. components: {
  53. SsHeader,
  54. SsNavigation,
  55. SsHeadline,
  56. SsInputBox,
  57. SsService,
  58. SsCommonProblem,
  59. SsGridEntrance,
  60. SsChat,
  61. SsDisclaimer
  62. },
  63. data() {
  64. return {
  65. global: useGlobalStore(),
  66. timeoutFlag: null
  67. };
  68. },
  69. computed: {
  70. serviceHotline() {
  71. return this.global.basic?.serviceHotline ?? '';
  72. },
  73. spread() {
  74. return this.global.spread;
  75. },
  76. pagePaddingTop() {
  77. return this.global.paddingTop;
  78. },
  79. bodyStyle() {
  80. let style = {};
  81. if (this.global.paddingTop > 0) {
  82. style = {
  83. paddingTop: this.global.paddingTop + 'px',
  84. height: 'calc(100% - ' + this.global.paddingTop + 'px)'
  85. };
  86. }
  87. return style;
  88. }
  89. },
  90. mounted() {},
  91. methods: {
  92. toggleSpread() {
  93. this.spread = !this.spread;
  94. },
  95. setSpread(val) {
  96. this.spread = val;
  97. },
  98. callServiceHotline() {
  99. uni
  100. .makePhoneCall({
  101. phoneNumber: this.serviceHotline
  102. })
  103. .then(() => {})
  104. .catch(() => {});
  105. },
  106. navigatorToFeedback() {
  107. uni.navigateTo({
  108. url: '/pages/index/feedback'
  109. });
  110. },
  111. quickSend(msg) {
  112. if (this.$refs.inputBox) {
  113. this.$refs.inputBox.quickSend(msg);
  114. }
  115. },
  116. loadService(categoryId, title, avatar) {
  117. if (this.$refs.inputBox) {
  118. this.$refs.inputBox.loadService(categoryId, title, avatar);
  119. }
  120. },
  121. editMessage(msg) {
  122. if (this.$refs.inputBox) {
  123. this.$refs.inputBox.editMessage(msg);
  124. }
  125. },
  126. changeChat() {
  127. if (this.$refs.chat) {
  128. this.$refs.chat.scrollToBottom();
  129. }
  130. },
  131. newMessage() {
  132. if (this.$refs.chat) {
  133. this.$refs.chat.newMessage();
  134. }
  135. },
  136. checkNetwork() {
  137. uni.getNetworkType({
  138. success: (e) => {
  139. if (e.networkType == 'none') {
  140. this.global.setNetworkIsConnected(false);
  141. uni.showToast({
  142. title: '未检测到网络',
  143. icon: 'none'
  144. });
  145. } else {
  146. this.global.setNetworkIsConnected(true);
  147. this.loadBasic();
  148. this.loadService();
  149. }
  150. },
  151. fail: () => {
  152. uni.showToast({
  153. title: '网络刷新失败',
  154. icon: 'none'
  155. });
  156. }
  157. });
  158. }
  159. }
  160. };
  161. </script>
  162. <style scoped lang="scss">
  163. .contanier {
  164. width: 100%;
  165. height: 100vh;
  166. .background-image {
  167. position: absolute;
  168. top: 0;
  169. left: 0;
  170. width: 100%;
  171. height: 100%;
  172. z-index: 20;
  173. opacity: 1;
  174. transition: opacity 0.3s linear;
  175. }
  176. .main-contanier {
  177. position: absolute;
  178. top: 0;
  179. left: 0;
  180. right: 0;
  181. bottom: 0;
  182. z-index: 100;
  183. .main-body {
  184. position: relative;
  185. opacity: 0;
  186. transition: opacity 0.3s linear;
  187. &.show {
  188. opacity: 1;
  189. }
  190. .main-scroll {
  191. width: 100%;
  192. height: 100%;
  193. overflow: hidden auto;
  194. .scroll-content {
  195. padding: 32rpx;
  196. padding-bottom: 64rpx;
  197. .ss-row {
  198. display: flex;
  199. justify-content: space-between;
  200. margin-bottom: 1.6rem;
  201. &.no-margin-bottom {
  202. margin-bottom: 0;
  203. }
  204. &.ss-flex {
  205. display: flex;
  206. .ss-col {
  207. width: calc(50% - 0.47rem);
  208. margin-bottom: 0;
  209. }
  210. }
  211. .ss-col {
  212. width: calc(50% - 0.9rem);
  213. }
  214. }
  215. }
  216. }
  217. }
  218. .no-network {
  219. position: fixed;
  220. top: 0;
  221. left: 0;
  222. bottom: 0;
  223. right: 0;
  224. z-index: 1000;
  225. background-color: rbga(255, 255, 255, 0.3);
  226. .network-center {
  227. position: absolute;
  228. top: 40%;
  229. left: 50%;
  230. width: 80%;
  231. text-align: center;
  232. transform: translate(-50%, -50%);
  233. .no-network-image {
  234. display: block;
  235. width: 360rpx;
  236. height: 240rpx;
  237. margin: 0 auto 32rpx auto;
  238. }
  239. .no-network-text {
  240. font-size: 32rpx;
  241. text-align: center;
  242. margin-bottom: 36rpx;
  243. color: #7e8aa2;
  244. }
  245. .no-network-button {
  246. border-radius: 100rpx;
  247. display: inline-block;
  248. padding: 0 120rpx;
  249. color: #ffffff;
  250. margin: 0 auto;
  251. background-color: #2943d6;
  252. &::after {
  253. display: none;
  254. }
  255. }
  256. }
  257. }
  258. }
  259. &.spread {
  260. .background-image {
  261. opacity: 0;
  262. }
  263. .main-contanier {
  264. .main-body {
  265. .main-scroll {
  266. overflow: hidden;
  267. }
  268. }
  269. }
  270. }
  271. }
  272. </style>