workercard.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  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: 60px;
  30. height: 60px;
  31. text-align: center;
  32. line-height: 60px;
  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: 20px;
  60. cursor: pointer;
  61. margin: 0 2px;
  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="手机号">
  105. <i-input v-model="formdata.telno" placeholder="请输入手机号"></i-input>
  106. </Form-item>
  107. <div id="editform">
  108. <Form-item label="姓名">
  109. <i-input v-model="formdata.name" placeholder="请输入姓名"></i-input>
  110. </Form-item>
  111. <Form-item label="工种">
  112. <i-input v-model="formdata.work_type" placeholder="请输入工种"></i-input>
  113. </Form-item>
  114. <Form-item label="工种标签" >
  115. <i-select v-model="formdata.key_word" style="width:200px" multiple>
  116. <i-option v-for="(item,key) in worktypeonelabel" :value="item.label" :key="item.id">{{ item.label }}</i-option>
  117. </i-select>
  118. </Form-item>
  119. <Form-item label="年龄">
  120. <Input-number :max="100" :min="17" v-model="formdata.age"></Input-number>
  121. </Form-item>
  122. <Form-item label="籍贯">
  123. <i-input v-model="formdata.native" placeholder="请输入籍贯"></i-input>
  124. </Form-item>
  125. <Form-item label="工作地区">
  126. <i-input v-model="formdata.region" placeholder="请输入工作地区"></i-input>
  127. </Form-item>
  128. <Form-item label="交通工具">
  129. <i-input v-model="formdata.traffic_tools" placeholder="请输入交通工具"></i-input>
  130. </Form-item>
  131. <Form-item label="备注">
  132. <i-input type="textarea" v-model="formdata.note" placeholder="请输入备注"></i-input>
  133. </Form-item>
  134. <Form-item label="图片上传">
  135. <div id="images">
  136. <div class="img_list">
  137. <div class="demo-upload-list" v-for="(url,index) in uploadList" :key="index">
  138. <img :src="url">
  139. <div class="demo-upload-list-cover">
  140. <Icon type="ios-eye-outline" @click.native="handleView2(index)" class="red"></Icon>
  141. <Icon type="ios-trash-outline" @click.native="handleRemove2(index)" class="red"></Icon>
  142. </div>
  143. <i-button type="primary" long>提交</i-button>
  144. </div>
  145. </div>
  146. <!--:max-size="204800"-->
  147. <!--:on-exceeded-size="handleMaxSize" //action="https://app.tjzhxx.cn:5443/api/Cos/savephoto" http://app.tjzhxx.local.cn/api/Cos/savephoto-->
  148. <Upload
  149. ref="upload"
  150. :show-upload-list="false"
  151. :on-success="handleSuccess"
  152. :format="['jpg','jpeg','png']"
  153. :on-format-error="handleFormatError"
  154. :before-upload="handleBeforeUpload"
  155. :on-exceeded-size="handleMaxSize"
  156. :max-size="20480"
  157. name="file"
  158. type="drag"
  159. action="https://app.tjzhxx.cn:5443/api/Cos/savephoto"
  160. style="display: inline-block;width:58px;">
  161. <div style="width: 58px;height:58px;line-height: 58px;">
  162. <Icon type="md-camera" size="20" class="red"></Icon>
  163. </div>
  164. </Upload>
  165. <Modal title="查看图片" v-model="visible">
  166. <img :src="viewimgurl" v-if="visible" style="width: 100%">
  167. </Modal>
  168. </div>
  169. </Form-item>
  170. <Form-item>
  171. <i-button type="primary" long @click="saveinfo" :loading="issavingloading">提交</i-button>
  172. </Form-item>
  173. <Form-item label="用户照片">
  174. <div v-if="imglist">
  175. <div class="img_list">
  176. <div class="demo-upload-list" v-for="(item,index) in imglist" :key="index">
  177. <img :src="item">
  178. <div class="demo-upload-list-cover">
  179. <Icon type="ios-eye-outline" @click.native="handleView(index)" class="red"></Icon>
  180. <!--<Icon type="ios-trash-outline" @click.native="handleRemove(item)"></Icon>-->
  181. </div>
  182. </div>
  183. </div>
  184. </div>
  185. </Form-item>
  186. </div>
  187. </i-form>
  188. </Card>
  189. </div>
  190. <script>
  191. var sharedata = {php}echo json_encode($sharedata);{/php};
  192. </script>
  193. <script src="/static/plugs/vue/vue.js"></script>
  194. <script src="/static/plugs/iview/iview.min.js"></script>
  195. <script src="/static/plugs/jquery/jquery.js"></script>
  196. <script src="/static/plugs/vuetify/vuetify.js"></script>
  197. <script src="/static/plugs/wechat/jweixin-1.0.0.js"></script>
  198. <!--<script src="/static/plugs/jssha/sha.js"></script>-->
  199. <script src="/static/plugs/js-sha1/sha1.js"></script>
  200. <!--<script src="/static/plugs/wechat/wx_share_config.js"></script>-->
  201. <script>
  202. var url =window.location.href;
  203. var string = "jsapi_ticket=" +sharedata.ticket + "&noncestr=" + sharedata.nonceStr+ "&timestamp=" +sharedata. timestamp + "&url=" + url;
  204. sign = sha1(string)
  205. wx.config({
  206. debug:false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  207. appId:sharedata.appid, // 必填,企业号的唯一标识,此处填写企业号corpid
  208. timestamp:sharedata.timestamp , // 必填,生成签名的时间戳
  209. nonceStr:sharedata.nonceStr, // 必填,生成签名的随机串
  210. signature: sign,// 必填,签名,见附录1
  211. jsApiList:['updateAppMessageShareData','onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo','onMenuShareQZone'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
  212. });
  213. wx.error(function(res){
  214. // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
  215. //alert(11)
  216. //alert(JSON.stringify(res));
  217. });
  218. var share_info = {
  219. title:"水猫工匠-用户名片",
  220. desc:"水猫工匠-用户名片",
  221. link:window.location.href,
  222. imgUrl:''
  223. };
  224. //alert(JSON.stringify(share_info));
  225. </script>
  226. <script src="/static/plugs/wechat/wx_share.js"></script>
  227. <script>
  228. var app = new Vue({
  229. el: '#app',
  230. vuetify: new Vuetify(),
  231. data: {
  232. issavingloading:false,
  233. formdata:{
  234. name:"",
  235. age:17,
  236. telno:'',
  237. work_type:'',
  238. region:'',
  239. note:'',
  240. native:'',
  241. traffic_tools:'',
  242. key_word:[],
  243. user_id:0
  244. },
  245. imglist:false,
  246. uploadList:[],
  247. viewimgurl:'',
  248. visible:false,
  249. url_host:"http://newwatercatserver.com/index.php/index",
  250. worktypeonelabel:[],
  251. userid:0
  252. },
  253. watch: {
  254. 'formdata.telno' (newValue, old) {
  255. //获取用户信息
  256. this.getinfobytelno(newValue)
  257. }
  258. },
  259. computed: {
  260. isloading: function () {
  261. }
  262. },
  263. methods:{
  264. handleView (index) {
  265. this.viewimgurl = this.imglist[index];
  266. this.visible = true;
  267. },
  268. handleRemove (file) {
  269. // 从 upload 实例删除数据
  270. const fileList = this.$refs.upload.fileList;
  271. this.$refs.upload.fileList.splice(fileList.indexOf(file), 1);
  272. },
  273. handleView2 (key) {
  274. this.viewimgurl = this.uploadList[key];
  275. this.visible = true;
  276. },
  277. handleRemove2 (index) {
  278. // 从 upload 实例删除数据
  279. //const fileList = this.$refs.upload.fileList;
  280. //console.log(fileList);
  281. //this.$refs.upload.fileList.splice(fileList.indexOf(file), 1);
  282. //this.uploadList = this.$refs.upload.fileList;
  283. //console.log(this.uploadList);
  284. this.uploadList.splice(index, 1);
  285. },
  286. handleSuccess (res, file) {
  287. console.log(res,file)
  288. if(1!=res.status){
  289. this.$Message.error(res.msg);
  290. return
  291. }
  292. var data = res.data
  293. var path = data.path
  294. // 因为上传过程为实例,这里模拟添加 url
  295. this.uploadList.push(path);
  296. //file.url = 'https://o5wwk8baw.qnssl.com/7eb99afb9d5f317c912f08b5212fd69a/avatar';
  297. //file.name = '7eb99afb9d5f317c912f08b5212fd69a';
  298. },
  299. handleFormatError (file) {
  300. this.$Notice.error({
  301. title: '文件格式不正确',
  302. desc: '文件 ' + file.name + ' 格式不正确,请上传 jpg 或 png 格式的图片。'
  303. });
  304. },
  305. handleMaxSize (file) {
  306. this.$Notice.warning({
  307. title: '超出文件大小限制',
  308. desc: '文件 ' + file.name + ' 太大,不能超过 20M。'
  309. });
  310. },
  311. handleBeforeUpload () {
  312. const check = this.uploadList.length < 5;
  313. if (!check) {
  314. this.$Notice.warning({
  315. title: '最多只能上传 5 张图片。'
  316. });
  317. }
  318. return check;
  319. },
  320. getinfobytelno(telno){
  321. //根据手机号获取信息
  322. var that = this;
  323. var url= this.url_host+"/workercardv1/getdatabytelnoforweb";
  324. var data ={telno:telno};
  325. $.ajax({
  326. type: 'POST',
  327. url: url,
  328. data:data,
  329. dataType: "json",
  330. success: function(res){
  331. //res = JSON.parse(res);
  332. if(200!=res.code){
  333. if(res.code<0){
  334. }else{
  335. that.$Notice.error({
  336. title: res.msg
  337. });
  338. }
  339. }else{
  340. that.formdata=res.data
  341. that.userid = that.formdata.user_id;
  342. //查询素材图片
  343. that.getimglist();
  344. }
  345. }
  346. });
  347. },
  348. getimglist(){
  349. userid = this.userid;
  350. if(!userid||userid==''){
  351. return false;
  352. }
  353. //获取用户素材图片列表
  354. var that = this;
  355. var url= this.url_host+"/workercardv1/getwcimgdatalistbyuserid";
  356. var data ={userid:userid};
  357. $.ajax({
  358. type: 'POST',
  359. url: url,
  360. data:data,
  361. dataType: "json",
  362. success: function(res){
  363. if(200!=res.code){
  364. if(res.code<0){
  365. }else{
  366. that.$Notice.error({
  367. title: res.msg
  368. });
  369. }
  370. }else{
  371. var resultData = res.resultData
  372. that.imglist = resultData.urls;
  373. }
  374. },
  375. error:function(XMLHttpRequest, textStatus, errorThrown){
  376. that.$Notice.error({
  377. title: textStatus
  378. });
  379. that.issavingloading = false;
  380. }
  381. });
  382. },
  383. saveinfo(){
  384. this.issavingloading = true;
  385. //保存用户信息
  386. var that = this;
  387. var url= this.url_host+"/workercardv1/savewcidinfoforweb";
  388. var data =this.formdata;
  389. $.ajax({
  390. type: 'POST',
  391. url: url,
  392. data:data,
  393. dataType: "json",
  394. success: function(res){
  395. console.log(res);
  396. if(200!=res.code){
  397. if(res.code<0){
  398. }else{
  399. that.$Notice.error({
  400. title: res.msg
  401. });
  402. }
  403. }else{
  404. that.$Notice.success({
  405. title: "用户信息保存成功"
  406. });
  407. var data = res.data
  408. that.userid = data['uid'];
  409. that.editimg();
  410. }
  411. that.issavingloading = false;
  412. },
  413. error:function(XMLHttpRequest, textStatus, errorThrown){
  414. that.$Notice.error({
  415. title: textStatus
  416. });
  417. that.issavingloading = false;
  418. }
  419. });
  420. },
  421. editimg(){
  422. //编辑素材图片
  423. var that = this;
  424. var url= this.url_host+"/workercardv1/editwcdataphotoimgforweb";
  425. if(this.uploadList.length>0){
  426. var data={userid:this.userid,url:this.uploadList}
  427. $.ajax({
  428. type: 'POST',
  429. url: url,
  430. data:data,
  431. dataType: "json",
  432. success: function(res){
  433. console.log(res);
  434. if(200!=res.code){
  435. if(res.code<0){
  436. }else{
  437. that.$Notice.error({
  438. title: res.msg
  439. });
  440. }
  441. }else{
  442. that.$Notice.success({
  443. title: "用户图片保存成功"
  444. });
  445. that.imglist=false
  446. that.uploadList=[]
  447. that.getimglist()
  448. }
  449. that.issavingloading = false;
  450. }
  451. });
  452. }
  453. },
  454. getworktypelabel(){
  455. //获取一级标签
  456. var that = this;
  457. var url= this.url_host+"/Worktype/getonelabellist";
  458. $.ajax({
  459. type: 'POST',
  460. url: url,
  461. dataType: "json",
  462. success: function(res){
  463. if(200!=res.code){
  464. that.$Notice.warning({
  465. title: res.msg
  466. });
  467. }else{
  468. that.worktypeonelabel=res.resultData
  469. let list = res.resultData
  470. for(let i in list){
  471. let item = list[i];
  472. if(item.is_default){
  473. that.formdata.key_word.push(item.label);
  474. }
  475. }
  476. }
  477. }
  478. });
  479. }
  480. },
  481. mounted() {
  482. this.getworktypelabel();
  483. }
  484. })
  485. </script>
  486. </body>
  487. </html>