fieldForm.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <view class="content">
  3. <view class="supplyInfo">
  4. <view class="flex">
  5. <label>公司名称:</label>
  6. <input type="text" v-model="supplyInfo.title" class="input card" />
  7. </view>
  8. <view class="flex">
  9. <label>活动人数:</label>
  10. <input type="number" v-model="supplyInfo.title" class="input card" />
  11. </view>
  12. <view class="update_photo">
  13. <view class="title"></view>
  14. <view style="margin-bottom: 20rpx;">上传资料:</view>
  15. <view class="update_container card upload-parent-box">
  16. <view class="update_button display-flex">
  17. <view class="upload-box" @click="getImage('album')">
  18. <view class="img">
  19. <image src="/static/appeal/photo.png" class="photo"></image>
  20. </view>
  21. <view class="txt">上传</view>
  22. </view>
  23. <view
  24. class="display-flex upload-box-photo"
  25. v-for="(item, index) in uploadList"
  26. :key="index"
  27. >
  28. <image
  29. :src="item"
  30. mode="aspectFit"
  31. style="width: 100%; height: 100%"
  32. @click="showLarge(item)"
  33. />
  34. <image
  35. src="../../static/del.png"
  36. class="del-icon"
  37. mode="aspectFit"
  38. style="width: 30rpx; height: 30rpx"
  39. @click="delPhoto(index)"
  40. ></image>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="approve-box">
  45. <view class="approve-title">请下载格式审批单,填写信息并加盖企业公章后上传</view>
  46. <view class="approve-content">格式审批单下载:<text>临空产业园党群服务中心线上预约审批单</text></view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="info">
  51. <view class="title">联系信息</view>
  52. <view class="name flex">
  53. <label>联系人:</label>
  54. <input type="text" class="card input" v-model="company.name" />
  55. </view>
  56. <view class="tel flex">
  57. <label>联系电话:</label>
  58. <input type="text" class="card input" v-model="company.tel" />
  59. </view>
  60. </view>
  61. <button class="submit" @tap="submit">提交</button>
  62. </view>
  63. </template>
  64. <script>
  65. import md5 from "@/common/md5.js";
  66. export default {
  67. data() {
  68. return {
  69. array: [{ name: "供需" }, { name: "需求" }],
  70. index: 0,
  71. supplyInfo: {
  72. title: "",
  73. msg: "",
  74. },
  75. company: {
  76. name: uni.getStorageSync("supply_name") || "",
  77. code: uni.getStorageSync("supply_code") || "",
  78. tel: uni.getStorageSync("supply_tel") || "",
  79. },
  80. uploadList: [],
  81. imgIdList: [],
  82. };
  83. },
  84. methods: {
  85. submit() {
  86. uni.showToast({
  87. title: "提交成功",
  88. icon: "none",
  89. });
  90. },
  91. bindPickerChange(e) {
  92. this.index = e.detail.value;
  93. },
  94. getImage(type) {
  95. let that = this;
  96. if (that.uploadList.length >= 3) {
  97. uni.showToast({
  98. title: "最多上传3张图片",
  99. icon: "none",
  100. duration: 2500,
  101. });
  102. return;
  103. }
  104. uni.chooseImage({
  105. sourceType: [type],
  106. count: 3 - that.uploadList.length,
  107. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  108. success: (res) => {
  109. for (let i = 0; i < res.tempFilePaths.length; i++) {
  110. that.uploadList.push(res.tempFilePaths[i]);
  111. that.uploadFileRequest(res.tempFilePaths[i]);
  112. }
  113. },
  114. });
  115. },
  116. uploadFileRequest(fileVal) {
  117. uni.showLoading({
  118. title: "上传中",
  119. mask: true,
  120. });
  121. let that = this;
  122. let md5Sign = md5(
  123. "method=" +
  124. "upload" +
  125. "&timestamp=" +
  126. getApp().globalData.globalTimestamp +
  127. "&secret=" +
  128. getApp().globalData.secret
  129. );
  130. let url =
  131. getApp().globalData.shareUrl +
  132. "api/api.php" +
  133. "?method=upload&source=consult&timestamp=" +
  134. getApp().globalData.globalTimestamp +
  135. "&sign=" +
  136. md5Sign;
  137. uni.uploadFile({
  138. url: url, //需要设置为全局
  139. filePath: fileVal,
  140. name: "file",
  141. formData: {
  142. file: fileVal,
  143. },
  144. success: (res) => {
  145. let tmpres = JSON.parse(res.data);
  146. console.log(tmpres);
  147. uni.hideLoading();
  148. that.imgIdList.push(tmpres.data.id);
  149. },
  150. fail: (res) => {
  151. console.log("上传请求失败");
  152. console.log(res);
  153. },
  154. });
  155. },
  156. delPhoto(idx) {
  157. this.uploadList.splice(idx, 1);
  158. this.imgIdList.splice(idx, 1);
  159. },
  160. showLarge(src) {
  161. uni.previewImage({
  162. urls: [src],
  163. longPressActions: {
  164. itemList: ["发送给朋友", "保存图片"],
  165. success: function (data) {},
  166. fail: function (err) {
  167. console.log(err.errMsg);
  168. },
  169. },
  170. });
  171. },
  172. },
  173. };
  174. </script>
  175. <style lang="scss" scoped>
  176. .upload-parent-box {
  177. height: 150rpx;
  178. padding-top: 25rpx;
  179. padding-left: 20rpx;
  180. }
  181. .upload-box {
  182. display: flex;
  183. flex-flow: column;
  184. width: 25%;
  185. background-color: #e0e0e0;
  186. height: 140rpx;
  187. border-radius: 10rpx;
  188. padding-top: 15rpx;
  189. color: #000;
  190. image {
  191. width: 60rpx !important;
  192. height: 60rpx !important;
  193. }
  194. }
  195. .upload-box-photo {
  196. width: 25%;
  197. height: 110rpx;
  198. border-radius: 10rpx;
  199. padding-top: 15rpx;
  200. position: relative;
  201. }
  202. .del-icon {
  203. position: absolute;
  204. right: 0;
  205. width: 30rpx;
  206. height: 30rpx;
  207. }
  208. .update_button {
  209. text-align: center;
  210. display: flex;
  211. }
  212. .content {
  213. font-size: 28rpx;
  214. font-weight: 200;
  215. padding: 1% 2%;
  216. .title {
  217. font-size: 30rpx;
  218. margin: 4% 0;
  219. color: #000;
  220. }
  221. label {
  222. display: inline-block;
  223. width: 25%;
  224. vertical-align: middle;
  225. color: #7f7f7f;
  226. }
  227. .card {
  228. background-color: rgb(248, 247, 247);
  229. border-radius: 10rpx;
  230. }
  231. .flex {
  232. display: flex;
  233. align-items: center;
  234. margin-bottom: 2%;
  235. }
  236. .input {
  237. padding: 0 2%;
  238. margin: 2% 0;
  239. display: inline-block;
  240. width: 80%;
  241. height: 70rpx;
  242. }
  243. .supplyInfo {
  244. border-radius: 40rpx;
  245. padding: 4%;
  246. box-shadow: rgba(100, 100, 111, 0.2) 14rpx 14rpx 40rpx 14rpx;
  247. margin: 30rpx 0 30rpx 0;
  248. color: #7f7f7f;
  249. .area {
  250. height: 200rpx;
  251. padding: 20rpx;
  252. box-sizing: border-box;
  253. }
  254. .picker {
  255. width: 80%;
  256. height: 70rpx;
  257. background: rgb(248, 247, 247);
  258. display: flex;
  259. align-items: center;
  260. position: relative;
  261. .pick {
  262. width: 100%;
  263. }
  264. .picker_title {
  265. display: flex;
  266. width: 100%;
  267. margin-left: 30rpx;
  268. align-items: center;
  269. justify-content: space-between;
  270. .triangle-down {
  271. width: 0;
  272. height: 0;
  273. border-top: 15rpx solid rgb(173, 173, 173);
  274. border-left: 15rpx solid transparent;
  275. border-right: 15rpx solid transparent;
  276. position: absolute;
  277. right: 10rpx;
  278. }
  279. }
  280. }
  281. .upload-box {
  282. width: 25%;
  283. background-color: #e0e0e0;
  284. height: 110rpx;
  285. border-radius: 10rpx;
  286. padding-top: 15rpx;
  287. }
  288. .upload-box-photo {
  289. width: 25%;
  290. height: 110rpx;
  291. border-radius: 10rpx;
  292. padding-top: 15rpx;
  293. position: relative;
  294. }
  295. .del-icon {
  296. position: absolute;
  297. right: 0;
  298. width: 30rpx;
  299. height: 30rpx;
  300. }
  301. image {
  302. width: 60rpx;
  303. height: 60rpx;
  304. }
  305. .update_button {
  306. text-align: center;
  307. display: flex;
  308. }
  309. }
  310. .approve-box {
  311. width: 100%;
  312. font-size: 24rpx;
  313. margin-top: 25rpx;
  314. padding-left: 20rpx;
  315. .approve-content {
  316. display: flex;
  317. margin: 20rpx 0 30rpx 0;
  318. text{
  319. color:#00a7f0;
  320. cursor: pointer;
  321. }
  322. }
  323. }
  324. .info {
  325. margin-top: 2%;
  326. border-radius: 40rpx;
  327. padding: 2% 4%;
  328. box-shadow: rgba(100, 100, 111, 0.2) 14rpx 14rpx 40rpx 14rpx;
  329. color: #7f7f7f;
  330. }
  331. .submit {
  332. color: white;
  333. font-weight: normal;
  334. width: 70%;
  335. border-radius: 20rpx;
  336. background-color: #02a7f0;
  337. margin: 50rpx auto;
  338. }
  339. }
  340. </style>