input2.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. <template>
  2. <view style="padding: 30rpx">
  3. <nav-bar title="填写审核资料"></nav-bar>
  4. <view class="topBox">
  5. <view>
  6. <u-icon name="error-circle-fill" color="#FF3B30" size="28"></u-icon>
  7. <text style="color: #ff3b30; margin-left: 10rpx"
  8. >学习前请提交完整审核资料</text
  9. >
  10. </view>
  11. <view style="color: #007aff" @click="backPage">稍后再填</view>
  12. </view>
  13. <u-collapse v-if="remarkStatus" :item-style="itemStyle" event-type="close">
  14. <u-collapse-item title="审核结果反馈">
  15. <view style="padding-bottom: 30rpx">
  16. <text class="collapse-item">{{ remark }}</text>
  17. </view>
  18. </u-collapse-item>
  19. </u-collapse>
  20. <view class="bodyBox" style="margin-top: 30rpx; padding: 0 20rpx">
  21. <u-form :model="form" ref="uForm">
  22. <template v-for="(item, index) in listData">
  23. <u-form-item
  24. v-if="item.inputType == 4"
  25. :key="index"
  26. :label="item.fieldName"
  27. :required="item.required"
  28. :label-width="auto"
  29. :prop="item.required ? item.fieldKey : ''"
  30. label-position="top"
  31. >
  32. <text
  33. style="
  34. color: #007aff;
  35. position: absolute;
  36. top: 20rpx;
  37. left: 180rpx;
  38. text-decoration: underline;
  39. "
  40. @click="downDocx(item.url)"
  41. >点击下载</text
  42. >
  43. <div>
  44. <view class="dis_stys">
  45. <text style="color: #999999">
  46. 下载承诺书进行填写并签名盖章后上传(≤2M)
  47. </text>
  48. </view>
  49. <image
  50. v-if="!form[item.fieldKey]"
  51. style="width: 169rpx; height: 169rpx"
  52. @click="getChast"
  53. src="@/static/info_4.png"
  54. ></image>
  55. <view class="quzw" v-if="form[item.fieldKey]">
  56. <view
  57. v-if="
  58. form[item.fieldKey].split('.').splice(-1)[0] == 'docx' ||
  59. form[item.fieldKey].split('.').splice(-1)[0] == 'doc'
  60. "
  61. class="borsrs"
  62. >
  63. <image
  64. src="@/static/icon/jy_icon.png"
  65. style="width: 168rpx; height: 168rpx"
  66. ></image>
  67. <text>{{ titleName }}</text>
  68. </view>
  69. <image
  70. v-else
  71. :src="form[item.fieldKey]"
  72. style="width: 100%; height: 100%"
  73. mode="aspectFit"
  74. @click="seePhotos(form[item.fieldKey])"
  75. ></image>
  76. <u-icon
  77. name="close-circle-fill"
  78. color="red"
  79. size="44"
  80. class="optionsAbs"
  81. @click="clearWord"
  82. ></u-icon>
  83. </view>
  84. </div>
  85. </u-form-item>
  86. </template>
  87. </u-form>
  88. </view>
  89. <view @click="submits" class="submit_btn">提交资料</view>
  90. <u-action-sheet
  91. :list="list"
  92. v-model="showTableDown"
  93. @click="clickIndex"
  94. ></u-action-sheet>
  95. </view>
  96. </template>
  97. <script>
  98. export default {
  99. data() {
  100. return {
  101. showTableDown: false,
  102. list: [
  103. {
  104. text: "上传图片",
  105. },
  106. // {
  107. // text: '上传文件'
  108. // }
  109. ],
  110. isUploading: false,
  111. itemStyle: {
  112. marginTop: "20px",
  113. backgroundColor: "#fff",
  114. borderRadius: "24rpx",
  115. padding: "0rpx 20rpx",
  116. },
  117. form: {
  118. commitment_seal: "",
  119. },
  120. goodsId: null,
  121. fileList1: [],
  122. id: null, //id有值的话就是修改页面
  123. listData: {}, //页面数据
  124. openVerify: false, // 控制是否手动验证
  125. nextStatus: false, //是否有下一步
  126. titleName: "文件名称居中对齐过长换行", //word名称
  127. remark: "", //反馈文本
  128. remarkStatus: false, //是否存在审核结果反馈
  129. rules: {
  130. commitment_seal: [
  131. {
  132. required: true,
  133. message: "请上传承诺书盖章",
  134. trigger: ["change", "blur"],
  135. },
  136. ],
  137. },
  138. orderGoodsId: 0,
  139. auto: "180rpx",
  140. };
  141. },
  142. created() {},
  143. onLoad(option) {
  144. this.orderGoodsId = Number(option.orderGoodsId);
  145. this.goodsId = Number(option.id);
  146. this.getInfo();
  147. },
  148. onReady() {
  149. this.$refs.uForm.setRules(this.rules);
  150. },
  151. methods: {
  152. backPage() {
  153. uni.navigateBack();
  154. },
  155. seePhotos(url) {
  156. uni.previewImage({
  157. urls: [url],
  158. });
  159. },
  160. downDocx(url) {
  161. this.$api
  162. .addWordbaseprofileStamp({ goodsId: this.goodsId })
  163. .then((res) => {
  164. // #ifdef H5
  165. window.location.href = this.$method.splitImgHost(res.data.msg);
  166. // #endif
  167. // #ifdef MP-WEIXIN
  168. uni.downloadFile({
  169. url: this.$method.splitImgHost(res.data.msg),
  170. success: (result) => {
  171. if (result.statusCode === 200) {
  172. const filePath = result.tempFilePath;
  173. console.log(this.$method.splitImgHost(res.data.msg), 111);
  174. this.$method.showToast("下载成功");
  175. uni.saveImageToPhotosAlbum({
  176. filePath: filePath,
  177. success: function (errMsg) {
  178. uni.showToast({
  179. mask: true,
  180. title: "保存成功",
  181. });
  182. },
  183. fail: (errMsg) => {
  184. uni.showToast({
  185. mask: true,
  186. title: "保存失败",
  187. });
  188. },
  189. complete: (errMsg) => {},
  190. });
  191. }
  192. },
  193. });
  194. // #endif
  195. });
  196. },
  197. clearWord() {
  198. this.$set(this.form, "commitment_seal", "");
  199. this.titleName = "";
  200. },
  201. clickIndex(inds) {
  202. console.log(inds, 789);
  203. if (inds === 0) {
  204. this.uploadImgs();
  205. }
  206. if (inds === 1) {
  207. this.uploadFieds();
  208. }
  209. },
  210. getChast() {
  211. this.showTableDown = true;
  212. },
  213. uploadImgs() {
  214. var self = this;
  215. uni.chooseImage({
  216. count: 1, //默认9
  217. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  218. success: function (res) {
  219. if (res.tempFiles[0].size > 2097152) {
  220. self.$method.showToast("上传图片不得大于2M");
  221. return;
  222. } else {
  223. // #ifdef MP-WEIXIN
  224. var type = res.tempFiles[0].path.split(".").splice(-1);
  225. // #endif
  226. // #ifdef H5
  227. var type = res.tempFiles[0].type.split("/").splice(-1);
  228. // #endif
  229. if (type[0] != "jpg" && type[0] != "png" && type[0] != "jpeg") {
  230. self.$method.showToast("请上传图片格式");
  231. return;
  232. }
  233. console.log(res.tempFiles[0].path, "res.tempFiles[0].path");
  234. self.$set(self.form, "commitment_seal", res.tempFiles[0].path);
  235. self.$nextTick(function () {
  236. this.resultForm();
  237. });
  238. }
  239. },
  240. });
  241. },
  242. uploadFieds() {
  243. var self = this;
  244. wx.chooseMessageFile({
  245. count: 1,
  246. size: 2097152,
  247. type: "file",
  248. success(res) {
  249. if (res.tempFiles[0].size > 2097152) {
  250. self.$method.showToast("上传文件不得大于2M");
  251. return;
  252. } else {
  253. var type = res.tempFiles[0].path.split(".").splice(-1);
  254. if (
  255. type[0] != "jpg" &&
  256. type[0] != "png" &&
  257. type[0] != "jpeg" &&
  258. type[0] != "docx" &&
  259. type[0] != "doc"
  260. ) {
  261. self.$method.showToast("请上传word文档或图片");
  262. return;
  263. }
  264. self.titleName = res.tempFiles[0].name;
  265. self.$set(self.form, "commitment_seal", res.tempFiles[0].path);
  266. self.$nextTick(function () {
  267. this.resultForm();
  268. });
  269. }
  270. },
  271. });
  272. },
  273. //提交表单
  274. async submitApi() {
  275. var data = JSON.parse(JSON.stringify(this.form));
  276. if (data["commitment_seal"]) {
  277. data.commitment_seal = await this.$method.uploadFile(
  278. data.commitment_seal,
  279. 0
  280. );
  281. }
  282. this.optionChanges(data);
  283. },
  284. optionChanges(data) {
  285. var self = this;
  286. var objs = {};
  287. for (let k in data) {
  288. objs[k] = {
  289. fieldKey: k,
  290. value: data[k],
  291. fieldName: (function () {
  292. for (let i = 0; i < self.listData.length; i++) {
  293. if (self.listData[i].fieldKey == k) {
  294. return self.listData[i].fieldName;
  295. }
  296. }
  297. })(),
  298. status: self.remarkStatus ? 1 : 0,
  299. };
  300. }
  301. var datas = {
  302. orderGoodsId: this.orderGoodsId,
  303. goodsId: self.goodsId,
  304. keyValue: JSON.stringify(objs),
  305. };
  306. if (self.remarkStatus) {
  307. datas.id = self.id;
  308. self.$api.editbaseprofileStamp(datas).then((res) => {
  309. this.isUploading = false;
  310. if (res.data.code === 200) {
  311. self.$method.showToast("提交成功");
  312. setTimeout(() => {
  313. console.log("延迟");
  314. uni.navigateBack();
  315. }, 1500);
  316. }
  317. });
  318. } else {
  319. self.$api.addbaseprofileStamp(datas).then((res) => {
  320. this.isUploading = false;
  321. if (res.data.code === 200) {
  322. self.$method.showToast("提交成功");
  323. setTimeout(() => {
  324. console.log("延迟");
  325. uni.navigateBack();
  326. }, 1500);
  327. }
  328. });
  329. }
  330. },
  331. //验证表单
  332. resultForm(int) {
  333. if (this.openVerify) {
  334. for (let i = 0; i < this.listData.length; i++) {
  335. if (
  336. this.listData[i].fieldKey === "commitment_seal" &&
  337. !this.listData[i].required
  338. ) {
  339. this.submitApi();
  340. return;
  341. }
  342. }
  343. this.$refs.uForm.validate((valid) => {
  344. if (valid) {
  345. if (int === 1) {
  346. this.submitApi();
  347. }
  348. } else {
  349. this.isUploading = false;
  350. console.log("验证失败");
  351. }
  352. });
  353. }
  354. },
  355. submits() {
  356. if (this.isUploading) {
  357. return;
  358. }
  359. this.isUploading = true;
  360. this.openVerify = true;
  361. this.resultForm(1);
  362. },
  363. async changePhotoListHeader1(lists, name) {
  364. if (lists.length) {
  365. this.fileList1 = lists;
  366. this.form.commitment_seal = await this.$method.imageInfos(lists[0].url);
  367. } else {
  368. this.fileList1 = [];
  369. this.$set(this.form, "commitment_seal", "");
  370. }
  371. this.$nextTick(function () {
  372. this.resultForm();
  373. });
  374. },
  375. getInfo() {
  376. var self = this;
  377. this.$api.getbaseprofiletpId(this.goodsId).then((res) => {
  378. var ast = JSON.parse(res.data.data.keyValue2);
  379. self.listData = ast;
  380. self.$api
  381. .getbaseprofileStampgetInfo({
  382. goodsId: self.goodsId,
  383. orderGoodsId: self.orderGoodsId,
  384. })
  385. .then((result) => {
  386. if (result.data.code === 200) {
  387. if (result.data.data && result.data.data.status === 3) {
  388. self.remark = result.data.data.text;
  389. self.remarkStatus = true;
  390. self.id = result.data.data.id;
  391. } else if (
  392. result.data.data &&
  393. (result.data.data.status === 1 || result.data.data.status === 2)
  394. ) {
  395. uni.showModal({
  396. showCancel: false,
  397. content:
  398. result.data.data.status === 1
  399. ? "该商品审核资料已通过,不可重复提交资料"
  400. : result.data.data.status === 2
  401. ? "该商品审核资料处于待审核状态,不可重复提交资料"
  402. : "请联系管理员",
  403. success: function (k) {
  404. if (k.confirm) {
  405. uni.navigateBack();
  406. }
  407. },
  408. });
  409. }
  410. }
  411. });
  412. });
  413. },
  414. },
  415. };
  416. </script>
  417. <style>
  418. page {
  419. background: #eaeef1;
  420. }
  421. </style>
  422. <style scopelang="scss">
  423. /deep/ .u-collapse-title {
  424. color: #ff3b30;
  425. font-size: 24rpx;
  426. }
  427. .collapse-item {
  428. color: #666;
  429. font-size: 24rpx;
  430. padding-bottom: 30rpx;
  431. }
  432. .quzw {
  433. width: 638rpx;
  434. height: 638rpx;
  435. position: relative;
  436. border: 2rpx solid #eee;
  437. border-radius: 8rpx;
  438. }
  439. .borsrs {
  440. width: 640rpx;
  441. height: 640rpx;
  442. display: flex;
  443. flex-direction: column;
  444. align-items: center;
  445. justify-content: center;
  446. }
  447. .optionsAbs {
  448. position: absolute;
  449. z-index: 99;
  450. top: 10rpx;
  451. right: 10rpx;
  452. }
  453. .dis_stys {
  454. /* display: flex;
  455. align-items: center;
  456. justify-content: space-between; */
  457. }
  458. .handCenter {
  459. background: #f7f7f7;
  460. border: 2rpx solid #eeeeee;
  461. border-radius: 24rpx;
  462. }
  463. .headerSDels {
  464. height: 58rpx;
  465. padding: 0rpx 24rpx;
  466. font-weight: bold;
  467. display: flex;
  468. align-items: center;
  469. flex-direction: row-reverse;
  470. }
  471. .listBox {
  472. margin: 24rpx 32rpx 0rpx;
  473. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  474. border-radius: 32rpx;
  475. background-color: #fff;
  476. overflow: hidden;
  477. }
  478. .imgBoxs {
  479. width: 156rpx;
  480. height: 203rpx;
  481. }
  482. .imgBoxs2 {
  483. width: 171rpx;
  484. height: 108rpx;
  485. }
  486. .submit_btn {
  487. width: 526rpx;
  488. height: 80rpx;
  489. background: #007aff;
  490. border-radius: 40rpx;
  491. text-align: center;
  492. line-height: 80rpx;
  493. color: #ffffff;
  494. margin: 30rpx auto;
  495. }
  496. .picker {
  497. text-align: right;
  498. }
  499. input {
  500. text-align: right;
  501. }
  502. .bodyBox {
  503. background: #ffffff;
  504. border-radius: 24rpx;
  505. width: 100%;
  506. }
  507. .topBox {
  508. height: 80rpx;
  509. background: #ffffff;
  510. border-radius: 24rpx;
  511. width: 100%;
  512. display: flex;
  513. justify-content: space-between;
  514. line-height: 80rpx;
  515. padding: 0 20rpx;
  516. font-size: 24rpx;
  517. }
  518. </style>