input2.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <view style="padding: 30rpx;">
  3. <view class="topBox">
  4. <view>
  5. <u-icon name="error-circle-fill" color="#FF3B30" size="28"></u-icon>
  6. <text style="color: #FF3B30;margin-left: 10rpx;">学习前请提交完整审核资料</text>
  7. </view>
  8. <view style="color: #007AFF;">稍后再填</view>
  9. </view>
  10. <view class="bodyBox" style="margin-top: 30rpx;padding:0 20rpx;">
  11. <u-form :model="form" ref="uForm">
  12. <template v-for="(item, index) in listData">
  13. <u-form-item
  14. v-if="item.inputType == 4"
  15. :key="index"
  16. :label="item.fieldName"
  17. :required="item.required"
  18. :label-width="auto"
  19. :prop="item.required ? item.fieldKey : ''"
  20. label-position="top"
  21. >
  22. <text style="color: blue;position: absolute;top: 20rpx;left: 180rpx;text-decoration: underline;" @click="downDocx(item.url)">点击下载</text>
  23. <view class="dis_stys"><text style="color: #999999;">下载承诺书进行填写并签名盖章后上传(≤2M)</text></view>
  24. <view style="width: 169rpx; height: 169rpx;position: relative;">
  25. <image v-if="!form[item.fieldKey]" style="width: 100%; height: 100%;" @click="uploadFieds" src="@/static/info_4.png"></image>
  26. <image v-if="form[item.fieldKey]" src="@/static/icon/jy_icon.png" style="width: 100%; height: 100%;"></image>
  27. <u-icon v-if="form[item.fieldKey]" name="close-circle-fill" color="red" size="44" class="optionsAbs" @click="clearWord"></u-icon>
  28. </view>
  29. </u-form-item>
  30. </template>
  31. </u-form>
  32. </view>
  33. <!-- <view style="width: 169rpx; height: 169rpx;position: relative;">
  34. <image v-if="!form.commitment_seal" style="width: 100%; height: 100%;" @click="uploadFieds" src="@/static/info_4.png"></image>
  35. <image v-if="form.commitment_seal" src="@/static/icon/jy_icon.png" style="width: 100%; height: 100%;"></image>
  36. <u-icon v-if="form.commitment_seal" name="close-circle-fill" color="red" size="44" class="optionsAbs" @click="clearWord"></u-icon>
  37. </view> -->
  38. <view @click="submits" class="submit_btn">提交资料</view>
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. data() {
  44. return {
  45. form: {
  46. commitment_seal: ''
  47. },
  48. goodsId: null,
  49. fileList1: [],
  50. listData: {}, //页面数据
  51. openVerify: false, // 控制是否手动验证
  52. nextStatus: false, //是否有下一步
  53. copyData: null,
  54. rules: {
  55. commitment_seal: [
  56. {
  57. required: true,
  58. message: '请上传承诺书盖章',
  59. trigger: ['change', 'blur']
  60. }
  61. ]
  62. }
  63. };
  64. },
  65. created() {},
  66. onLoad(option) {
  67. this.goodsId = Number(option.id);
  68. this.getInfo();
  69. },
  70. onReady() {
  71. this.$refs.uForm.setRules(this.rules);
  72. },
  73. methods: {
  74. downDocx(url) {
  75. uni.downloadFile({
  76. url: this.$method.splitImgHost(url),
  77. success: res => {
  78. if (res.statusCode === 200) {
  79. console.log(this.$method.splitImgHost(url));
  80. this.$method.showToast('下载成功');
  81. }
  82. }
  83. });
  84. },
  85. clearWord() {
  86. this.$set(this.form, 'commitment_seal', '');
  87. },
  88. uploadFieds() {
  89. var self = this;
  90. wx.chooseMessageFile({
  91. count: 1,
  92. size: 2097152,
  93. type: 'file',
  94. success(res) {
  95. if (res.tempFiles[0].size > 2097152) {
  96. self.$method.showToast('上传文件不得大于2M');
  97. return;
  98. } else {
  99. self.$set(self.form, 'commitment_seal', res.tempFiles[0].path);
  100. self.$nextTick(function() {
  101. this.resultForm();
  102. });
  103. }
  104. }
  105. });
  106. },
  107. //提交表单
  108. async submitApi() {
  109. var data = JSON.parse(JSON.stringify(this.form));
  110. if (data['commitment_seal']) {
  111. console.log(123);
  112. data.commitment_seal = await this.$method.uploadFile(data.commitment_seal, 0);
  113. } else {
  114. console.log(456);
  115. }
  116. var concatData = {};
  117. Object.assign(concatData, this.copyData, data);
  118. console.log(concatData);
  119. },
  120. //验证表单
  121. resultForm(int) {
  122. if (this.openVerify) {
  123. for (let i = 0; i < this.listData.length; i++) {
  124. if (this.listData[i].fieldKey === 'commitment_seal' && !this.listData[i].required) {
  125. this.submitApi();
  126. return
  127. }
  128. }
  129. this.$refs.uForm.validate(valid => {
  130. if (valid) {
  131. if (int === 1) {
  132. this.submitApi();
  133. }
  134. } else {
  135. console.log('验证失败');
  136. }
  137. });
  138. }
  139. },
  140. submits() {
  141. this.openVerify = true;
  142. this.resultForm(1);
  143. },
  144. async changePhotoListHeader1(lists, name) {
  145. if (lists.length) {
  146. this.fileList1 = lists;
  147. this.form.commitment_seal = await this.$method.imageInfos(lists[0].url);
  148. } else {
  149. this.fileList1 = [];
  150. this.$set(this.form, 'commitment_seal', '');
  151. }
  152. this.$nextTick(function() {
  153. this.resultForm();
  154. });
  155. },
  156. getInfo() {
  157. // this.copyData = this.$store.getters.getCopyData
  158. this.copyData = {
  159. name: '唐立安',
  160. sex: '男'
  161. };
  162. this.$api.getbaseprofiletpId(this.goodsId).then(res => {
  163. var ast = JSON.parse(res.data.data.keyValue2);
  164. this.listData = ast;
  165. });
  166. }
  167. }
  168. };
  169. </script>
  170. <style>
  171. page {
  172. background: #eaeef1;
  173. }
  174. </style>
  175. <style scope>
  176. .optionsAbs {
  177. position: absolute;
  178. z-index: 99;
  179. top: 10rpx;
  180. right: 10rpx;
  181. }
  182. .dis_stys {
  183. display: flex;
  184. align-items: center;
  185. justify-content: space-between;
  186. }
  187. .handCenter {
  188. background: #f7f7f7;
  189. border: 2rpx solid #eeeeee;
  190. border-radius: 24rpx;
  191. }
  192. .headerSDels {
  193. height: 58rpx;
  194. padding: 0rpx 24rpx;
  195. font-weight: bold;
  196. display: flex;
  197. align-items: center;
  198. flex-direction: row-reverse;
  199. }
  200. .listBox {
  201. margin: 24rpx 32rpx 0rpx;
  202. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  203. border-radius: 32rpx;
  204. background-color: #fff;
  205. overflow: hidden;
  206. }
  207. .imgBoxs {
  208. width: 156rpx;
  209. height: 203rpx;
  210. }
  211. .imgBoxs2 {
  212. width: 171rpx;
  213. height: 108rpx;
  214. }
  215. .submit_btn {
  216. width: 526rpx;
  217. height: 80rpx;
  218. background: #007aff;
  219. border-radius: 40rpx;
  220. text-align: center;
  221. line-height: 80rpx;
  222. color: #ffffff;
  223. margin: 30rpx auto;
  224. }
  225. .picker {
  226. text-align: right;
  227. }
  228. input {
  229. text-align: right;
  230. }
  231. .bodyBox {
  232. background: #ffffff;
  233. border-radius: 24rpx;
  234. width: 100%;
  235. }
  236. .topBox {
  237. height: 80rpx;
  238. background: #ffffff;
  239. border-radius: 24rpx;
  240. width: 100%;
  241. display: flex;
  242. justify-content: space-between;
  243. line-height: 80rpx;
  244. padding: 0 20rpx;
  245. font-size: 24rpx;
  246. }
  247. </style>