workercard.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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. </style>
  64. </head>
  65. <body>
  66. <div id="app" v-cloak>
  67. <!--<div id="header">
  68. <h1>水猫工匠-用户名片</h1>
  69. </div>-->
  70. <Card :bordered="false" id="form">
  71. <p slot="title">水猫工匠-用户名片信息</p>
  72. <i-form :model="formdata" :label-width="80">
  73. <Form-item label="手机号">
  74. <i-input v-model="formdata.telno" placeholder="请输入手机号"></i-input>
  75. </Form-item>
  76. <div id="editform">
  77. <Form-item label="姓名">
  78. <i-input v-model="formdata.name" placeholder="请输入姓名"></i-input>
  79. </Form-item>
  80. <Form-item label="工种">
  81. <i-input v-model="formdata.work_type" placeholder="请输入工种"></i-input>
  82. </Form-item>
  83. <Form-item label="工种标签" >
  84. <i-select v-model="formdata.key_word" style="width:200px" multiple>
  85. <i-option v-for="(item,key) in worktypeonelabel" :value="item.label" :key="item.id">{{ item.label }}</i-option>
  86. </i-select>
  87. </Form-item>
  88. <Form-item label="年龄">
  89. <Input-number :max="100" :min="17" v-model="formdata.age"></Input-number>
  90. </Form-item>
  91. <Form-item label="籍贯">
  92. <i-input v-model="formdata.native" placeholder="请输入籍贯"></i-input>
  93. </Form-item>
  94. <Form-item label="工作地区">
  95. <i-input v-model="formdata.region" placeholder="请输入工作地区"></i-input>
  96. </Form-item>
  97. <Form-item label="交通工具">
  98. <i-input v-model="formdata.traffic_tools" placeholder="请输入交通工具"></i-input>
  99. </Form-item>
  100. <Form-item label="备注">
  101. <i-input type="textarea" v-model="formdata.note" placeholder="请输入备注"></i-input>
  102. </Form-item>
  103. <Form-item label="图片上传">
  104. <div id="images">
  105. <div v-if="imglist">
  106. <div class="img_list">
  107. <div class="demo-upload-list" v-for="(item,index) in imglist" :key="index">
  108. <img :src="item">
  109. <div class="demo-upload-list-cover">
  110. <Icon type="ios-eye-outline" @click.native="handleView(index)"></Icon>
  111. <!--<Icon type="ios-trash-outline" @click.native="handleRemove(item)"></Icon>-->
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. <div class="img_list">
  117. <div class="demo-upload-list" v-for="(url,index) in uploadList" :key="index">
  118. <img :src="url">
  119. <div class="demo-upload-list-cover">
  120. <Icon type="ios-eye-outline" @click.native="handleView2(index)"></Icon>
  121. <Icon type="ios-trash-outline" @click.native="handleRemove2(index)"></Icon>
  122. </div>
  123. <i-button type="primary" long>提交</i-button>
  124. </div>
  125. </div>
  126. <Upload
  127. ref="upload"
  128. :show-upload-list="false"
  129. :on-success="handleSuccess"
  130. :format="['jpg','jpeg','png']"
  131. :max-size="2048"
  132. :on-format-error="handleFormatError"
  133. :on-exceeded-size="handleMaxSize"
  134. :before-upload="handleBeforeUpload"
  135. name="file"
  136. type="drag"
  137. action="https://app.tjzhxx.cn:5443/api/Cos/savephoto"
  138. style="display: inline-block;width:58px;">
  139. <div style="width: 58px;height:58px;line-height: 58px;">
  140. <Icon type="md-camera" size="20"></Icon>
  141. </div>
  142. </Upload>
  143. <Modal title="查看图片" v-model="visible">
  144. <img :src="viewimgurl" v-if="visible" style="width: 100%">
  145. </Modal>
  146. </div>
  147. </Form-item>
  148. <Form-item>
  149. <i-button type="primary" long>提交</i-button>
  150. </Form-item>
  151. </div>
  152. </i-form>
  153. </Card>
  154. </div>
  155. <script>
  156. var sharedata = {php}echo json_encode($sharedata);{/php};
  157. </script>
  158. <script src="/static/plugs/vue/vue.js"></script>
  159. <script src="/static/plugs/iview/iview.min.js"></script>
  160. <script src="/static/plugs/jquery/jquery.js"></script>
  161. <script src="/static/plugs/vuetify/vuetify.js"></script>
  162. <script src="/static/plugs/wechat/jweixin-1.0.0.js"></script>
  163. <!--<script src="/static/plugs/jssha/sha.js"></script>-->
  164. <script src="/static/plugs/js-sha1/sha1.js"></script>
  165. <!--<script src="/static/plugs/wechat/wx_share_config.js"></script>-->
  166. <script>
  167. var url =window.location.href;
  168. var string = "jsapi_ticket=" +sharedata.ticket + "&noncestr=" + sharedata.nonceStr+ "&timestamp=" +sharedata. timestamp + "&url=" + url;
  169. sign = sha1(string)
  170. wx.config({
  171. debug:false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  172. appId:sharedata.appid, // 必填,企业号的唯一标识,此处填写企业号corpid
  173. timestamp:sharedata.timestamp , // 必填,生成签名的时间戳
  174. nonceStr:sharedata.nonceStr, // 必填,生成签名的随机串
  175. signature: sign,// 必填,签名,见附录1
  176. jsApiList:['updateAppMessageShareData','onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo','onMenuShareQZone'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
  177. });
  178. wx.error(function(res){
  179. // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
  180. //alert(11)
  181. //alert(JSON.stringify(res));
  182. });
  183. var share_info = {
  184. title:"水猫工匠-用户名片",
  185. desc:"水猫工匠-用户名片",
  186. link:window.location.href,
  187. imgUrl:''
  188. };
  189. //alert(JSON.stringify(share_info));
  190. </script>
  191. <script src="/static/plugs/wechat/wx_share.js"></script>
  192. <script>
  193. var app = new Vue({
  194. el: '#app',
  195. vuetify: new Vuetify(),
  196. data: {
  197. formdata:{
  198. name:"",
  199. age:17,
  200. telno:'',
  201. work_type:'',
  202. region:'',
  203. note:'',
  204. native:'',
  205. traffic_tools:'',
  206. key_word:[],
  207. user_id:0
  208. },
  209. imglist:false,
  210. uploadList:[],
  211. viewimgurl:'',
  212. visible:false,
  213. url_host:"http://newwatercatserver.com/index.php/index",
  214. worktypeonelabel:[],
  215. },
  216. watch: {
  217. 'formdata.telno' (newValue, old) {
  218. //获取用户信息
  219. this.getinfobytelno(newValue)
  220. }
  221. },
  222. computed: {
  223. isloading: function () {
  224. }
  225. },
  226. methods:{
  227. handleView (index) {
  228. this.viewimgurl = this.imglist[index];
  229. this.visible = true;
  230. },
  231. handleRemove (file) {
  232. // 从 upload 实例删除数据
  233. const fileList = this.$refs.upload.fileList;
  234. this.$refs.upload.fileList.splice(fileList.indexOf(file), 1);
  235. },
  236. handleView2 (key) {
  237. this.viewimgurl = this.uploadList[key];
  238. this.visible = true;
  239. },
  240. handleRemove2 (index) {
  241. // 从 upload 实例删除数据
  242. //const fileList = this.$refs.upload.fileList;
  243. //console.log(fileList);
  244. //this.$refs.upload.fileList.splice(fileList.indexOf(file), 1);
  245. //this.uploadList = this.$refs.upload.fileList;
  246. //console.log(this.uploadList);
  247. this.uploadList.splice(index, 1);
  248. },
  249. handleSuccess (res, file) {
  250. console.log(res,file)
  251. if(1!=res.status){
  252. this.$Message.error(res.msg);
  253. return
  254. }
  255. var data = res.data
  256. var path = data.path
  257. // 因为上传过程为实例,这里模拟添加 url
  258. this.uploadList.push(path);
  259. //file.url = 'https://o5wwk8baw.qnssl.com/7eb99afb9d5f317c912f08b5212fd69a/avatar';
  260. //file.name = '7eb99afb9d5f317c912f08b5212fd69a';
  261. },
  262. handleFormatError (file) {
  263. this.$Notice.warning({
  264. title: '文件格式不正确',
  265. desc: '文件 ' + file.name + ' 格式不正确,请上传 jpg 或 png 格式的图片。'
  266. });
  267. },
  268. handleMaxSize (file) {
  269. this.$Notice.warning({
  270. title: '超出文件大小限制',
  271. desc: '文件 ' + file.name + ' 太大,不能超过 2M。'
  272. });
  273. },
  274. handleBeforeUpload () {
  275. const check = this.uploadList.length < 5;
  276. if (!check) {
  277. this.$Notice.warning({
  278. title: '最多只能上传 5 张图片。'
  279. });
  280. }
  281. return check;
  282. },
  283. getinfobytelno(telno){
  284. //根据手机号获取信息
  285. var that = this;
  286. var url= this.url_host+"/workercardv1/getdatabytelnoforweb";
  287. var data ={telno:telno};
  288. $.ajax({
  289. type: 'POST',
  290. url: url,
  291. data:data,
  292. dataType: "json",
  293. success: function(res){
  294. //res = JSON.parse(res);
  295. if(200!=res.code){
  296. if(res.code<0){
  297. }else{
  298. that.$Notice.error({
  299. title: res.msg
  300. });
  301. }
  302. }else{
  303. that.formdata=res.data
  304. var userid = that.formdata.user_id
  305. //查询素材图片
  306. if(userid>0){
  307. that.getimglist(userid)
  308. }
  309. }
  310. }
  311. });
  312. },
  313. getimglist(userid){
  314. //获取用户素材图片列表
  315. var that = this;
  316. var url= this.url_host+"/workercardv1/getwcimgdatalistbyuserid";
  317. var data ={userid:userid};
  318. $.ajax({
  319. type: 'POST',
  320. url: url,
  321. data:data,
  322. dataType: "json",
  323. success: function(res){
  324. if(200!=res.code){
  325. if(res.code<0){
  326. }else{
  327. that.$Notice.error({
  328. title: res.msg
  329. });
  330. }
  331. }else{
  332. var resultData = res.resultData
  333. that.imglist = resultData.urls;
  334. }
  335. }
  336. });
  337. },
  338. saveinfo(){
  339. //保存用户信息
  340. var url= this.url_host+"/workercardv1/getdatabytelnoforweb";
  341. },
  342. editimg(){
  343. //编辑素材图片
  344. var url= this.url_host+"/workercardv1/editwcdataphotoimgforweb";
  345. },
  346. getworktypelabel(){
  347. //获取一级标签
  348. var that = this;
  349. var url= this.url_host+"/Worktype/getonelabellist";
  350. $.ajax({
  351. type: 'POST',
  352. url: url,
  353. dataType: "json",
  354. success: function(res){
  355. if(200!=res.code){
  356. that.$Notice.warning({
  357. title: res.msg
  358. });
  359. }else{
  360. that.worktypeonelabel=res.resultData
  361. let list = res.resultData
  362. for(let i in list){
  363. let item = list[i];
  364. if(item.is_default){
  365. that.formdata.key_word.push(item.label);
  366. }
  367. }
  368. }
  369. }
  370. });
  371. }
  372. },
  373. mounted() {
  374. this.getworktypelabel();
  375. }
  376. })
  377. </script>
  378. </body>
  379. </html>