record.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. <template>
  2. <view class="content-box">
  3. <form @submit="formSubmit" style="width: 100%">
  4. <view class="info-box" style="flex-direction: row;">
  5. <view class="info-title-box">
  6. <!-- <image src="/static/require-icon.png" mode="aspectFill"></image> -->
  7. <text>上传图片</text>
  8. </view>
  9. <view class="info-value-box">
  10. <view class="update_button display-flex">
  11. <view class="upload-box" @click="getImage('album')">
  12. <view class="img">
  13. <image src="/static/upload-photo.png" class="photo"></image>
  14. </view>
  15. </view>
  16. <view
  17. class="display-flex upload-box-photo"
  18. v-for="(item, index) in uploadList"
  19. :key="index"
  20. >
  21. <image :src="item" mode="aspectFit" style="width: 100%; height: 100%" @click="showLarge(item)"/>
  22. <image src="/static/del.png" class="del-icon"mode="aspectFit"
  23. style="width: 30rpx; height: 30rpx" @click="delPhoto(index)"></image>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="info-box">
  29. <view class="info-title-box">
  30. <!-- <image src="/static/require-icon.png" mode="aspectFill"></image> -->
  31. <text>荣誉级别</text>
  32. </view>
  33. <view class="info-value-box">
  34. <picker @change="bindPickerChange($event,'level')" :range="honorLevel" class="select-box" name="education">
  35. <view class="uni-input">{{levelValue}}</view>
  36. <image src="/static/arrow_down.svg" mode="aspectFill"></image>
  37. </picker>
  38. </view>
  39. </view>
  40. <view class="info-box">
  41. <view class="info-title-box">
  42. <!-- <image src="/static/require-icon.png" mode="aspectFill"></image> -->
  43. <text>荣誉来源</text>
  44. </view>
  45. <view class="info-value-box">
  46. <picker @change="bindPickerChange($event,'education')" :range="honorFrom" class="select-box" name="education">
  47. <view class="uni-input">{{fromValue}}</view>
  48. <image src="/static/arrow_down.svg" mode="aspectFill"></image>
  49. </picker>
  50. </view>
  51. </view>
  52. <view class="info-box">
  53. <view class="info-title-box">
  54. <!-- <image src="/static/require-icon.png" mode="aspectFill"></image> -->
  55. <text>所属支部</text>
  56. </view>
  57. <view class="info-value-box">
  58. <picker @change="bindPickerChange($event,'education')" :range="honorBranch" class="select-box" name="education">
  59. <view class="uni-input">{{branchValue}}</view>
  60. <image src="/static/arrow_down.svg" mode="aspectFill"></image>
  61. </picker>
  62. </view>
  63. </view>
  64. <view class="info-box">
  65. <view class="info-title-box">
  66. <!-- <image src="/static/require-icon.png" mode="aspectFill"></image> -->
  67. <text>荣誉类型</text>
  68. </view>
  69. <view class="info-value-box">
  70. <picker @change="bindPickerChange($event,'education')" :range="honorType" class="select-box" name="education">
  71. <view class="uni-input">{{typeValue}}</view>
  72. <image src="/static/arrow_down.svg" mode="aspectFill"></image>
  73. </picker>
  74. </view>
  75. <view class="info-value-box">
  76. <picker @change="bindPickerChange($event,'education')" :range="honorType2" class="select-box" name="education">
  77. <view class="uni-input">{{typeValue2}}</view>
  78. <image src="/static/arrow_down.svg" mode="aspectFill"></image>
  79. </picker>
  80. </view>
  81. </view>
  82. <view class="info-box">
  83. <view class="info-title-box">
  84. <!-- <image src="/static/require-icon.png" mode="aspectFill"></image> -->
  85. <text>选择成员</text>
  86. </view>
  87. <view class="info-value-box display-flex-start select-member">
  88. <input type="text" placeholder="请输入手机号" name="selfName">
  89. <button type="primary" class="submit-bth" style="background-color: #169bd5;" @click="addMember()">添加</button>
  90. </view>
  91. <view>
  92. <checkbox-group @change="checkboxChange" class="display-wrap">
  93. <label class="display-flex-start" v-for="(item,index) in memberList" :key="item.value" style="margin-right:10rpx;transform:scale(.8);">
  94. <view>
  95. <checkbox :value="item.value" :checked="item.checked"/>
  96. </view>
  97. <view>{{item.name}}</view>
  98. <image src="/static/del.png" mode="aspectFit"
  99. style="width: 30rpx; height: 30rpx;margin-left: 10rpx;" @click="delMember(index)"></image>
  100. </label>
  101. </checkbox-group>
  102. </view>
  103. </view>
  104. <view style="display: flex;justify-content: space-evenly;">
  105. <button type="default" class="submit-bth" style="background-color: #aaaaaa;">清空</button>
  106. <button type="primary" class="submit-bth" style="background-color: #169bd5;" formType="submit">提交</button>
  107. </view>
  108. </form>
  109. </view>
  110. </template>
  111. <script>
  112. import md5 from "@/common/md5.js";
  113. // import pickerAddress from '@/components/liudx-pickerAddress/index.vue'
  114. // var graceChecker = require("../../../common/graceChecker.js");
  115. export default {
  116. components: {
  117. },
  118. data() {
  119. return {
  120. dateYear:new Date().getFullYear(),
  121. dateMonth:new Date().getMonth() + 1,
  122. arrayMonth:["1", "2","3", "4","5", "6","7", "8","9", "10","11", "12"],
  123. title: 'Hello',
  124. detailObj:{},
  125. storeImg:'',
  126. isAuthPhone:getApp().globalData.user_phone,
  127. userSex:'1',
  128. txt: '请选择',
  129. levelValue:'请选择',
  130. honorLevel:['中央','省级','市级','区级','单位'],
  131. fromValue:'请选择',
  132. honorFrom:['党内荣誉','社会荣誉','单位荣誉','行业荣誉'],
  133. branchValue:'请选择',
  134. honorBranch:['浐灞一支部','浐灞二支部'],
  135. typeValue:'请选择',
  136. typeValue2:'请选择',
  137. honorType:['集体荣誉','个人荣誉','集体个人兼有'],
  138. honorType2:['多人','单人'],
  139. professionArray:[],
  140. memberList: [
  141. {
  142. value: 'USA',
  143. name: '路小璐'
  144. },
  145. {
  146. value: 'CHN',
  147. name: '张三',
  148. checked: 'true'
  149. },
  150. {
  151. value: 'BRA',
  152. name: '李四'
  153. },
  154. {
  155. value: 'JPN',
  156. name: '王五'
  157. },
  158. ],
  159. uploadList: [],
  160. imgIdList: [],
  161. }
  162. },
  163. onLoad() {
  164. //this.getTradeRequest();
  165. },
  166. onShow() {
  167. },
  168. // onShareAppMessage() {
  169. // return {
  170. // title: '分销小助手',
  171. // path:'/pages/index/index?scene=' + getApp().globalData.user_id
  172. // }
  173. // },
  174. methods: {
  175. bindDateChange(e){
  176. this.dateYear = e.target.value
  177. },
  178. bindDateMonthChange(e){
  179. this.dateMonth = this.arrayMonth[e.target.value]
  180. },
  181. change(e) {
  182. this.single = e;
  183. console.log("-change事件:", e);
  184. },
  185. checkboxChange: function (e) {
  186. var items = this.items,
  187. values = e.detail.value;
  188. for (var i = 0, lenI = items.length; i < lenI; ++i) {
  189. const item = items[i]
  190. if(values.includes(item.value)){
  191. this.$set(item,'checked',true)
  192. }else{
  193. this.$set(item,'checked',false)
  194. }
  195. }
  196. },
  197. addMember(){
  198. let items = {value: '6',name: '13630230648'}
  199. this.memberList.push(items)
  200. },
  201. delMember(idx){
  202. this.memberList.splice(idx, 1);
  203. },
  204. getImage(type) {
  205. let that = this;
  206. // if (that.uploadList.length >= 9) {
  207. // uni.showToast({
  208. // title: "最多上传9张图片",
  209. // icon: "none",
  210. // duration: 2500,
  211. // });
  212. // return;
  213. // }
  214. uni.chooseImage({
  215. sourceType: [type],
  216. count: 1,
  217. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  218. success: (res) => {
  219. for (let i = 0; i < res.tempFilePaths.length; i++) {
  220. console.log(res.tempFilePaths[i])
  221. that.uploadList.push(res.tempFilePaths[i]);
  222. that.uploadFileRequest(res.tempFilePaths[i]);
  223. }
  224. },
  225. });
  226. },
  227. uploadFileRequest(fileVal) {
  228. uni.showLoading({
  229. title: "上传中",
  230. mask: true,
  231. });
  232. let that = this;
  233. let md5Sign = md5(
  234. "method=" +
  235. "upload" +
  236. "&timestamp=" +
  237. getApp().globalData.globalTimestamp +
  238. "&secret=" +
  239. getApp().globalData.secret
  240. );
  241. let url =
  242. getApp().globalData.shareUrl +
  243. "api/api.php" +
  244. "?method=upload&source=activity&id=1&timestamp=" +
  245. getApp().globalData.globalTimestamp +
  246. "&sign=" +
  247. md5Sign;
  248. uni.uploadFile({
  249. url: url, //需要设置为全局
  250. filePath: fileVal,
  251. name: "file",
  252. formData: {
  253. file: fileVal,
  254. },
  255. success: (res) => {
  256. let tmpres = JSON.parse(res.data);
  257. console.log(tmpres);
  258. uni.hideLoading();
  259. that.imgIdList.push(tmpres.data.id);
  260. },
  261. fail: (res) => {
  262. console.log("上传请求失败");
  263. console.log(res);
  264. },
  265. });
  266. },
  267. delPhoto(idx) {
  268. this.uploadList.splice(idx, 1);
  269. this.imgIdList.splice(idx, 1);
  270. },
  271. showLarge(src) {
  272. uni.previewImage({
  273. urls: [src],
  274. longPressActions: {
  275. itemList: ["发送给朋友", "保存图片"],
  276. success: function (data) {},
  277. fail: function (err) {
  278. console.log(err.errMsg);
  279. },
  280. },
  281. });
  282. },
  283. getProvinceRequest(){
  284. let that = this;
  285. },
  286. getTradeRequest(){
  287. let that = this;
  288. },
  289. radioCheck(e){
  290. console.log(e.target.value)
  291. this.userSex = e.target.value;
  292. //this.gender = e.target.value == '0' ? '男' : '女';
  293. },
  294. changeCity(data) {
  295. this.txt = data.data.join('')
  296. console.log(data.data.join(''))
  297. },
  298. bindPickerChange(e,type) {
  299. let that = this;
  300. switch (type){
  301. case 'education':
  302. that.educationValue = that.educationArray[e.target.value]
  303. console.log(that.educationValue)
  304. break;
  305. case 'profession':
  306. that.professionValue = that.professionArray[e.target.value]
  307. break;
  308. case 'ends':
  309. that.endsValue = that.endsArray[e.target.value]
  310. break;
  311. }
  312. },
  313. testLength(){
  314. if(this.addressDetail.length > 25){
  315. uni.showToast({
  316. title: '详细地址应为0-25个字符',
  317. icon: 'none'
  318. });
  319. }
  320. },
  321. formSubmit(e) {
  322. //this.goCustomCardPage()
  323. //将下列代码加入到对应的检查位置
  324. //定义表单规则
  325. var rule = [
  326. {
  327. name: "selfName",
  328. checkType: "notnull",
  329. errorMsg: "姓名不能为空"
  330. },
  331. // {
  332. // name: "selfName",
  333. // checkType: "string",
  334. // checkRule: "2,15",
  335. // errorMsg: "姓名不能少于2个汉字"
  336. // },
  337. {
  338. name: "selfName",
  339. checkType: "reg",
  340. checkRule: "[\u4e00-\u9fa5]",
  341. errorMsg: "姓名需为中文"
  342. }
  343. // {
  344. // name: "trade",
  345. // checkType: "notnull",
  346. // errorMsg: "行业不能为空"
  347. // }
  348. ];
  349. //进行表单检查
  350. var formData = e.detail.value;
  351. console.log(formData)
  352. var checkRes = graceChecker.check(formData, rule);
  353. if (checkRes) {
  354. this.txt === '请选择' ?
  355. uni.showToast({
  356. title: '请选择地区',
  357. icon: "none"
  358. }):
  359. this.submitRequest(formData);
  360. } else {
  361. uni.showToast({
  362. title: graceChecker.error,
  363. icon: "none"
  364. });
  365. }
  366. },
  367. submitRequest(params){
  368. console.log(params)
  369. let that = this;
  370. },
  371. goCustomCardPage(){
  372. uni.redirectTo({
  373. url: '/pages/index/successPage/index?types='+'custom', //游客成功页面
  374. success: res => {},
  375. fail: () => {},
  376. complete: () => {}
  377. })
  378. }
  379. }
  380. }
  381. </script>
  382. <style lang="scss" scoped>
  383. .content {
  384. &_list{
  385. display: flex;
  386. flex-direction: row;
  387. align-items: center;
  388. justify-content:space-around;
  389. &_lable{
  390. }
  391. &_content{
  392. flex: 1;
  393. width: auto;
  394. text-align: right;
  395. }
  396. }
  397. }
  398. .content-box {
  399. width: 100%;
  400. /* height: 100%; */
  401. display: flex;
  402. flex-direction: column;
  403. align-items: center;
  404. /* justify-content: center; */
  405. }
  406. .header-box {
  407. width: 85%;
  408. height:80rpx;
  409. border: .5px dotted #00A1B4;
  410. border-radius: 50rpx;
  411. display: flex;
  412. justify-content: center;
  413. align-items: center;
  414. font-size: 24rpx;
  415. color:#00A1B4 ;
  416. /* font-family: PingFangSC-Regular; */
  417. margin-top: 2%;
  418. }
  419. .header-box image {
  420. width: 36rpx;
  421. height: 36rpx;
  422. margin-right: 1%;
  423. }
  424. .self-title-box {
  425. width: 90%;
  426. display: flex;
  427. align-items: center;
  428. font-size: 32rpx;
  429. letter-spacing: 2rpx;
  430. color:#3C3C3C ;
  431. /* font-family: SimHei; */
  432. margin: 4% auto;
  433. font-weight: bold;
  434. height: 50rpx;
  435. line-height: 50rpx;
  436. }
  437. .self-title-box image {
  438. width: 6rpx;
  439. height: 32rpx;
  440. margin-right: 2%;
  441. }
  442. .info-box {
  443. width: 90%;
  444. margin: 3% auto;
  445. display: flex;
  446. flex-direction: column;
  447. // align-items: center;
  448. // height: 180rpx;
  449. }
  450. .info-title-box {
  451. width: 20%;
  452. display: flex;
  453. align-items: center;
  454. font-size: 26rpx;
  455. }
  456. .info-title-box image{
  457. width: 15rpx;
  458. height: 15rpx;
  459. margin-right: 2%;
  460. }
  461. .info-value-box {
  462. width: 100%;
  463. }
  464. .info-value-box input {
  465. height: 88rpx;
  466. background: #f7f7f7;
  467. font-size: 26rpx;
  468. padding-left: 4%;
  469. margin: 2% auto;
  470. }
  471. .info-value-box picker {
  472. position: relative;
  473. }
  474. .info-value-box picker image {
  475. position: absolute;
  476. width: 25rpx;
  477. height: 25rpx;
  478. right: 10px;
  479. top: 30rpx;
  480. }
  481. .select-box {
  482. height: 80rpx;
  483. background: #f7f7f7;
  484. font-size: 26rpx;
  485. padding-left: 4%;
  486. margin: 2% auto;
  487. color: #888;
  488. line-height: 88rpx;
  489. }
  490. .info-gender-box {
  491. width: 75%;
  492. font-size: 28rpx;
  493. }
  494. .form-radio {
  495. transform: scale(0.6);
  496. }
  497. .padding-left-2 {
  498. // padding-left: 2%;
  499. }
  500. .margin-right-10 {
  501. margin-right: 10%;
  502. }
  503. .border-line-box {
  504. width: 100%;
  505. height: 20rpx;
  506. background: #f7f7f7;
  507. }
  508. .picker-box{
  509. display: flex;
  510. align-items: center;
  511. justify-content: space-between;
  512. height: 60rpx;
  513. line-height: 60rpx;
  514. background: #f7f7f7;
  515. height: 88rpx;
  516. line-height: 88rpx;
  517. background: #f7f7f7;
  518. font-size: 28rpx;
  519. padding-left: 4%;
  520. }
  521. .uni-input image {
  522. width: 40rpx;
  523. height: 40rpx;
  524. margin-right: 2%;
  525. float: right;
  526. }
  527. .textarea-box {
  528. background: #f7f7f7;
  529. min-height: 120rpx;
  530. font-size: 28rpx;
  531. margin: 5% auto;
  532. padding: 4%;
  533. margin-bottom: 8%;
  534. }
  535. .upload-box {
  536. display: flex;
  537. flex-flow: column;
  538. width: 25%;
  539. height: 100rpx;
  540. border-radius: 10rpx;
  541. padding-top: 15rpx;
  542. image {
  543. width: 100rpx;
  544. height:100rpx;
  545. }
  546. }
  547. .upload-box-photo {
  548. width: 25%;
  549. height: 100rpx;
  550. border-radius: 10rpx;
  551. padding-top: 15rpx;
  552. position: relative;
  553. margin-left: 10rpx;
  554. }
  555. .del-icon {
  556. position: absolute;
  557. right: 0;
  558. width: 30rpx;
  559. height: 30rpx;
  560. }
  561. .update_button {
  562. text-align: center;
  563. display: flex;
  564. flex-wrap: wrap;
  565. }
  566. .picker-class {
  567. border-radius: 10rpx;
  568. padding: 10rpx;
  569. width: 73%;
  570. font-size: 28rpx;
  571. background: #f5f5f5;
  572. }
  573. .picker-class image {
  574. width: 26rpx;
  575. height: 26rpx;
  576. }
  577. .submit-bth {
  578. width: 25%;
  579. font-size: 26rpx;
  580. margin: 0 0 5% 0;
  581. color: #fff;
  582. }
  583. .select-member {
  584. input {
  585. margin: 2% 2% 2% 0;
  586. height: 80rpx;
  587. line-height: 80rpx;
  588. }
  589. button {
  590. background-color: #169bd5;
  591. margin: 0;
  592. height: 60rpx;
  593. line-height: 60rpx;
  594. width: 20%;
  595. }
  596. }
  597. </style>