form.js 20 KB

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