活动问卷
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

question.vue 7.4 KiB

10 miesięcy temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <view class="page">
  3. <block v-for="(obj, index) in pageList">
  4. <!-- :key="index" -->
  5. <template v-if="obj.type == 0">
  6. <!-- 多选 -->
  7. <view :key="index" class="sections">
  8. <view class="s-title">
  9. {{ obj.questionTitle }}
  10. </view>
  11. <view class="s-radio">
  12. <block v-for="(item) in obj.selectArr">
  13. <view class="s-radio" :key="item.value">
  14. <view class="s-radio-item">
  15. <view class="checked" @click="checkBox(item, obj)">
  16. <image v-if="item.select" src="../../static/image/checked.png" mode=""></image>
  17. </view>
  18. <view class="s-text">
  19. {{ item.name }}
  20. </view>
  21. </view>
  22. </view>
  23. </block>
  24. </view>
  25. </view>
  26. </template>
  27. <template v-if="obj.type == 1">
  28. <!-- 单选 -->
  29. <view :key="index" class="sections">
  30. <view class="s-title">
  31. {{ obj.questionTitle }}
  32. </view>
  33. <view class="s-radio">
  34. <block v-for="(item, oIndex) in obj.selectArr">
  35. <view class="s-radio" :key="item.value">
  36. <view class="s-radio-item">
  37. <view class="doit" @click="radioBox(obj.selectArr, oIndex, obj)">
  38. <image v-if="item.select" src="../../static/image/radioed.png" mode=""></image>
  39. </view>
  40. <view class="s-text">
  41. {{ item.name }}
  42. </view>
  43. </view>
  44. </view>
  45. </block>
  46. </view>
  47. </view>
  48. </template>
  49. <template v-if="obj.type == 2">
  50. <!-- 文本框 -->
  51. <view :key="index" class="sections">
  52. <view class="s-title">
  53. {{ obj.questionTitle }}
  54. </view>
  55. <view class="s-input">
  56. <input v-model="obj.answer" type="text" value="" />
  57. </view>
  58. </view>
  59. </template>
  60. <template v-if="obj.type == 3">
  61. <!-- 日期 -->
  62. <view :key="index" class="sections">
  63. <view class="s-title">
  64. {{ obj.questionTitle }}
  65. </view>
  66. <view class="s-picker">
  67. <picker mode="date" @change="(e) => {selectDate(e, obj)}">
  68. <view class="s-texs">{{ obj.dateText }}</view>
  69. </picker>
  70. </view>
  71. </view>
  72. </template>
  73. <template v-if="obj.type == 4">
  74. <!-- 文本域 -->
  75. <view :key="index" class="sections">
  76. <view class="s-title">
  77. {{ obj.questionTitle }}
  78. </view>
  79. <view class="s-textarea">
  80. <textarea v-model="obj.answer" maxlength="100" placeholder=" " />
  81. </view>
  82. </view>
  83. </template>
  84. </block>
  85. <!-- 提交 -->
  86. <view class="btns" v-if="pageList.length > 0">
  87. <button class="btns" type="dgefault" @getphonenumber="backframesurveycusAdd" open-type="getPhoneNumber">
  88. 提交
  89. </button>
  90. </view>
  91. </view>
  92. </template>
  93. <script>
  94. import uParse from '@/components/u-parse/u-parse.vue';
  95. import WXBizDataCrypt from "@/common/utils/WXBizDataCrypt.js";
  96. export default {
  97. components: {
  98. uParse
  99. },
  100. data() {
  101. return {
  102. id: '',
  103. pageList: [], // 问题列表
  104. };
  105. },
  106. onLoad(option) {
  107. if (option.id) this.id = option.id
  108. this.backframesurveycusList()
  109. },
  110. methods: {
  111. // 多选
  112. checkBox(data, obj) {
  113. data.select = !data.select
  114. this.$forceUpdate()
  115. let arr = obj.selectArr.filter(item => item.select).map(item => {
  116. return item.name
  117. })
  118. obj.answer = arr.join(',')
  119. console.log(obj)
  120. },
  121. // 单选
  122. radioBox(arr, index, obj) {
  123. arr.map(item => {
  124. item.select = false
  125. })
  126. arr[index].select = true
  127. obj.answer = arr[index].name
  128. },
  129. // 日期选择
  130. selectDate(e, data) {
  131. data.dateText = e.detail.value
  132. data.answer = e.detail.value
  133. },
  134. // 提交
  135. backframesurveycusAdd(e) {
  136. console.log(e)
  137. if (e.detail.errMsg == "getPhoneNumber:ok") {
  138. this.$request.get(this.$apiUrls.findPhone, {
  139. code: e.detail.code,
  140. }).then(res => {
  141. let phoneNum = JSON.parse(res.data).phone_info.phoneNumber
  142. this.addBackframesurveycusAdd(phoneNum)
  143. })
  144. } else {
  145. this.addBackframesurveycusAdd()
  146. }
  147. },
  148. //
  149. addBackframesurveycusAdd(data) {
  150. this.$request.post(this.$apiUrls.backframesurveycusAdd, {
  151. answer: JSON.stringify(this.pageList),
  152. phone: data,
  153. surveyId: this.id
  154. }).then(res => {
  155. uni.navigateTo({
  156. url: `/pages/success/success?id=${this.id}`
  157. })
  158. }).catch(e => {
  159. uni.navigateTo({
  160. url: `/pages/success/success?id=${this.id}`
  161. })
  162. })
  163. },
  164. // 详情
  165. backframesurveycusList() {
  166. this.$request.get(this.$apiUrls.backframesurveycusList, {
  167. id: this.id
  168. }).then(res => {
  169. console.log(res)
  170. this.pageList = res.data.questionList.map(item => {
  171. // 单选,多选选项处理
  172. if (item.type == 0 || item.type == 1) {
  173. item.selectArr = item.select.split(',').map(i => {
  174. let value = new Date().getTime() + i
  175. return {
  176. name: i,
  177. value: value,
  178. select: false
  179. }
  180. })
  181. }
  182. return {
  183. ...item,
  184. answer: '',
  185. dateText: "请选择日期"
  186. }
  187. })
  188. })
  189. },
  190. },
  191. }
  192. </script>
  193. <style lang="scss">
  194. @import url("@/components/u-parse/u-parse.css");
  195. .page {
  196. width: 100vw;
  197. min-height: 100vh;
  198. display: flex;
  199. flex-direction: column;
  200. align-items: center;
  201. background: linear-gradient(180deg, #3D78F6 0%, #BFD0F3 100%);
  202. .sections {
  203. margin-bottom: 24rpx;
  204. padding: 0 24rpx;
  205. width: 702rpx;
  206. min-height: 230rpx;
  207. background: #FFFFFF;
  208. border-radius: 12rpx;
  209. display: flex;
  210. flex-direction: column;
  211. align-items: center;
  212. overflow: hidden;
  213. &:first-of-type {
  214. margin-top: 24rpx;
  215. }
  216. .s-title {
  217. width: 100%;
  218. height: 106rpx;
  219. display: flex;
  220. align-items: center;
  221. background: #fff;
  222. font-size: 30rpx;
  223. font-weight: 600;
  224. color: #000000;
  225. }
  226. .s-input {
  227. width: 100%;
  228. height: 88rpx;
  229. background: #F6F8FE;
  230. border-radius: 8rpx;
  231. input {
  232. padding: 0 24rpx;
  233. width: 100%;
  234. height: 100%;
  235. font-size: 30rpx;
  236. font-weight: 600;
  237. color: #000000;
  238. }
  239. }
  240. .s-textarea {
  241. margin: 0 0 32rpx 0;
  242. width: 100%;
  243. min-height: 182rpx;
  244. background: #F6F8FE;
  245. border-radius: 8rpx;
  246. textarea {
  247. padding: 24rpx;
  248. width: 100%;
  249. height: 182rpx;
  250. }
  251. }
  252. .s-radio {
  253. margin: 0 0 32rpx 0;
  254. width: 100%;
  255. .s-radio-item {
  256. width: 100%;
  257. height: 60rpx;
  258. display: flex;
  259. align-items: center;
  260. .doit {
  261. width: 34rpx;
  262. height: 34rpx;
  263. background: #F0F1F5;
  264. border-radius: 50%;
  265. image {
  266. width: 34rpx;
  267. height: 34rpx;
  268. border-radius: 50%;
  269. }
  270. }
  271. .checked {
  272. width: 34rpx;
  273. height: 34rpx;
  274. background: #F0F1F5;
  275. border-radius: 8rpx;
  276. image {
  277. width: 34rpx;
  278. height: 34rpx;
  279. border-radius: 8rpx;
  280. }
  281. }
  282. .s-text {
  283. margin-left: 20rpx;
  284. flex-grow: 1;
  285. font-size: 28rpx;
  286. font-weight: 400;
  287. color: #000000;
  288. }
  289. }
  290. }
  291. .s-picker {
  292. width: 100%;
  293. height: auto;
  294. .s-texs {
  295. padding: 0 24rpx;
  296. width: 654rpx;
  297. height: 88rpx;
  298. background: #F6F8FE;
  299. border-radius: 8rpx;
  300. display: flex;
  301. align-items: center;
  302. font-size: 30rpx;
  303. font-weight: 400;
  304. color: #000000;
  305. }
  306. }
  307. }
  308. .btns {
  309. position: sticky;
  310. bottom: 0;
  311. margin: 0 auto 80rpx;
  312. width: 560rpx;
  313. height: 88rpx;
  314. background: #3D78F6;
  315. border-radius: 8rpx;
  316. font-size: 32rpx;
  317. font-weight: 600;
  318. color: #FFFFFF;
  319. text-align: center;
  320. line-height: 88rpx;
  321. }
  322. }
  323. </style>