flow-intro.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <view class="fi-wrap">
  3. <view class="fi-header">
  4. <text class="fi-title">{{ domainName || '服务流程' }}</text>
  5. <text class="fi-sub">了解你将获得的完整服务</text>
  6. </view>
  7. <view class="fi-loading" v-if="loading">加载中...</view>
  8. <view class="fi-empty" v-else-if="!steps || steps.length === 0">暂无流程信息</view>
  9. <view class="fi-timeline" v-else>
  10. <view class="fi-step" v-for="(s, i) in steps" :key="s.key" :class="{ 'fi-step-last': i === steps.length - 1 }">
  11. <view class="fi-step-dot" :class="{ 'fi-step-dot-cur': i <= currentStep }">
  12. <text class="fi-step-num">{{ i + 1 }}</text>
  13. </view>
  14. <view class="fi-step-line" v-if="i < steps.length - 1"></view>
  15. <view class="fi-step-body">
  16. <text class="fi-step-title">{{ s.title }}</text>
  17. <text class="fi-step-desc" v-if="s.desc">{{ s.desc }}</text>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="fi-btn-wrap" v-if="!loading && steps.length > 0">
  22. <view class="fi-btn" @click="goSurvey">
  23. <text class="fi-btn-text">开始填写调研</text>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import { getProblemDomainList } from '../../utils/api.js'
  30. import { updateUserIntentStage } from '../../utils/api.js'
  31. export default {
  32. data() {
  33. return {
  34. code: '',
  35. domainName: '',
  36. steps: [],
  37. loading: false,
  38. currentStep: 0
  39. }
  40. },
  41. onLoad(options) {
  42. var code = options && options.code
  43. if (code) {
  44. this.code = code
  45. }
  46. this.loadDomainDetail()
  47. },
  48. onReady() {
  49. this.advanceStage()
  50. },
  51. methods: {
  52. getKey(item, i) {
  53. return 's' + i
  54. },
  55. loadDomainDetail() {
  56. var self = this
  57. self.loading = true
  58. uni.showLoading({ title: '加载中...', mask: true })
  59. getProblemDomainList().then(function(res) {
  60. uni.hideLoading()
  61. self.loading = false
  62. var list = res && res.data
  63. if (Array.isArray(list)) {
  64. var found = null
  65. for (var i = 0; i < list.length; i++) {
  66. if (list[i].code === self.code) {
  67. found = list[i]
  68. break
  69. }
  70. }
  71. if (found) {
  72. self.domainName = found.name
  73. var flowJson = found.flow_intro_json
  74. if (flowJson) {
  75. var parsed = typeof flowJson === 'string' ? JSON.parse(flowJson) : flowJson
  76. self.steps = Array.isArray(parsed) ? parsed.map(function(s, idx) {
  77. return { key: 'step' + idx, title: s.title || '第' + (idx + 1) + '步', desc: s.desc || '' }
  78. }) : []
  79. } else {
  80. self.steps = self.getDefaultSteps()
  81. }
  82. self.surveyTemplateId = found.surveyTemplateId || (found.surveyTemplate && found.surveyTemplate.id) || ''
  83. } else {
  84. self.steps = self.getDefaultSteps()
  85. }
  86. } else {
  87. self.steps = self.getDefaultSteps()
  88. }
  89. }).catch(function() {
  90. uni.hideLoading()
  91. self.loading = false
  92. self.steps = self.getDefaultSteps()
  93. })
  94. },
  95. getDefaultSteps() {
  96. var defaultTitles = ['选择问题域', '了解服务流程', '填写专项调研', '选购推荐方案', '接收试剂盒', '获取报告', '确认方案并执行']
  97. return defaultTitles.map(function(t, i) {
  98. return { key: 'step' + i, title: t, desc: '' }
  99. })
  100. },
  101. advanceStage() {
  102. updateUserIntentStage(1).then(function() {
  103. // 静默推进
  104. }).catch(function() {
  105. // 静默
  106. })
  107. },
  108. goSurvey() {
  109. var url = '/pages/problem/survey?code=' + this.code
  110. if (this.surveyTemplateId) {
  111. url += '&templateId=' + this.surveyTemplateId
  112. }
  113. uni.navigateTo({ url: url })
  114. }
  115. }
  116. }
  117. </script>
  118. <style scoped>
  119. .fi-wrap {
  120. min-height: 100vh;
  121. background: #FFF7ED;
  122. padding: 40rpx 32rpx 120rpx;
  123. box-sizing: border-box;
  124. }
  125. .fi-header {
  126. margin-bottom: 40rpx;
  127. }
  128. .fi-title {
  129. display: block;
  130. font-size: 38rpx;
  131. font-weight: bold;
  132. color: #333;
  133. text-align: center;
  134. }
  135. .fi-sub {
  136. display: block;
  137. font-size: 26rpx;
  138. color: #999;
  139. text-align: center;
  140. margin-top: 10rpx;
  141. }
  142. .fi-loading, .fi-empty {
  143. text-align: center;
  144. font-size: 28rpx;
  145. color: #999;
  146. padding: 80rpx 0;
  147. }
  148. .fi-timeline {
  149. padding-left: 30rpx;
  150. }
  151. .fi-step {
  152. position: relative;
  153. padding-left: 60rpx;
  154. padding-bottom: 40rpx;
  155. }
  156. .fi-step-last {
  157. padding-bottom: 0;
  158. }
  159. .fi-step-dot {
  160. position: absolute;
  161. left: 0;
  162. top: 0;
  163. width: 44rpx;
  164. height: 44rpx;
  165. border-radius: 50%;
  166. background: #FED7AA;
  167. display: flex;
  168. align-items: center;
  169. justify-content: center;
  170. z-index: 2;
  171. }
  172. .fi-step-dot-cur {
  173. background: #F97316;
  174. }
  175. .fi-step-num {
  176. font-size: 22rpx;
  177. color: #fff;
  178. font-weight: bold;
  179. }
  180. .fi-step-line {
  181. position: absolute;
  182. left: 20rpx;
  183. top: 44rpx;
  184. width: 4rpx;
  185. height: 100%;
  186. background: #FED7AA;
  187. z-index: 1;
  188. }
  189. .fi-step-body {
  190. background: #fff;
  191. border-radius: 20rpx;
  192. padding: 24rpx 28rpx;
  193. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
  194. }
  195. .fi-step-title {
  196. display: block;
  197. font-size: 28rpx;
  198. font-weight: 600;
  199. color: #333;
  200. }
  201. .fi-step-desc {
  202. display: block;
  203. font-size: 24rpx;
  204. color: #999;
  205. margin-top: 8rpx;
  206. }
  207. .fi-btn-wrap {
  208. position: fixed;
  209. left: 0;
  210. right: 0;
  211. bottom: 0;
  212. padding: 20rpx 32rpx 40rpx;
  213. background: #FFF7ED;
  214. box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.06);
  215. }
  216. .fi-btn {
  217. background: linear-gradient(135deg, #F97316, #FB923C);
  218. border-radius: 48rpx;
  219. padding: 26rpx 0;
  220. text-align: center;
  221. }
  222. .fi-btn:active {
  223. opacity: 0.9;
  224. }
  225. .fi-btn-text {
  226. color: #fff;
  227. font-size: 32rpx;
  228. font-weight: 600;
  229. }
  230. </style>