fill-form.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. <template>
  2. <view class="fill-form">
  3. <uni-forms>
  4. <view class="a-form-item uni-form-item">
  5. <view class="title">
  6. CashBack
  7. </view>
  8. <view class="cash-back">
  9. <image src="../../../static/7.png"></image>
  10. <text>{{props.days}} Days</text>
  11. </view>
  12. </view>
  13. <view class="a-form-item uni-form-item">
  14. <view class="title">
  15. {{$t('index.finance.platform')}}
  16. </view>
  17. <view>
  18. {{props.platform}}
  19. </view>
  20. </view>
  21. <view class="a-form-item uni-form-item">
  22. <view class="title">
  23. {{$t('index.finance.order_sn')}}
  24. </view>
  25. <view>
  26. <picker :value="data.selectedOrderIndex" :range="data.orderList" @change="changeOrder">
  27. <view>
  28. {{selectedOrder()}}
  29. </view>
  30. </picker>
  31. </view>
  32. </view>
  33. <!-- <view class="a-form-item uni-form-item">
  34. <view class="title">
  35. 金额
  36. </view>
  37. <uni-easyinput :input-border="false"></uni-easyinput>
  38. </view> -->
  39. <view class="a-form-item steps">
  40. <view class="tab-header">
  41. <view :class="{'active':data.selectedTabIndex===0}" @tap="go(0)"><text>{{$t('index.finance.step')}}</text></view>
  42. <view :class="{'active':data.selectedTabIndex===1}" @tap="go(1)"><text>{{$t('index.finance.example')}}</text></view>
  43. </view>
  44. <view v-if="data.selectedTabIndex===0" class="step-texts">
  45. <textarea type="text" :value="props.task_step" disabled />
  46. <!-- <rich-text :nodes="props.task_step"></rich-text> -->
  47. </view>
  48. <view v-if="data.selectedTabIndex===1" class="step-pics">
  49. <view v-for="(item,index) in data.stepPics" class="step-pic">
  50. <image mode="aspectFit" :src="item"></image>
  51. <view @tap="removeImage(index)" class="step-pic-close">
  52. <image src="../../../static/10.png"></image>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="a-form-item upload-image" v-if="data.stepPics.length<3">
  58. <input type="file" name="file" accept="image/*" />
  59. <view @tap="uploadFile()" class="upload-btn">
  60. <view class="upload-icon">
  61. <text>+</text>
  62. </view>
  63. <text>
  64. {{$t('index.finance.uploadfile')}}
  65. </text>
  66. </view>
  67. </view>
  68. </uni-forms>
  69. <view class="submit-btn-wrapper">
  70. <button class="submit-btn" @tap="handleSubmit()">{{$t('index.finance.submit')}}</button>
  71. </view>
  72. <view class="dialog-wrapper" v-if="data.showDialog" @tap="data.showDialog=false">
  73. <view class="dialog">
  74. <view class="close" @tap="$emit('submit')">
  75. <image src="../../../static/10.png"></image>
  76. </view>
  77. <text>{{$t('index.finance.submitSuccess')}}</text>
  78. <image class="success-image" src="../../../static/6.png" />
  79. <view class="progress">
  80. <view class="progress-item">
  81. <view class="done">
  82. <image src="../../../static/7.png"></image>
  83. </view>
  84. </view>
  85. <view class="progress-line"></view>
  86. <view class="progress-item">
  87. <view class="ongoing">
  88. <text>2</text>
  89. </view>
  90. </view>
  91. <view class="progress-line"></view>
  92. <view class="progress-item">
  93. <view>
  94. <text>3</text>
  95. </view>
  96. </view>
  97. </view>
  98. <view class="progress-texts">
  99. <view><text>{{$t('index.finance.apply')}}</text></view>
  100. <view><text>{{$t('index.finance.audit')}}</text></view>
  101. <view><text>{{$t('index.finance.return_money')}}</text></view>
  102. </view>
  103. <!-- <view class="tips">
  104. <view class="tips-content">
  105. <image src="/static/8.png"></image>
  106. <text>特别声明: 文档内容文档内容文档内容</text>
  107. </view>
  108. </view> -->
  109. </view>
  110. </view>
  111. </view>
  112. </template>
  113. <script setup>
  114. import sheep from '@/sheep';
  115. import { onLoad } from '@dcloudio/uni-app';
  116. import {
  117. reactive,
  118. ref,
  119. } from 'vue'
  120. const props = defineProps(['id','days','platform','task_step'])
  121. const selectedOrder = () => {
  122. return data.orderList[data.selectedOrderIndex];
  123. }
  124. const popup = ref();
  125. async function handleSubmit() {
  126. for(var i = 0;i < data.dataList.length;i++){
  127. if(data.dataList[i].order_sn == data.orderList[data.selectedOrderIndex]){
  128. data.order_id = data.dataList[i].id;
  129. }
  130. }
  131. const res = await sheep.$api.task.submitTask({
  132. id: data.order_id,
  133. images: data.images,
  134. task_id: props.id
  135. });
  136. console.log(res)
  137. if(res.code == 1){
  138. data.showDialog = true;
  139. }else{
  140. sheep.$helper.toast(res.msg);
  141. }
  142. }
  143. const changeOrder = e => {
  144. data.selectedOrderIndex = e.detail.value;
  145. }
  146. const data = reactive({
  147. selectedTabIndex: 0,
  148. stepText: '',
  149. stepPics: [],
  150. showDialog: false,
  151. images: '',
  152. orderList: [],
  153. dataList: [],
  154. order_id: 0,
  155. selectedOrderIndex: 0,
  156. })
  157. onLoad(async () => {
  158. await getTaskListByDay();
  159. });
  160. async function getTaskListByDay(){
  161. const res = await sheep.$api.task.listByDay({
  162. day: props.days
  163. });
  164. console.log(res)
  165. if(res.code == 1){
  166. data.dataList = res.data;
  167. for(var i = 0;i < res.data.length;i++){
  168. data.orderList.push(res.data[i].order_sn);
  169. }
  170. }
  171. }
  172. const go = (idx) => {
  173. data.selectedTabIndex = idx;
  174. }
  175. const handleFileChange = (e) => {
  176. data.selectedTabIndex = 1;
  177. for (const f of e.target.files) {
  178. const name = URL.createObjectURL(f);
  179. data.stepPics.push(name);
  180. const a = new FileReader();
  181. a.readAsDataURL(f);
  182. a.onload = (e) => {
  183. data.images = e.target.result
  184. console.log(data.images)
  185. }
  186. if (data.stepPics.length >= 1) {
  187. break;
  188. }
  189. }
  190. }
  191. const uploadFile = () => {
  192. const f = document.querySelector("input[type='file']");
  193. f.removeEventListener('change', handleFileChange);
  194. f.addEventListener('change', handleFileChange);
  195. f.click();
  196. }
  197. const removeImage = (idx) => {
  198. data.stepPics.splice(idx, 1);
  199. }
  200. </script>
  201. <style scoped lang="scss">
  202. .dialog-wrapper {
  203. z-index: 999;
  204. position: fixed;
  205. width: 100%;
  206. height: 100%;
  207. top: 0;
  208. left: 0;
  209. display: flex;
  210. flex-direction: column;
  211. justify-content: center;
  212. align-items: center;
  213. background: rgba(0, 0, 0, 0.7);
  214. }
  215. .dialog {
  216. position: relative;
  217. background-color: white;
  218. border-radius: 20upx;
  219. width: 80%;
  220. min-height: 100upx;
  221. display: flex;
  222. flex-direction: column;
  223. align-items: center;
  224. padding: 20upx;
  225. .close {
  226. position: absolute;
  227. right: 10upx;
  228. top: 10upx;
  229. &>image {
  230. width: 60upx;
  231. height: 60upx;
  232. }
  233. }
  234. .success-image {
  235. margin: 20upx 0upx;
  236. width: 100upx;
  237. height: 100upx;
  238. }
  239. .progress-texts {
  240. margin-top: 10upx;
  241. width: 100%;
  242. display: flex;
  243. color: #777;
  244. &>view {
  245. flex: 1;
  246. display: flex;
  247. justify-content: center;
  248. }
  249. }
  250. .progress {
  251. display: flex;
  252. width: 70%;
  253. justify-content: space-between;
  254. .progress-line {
  255. border-top: 1px dashed #FAA435;
  256. margin-top: 20upx;
  257. min-width: 35%;
  258. }
  259. &>.progress-item {
  260. display: flex;
  261. flex-direction: column;
  262. align-items: center;
  263. image {
  264. width: 40upx;
  265. height: 40upx;
  266. }
  267. view:nth-child(1) {
  268. display: flex;
  269. flex-direction: column;
  270. justify-content: center;
  271. align-items: center;
  272. border: 1px solid #FAA435;
  273. border-radius: 50%;
  274. min-width: 40upx;
  275. min-height: 40upx;
  276. color: #faa435;
  277. font-size: 14upx;
  278. &.done {
  279. border: none;
  280. }
  281. &.ongoing {
  282. background: #faa435;
  283. color: white;
  284. }
  285. }
  286. }
  287. }
  288. .tips {
  289. background: #FDEAC9;
  290. border-radius: 40px;
  291. padding: 7px 15px;
  292. margin-top: 50px;
  293. margin-bottom: 10px;
  294. }
  295. .tips .tips-content {
  296. width: 100%;
  297. }
  298. .tips image {
  299. width: 14px;
  300. height: 14px;
  301. vertical-align: middle;
  302. padding-right: 6px;
  303. }
  304. .tips text {
  305. color: #8C7E75;
  306. font-size: 12px;
  307. }
  308. }
  309. .fill-form {
  310. display: flex;
  311. flex-direction: column;
  312. }
  313. .a-form-item {
  314. display: flex;
  315. align-items: center;
  316. padding: 20upx;
  317. border-radius: 10upx;
  318. box-shadow: 0px 0px 5px #ddd;
  319. margin: 15upx;
  320. }
  321. .cash-back {
  322. display: flex;
  323. align-items: center;
  324. image {
  325. margin-right: 10upx;
  326. width: 40upx;
  327. height: 40upx;
  328. }
  329. }
  330. .uni-form-item {
  331. justify-content: space-between;
  332. .uni-easyinput {
  333. max-width: 500upx;
  334. text-align: right;
  335. }
  336. }
  337. .steps {
  338. align-items: flex-start;
  339. flex-direction: column;
  340. }
  341. .step-texts {
  342. display: flex;
  343. flex-direction: column;
  344. textarea {
  345. color: #555;
  346. font-size: 0.825rem;
  347. margin-top: 40upx;
  348. height: 300upx;
  349. }
  350. }
  351. .step-pics {
  352. display: flex;
  353. flex-wrap: wrap;
  354. width: 100%;
  355. height: 300upx;
  356. .step-pic {
  357. position: relative;
  358. width: 100%;
  359. margin: 12px 0;
  360. &>image {
  361. width: 100%;
  362. height: 100%;
  363. }
  364. .step-pic-close {
  365. z-index: 1;
  366. &>image {
  367. width: 50upx;
  368. height: 50upx;
  369. }
  370. position: absolute;
  371. top: 0;
  372. right: 0;
  373. }
  374. }
  375. }
  376. .tab-header {
  377. display: flex;
  378. align-self: center;
  379. &>view {
  380. border-bottom: 6upx solid #FDEAC9;
  381. &>text {
  382. padding: 0upx 20upx;
  383. color: #50555555;
  384. }
  385. &.active {
  386. border-bottom-color: #FAA435;
  387. &>text {
  388. color: #FAA435;
  389. }
  390. }
  391. }
  392. }
  393. .upload-image {
  394. &>input {
  395. display: none;
  396. }
  397. }
  398. .upload-btn {
  399. display: flex;
  400. align-items: center;
  401. .upload-icon {
  402. border: 1px dashed #50555555;
  403. color: #50555555;
  404. border-radius: 8upx;
  405. width: 90upx;
  406. height: 90upx;
  407. display: flex;
  408. align-items: center;
  409. justify-content: center;
  410. margin-right: 10upx;
  411. }
  412. }
  413. .submit-btn-wrapper {
  414. position: fixed;
  415. width: 100%;
  416. display: flex;
  417. justify-content: center;
  418. bottom: 100upx;
  419. ;
  420. }
  421. .submit-btn {
  422. padding: 0;
  423. margin: 0;
  424. font-size: inherit;
  425. background-color: transparent;
  426. color: inherit;
  427. border: 0;
  428. display: flex;
  429. align-items: center;
  430. justify-content: center;
  431. box-sizing: border-box;
  432. text-align: center;
  433. text-decoration: none;
  434. white-space: nowrap;
  435. vertical-align: baseline;
  436. transform: translate(0, 0);
  437. width: 18.9375rem;
  438. height: 2.75rem;
  439. line-height: normal;
  440. background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  441. border-radius: 1rem;
  442. font-size: 0.8125rem;
  443. font-weight: 500;
  444. color: #fff;
  445. align-self: center;
  446. margin-top: 50upx;
  447. margin-bottom: 50upx;
  448. }
  449. </style>