form.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. var secondHandrelease = new Vue({
  2. el:'#secondHandrelease',
  3. data:{
  4. fenlei:[
  5. {name:'二手仪器',value:'1'},
  6. {name:'临期产品',value:'2'},
  7. {name:'其他',value:'3'},
  8. ],
  9. currentId:0,
  10. radioList:[
  11. {name:'轻光电',value:'1',isChecked:false},
  12. {name:'重光电',value:'2',isChecked:false},
  13. {name:'耗材配件',value:'3',isChecked:false},
  14. ],
  15. beauty:[
  16. {name:'医美',value:'1'},
  17. {name:'非医美',value:'2'},
  18. ],
  19. BrandList:[],
  20. isShow:false,
  21. includedTax:'',
  22. GoodsImagesList:[],
  23. oldNum:0,
  24. secondType:0,
  25. vShow_GoodsImages:false,
  26. fromMessage:'',//提示文字
  27. formData:new FormData(),
  28. secondParams:{
  29. secondHandType:'',//一级分类
  30. instrumentType:'',//二手仪器分类
  31. name:'',
  32. brandID:'',//品牌ID
  33. brandName:'',//其他品牌
  34. fixedYears:null,//出厂
  35. companyName:'',//公司名称
  36. maturityYears:'',//产品到期
  37. price1:'',//交易价
  38. detailTalkFlag:1,//是否启用详聊
  39. normalPrice:'',//市场价
  40. originalPrice:'',//采购价
  41. stock:'',//数量
  42. productQuality:'',//商品成色
  43. contactName:'',//联系人
  44. contactMobile:'',//联系方式
  45. secondProductType:null,//
  46. townId:'',//县区地址
  47. address:'',//详细地址
  48. image1:'',//图片
  49. productDetails:'',//商品详细信息
  50. source:1,
  51. },
  52. brandname:'请选择',
  53. checkbox:false,
  54. shoplogoTwo:false,
  55. provinceIndex:'',
  56. provinceArray:[],
  57. cityArray: [],//市
  58. townArray: [],//区
  59. from: {
  60. name:'',
  61. province: '',//省id
  62. city: '',
  63. town: ''
  64. },
  65. TypeList:'',
  66. playid:'',
  67. checkVal:[],
  68. vShow_secondBj:false,
  69. resultBj:false,
  70. vShow_detailTalkFlag:false,
  71. vShow_secondHandType:false,
  72. vShow_instrumentType:false,
  73. vShow_BrandID:false,
  74. vShow_Name:false,
  75. vShow_Price:false,
  76. vShow_shopColor:false,
  77. vShow_contactName:false,
  78. vShow_contactMobile:false,
  79. vShow_Address:false,
  80. vShow_TownId:false,
  81. vShow_Market:false,
  82. vShow_original:false,
  83. vShow_Number:false,
  84. vShow_expire:false,
  85. vShow_detailInfoEditor:true,
  86. vShow_GoodsImages:false,
  87. vShow_checkBox:false,
  88. selectBrand:false
  89. },
  90. methods:{
  91. showBrand:function(){
  92. var _this = this;
  93. _this.selectBrand = !_this.selectBrand;
  94. },
  95. secondHandRidio: function(item) {
  96. var _this = this;
  97. _this.currentId = item.value;
  98. _this.secondParams.secondHandType = item.value;
  99. if (item.value==1){
  100. _this.isShow = true;
  101. }else {
  102. _this.isShow = false;
  103. }
  104. },
  105. secondHandType:function(item){ //二手仪器
  106. item.isChecked = ! item.isChecked;
  107. var _this = this;
  108. if(item.isChecked){
  109. _this.checkVal.push(item.value);
  110. _this.secondParams.instrumentType = _this.checkVal.toString();
  111. } else {
  112. _this.checkVal.splice(_this.checkVal.indexOf(item.value), 1);
  113. _this.secondParams.instrumentType = _this.checkVal.toString();
  114. }
  115. },
  116. ChangeBrand:function(item){ //品牌列表
  117. var _this = this;
  118. _this.brandname = item.name;
  119. console.log(_this.name)
  120. _this.secondParams.brandID = item.id;
  121. if(_this.secondParams.brandID==161){
  122. _this.shoplogoTwo = true;
  123. }else {
  124. _this.shoplogoTwo = false;
  125. }
  126. },
  127. Detailed:function(){
  128. var _this = this;
  129. if(event.target.checked==true){
  130. _this.secondParams.detailTalkFlag = 2 ;//启用价格详聊
  131. _this.vShow_detailTalkFlag = true;
  132. }else {
  133. _this.secondParams.detailTalkFlag = 1 ;//不启用价格详聊
  134. _this.vShow_detailTalkFlag = false;
  135. }
  136. console.log(_this.secondParams.detailTalkFlag)
  137. },
  138. dragstart: function(value) { // 记录初始信息
  139. this.oldNum = value;
  140. },
  141. uploadGoodsImagesFn: function(event){//上传商品图片
  142. var _this = this;
  143. var inputDOM = _this.$refs.goodsImages;
  144. var file = inputDOM.files;
  145. _this.formData.append('file', file[0]);
  146. SecondApi.uploadimg(_this.formData,function(response){
  147. _this.GoodsImagesList.push(response.data);
  148. _this.secondParams.image1 =_this.GoodsImagesList.toString()+',';
  149. event.target.value = '';
  150. });
  151. },
  152. removeGoodsImagesFn: function(index){//删除商品图片
  153. var _this = this;
  154. _this.GoodsImagesList.splice(index,1);
  155. _this.secondParams.image1 =_this.GoodsImagesList.toString()+',';
  156. },
  157. getProductType:function(item){
  158. var _this = this;
  159. _this.secondType=item;
  160. _this.secondParams.secondProductType = item ;
  161. },
  162. submitBtn:function () {
  163. var _this = this;
  164. if(_this.secondParams.secondHandType == ''){
  165. _this.vShow_secondHandType = true;
  166. _this.fromMessage = '请选择分类';
  167. _this.scrollIntoView();
  168. setTimeout(function(){
  169. _this.vShow_secondHandType= false;
  170. },2000);
  171. return;
  172. }
  173. if(_this.secondParams.secondHandType == 1 ){
  174. if(_this.secondParams.instrumentType ==''){
  175. _this.vShow_instrumentType = true;
  176. _this.fromMessage = '请完善仪器分类';
  177. _this.scrollIntoView();
  178. setTimeout(function(){
  179. _this.vShow_instrumentType= false;
  180. },2000);
  181. return;
  182. }
  183. }
  184. if(_this.secondParams.brandID == ''){
  185. _this.vShow_BrandID = true;
  186. _this.fromMessage = '请选择商品品牌';
  187. _this.scrollIntoView();
  188. setTimeout(function(){
  189. _this.vShow_BrandID = false;
  190. },2000);
  191. return;
  192. }
  193. if(_this.secondParams.name == ''){
  194. _this.vShow_Name = true;
  195. _this.fromMessage = '请输入商品名称';
  196. _this.scrollIntoView();
  197. setTimeout(function(){
  198. _this.vShow_Name = false;
  199. },2000);
  200. return
  201. }
  202. if(_this.secondParams.secondHandType ==2) {
  203. if (_this.secondParams.normalPrice == '') {
  204. _this.vShow_Market = true;
  205. _this.fromMessage = '请输入市场价';
  206. _this.scrollIntoView();
  207. setTimeout(function () {
  208. _this.vShow_Market = false;
  209. }, 2000);
  210. return
  211. }
  212. if (_this.secondParams.maturityYears == '') {
  213. _this.vShow_expire = true;
  214. _this.fromMessage = '请输入产品到期日';
  215. _this.scrollIntoView();
  216. setTimeout(function () {
  217. _this.vShow_expire = false;
  218. }, 2000);
  219. return
  220. }
  221. }
  222. if(_this.secondParams.price1 == ''){
  223. _this.vShow_Price = true;
  224. _this.fromMessage = '请输入交易价';
  225. _this.scrollIntoView();
  226. setTimeout(function(){
  227. _this.vShow_Price = false;
  228. },2000);
  229. return
  230. }
  231. if(_this.secondParams.secondHandType ==2){
  232. if(_this.secondParams.originalPrice == ''){
  233. _this.vShow_original = true;
  234. _this.fromMessage = '请输入采购价/原价';
  235. _this.scrollIntoView();
  236. setTimeout(function(){
  237. _this.vShow_original = false;
  238. },2000);
  239. return
  240. }
  241. if(_this.secondParams.stock == ''){
  242. _this.vShow_Number = true;
  243. _this.fromMessage = '请输入数量';
  244. _this.scrollIntoView();
  245. setTimeout(function(){
  246. _this.vShow_Number = false;
  247. },2000);
  248. return
  249. }
  250. }
  251. if(_this.secondParams.productQuality == ''){
  252. _this.vShow_shopColor = true;
  253. _this.fromMessage = '请输入商品成色';
  254. _this.scrollIntoView();
  255. setTimeout(function(){
  256. _this.vShow_shopColor = false;
  257. },2000);
  258. return
  259. }
  260. if(_this.secondParams.contactName == ''){
  261. _this.vShow_contactName = true;
  262. _this.fromMessage = '请输入联系人姓名';
  263. _this.scrollIntoView();
  264. setTimeout(function(){
  265. _this.vShow_contactName = false;
  266. },2000);
  267. return
  268. }
  269. if(_this.secondParams.contactMobile == ''){
  270. _this.vShow_contactMobile = true;
  271. _this.fromMessage = '请输入联系方式';
  272. _this.scrollIntoView();
  273. setTimeout(function(){
  274. _this.vShow_contactMobile = false;
  275. },2000);
  276. return
  277. }
  278. if(_this.secondParams.contactMobile.length !=11){
  279. _this.vShow_contactMobile = true;
  280. _this.fromMessage = '联系方式格式不正确';
  281. _this.scrollIntoView();
  282. setTimeout(function(){
  283. _this.vShow_contactMobile = false;
  284. },2000);
  285. return
  286. }
  287. if(_this.secondParams.townId == ''|| _this.secondParams.townId == undefined){
  288. _this.vShow_TownId = true;
  289. _this.fromMessage = '请完善联系地址';
  290. _this.scrollIntoView();
  291. setTimeout(function(){
  292. _this.vShow_TownId = false;
  293. },2000);
  294. return
  295. }
  296. if(_this.secondParams.address == ''){
  297. _this.vShow_Address = true;
  298. _this.fromMessage = '请填写详细地址';
  299. document.getElementById('Address').scrollIntoView({block: 'start', behavior: 'smooth'});
  300. setTimeout(function(){
  301. _this.vShow_Address = false;
  302. },2000);
  303. return
  304. }
  305. if(_this.GoodsImagesList ==''){
  306. _this.vShow_GoodsImages = true;
  307. _this.fromMessage = '请上传图片';
  308. document.documentElement.scrollTop=900;
  309. setTimeout(function(){
  310. _this.vShow_GoodsImages = false;
  311. },2000);
  312. return;
  313. }
  314. if(_this.checkbox==false){
  315. _this.vShow_checkBox = true;
  316. _this.fromMessage='请勾选已阅读';
  317. setTimeout(function(){
  318. _this.vShow_checkBox = false;
  319. },2000);
  320. return
  321. }
  322. console.log(_this.secondParams)
  323. SecondApi.SecondHandProduct(_this.secondParams,function (res) { //提交发布
  324. if (res.code==0){
  325. console.log(res)
  326. _this.vShow_secondBj = true;
  327. _this.playid= res.data;
  328. }else{
  329. // layer.msg(res.msg, {icon: 7});
  330. CAIMEI.Alert(res.msg)
  331. _this.secondBj = false;
  332. return
  333. }
  334. })
  335. console.log(_this.secondParams)
  336. },
  337. quxiao:function(){
  338. var _this = this;
  339. _this.vShow_secondBj = false;
  340. },
  341. gopay:function(){
  342. var _this = this;
  343. window.location.href = '';
  344. _this.vShow_secondBj = false;
  345. },
  346. scrollIntoView: function(){
  347. document.getElementById('secondHandrelease').scrollIntoView({block: 'start', behavior: 'smooth'});
  348. },
  349. province:function () {
  350. var _this = this;
  351. _this.from.province = event.target.value;
  352. if(_this.from.province==''){//省为请选择时市区初始化
  353. _this.cityArray=[];
  354. _this.townArray=[];
  355. _this.secondParams.townId=''
  356. }else {
  357. _this.getcity();
  358. }
  359. },
  360. getcity:function(event){//加载市
  361. var _this = this;
  362. PublicApi.GetCity({ provinceId: _this.from.province },function(response){
  363. if(response.code == 0 ){
  364. _this.cityArray = response.data;
  365. _this.from.city = event.target.value;
  366. if(_this.from.city==''){
  367. _this.townArray=[];
  368. }else {
  369. _this.getcTown();
  370. }
  371. }
  372. })
  373. },
  374. getcTown:function(event){
  375. var _this = this;
  376. PublicApi.GetTown({cityId:_this.from.city},function(response){
  377. if(response.code == 0 ){
  378. _this.townArray = response.data;
  379. _this.secondParams.townId = event.target.value;
  380. console.log(_this.secondParams.townId)
  381. }else{
  382. layer.msg(response.msg, {icon: 7});
  383. }
  384. })
  385. },
  386. changeBox:function () {
  387. if(event.target.checked ==true){
  388. this.checkbox = true
  389. }else {
  390. this.checkbox = false
  391. }
  392. },
  393. },
  394. mounted:function () {
  395. var _this = this;
  396. SecondApi.brandList({},function (res) {//品牌列表
  397. if(res.code == 0){
  398. _this.BrandList = res.data;
  399. }
  400. })
  401. PublicApi.GetProvince({},function(response){ //省份
  402. if(response.code == 0){
  403. console.log(response)
  404. _this.provinceArray = response.data
  405. }else{
  406. layer.msg(response.msg, {icon: 7});
  407. }
  408. })
  409. },
  410. })