input2.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. data.commitment_seal = await this.$method.uploadFile(data.commitment_seal, 0);
  112. }
  113. var concatData = {}
  114. Object.assign(concatData,this.copyData,data)
  115. console.log(concatData);
  116. },
  117. //验证表单
  118. resultForm(int) {
  119. if (this.openVerify) {
  120. this.$refs.uForm.validate(valid => {
  121. if (valid) {
  122. if (int === 1) {
  123. this.submitApi();
  124. }
  125. } else {
  126. console.log('验证失败');
  127. }
  128. });
  129. }
  130. },
  131. submits() {
  132. this.openVerify = true;
  133. this.resultForm(1);
  134. },
  135. async changePhotoListHeader1(lists, name) {
  136. if (lists.length) {
  137. this.fileList1 = lists;
  138. this.form.commitment_seal = await this.$method.imageInfos(lists[0].url);
  139. } else {
  140. this.fileList1 = [];
  141. this.$set(this.form, 'commitment_seal', '');
  142. }
  143. this.$nextTick(function() {
  144. this.resultForm();
  145. });
  146. },
  147. getInfo() {
  148. // this.copyData = this.$store.getters.getCopyData
  149. this.copyData = {
  150. name: '唐立安',
  151. sex: '男'
  152. };
  153. this.$api.getbaseprofiletpId(this.goodsId).then(res => {
  154. var ast = JSON.parse(res.data.data.keyValue2);
  155. this.listData = ast;
  156. });
  157. }
  158. }
  159. };
  160. </script>
  161. <style>
  162. page {
  163. background: #eaeef1;
  164. }
  165. </style>
  166. <style scope>
  167. .optionsAbs {
  168. position: absolute;
  169. z-index: 99;
  170. top: 10rpx;
  171. right: 10rpx;
  172. }
  173. .dis_stys {
  174. display: flex;
  175. align-items: center;
  176. justify-content: space-between;
  177. }
  178. .handCenter {
  179. background: #f7f7f7;
  180. border: 2rpx solid #eeeeee;
  181. border-radius: 24rpx;
  182. }
  183. .headerSDels {
  184. height: 58rpx;
  185. padding: 0rpx 24rpx;
  186. font-weight: bold;
  187. display: flex;
  188. align-items: center;
  189. flex-direction: row-reverse;
  190. }
  191. .listBox {
  192. margin: 24rpx 32rpx 0rpx;
  193. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  194. border-radius: 32rpx;
  195. background-color: #fff;
  196. overflow: hidden;
  197. }
  198. .imgBoxs {
  199. width: 156rpx;
  200. height: 203rpx;
  201. }
  202. .imgBoxs2 {
  203. width: 171rpx;
  204. height: 108rpx;
  205. }
  206. .submit_btn {
  207. width: 526rpx;
  208. height: 80rpx;
  209. background: #007aff;
  210. border-radius: 40rpx;
  211. text-align: center;
  212. line-height: 80rpx;
  213. color: #ffffff;
  214. margin: 30rpx auto;
  215. }
  216. .picker {
  217. text-align: right;
  218. }
  219. input {
  220. text-align: right;
  221. }
  222. .bodyBox {
  223. background: #ffffff;
  224. border-radius: 24rpx;
  225. width: 100%;
  226. }
  227. .topBox {
  228. height: 80rpx;
  229. background: #ffffff;
  230. border-radius: 24rpx;
  231. width: 100%;
  232. display: flex;
  233. justify-content: space-between;
  234. line-height: 80rpx;
  235. padding: 0 20rpx;
  236. font-size: 24rpx;
  237. }
  238. </style>