workercard.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <link rel="icon" href="/static/image/logo.png">
  8. <!--<link href="https://cdn.jsdelivr.net/npm/@mdi/font@6.x/css/materialdesignicons.min.css" rel="stylesheet">-->
  9. <link href="/static/plugs/font-awesome-4.7.0/css/font-awesome.css" rel="stylesheet">
  10. <link href="/static/plugs/vuetify/vuetify.css" rel="stylesheet">
  11. <!-- 引入样式 -->
  12. <link rel="stylesheet" href="/static/plugs/iview/styles/iview.css">
  13. <title>水猫工匠-用户名片</title>
  14. <style>
  15. [v-cloak] {
  16. display: none !important;
  17. }
  18. body{
  19. color: #000;
  20. }
  21. #app{
  22. /**padding: 1em;*/
  23. }
  24. #images .img_list{
  25. margin-top: 10px;
  26. }
  27. .demo-upload-list{
  28. display: inline-block;
  29. width: 100%;
  30. height: 200px;
  31. text-align: center;
  32. line-height: 200px;
  33. border: 1px solid transparent;
  34. border-radius: 4px;
  35. overflow: hidden;
  36. background: #fff;
  37. position: relative;
  38. box-shadow: 0 1px 1px rgba(0,0,0,.2);
  39. margin-right: 4px;
  40. }
  41. .demo-upload-list img{
  42. width: 100%;
  43. height: 100%;
  44. }
  45. .demo-upload-list-cover{
  46. display: none;
  47. position: absolute;
  48. top: 0;
  49. bottom: 0;
  50. left: 0;
  51. right: 0;
  52. background: rgba(0,0,0,.6);
  53. }
  54. .demo-upload-list:hover .demo-upload-list-cover{
  55. display: block;
  56. }
  57. .demo-upload-list-cover i{
  58. color: #fff;
  59. font-size: 70px;
  60. cursor: pointer;
  61. margin: 0 20px;
  62. }
  63. #form .ivu-card-head{
  64. padding: 0px;
  65. width: 100%;
  66. height: 120px;
  67. }
  68. #form .ivu-card-head div{
  69. width: 100%;
  70. height: 100%;
  71. }
  72. #form .ivu-card-head div img{
  73. width: 100%;
  74. height: 100%;
  75. }
  76. .ivu-btn-primary:hover {
  77. color: #fff;
  78. background-color: #B3000F;
  79. border-color: #B3000F;
  80. }
  81. .ivu-btn-primary {
  82. color: #fff;
  83. background-color: #E60012;
  84. border-color: #E60012;
  85. }
  86. .red{
  87. color: #E60012;
  88. }
  89. .ivu-upload-drag:hover {
  90. border: 1px dashed #E60012;
  91. }
  92. </style>
  93. </head>
  94. <body>
  95. <div id="app" v-cloak>
  96. <!--<div id="header">
  97. <h1>水猫工匠-用户名片</h1>
  98. </div>-->
  99. <Card :bordered="false" id="form">
  100. <div slot="title">
  101. <img src="/static/image/workercard/banner.png">
  102. </div>
  103. <i-form :model="formdata" :label-width="80">
  104. <Form-item label="手机号" v-if="!isedit">
  105. <i-input v-model="formdata.telno" placeholder="请输入手机号"></i-input>
  106. </Form-item>
  107. <Form-item label="手机号" v-else>
  108. {{formdata.telno}}
  109. </Form-item>
  110. <div id="editform">
  111. <Form-item label="姓名">
  112. <i-input v-model="formdata.name" placeholder="请输入姓名"></i-input>
  113. </Form-item>
  114. <Form-item label="工种">
  115. <i-input v-model="formdata.work_type" placeholder="请输入工种"></i-input>
  116. </Form-item>
  117. <Form-item label="工种标签" >
  118. <i-select v-model="formdata.key_word" style="width:200px" multiple>
  119. <i-option v-for="(item,key) in worktypeonelabel" :value="item.label" :key="item.id">{{ item.label }}</i-option>
  120. </i-select>
  121. </Form-item>
  122. <Form-item label="年龄">
  123. <Input-number :max="100" :min="17" v-model="formdata.age"></Input-number>
  124. </Form-item>
  125. <Form-item label="籍贯">
  126. <i-input v-model="formdata.native" placeholder="请输入籍贯"></i-input>
  127. </Form-item>
  128. <Form-item label="工作地区">
  129. <i-input v-model="formdata.region" placeholder="请输入工作地区"></i-input>
  130. </Form-item>
  131. <Form-item label="交通工具">
  132. <i-input v-model="formdata.traffic_tools" placeholder="请输入交通工具"></i-input>
  133. </Form-item>
  134. <Form-item label="备注">
  135. <i-input type="textarea" v-model="formdata.note" placeholder="请输入备注"></i-input>
  136. </Form-item>
  137. <Form-item label="图片上传" v-if="!issavingloading&&!issavingimg">
  138. <div id="images">
  139. <div class="img_list">
  140. <div class="demo-upload-list" v-for="(url,index) in uploadList" :key="index">
  141. <img :src="url">
  142. <div class="demo-upload-list-cover">
  143. <Icon type="ios-eye-outline" @click.native="handleView2(index)" class="red"></Icon>
  144. <Icon type="ios-trash-outline" @click.native="setdel2(index)" class="red"></Icon>
  145. </div>
  146. <i-button type="primary" long>提交</i-button>
  147. </div>
  148. </div>
  149. <!--:max-size="204800"-->
  150. <!--:on-exceeded-size="handleMaxSize" //action="https://app.tjzhxx.cn:5443/api/Cos/savephoto" http://app.tjzhxx.local.cn/api/Cos/savephoto-->
  151. <Upload
  152. multiple
  153. ref="upload"
  154. :show-upload-list="false"
  155. :on-success="handleSuccess"
  156. :format="['jpg','jpeg','png']"
  157. :on-format-error="handleFormatError"
  158. :before-upload="handleBeforeUpload"
  159. :on-exceeded-size="handleMaxSize"
  160. :max-size="2048"
  161. accept="image/*"
  162. name="file"
  163. type="drag"
  164. action="https://app.tjzhxx.cn:5443/api/Cos/savephoto"
  165. style="display: inline-block;width:100%;">
  166. <div style="width: 100%;height:58px;line-height: 58px;">
  167. <Icon type="md-camera" size="20" class="red"></Icon>
  168. </div>
  169. </Upload>
  170. <Modal title="查看图片" v-model="visible">
  171. <img :src="viewimgurl" v-if="visible" style="width: 100%">
  172. </Modal>
  173. </div>
  174. </Form-item>
  175. <Form-item>
  176. <i-button type="primary" long @click="saveinfo" :loading="issavingloading">提交</i-button>
  177. </Form-item>
  178. <Form-item label="用户照片" v-if="imglist&&imglist.length>0">
  179. <div class="img_list">
  180. <div class="demo-upload-list" v-for="(item,index) in imglist" :key="index">
  181. <img :src="item">
  182. <div class="demo-upload-list-cover">
  183. <Icon type="ios-eye-outline" @click.native="handleView(index)" class="red"></Icon>
  184. <Icon type="ios-trash-outline" @click.native="setdel1(item)"></Icon>
  185. </div>
  186. </div>
  187. </div>
  188. </Form-item>
  189. </div>
  190. </i-form>
  191. </Card>
  192. <Modal v-model="del1" width="360">
  193. <p style="color:#f60;text-align:center">
  194. <Icon type="information-circled"></Icon>
  195. <span>确认删除用户图片</span>
  196. </p>
  197. <div slot="footer">
  198. <Button type="error" size="large" long @click="delimg">删除</Button>
  199. </div>
  200. </Modal>
  201. <Modal v-model="del2" width="360">
  202. <p style="color:#f60;text-align:center">
  203. <Icon type="information-circled"></Icon>
  204. <span>确认删除上传图片</span>
  205. </p>
  206. <div slot="footer">
  207. <Button type="error" size="large" long @click="handleRemove2">删除</Button>
  208. </div>
  209. </Modal>
  210. </div>
  211. <script>
  212. var sharedata = {php}echo json_encode($sharedata);{/php};
  213. </script>
  214. <script src="/static/plugs/vue/vue.js"></script>
  215. <script src="/static/plugs/iview/iview.min.js"></script>
  216. <script src="/static/plugs/jquery/jquery.js"></script>
  217. <script src="/static/plugs/vuetify/vuetify.js"></script>
  218. <script src="/static/plugs/wechat/jweixin-1.0.0.js"></script>
  219. <!--<script src="/static/plugs/jssha/sha.js"></script>-->
  220. <script src="/static/plugs/js-sha1/sha1.js"></script>
  221. <!--<script src="/static/plugs/wechat/wx_share_config.js"></script>-->
  222. <script>
  223. var url =window.location.href;
  224. var string = "jsapi_ticket=" +sharedata.ticket + "&noncestr=" + sharedata.nonceStr+ "&timestamp=" +sharedata. timestamp + "&url=" + url;
  225. sign = sha1(string)
  226. wx.config({
  227. debug:false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  228. appId:sharedata.appid, // 必填,企业号的唯一标识,此处填写企业号corpid
  229. timestamp:sharedata.timestamp , // 必填,生成签名的时间戳
  230. nonceStr:sharedata.nonceStr, // 必填,生成签名的随机串
  231. signature: sign,// 必填,签名,见附录1
  232. jsApiList:['updateAppMessageShareData','onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo','onMenuShareQZone'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
  233. });
  234. wx.error(function(res){
  235. // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
  236. //alert(11)
  237. //alert(JSON.stringify(res));
  238. });
  239. var share_info = {
  240. title:"水猫工匠-用户名片",
  241. desc:"水猫工匠-用户名片",
  242. link:window.location.href,
  243. imgUrl:''
  244. };
  245. //alert(JSON.stringify(share_info));
  246. </script>
  247. <script src="/static/plugs/wechat/wx_share.js"></script>
  248. <script>
  249. var app = new Vue({
  250. el: '#app',
  251. vuetify: new Vuetify(),
  252. data: {
  253. issavingloading:false,
  254. issavingimg:false,
  255. formdata:{
  256. name:"",
  257. age:17,
  258. telno:'',
  259. work_type:'',
  260. region:'',
  261. note:'',
  262. native:'',
  263. traffic_tools:'',
  264. key_word:[],
  265. user_id:0
  266. },
  267. imglistobj:{},
  268. imglist:false,
  269. uploadList:[],
  270. viewimgurl:'',
  271. visible:false,
  272. //url_host:"http://newwatercatserver.com/index.php/index",
  273. //url_host:"https://app.tjzhxx.cn:11443/index.php/index",
  274. url_host:"https://app.tjzhxx.cn:10443/index.php/index",
  275. worktypeonelabel:[],
  276. userid:0,
  277. isedit:false,
  278. del1:false,
  279. del2:false,
  280. del_file:false,
  281. del_imgurl:false,
  282. },
  283. watch: {
  284. 'formdata.telno' (newValue, old) {
  285. //获取用户信息
  286. this.getinfobytelno(newValue)
  287. }
  288. },
  289. computed: {
  290. isloading: function () {
  291. }
  292. },
  293. methods:{
  294. handleView (index) {
  295. this.viewimgurl = this.imglist[index];
  296. this.visible = true;
  297. },
  298. setdel2(index){
  299. this.del2=true
  300. this.del_index = index;
  301. },
  302. setdel1(imgurl){
  303. //删除用户图片
  304. this.del1=true
  305. this.del_imgurl = imgurl;
  306. },
  307. handleRemove () {
  308. var file =this.del_file
  309. // 从 upload 实例删除数据
  310. const fileList = this.$refs.upload.fileList;
  311. this.$refs.upload.fileList.splice(fileList.indexOf(file), 1);
  312. this.del_file=false
  313. },
  314. handleView2 (key) {
  315. this.viewimgurl = this.uploadList[key];
  316. this.visible = true;
  317. },
  318. handleRemove2 () {
  319. var index = this.del_index
  320. // 从 upload 实例删除数据
  321. //const fileList = this.$refs.upload.fileList;
  322. //console.log(fileList);
  323. //this.$refs.upload.fileList.splice(fileList.indexOf(file), 1);
  324. //this.uploadList = this.$refs.upload.fileList;
  325. //console.log(this.uploadList);
  326. this.uploadList.splice(index, 1);
  327. this.del_index=false
  328. this.del2=false
  329. },
  330. handleSuccess (res, file) {
  331. this.$Message.destroy()
  332. this.issavingimg=false;
  333. if(1!=res.status){
  334. this.$Message.error(res.msg);
  335. return
  336. }
  337. var data = res.data
  338. var path = data.path
  339. // 因为上传过程为实例,这里模拟添加 url
  340. this.uploadList.push(path);
  341. //file.url = 'https://o5wwk8baw.qnssl.com/7eb99afb9d5f317c912f08b5212fd69a/avatar';
  342. //file.name = '7eb99afb9d5f317c912f08b5212fd69a';
  343. },
  344. handleFormatError (file) {
  345. this.$Notice.error({
  346. title: '文件格式不正确',
  347. desc: '文件 ' + file.name + ' 格式不正确,请上传 jpg 或 png 格式的图片。'
  348. });
  349. },
  350. handleMaxSize (file) {
  351. this.$Notice.warning({
  352. title: '超出文件大小限制',
  353. desc: '文件 ' + file.name + ' 太大,不能超过 2M。'
  354. });
  355. },
  356. handleBeforeUpload () {
  357. const check = this.uploadList.length < 5;
  358. if (!check) {
  359. this.$Notice.warning({
  360. title: '最多只能上传 5 张图片。'
  361. });
  362. }
  363. this.$Message.loading('图片上传中', 0);
  364. this.issavingimg=true;
  365. return check;
  366. },
  367. getinfobytelno(telno){
  368. //根据手机号获取信息
  369. var that = this;
  370. var url= this.url_host+"/workercardv1/getdatabytelnoforweb";
  371. var data ={telno:telno};
  372. $.ajax({
  373. type: 'POST',
  374. url: url,
  375. data:data,
  376. dataType: "json",
  377. success: function(res){
  378. //res = JSON.parse(res);
  379. //console.log(res);
  380. if(200!=res.code){
  381. if(res.code<0){
  382. that.isedit =false;
  383. }else{
  384. that.$Notice.error({
  385. title: res.msg
  386. });
  387. }
  388. }else{
  389. that.isedit =true
  390. that.formdata=res.data
  391. that.userid = that.formdata.user_id;
  392. //查询素材图片
  393. that.getimglist();
  394. }
  395. }
  396. });
  397. },
  398. getimglist(){
  399. userid = this.userid;
  400. if(!userid||userid==''){
  401. return false;
  402. }
  403. //获取用户素材图片列表
  404. var that = this;
  405. var url= this.url_host+"/workercardv1/getwcimgdatalistbyuserid";
  406. var data ={userid:userid};
  407. $.ajax({
  408. type: 'POST',
  409. url: url,
  410. data:data,
  411. dataType: "json",
  412. success: function(res){
  413. if(200!=res.code){
  414. /*if(res.code<0){
  415. }else{
  416. that.$Notice.error({
  417. title: res.msg
  418. });
  419. }*/
  420. }else{
  421. var resultData = res.resultData
  422. that.imglistobj = resultData
  423. that.imglist = resultData.urls;
  424. }
  425. },
  426. error:function(XMLHttpRequest, textStatus, errorThrown){
  427. that.$Notice.error({
  428. title: textStatus
  429. });
  430. that.issavingloading = false;
  431. }
  432. });
  433. },
  434. saveinfo(){
  435. this.issavingloading = true;
  436. //保存用户信息
  437. var that = this;
  438. var url= this.url_host+"/workercardv1/savewcidinfoforweb";
  439. var data =this.formdata;
  440. $.ajax({
  441. type: 'POST',
  442. url: url,
  443. data:data,
  444. dataType: "json",
  445. success: function(res){
  446. //console.log(res);
  447. if(200!=res.code){
  448. if(res.code<0){
  449. }else{
  450. that.$Notice.error({
  451. title: res.msg
  452. });
  453. }
  454. }else{
  455. that.isedit=true
  456. that.$Notice.success({
  457. title: "用户信息保存成功"
  458. });
  459. var data = res.data
  460. that.userid = data['uid'];
  461. that.editimg();
  462. }
  463. that.issavingloading = false;
  464. },
  465. error:function(XMLHttpRequest, textStatus, errorThrown){
  466. that.$Notice.error({
  467. title: textStatus
  468. });
  469. that.issavingloading = false;
  470. }
  471. });
  472. },
  473. editimg(){
  474. //编辑素材图片
  475. var that = this;
  476. var url= this.url_host+"/workercardv1/editwcdataphotoimgforweb";
  477. if(this.uploadList.length>0){
  478. var data={userid:this.userid,url:this.uploadList}
  479. $.ajax({
  480. type: 'POST',
  481. url: url,
  482. data:data,
  483. dataType: "json",
  484. success: function(res){
  485. //console.log(res);
  486. if(200!=res.code){
  487. if(res.code<0){
  488. }else{
  489. that.$Notice.error({
  490. title: res.msg
  491. });
  492. }
  493. }else{
  494. that.$Notice.success({
  495. title: "用户图片保存成功"
  496. });
  497. that.imglist=false
  498. that.uploadList=[]
  499. that.getimglist()
  500. }
  501. that.issavingloading = false;
  502. }
  503. });
  504. }
  505. },
  506. getworktypelabel(){
  507. //获取一级标签
  508. var that = this;
  509. var url= this.url_host+"/Worktype/getonelabellist";
  510. $.ajax({
  511. type: 'POST',
  512. url: url,
  513. dataType: "json",
  514. success: function(res){
  515. if(200!=res.code){
  516. that.$Notice.warning({
  517. title: res.msg
  518. });
  519. }else{
  520. that.worktypeonelabel=res.resultData
  521. let list = res.resultData
  522. for(let i in list){
  523. let item = list[i];
  524. if(item.is_default){
  525. that.formdata.key_word.push(item.label);
  526. }
  527. }
  528. }
  529. }
  530. });
  531. },
  532. getUrlParam(name) {
  533. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
  534. var r = window.location.search.substr(1).match(reg); //匹配目标参数
  535. if (r != null) return unescape(r[2]); return null; //返回参数值
  536. },
  537. delimg(){
  538. var imgurl = this.del_imgurl
  539. var that = this;
  540. var url= this.url_host+"/workercardv1/deleteuserimg";
  541. var data ={
  542. 'url':imgurl,
  543. 'userid':this.userid
  544. }
  545. $.ajax({
  546. type: 'POST',
  547. url: url,
  548. data:data,
  549. dataType: "json",
  550. success: function(res){
  551. if(200!=res.code){
  552. that.$Notice.warning({
  553. title: res.msg
  554. });
  555. }else{
  556. this.del_imgurl =false
  557. that.$Notice.success({
  558. title: res.msg
  559. });
  560. that.getimglist();
  561. that.del1=false
  562. }
  563. }
  564. });
  565. }
  566. },
  567. mounted() {
  568. var web_user_id=this.getUrlParam('reid');
  569. this.formdata.referrer_uid = web_user_id;
  570. this.getworktypelabel();
  571. }
  572. })
  573. </script>
  574. </body>
  575. </html>