form.js 19 KB

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