form.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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://img.caimei365.com/group1/M00/03/CB/Cmis2F_NkrqAfl7uAADETMOGKpQ791.png'],
  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://img.caimei365.com/group1/M00/03/CB/Cmis2F_NkrqAfl7uAADETMOGKpQ791.png',//图片
  50. productDetails:'',//商品详细信息
  51. source:1,
  52. dockingPeopleMobile:'',
  53. dockingPeopleName:''
  54. },
  55. brandname:'请选择',
  56. checkbox:false,
  57. shoplogoTwo:false,
  58. provinceIndex:'',
  59. provinceArray:[],
  60. cityArray: [],//市
  61. townArray: [],//区
  62. from: {
  63. name:'',
  64. province: '',//省id
  65. city: '',
  66. town: ''
  67. },
  68. TypeList:'',
  69. playid:'',
  70. checkVal:[],
  71. vShow_secondBj:false,
  72. resultBj:false,
  73. vShow_detailTalkFlag:false,
  74. vShow_secondHandType:false,
  75. vShow_instrumentType:false,
  76. vShow_BrandID:false,
  77. vShow_Name:false,
  78. vShow_Price:false,
  79. vShow_shopColor:false,
  80. vShow_contactName:false,
  81. vShow_contactMobile:false,
  82. vShow_caimeiMobile:false,
  83. vShow_Address:false,
  84. vShow_TownId:false,
  85. vShow_Market:false,
  86. vShow_original:false,
  87. vShow_Number:false,
  88. vShow_expire:false,
  89. vShow_detailInfoEditor:true,
  90. vShow_GoodsImages:false,
  91. vShow_checkBox:false,
  92. selectBrand:false
  93. },
  94. methods:{
  95. showBrand:function(){
  96. var _this = this;
  97. _this.selectBrand = !_this.selectBrand;
  98. },
  99. secondHandRidio: function(item) {
  100. var _this = this;
  101. _this.currentId = item.value;
  102. _this.secondParams.secondHandType = item.value;
  103. if (item.value==1){
  104. _this.isShow = true;
  105. }else {
  106. _this.isShow = false;
  107. }
  108. },
  109. secondHandType:function(item){ //二手仪器
  110. item.isChecked = ! item.isChecked;
  111. var _this = this;
  112. if(item.isChecked){
  113. _this.checkVal.push(item.value);
  114. _this.secondParams.instrumentType = _this.checkVal.toString();
  115. } else {
  116. _this.checkVal.splice(_this.checkVal.indexOf(item.value), 1);
  117. _this.secondParams.instrumentType = _this.checkVal.toString();
  118. }
  119. },
  120. ChangeBrand:function(item){ //品牌列表
  121. var _this = this;
  122. _this.brandname = item.name;
  123. _this.secondParams.brandId = item.id;
  124. if(_this.secondParams.brandId==161){
  125. _this.shoplogoTwo = true;
  126. }else {
  127. _this.shoplogoTwo = false;
  128. }
  129. },
  130. Detailed:function(){
  131. var _this = this;
  132. if(event.target.checked==true){
  133. _this.secondParams.detailTalkFlag = 2 ;//启用价格详聊
  134. _this.vShow_detailTalkFlag = true;
  135. }else {
  136. _this.secondParams.detailTalkFlag = 1 ;//不启用价格详聊
  137. _this.vShow_detailTalkFlag = false;
  138. }
  139. },
  140. dragstart: function(value) { // 记录初始信息
  141. this.oldNum = value;
  142. },
  143. uploadGoodsImagesFn: function(event){//上传商品图片
  144. var _this = this;
  145. var inputDOM = _this.$refs.goodsImages;
  146. var file = inputDOM.files;
  147. _this.formData.append('file', file[0]);
  148. SecondApi.uploadimg(_this.formData,function(response){
  149. _this.GoodsImagesList.push(response.data);
  150. _this.secondParams.image =_this.GoodsImagesList.toString()+',';
  151. event.target.value = '';
  152. });
  153. },
  154. removeGoodsImagesFn: function(index){//删除商品图片
  155. var _this = this;
  156. _this.GoodsImagesList.splice(index,1);
  157. _this.secondParams.image =_this.GoodsImagesList.toString()+',';
  158. },
  159. getProductType:function(item){
  160. var _this = this;
  161. _this.secondType=item;
  162. _this.secondParams.secondProductType = item ;
  163. },
  164. submitBtn:function () {
  165. var _this = this;
  166. var re = /^1\d{10}$/;
  167. if(_this.secondParams.secondHandType == ''){
  168. _this.vShow_secondHandType = true;
  169. _this.fromMessage = '请选择分类';
  170. _this.scrollIntoView();
  171. setTimeout(function(){
  172. _this.vShow_secondHandType= false;
  173. },2000);
  174. return;
  175. }
  176. if(_this.secondParams.secondHandType == 1 ){
  177. if(_this.secondParams.instrumentType ==''){
  178. _this.vShow_instrumentType = true;
  179. _this.fromMessage = '请完善仪器分类';
  180. _this.scrollIntoView();
  181. setTimeout(function(){
  182. _this.vShow_instrumentType= false;
  183. },2000);
  184. return;
  185. }
  186. }
  187. if(_this.secondParams.brandID == ''){
  188. _this.vShow_BrandID = true;
  189. _this.fromMessage = '请选择商品品牌';
  190. _this.scrollIntoView();
  191. setTimeout(function(){
  192. _this.vShow_BrandID = false;
  193. },2000);
  194. return;
  195. }
  196. if(_this.secondParams.name == ''){
  197. _this.vShow_Name = true;
  198. _this.fromMessage = '请输入商品名称';
  199. _this.scrollIntoView();
  200. setTimeout(function(){
  201. _this.vShow_Name = false;
  202. },2000);
  203. return
  204. }
  205. if(_this.secondParams.price == ''){
  206. _this.vShow_Price = true;
  207. _this.fromMessage = '请输入交易价';
  208. _this.scrollIntoView();
  209. setTimeout(function(){
  210. _this.vShow_Price = false;
  211. },2000);
  212. return
  213. }
  214. if(_this.secondParams.productQuality == ''){
  215. _this.vShow_shopColor = true;
  216. _this.fromMessage = '请输入商品成色';
  217. _this.scrollIntoView();
  218. setTimeout(function(){
  219. _this.vShow_shopColor = false;
  220. },2000);
  221. return
  222. }
  223. if(_this.secondParams.contactName == ''){
  224. _this.vShow_contactName = true;
  225. _this.fromMessage = '请输入联系人姓名';
  226. _this.scrollIntoView();
  227. setTimeout(function(){
  228. _this.vShow_contactName = false;
  229. },2000);
  230. return
  231. }
  232. if(_this.secondParams.contactMobile == ''){
  233. _this.vShow_contactMobile = true;
  234. _this.fromMessage = '请输入联系方式';
  235. _this.scrollIntoView();
  236. setTimeout(function(){
  237. _this.vShow_contactMobile = false;
  238. },2000);
  239. return
  240. }
  241. if(!re.test(_this.secondParams.contactMobile)){
  242. _this.vShow_contactMobile = true;
  243. _this.fromMessage = '联系方式格式不正确';
  244. _this.scrollIntoView();
  245. setTimeout(function(){
  246. _this.vShow_contactMobile = false;
  247. },2000);
  248. return
  249. }
  250. if(_this.secondParams.dockingPeopleMobile!='' && !re.test(_this.secondParams.dockingPeopleMobile)){
  251. _this.vShow_caimeiMobile = true;
  252. _this.fromMessage = '联系方式格式不正确';
  253. _this.scrollIntoView();
  254. setTimeout(function(){
  255. _this.vShow_caimeiMobile = false;
  256. },2000);
  257. return
  258. }
  259. if(_this.secondParams.townId == ''|| _this.secondParams.townId == undefined){
  260. _this.vShow_TownId = true;
  261. _this.fromMessage = '请完善联系地址';
  262. _this.scrollIntoView();
  263. setTimeout(function(){
  264. _this.vShow_TownId = false;
  265. },2000);
  266. return
  267. }
  268. if(_this.secondParams.address == ''){
  269. _this.vShow_Address = true;
  270. _this.fromMessage = '请填写详细地址';
  271. document.getElementById('Address').scrollIntoView({block: 'start', behavior: 'smooth'});
  272. setTimeout(function(){
  273. _this.vShow_Address = false;
  274. },2000);
  275. return
  276. }
  277. if(_this.GoodsImagesList ==''){
  278. _this.vShow_GoodsImages = true;
  279. _this.fromMessage = '请上传图片';
  280. document.documentElement.scrollTop=900;
  281. setTimeout(function(){
  282. _this.vShow_GoodsImages = false;
  283. },2000);
  284. return;
  285. }
  286. if(_this.checkbox==false){
  287. _this.vShow_checkBox = true;
  288. _this.fromMessage='请勾选已阅读';
  289. setTimeout(function(){
  290. _this.vShow_checkBox = false;
  291. },2000);
  292. return
  293. }
  294. console.log(_this.secondParams)
  295. SecondApi.SecondHandProduct(_this.secondParams,function (res) { //提交发布
  296. if (res.code==0){
  297. console.log(res)
  298. _this.vShow_secondBj = true;
  299. _this.playid= res.data;
  300. }else{
  301. CAIMEI.Alert(res.msg, '确定', false);
  302. _this.secondBj = false;
  303. return
  304. }
  305. })
  306. },
  307. quxiao:function(){
  308. var _this = this;
  309. _this.vShow_secondBj = false;
  310. },
  311. gopay:function(){
  312. var _this = this;
  313. window.location.href = '/pay/caimei-paycash.html?pageType=1&&type=confirm&productID='+_this.playid;
  314. _this.vShow_secondBj = false;
  315. },
  316. scrollIntoView: function(){
  317. document.getElementById('secondHandrelease').scrollIntoView({block: 'start', behavior: 'smooth'});
  318. },
  319. province:function () {
  320. var _this = this;
  321. _this.from.province = event.target.value;
  322. if(_this.from.province==''){//省为请选择时市区初始化
  323. _this.cityArray=[];
  324. _this.townArray=[];
  325. _this.secondParams.townId=''
  326. }else {
  327. _this.getcity();
  328. }
  329. },
  330. getcity:function(event){//加载市
  331. var _this = this;
  332. PublicApi.GetCity({ provinceId: _this.from.province },function(response){
  333. if(response.code == 0 ){
  334. _this.cityArray = response.data;
  335. _this.from.city = event.target.value;
  336. if(_this.from.city==''){
  337. _this.townArray=[];
  338. }else {
  339. _this.getcTown();
  340. }
  341. }
  342. })
  343. },
  344. getcTown:function(event){
  345. var _this = this;
  346. PublicApi.GetTown({cityId:_this.from.city},function(response){
  347. if(response.code == 0 ){
  348. _this.townArray = response.data;
  349. _this.secondParams.townId = event.target.value;
  350. }else{
  351. CAIMEI.Alert(response.msg, '确定', false);
  352. }
  353. })
  354. },
  355. changeBox:function () {
  356. if(event.target.checked ==true){
  357. this.checkbox = true
  358. }else {
  359. this.checkbox = false
  360. }
  361. },
  362. },
  363. mounted:function () {
  364. var _this = this;
  365. SecondApi.brandList({},function (res) {//品牌列表
  366. if(res.code == 0){
  367. _this.BrandList = res.data;
  368. }
  369. })
  370. PublicApi.GetProvince({},function(response){ //省份
  371. if(response.code == 0){
  372. _this.provinceArray = response.data
  373. }else{
  374. CAIMEI.Alert(response.msg, '确定', false);
  375. }
  376. })
  377. },
  378. })