form.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. var isPC = ($(window).width()>768);
  2. var fleaMarketForm = new Vue({
  3. el:'#fleaMarketForm',
  4. data:{
  5. fenlei:[
  6. {name:'二手仪器',value:'1'},
  7. // {name:'临期产品',value:'2'},
  8. {name:'其他',value:'3'},
  9. ],
  10. currentId:0,
  11. radioList:[
  12. {name:'轻光电',value:'1',isChecked:false},
  13. {name:'重光电',value:'2',isChecked:false},
  14. {name:'耗材配件',value:'3',isChecked:false},
  15. ],
  16. beauty:[
  17. {name:'医美',value:'1'},
  18. {name:'非医美',value:'2'},
  19. ],
  20. BrandList:[],
  21. isShow:false,
  22. includedTax:'',
  23. GoodsImagesList:['https://dss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2306696130,3636777462&fm=26&gp=0.jpg'],
  24. oldNum:0,
  25. secondType:0,
  26. vShow_GoodsImages:false,
  27. fromMessage:'',//提示文字
  28. formData:new FormData(),
  29. secondParams:{
  30. secondHandType:'',//一级分类
  31. instrumentType:'',//二手仪器分类
  32. name:'',
  33. brandId:'',//品牌ID
  34. brandName:'',//其他品牌
  35. fixedYears:null,//出厂
  36. companyName:'',//公司名称
  37. // maturityYears:'',//产品到期
  38. price:'',//交易价
  39. detailTalkFlag:1,//是否启用详聊
  40. // normalPrice:'',//市场价
  41. // originalPrice:'',//采购价
  42. // stock:'',//数量
  43. productQuality:'',//商品成色
  44. contactName:'',//联系人
  45. contactMobile:'',//联系方式
  46. secondProductType:'',//
  47. townId:'',//县区地址
  48. address:'',//详细地址
  49. image:'https://dss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2306696130,3636777462&fm=26&gp=0.jpg',//图片
  50. productDetails:'',//商品详细信息
  51. source:1,
  52. dockingPeopleMobile:'',
  53. dockingPeopleName:'',
  54. authenticationImage:'https://dss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2306696130,3636777462&fm=26&gp=0.jpg',//身份证照片
  55. commitmentImage:'https://dss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2306696130,3636777462&fm=26&gp=0.jpg',//承诺函图片
  56. fileName:'',//文件名称
  57. ossName:'',//文件OSS名称
  58. },
  59. brandname:'请选择',
  60. checkbox:false,
  61. shoplogoTwo:false,
  62. provinceIndex:'',
  63. provinceArray:[],
  64. cityArray: [],//市
  65. townArray: [],//区
  66. from: {
  67. name:'',
  68. province: '',//省id
  69. city: '',
  70. town: ''
  71. },
  72. TypeList:'',
  73. playid:'',
  74. checkVal:[],
  75. resultBj:false,
  76. vShow_detailTalkFlag:false,
  77. vShow_secondHandType:false,
  78. vShow_instrumentType:false,
  79. vShow_BrandID:false,
  80. vShow_Name:false,
  81. vShow_Price:false,
  82. vShow_shopColor:false,
  83. vShow_contactName:false,
  84. vShow_contactMobile:false,
  85. vShow_caimeiMobile:false,
  86. vShow_Address:false,
  87. vShow_TownId:false,
  88. vShow_Market:false,
  89. vShow_original:false,
  90. vShow_Number:false,
  91. vShow_expire:false,
  92. vShow_detailInfoEditor:true,
  93. vShow_GoodsImages:false,
  94. vShow_checkBox:false,
  95. selectBrand:false,
  96. PopupShow:false,
  97. tipsContentText:'发布二手商品,采美需要收取您每个商品100元的展示费,展示期为3个月支付完成后,商品会在1-2个工作日内进行审核,审核通过后,商品会立即上线',
  98. cancelButtonText:'取消发布',
  99. confirmButtonText:'去支付',
  100. isButtonsType:0,
  101. },
  102. methods:{
  103. showBrand:function(){
  104. var _this = this;
  105. _this.selectBrand = !_this.selectBrand;
  106. },
  107. secondHandRidio: function(item) {
  108. var _this = this;
  109. _this.currentId = item.value;
  110. _this.secondParams.secondHandType = item.value;
  111. if (item.value==1){
  112. _this.isShow = true;
  113. }else {
  114. _this.isShow = false;
  115. }
  116. },
  117. secondHandType:function(item){ //二手仪器
  118. item.isChecked = ! item.isChecked;
  119. var _this = this;
  120. if(item.isChecked){
  121. _this.checkVal.push(item.value);
  122. _this.secondParams.instrumentType = _this.checkVal.toString();
  123. } else {
  124. _this.checkVal.splice(_this.checkVal.indexOf(item.value), 1);
  125. _this.secondParams.instrumentType = _this.checkVal.toString();
  126. }
  127. },
  128. ChangeBrand:function(item){ //品牌列表
  129. var _this = this;
  130. _this.brandname = item.name;
  131. _this.secondParams.brandId = item.id;
  132. if(_this.secondParams.brandId==161){
  133. _this.shoplogoTwo = true;
  134. }else {
  135. _this.shoplogoTwo = false;
  136. }
  137. },
  138. Detailed:function(){
  139. var _this = this;
  140. if(event.target.checked==true){
  141. _this.secondParams.detailTalkFlag = 2 ;//启用价格详聊
  142. _this.vShow_detailTalkFlag = true;
  143. }else {
  144. _this.secondParams.detailTalkFlag = 1 ;//不启用价格详聊
  145. _this.vShow_detailTalkFlag = false;
  146. }
  147. },
  148. dragstart: function(value) { // 记录初始信息
  149. this.oldNum = value;
  150. },
  151. uploadGoodsImagesFn: function(event){//上传商品图片
  152. var _this = this;
  153. var inputDOM = _this.$refs.goodsImages;
  154. var file = inputDOM.files;
  155. _this.formData.append('file', file[0]);
  156. SecondApi.uploadimg(_this.formData,function(response){
  157. _this.GoodsImagesList.push(response.data);
  158. _this.secondParams.image =_this.GoodsImagesList.toString()+',';
  159. event.target.value = '';
  160. });
  161. },
  162. uploadAuthenticationImagesFn: function(event){//上传身份验证照片
  163. var _this = this;
  164. var inputDOM = _this.$refs.AuthenticationImage;
  165. var file = inputDOM.files;
  166. _this.formData.append('file', file[0]);
  167. SecondApi.uploadimg(_this.formData,function(response){
  168. _this.secondParams.authenticationImage = response.data;
  169. event.target.value = '';
  170. });
  171. },
  172. uploadCommitmentImagesFn: function(event){//上传承诺函图片
  173. var _this = this;
  174. var inputDOM = _this.$refs.CommitmentImage;
  175. var file = inputDOM.files;
  176. _this.formData.append('file', file[0]);
  177. SecondApi.uploadimg(_this.formData,function(response){
  178. _this.secondParams.commitmentImage = response.data;
  179. event.target.value = '';
  180. });
  181. },
  182. uploadCommitmentFileFn : function(event){//上传承诺函文件
  183. var _this = this;
  184. var inputDOM = _this.$refs.CommitmentImagefile;
  185. var file = inputDOM.files;
  186. var formData = new FormData();
  187. console.log(file[0])
  188. formData.append('file', file[0]);
  189. SecondApi.uploadFile(formData,function(response){
  190. _this.secondParams.ossName = response.data.ossName;
  191. _this.secondParams.fileName = response.data.fileName;
  192. event.target.value = '';
  193. });
  194. },
  195. removeGoodsImagesFn: function(index){//删除商品图片
  196. var _this = this;
  197. _this.GoodsImagesList.splice(index,1);
  198. _this.secondParams.image =_this.GoodsImagesList.toString()+',';
  199. },
  200. removeAuthenticationImagesFn:function(){//删除身份验证照片
  201. var _this = this;
  202. _this.secondParams.authenticationImage = '';
  203. },
  204. removeCommitmentImagesFn:function(){//删除授权函文件图片
  205. var _this = this;
  206. _this.secondParams.commitmentImage = '';
  207. },
  208. deleteCommitmentFile:function(){//删除承诺函文件
  209. var _this = this;
  210. SecondApi.deleteOssFile({ ossName : _this.secondParams.ossName },function (response) {
  211. if (response.code==0){
  212. _this.secondParams.fileName = '';
  213. _this.secondParams.ossName = '';
  214. }else{
  215. console.log('删除文件异常提示===>',response.msg)
  216. }
  217. })
  218. },
  219. getProductType:function(item){
  220. var _this = this;
  221. _this.secondType=item;
  222. _this.secondParams.secondProductType = item ;
  223. },
  224. submitBtn:function () {
  225. var _this = this;
  226. var re = /^1\d{10}$/;
  227. if(_this.secondParams.secondHandType == ''){
  228. _this.vShow_secondHandType = true;
  229. _this.fromMessage = '请选择分类';
  230. _this.scrollIntoView();
  231. setTimeout(function(){
  232. _this.vShow_secondHandType= false;
  233. },2000);
  234. return;
  235. }
  236. if(_this.secondParams.secondHandType == 1 ){
  237. if(_this.secondParams.instrumentType ==''){
  238. _this.vShow_instrumentType = true;
  239. _this.fromMessage = '请完善仪器分类';
  240. _this.scrollIntoView();
  241. setTimeout(function(){
  242. _this.vShow_instrumentType= false;
  243. },2000);
  244. return;
  245. }
  246. }
  247. if(_this.secondParams.brandID == ''){
  248. _this.vShow_BrandID = true;
  249. _this.fromMessage = '请选择商品品牌';
  250. _this.scrollIntoView();
  251. setTimeout(function(){
  252. _this.vShow_BrandID = false;
  253. },2000);
  254. return;
  255. }
  256. if(_this.secondParams.name == ''){
  257. _this.vShow_Name = true;
  258. _this.fromMessage = '请输入商品名称';
  259. _this.scrollIntoView();
  260. setTimeout(function(){
  261. _this.vShow_Name = false;
  262. },2000);
  263. return
  264. }
  265. if(_this.secondParams.price == ''){
  266. _this.vShow_Price = true;
  267. _this.fromMessage = '请输入交易价';
  268. _this.scrollIntoView();
  269. setTimeout(function(){
  270. _this.vShow_Price = false;
  271. },2000);
  272. return
  273. }
  274. if(_this.secondParams.productQuality == ''){
  275. _this.vShow_shopColor = true;
  276. _this.fromMessage = '请输入商品成色';
  277. _this.scrollIntoView();
  278. setTimeout(function(){
  279. _this.vShow_shopColor = false;
  280. },2000);
  281. return
  282. }
  283. if(_this.secondParams.contactName == ''){
  284. _this.vShow_contactName = true;
  285. _this.fromMessage = '请输入联系人姓名';
  286. _this.scrollIntoView();
  287. setTimeout(function(){
  288. _this.vShow_contactName = false;
  289. },2000);
  290. return
  291. }
  292. if(_this.secondParams.contactMobile == ''){
  293. _this.vShow_contactMobile = true;
  294. _this.fromMessage = '请输入联系方式';
  295. _this.scrollIntoView();
  296. setTimeout(function(){
  297. _this.vShow_contactMobile = false;
  298. },2000);
  299. return
  300. }
  301. if(!re.test(_this.secondParams.contactMobile)){
  302. _this.vShow_contactMobile = true;
  303. _this.fromMessage = '联系方式格式不正确';
  304. _this.scrollIntoView();
  305. setTimeout(function(){
  306. _this.vShow_contactMobile = false;
  307. },2000);
  308. return
  309. }
  310. if(_this.secondParams.dockingPeopleMobile!='' && !re.test(_this.secondParams.dockingPeopleMobile)){
  311. _this.vShow_caimeiMobile = true;
  312. _this.fromMessage = '联系方式格式不正确';
  313. _this.scrollIntoView();
  314. setTimeout(function(){
  315. _this.vShow_caimeiMobile = false;
  316. },2000);
  317. return
  318. }
  319. if(_this.secondParams.townId == ''|| _this.secondParams.townId == undefined){
  320. _this.vShow_TownId = true;
  321. _this.fromMessage = '请完善联系地址';
  322. _this.scrollIntoView();
  323. setTimeout(function(){
  324. _this.vShow_TownId = false;
  325. },2000);
  326. return
  327. }
  328. if(_this.secondParams.address == ''){
  329. _this.vShow_Address = true;
  330. _this.fromMessage = '请填写详细地址';
  331. document.getElementById('Address').scrollIntoView({block: 'start', behavior: 'smooth'});
  332. setTimeout(function(){
  333. _this.vShow_Address = false;
  334. },2000);
  335. return
  336. }
  337. if(_this.GoodsImagesList ==''){
  338. _this.vShow_GoodsImages = true;
  339. _this.fromMessage = '请上传图片';
  340. document.documentElement.scrollTop=900;
  341. setTimeout(function(){
  342. _this.vShow_GoodsImages = false;
  343. },2000);
  344. return;
  345. }
  346. if(_this.checkbox==false){
  347. _this.vShow_checkBox = true;
  348. _this.fromMessage='请勾选已阅读';
  349. setTimeout(function(){
  350. _this.vShow_checkBox = false;
  351. },2000);
  352. return
  353. }
  354. console.log(_this.secondParams);
  355. if(_this.secondParams.authenticationImage == ''){
  356. _this.PopupShow = true;
  357. _this.tipsContentText = '上传身份验证照片。您的二手商品将获得更好的推荐推荐和曝光,方便您快速卖出。';
  358. _this.cancelButtonText = '继续发布';
  359. _this.confirmButtonText = '去上传';
  360. _this.isButtonsType = 1;
  361. return;
  362. }
  363. if(_this.secondParams.commitmentImage == '' || _this.secondParams.ossName == ''){
  364. _this.PopupShow = true;
  365. _this.tipsContentText = '上传二手出让承诺函。您的二手商品将获得更好的推荐推荐和曝光,方便您快速卖出。';
  366. _this.cancelButtonText = '继续发布';
  367. _this.confirmButtonText = '去上传';
  368. _this.isButtonsType = 1;
  369. return;
  370. }
  371. _this.SecondHandProduct(_this.secondParams)
  372. },
  373. SecondHandProduct:function(params){//提交发布
  374. var _this = this;
  375. SecondApi.SecondHandProduct(params,function (res) {
  376. if (res.code==0){
  377. _this.PopupShow = true;
  378. _this.tipsContentText = '发布二手商品,采美需要收取您每个商品100元的展示费,展示期为3个月支付完成后,商品会在1-2个工作日内进行审核,审核通过后,商品会立即上线';
  379. _this.cancelButtonText = '取消发布';
  380. _this.confirmButtonText = '去支付';
  381. _this.isButtonsType = 2;
  382. _this.playid= res.data;
  383. }else{
  384. CAIMEI.Alert(res.msg, '确定', false);
  385. _this.secondBj = false;
  386. return
  387. }
  388. })
  389. },
  390. cancelButtonFn:function(){//弹窗操作按钮
  391. var _this = this;
  392. switch(_this.isButtonsType){
  393. case 1:
  394. _this.SecondHandProduct(_this.secondParams);
  395. break;
  396. case 2:
  397. _this.PopupShow = false;
  398. break;
  399. }
  400. },
  401. confirmButtonFn:function(){//弹窗操作按钮
  402. var _this = this;
  403. switch(_this.isButtonsType){
  404. case 1:
  405. _this.PopupShow = false;
  406. break;
  407. case 2:
  408. window.location.href = '/pay/caimei-paycash.html?pageType=1&&type=confirm&productID='+_this.playid;
  409. _this.PopupShow = false;
  410. break;
  411. }
  412. },
  413. closePopupShow:function(){//关闭操作弹窗
  414. var _this = this;
  415. _this.PopupShow = false;
  416. },
  417. scrollIntoView: function(){
  418. document.getElementById('secondHandrelease').scrollIntoView({block: 'start', behavior: 'smooth'});
  419. },
  420. province:function () {
  421. var _this = this;
  422. _this.from.province = event.target.value;
  423. if(_this.from.province==''){//省为请选择时市区初始化
  424. _this.cityArray=[];
  425. _this.townArray=[];
  426. _this.secondParams.townId=''
  427. }else {
  428. _this.getcity();
  429. }
  430. },
  431. getcity:function(event){//加载市
  432. var _this = this;
  433. PublicApi.GetCity({ provinceId: _this.from.province },function(response){
  434. if(response.code == 0 ){
  435. _this.cityArray = response.data;
  436. _this.from.city = event.target.value;
  437. if(_this.from.city==''){
  438. _this.townArray=[];
  439. }else {
  440. _this.getcTown();
  441. }
  442. }
  443. })
  444. },
  445. getcTown:function(event){
  446. var _this = this;
  447. PublicApi.GetTown({cityId:_this.from.city},function(response){
  448. if(response.code == 0 ){
  449. _this.townArray = response.data;
  450. _this.secondParams.townId = event.target.value;
  451. }else{
  452. CAIMEI.Alert(response.msg, '确定', false);
  453. }
  454. })
  455. },
  456. changeBox:function () {
  457. if(event.target.checked ==true){
  458. this.checkbox = true
  459. }else {
  460. this.checkbox = false
  461. }
  462. },
  463. },
  464. mounted:function () {
  465. var _this = this;
  466. SecondApi.brandList({},function (res) {//品牌列表
  467. if(res.code == 0){
  468. _this.BrandList = res.data;
  469. }
  470. })
  471. PublicApi.GetProvince({},function(response){ //省份
  472. if(response.code == 0){
  473. _this.provinceArray = response.data
  474. }else{
  475. CAIMEI.Alert(response.msg, '确定', false);
  476. }
  477. })
  478. },
  479. })