form.js 19 KB

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