addmendianSP.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. <template>
  2. <view class="contentV">
  3. <customNav :shownav="true" :deleteBt="edeatState" :title="$t('index.shangpinedit')" titledetl="" v-on:Enavbarsel="navbarsel"></customNav>
  4. <view class="contentInRowC" style="margin-top: 40rpx;">
  5. <text style="font-size: 28rpx;color: darkgray;">{{$t('goods.xiugaishx')}}</text>
  6. </view>
  7. <!-- <view class="contentInRowL" style="margin-left: 30rpx;margin-top: 60rpx;">
  8. <text>{{$t('shangpin.fenleiyuyan')}}: {{langtext}}</text>
  9. <uni-icons style="margin-left: 16rpx;" custom-prefix="custom-icon" color="#006AFF" type="loop" size="26" @click="changeLang"></uni-icons>
  10. </view> -->
  11. <view class="yzmctV" >
  12. <view class="contentInRowS" style="width: 80%;align-items: center;">
  13. <view v-if="stackingUp==1" style="align-items: center;" @click="salestate">
  14. <uni-icons custom-prefix="custom-icon" color="darkgray" type="checkbox-filled" size="26"></uni-icons>
  15. <text style="font-size: 30rpx;color:darkgray;">{{$t('mend.yishangjia')}}</text>
  16. </view>
  17. <view v-if="stackingUp==0" style="align-items: center;" @click="salestate">
  18. <uni-icons custom-prefix="custom-icon" color="crimson" type="checkbox-filled" size="26"></uni-icons>
  19. <text style="font-size: 30rpx;color:crimson;">{{$t('mend.yishangjia')}}</text>
  20. </view>
  21. <view v-if="shenhe=='0'" style="align-items: center;">
  22. <uni-icons custom-prefix="custom-icon" color="darkgray" type="checkbox-filled" size="26"></uni-icons>
  23. <text style="font-size: 30rpx;color:darkgray;">{{$t('order.weishenhe')}}</text>
  24. </view>
  25. <view v-if="shenhe=='1'" style="align-items: center;">
  26. <uni-icons custom-prefix="custom-icon" color="crimson" type="checkbox-filled" size="26"></uni-icons>
  27. <text style="font-size: 30rpx;color:crimson;">{{$t('order.shenhetg')}}</text>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="yzmctV">
  32. <text class="yzmbt">{{$t('mend.shangpinmc')}}:</text>
  33. <input class="noinputV" type="text" :placeholder="$t('mend.qingshurspmc')" :value="name" @input="inpuact1">
  34. </view>
  35. <view class="yzmctV">
  36. <text class="yzmbt">{{$t('mend.shangpinjj')}}:</text>
  37. <input class="noinputV" type="text" :placeholder="$t('mend.qingshurspjj')" :value="introduce" @input="inpuact2">
  38. </view>
  39. <view class="yzmctV">
  40. <text class="yzmbt">{{$t('index.goodsfenlei')}}:</text>
  41. <view class="xialakuangL">
  42. <uni-data-select class="" v-model="value" :localdata="range" :placeholder="$t('mend.qingxuanze')" @change="selectchangefl" ></uni-data-select>
  43. </view>
  44. </view>
  45. <danxuanlist style="width:100%;" :infolistD="infosku" :isedit="true" v-on:ElistDatachange="listDatachange"></danxuanlist>
  46. <view class="yzmctV">
  47. <text class="yzmbt">{{$t('mend.shangpinjg')}}:</text>
  48. <input class="noinputV" type="number" :value="price" :placeholder="$t('mend.shangpinsj')" @input="inpuact3">
  49. </view>
  50. <view class="contentInRowL" style="padding-left: 8%;margin-top: 40rpx;">
  51. <text class="yzmbt">{{$t('mend.shangpintp')}}:</text>
  52. </view>
  53. <view class="yzmctV">
  54. <yhdslCropper ref="yhdslCropper" :quality="1" mode="scale" @uploadImg="uploadImg" :scale="scale"></yhdslCropper>
  55. <image class="imagV" :src="baseUrl+spImage" mode="scaleToFill" @click="selectImage"></image>
  56. </view>
  57. <view class="yzmctV" style="margin-bottom: 40rpx;">
  58. <text class="querenBt" @click="tijiao">{{$t('index.tijiao')}}</text>
  59. </view>
  60. <uni-popup ref="langPop">
  61. <view class="contentColumnC" style="width: 100%;background-color: white;">
  62. <text class="poptextList" style="margin-top: 20rpx;" @click="langSel('0')">Tiếng Việt</text>
  63. <text class="poptextList" @click="langSel('2')">简体中文</text>
  64. <text class="poptextList" @click="langSel('3')">繁體中文</text>
  65. </view>
  66. </uni-popup>
  67. </view>
  68. </template>
  69. <script>
  70. import api from "@/pages/api/api.js";
  71. import ApibaseUrl from "@/config/urlConfig.js"
  72. import yhdslCropper from '@/components/yhdsl-cropper/yhdsl-cropper.vue';
  73. export default {
  74. components: {
  75. yhdslCropper
  76. },
  77. data() {
  78. return {
  79. foodDT:[],
  80. value:0,
  81. range: [],
  82. flId:0,
  83. spid:-1,
  84. mdid:-1,
  85. name: "",
  86. image: "",
  87. price: 0,
  88. introduce: "",
  89. recommend: 0,
  90. sort: 0,
  91. shangpinfenlei:[],
  92. infosku:[],
  93. sku:[],
  94. spImage:'',
  95. baseUrl:this.$baseImagurl,
  96. scale:1,
  97. edeatState:0,
  98. stackingUp:0,
  99. shenhe:'0',//0未审核或不通过,1已审核
  100. lang:"0",
  101. langtext:'Tiếng Việt'
  102. }
  103. },
  104. onLoad(option) {
  105. console.log('option',option)
  106. var language = uni.getStorageSync('language');
  107. if(language=='yuenan'){
  108. this.lang='0';
  109. this.langtext='Tiếng Việt';
  110. }
  111. if(language=='zh-Hans'){
  112. this.lang='2';
  113. this.langtext='简体中文';
  114. }
  115. if(language=='zh-Hant'){
  116. this.lang='3';
  117. this.langtext='繁體中文';
  118. }
  119. if(option.mendid){
  120. this.mdid=option.mendid;
  121. }
  122. if(option.spid){
  123. this.spid=option.spid;
  124. }
  125. if(option.sh){
  126. if(option.sh!='null'){
  127. this.shenhe=option.sh;
  128. }
  129. }
  130. if(this.spid>=0){
  131. this.edeatState=1;
  132. this.getGoodsDetail(this.spid);
  133. }
  134. else{
  135. this.getmendianshangpinFL(this.mdid);
  136. }
  137. },
  138. onShow() {
  139. console.log("onShowonShowonShow");
  140. },
  141. methods: {
  142. salestate(){
  143. if(this.shenhe=='0'){
  144. return
  145. }
  146. if(this.stackingUp==0){
  147. this.stackingUp=1;
  148. }
  149. else{
  150. this.stackingUp=0;
  151. }
  152. },
  153. changeLang(){
  154. this.$refs.langPop.open('bottom');
  155. },
  156. langInit(){
  157. if(this.lang=='0'){
  158. this.langtext='Tiếng Việt';
  159. }
  160. if(this.lang=='2'){
  161. this.langtext='简体中文';
  162. }
  163. if(this.lang=='3'){
  164. this.langtext='繁體中文';
  165. }
  166. },
  167. langSel(index){
  168. this.lang=index;
  169. this.langInit();
  170. this.$refs.langPop.close();
  171. this.getmendianshangpinFL(this.mdid);
  172. },
  173. inpuact1(v){
  174. if(this.shangpinfenlei.length==1){
  175. uni.showToast({
  176. title:this.$t('mend.qxtianjiafl'),
  177. icon:"none",
  178. duration: 3000
  179. })
  180. }
  181. this.name = v.target.value;
  182. },
  183. inpuact2(v){
  184. this.introduce = v.target.value;
  185. },
  186. inpuact3(v){
  187. this.price = v.target.value;
  188. },
  189. selectchangefl(e){
  190. this.flId=e;
  191. console.log(e)
  192. },
  193. tijiao(){
  194. this.addmendianshangpin()
  195. },
  196. listDatachange(listData){
  197. this.sku=listData;
  198. },
  199. selectImage(){
  200. this.$refs.yhdslCropper.chooseImage();
  201. },
  202. uploadImg(e) {
  203. console.log('------------uploadImg:',e)
  204. this.spImage = e;
  205. var that = this;
  206. var uplurl = ApibaseUrl.getUploadUrl();
  207. uni.uploadFile({
  208. url: uplurl, //上传图片api
  209. filePath: e,
  210. name: 'file',
  211. header:{
  212. //"Authorization": userinfo.token
  213. },
  214. success: (res) => {
  215. let group = JSON.parse(res.data);
  216. this.spImage=group.data;
  217. console.log(group)
  218. uni.showToast({
  219. title:that.$t('mend.shangccg'),
  220. icon:"success"
  221. })
  222. }
  223. });
  224. },
  225. getmendianshangpinFL(id){
  226. api('getmendianshangpinFL',{
  227. id:id,
  228. language:this.lang
  229. },r=>{
  230. this.shangpinfenlei=r.data.data;
  231. var Trange=[];
  232. for(var i=0;i<this.shangpinfenlei.length;i++){
  233. Trange.push({value:this.shangpinfenlei[i].id, text:this.shangpinfenlei[i].name});
  234. }
  235. this.range=Trange;
  236. if(this.shangpinfenlei.length==0){
  237. this.value=0;
  238. this.flId=0;
  239. uni.showToast({
  240. title:this.$t('mend.qxtianjiafl'),
  241. icon:"none",
  242. duration: 3000
  243. })
  244. }
  245. },failc=>{
  246. uni.hideLoading();
  247. //console.log('getadvertis----',failc)
  248. })
  249. },
  250. getGoodsDetail(id){
  251. api('GoodsDetail',{
  252. id:id
  253. },r=>{
  254. console.log('12--',r.data.data)
  255. this.foodDT=r.data.data;
  256. this.flId=this.foodDT.fenlei.id;
  257. this.mdid=this.foodDT.store.id;
  258. this.name=this.foodDT.name;
  259. this.spImage=this.foodDT.image;
  260. this.price=this.foodDT.price;
  261. this.introduce=this.foodDT.introduce;
  262. this.stackingUp = this.foodDT.stackingUp;
  263. this.lang=r.data.data.fenlei.language;
  264. //this.sku=[];
  265. this.sku=this.foodDT.foodSku;
  266. if(0==this.sku.length||undefined==this.sku.length){
  267. this.sku=[];
  268. }
  269. this.infosku= this.sku;
  270. this.langInit();
  271. this.getmendianshangpinFL(this.mdid);
  272. },failc=>{
  273. //console.log('getadvertis----',failc)
  274. })
  275. },
  276. addmendianshangpin(){
  277. console.log("addmendianshangpin")
  278. if(this.name==""){
  279. uni.showToast({
  280. title:this.$t('mend.qingshurspmc'),
  281. icon:"none"
  282. })
  283. return;
  284. }
  285. if(this.introduce==""){
  286. uni.showToast({
  287. title:this.$t('mend.qingshurspjj'),
  288. icon:"none"
  289. })
  290. return;
  291. }
  292. if(this.flId==0){
  293. uni.showToast({
  294. title:this.$t('mend.qingxuanzefl'),
  295. icon:"none"
  296. })
  297. return;
  298. }
  299. if(this.price<=0){
  300. uni.showToast({
  301. title:this.$t('mend.shangpinsj'),
  302. icon:"none"
  303. })
  304. return;
  305. }
  306. if(this.spImage==""){
  307. uni.showToast({
  308. title:this.$t('mend.qingxuanze')+this.$t('mend.shangpintp'),
  309. icon:"none"
  310. })
  311. return;
  312. }
  313. var spdata;
  314. if(this.spid<0){
  315. spdata={
  316. "flId": this.flId,
  317. "mdid": this.mdid,
  318. "name": this.name,
  319. "image":this.spImage,
  320. "price": this.price,
  321. "introduce": this.introduce,
  322. "stackingUp":this.stackingUp,
  323. "recommend": 0,
  324. "sort": 0,
  325. "sku":this.sku,
  326. "language":this.lang
  327. }
  328. }
  329. else{
  330. spdata={
  331. "id":this.spid,
  332. "flId": this.flId,
  333. "mdid": this.mdid,
  334. "name": this.name,
  335. "image":this.spImage,
  336. "price": this.price,
  337. "introduce": this.introduce,
  338. "stackingUp":this.stackingUp,
  339. "recommend": 0,
  340. "sort": 0,
  341. "sku":this.sku,
  342. "language":this.lang
  343. }
  344. }
  345. var checkdataR = this.checkdata(spdata);
  346. if(!checkdataR){
  347. return;
  348. }
  349. api('addmendianshangpin',spdata,
  350. r=>{
  351. uni.navigateBack({
  352. delta:1,//返回层数,2则上上页
  353. })
  354. },failc=>{
  355. console.log('addmendianshangpin',failc)
  356. })
  357. },
  358. checkdata(data){
  359. if(data.flId.length<1){
  360. uni.showToast({
  361. title:this.$t('index.xuanzspfl'),
  362. icon:"error"
  363. })
  364. return false;
  365. }
  366. if(data.name.length<1){
  367. uni.showToast({
  368. title:this.$t('mend.qingshurspmc'),
  369. icon:"error"
  370. })
  371. return false;
  372. }
  373. if(data.introduce.length<1){
  374. uni.showToast({
  375. title:this.$t('mend.qingshurspjj'),
  376. icon:"error"
  377. })
  378. return false;
  379. }
  380. if(data.image.length<1){
  381. uni.showToast({
  382. title:this.$t('mend.qingtianx'),
  383. icon:"error"
  384. })
  385. return false;
  386. }
  387. if(data.price.length<1){
  388. uni.showToast({
  389. title:this.$t('mend.shangpinsj'),
  390. icon:"error"
  391. })
  392. return false;
  393. }
  394. return true;
  395. },
  396. navbarsel(index){
  397. if(index!=5){
  398. return;
  399. }
  400. var that = this;
  401. uni.showModal({
  402. cancelText: that.$t('order.quxiao'), // 取消按钮的文字
  403. confirmText: that.$t('comp.queren'), // 确认按钮的文字
  404. title: that.$t('api.message'),
  405. content: that.$t('index.sanchushangp'),
  406. success: function (res) {
  407. if (res.confirm) { //这里是点击了确定以后
  408. that.delefood();
  409. } else { //这里是点击了取消以后
  410. console.log('用户点击取消')
  411. }
  412. }
  413. })
  414. },
  415. delefood(){
  416. api('delefood',{
  417. id:this.spid
  418. },
  419. r=>{
  420. console.log(r)
  421. if(r.data.code==200){
  422. uni.showToast({
  423. title:this.$t('index.sanchuchengg'),
  424. icon:"none",
  425. duration: 2500
  426. })
  427. setTimeout(() => {
  428. uni.navigateBack({
  429. delta: 1,
  430. });
  431. }, 2500);
  432. }
  433. else{
  434. uni.showToast({
  435. title:r.data.msg,
  436. icon:"none"
  437. })
  438. }
  439. },failc=>{
  440. uni.showToast({
  441. title:failc,
  442. icon:"none"
  443. })
  444. })
  445. },
  446. }
  447. }
  448. </script>
  449. <style>
  450. .contentV{
  451. display: flex;
  452. width: 100%;
  453. justify-content: center;
  454. display: inline-block;
  455. }
  456. .skuViewCt{
  457. display: flex;
  458. flex-direction: column;
  459. justify-content:center;
  460. width: 100%;
  461. margin-top: 10rpx;
  462. }
  463. .contensb{
  464. display: flex;
  465. flex-direction: row;
  466. justify-content:space-between;
  467. align-items:center;
  468. margin-left: 5%;
  469. width: 90%;
  470. }
  471. .contensbgg{
  472. display: flex;
  473. flex-wrap: wrap;
  474. justify-content:flex-start;
  475. align-items:center;
  476. margin-left: 5%;
  477. width: 90%;
  478. }
  479. .rconten{
  480. margin-left: 5%;
  481. flex-wrap: wrap;
  482. margin-top: 0rpx;
  483. }
  484. .peisongsuoming{
  485. font-size: 30rpx;
  486. line-height: 38rpx;
  487. height: 38rpx;
  488. color: dimgray;
  489. }
  490. .guige{
  491. padding: 8rpx;
  492. border: 2rpx solid rosybrown;
  493. border-radius: 6rpx;
  494. height: 70rpx;
  495. line-height: 70rpx;
  496. font-size: 26rpx;
  497. }
  498. .imageR{
  499. width: 56rpx;
  500. height: 56rpx;
  501. margin-left: 6rpx;
  502. }
  503. .yzmctV{
  504. display: flex;
  505. flex-direction: row;
  506. align-items: center;
  507. justify-content: center;
  508. margin-top: 40rpx;
  509. }
  510. .noinputV{
  511. font-size: 30rpx;
  512. margin-left: 20rpx;
  513. width: 60%;
  514. height: 60rpx;
  515. line-height: 60rpx;
  516. border-radius: 20rpx;
  517. border: 2rpx solid darkgray;
  518. }
  519. .addrtext{
  520. margin-left: 20rpx;
  521. font-size: 26rpx;
  522. width: 60%;
  523. height: 60rpx;
  524. line-height: 60rpx;
  525. text-decoration:underline;
  526. }
  527. .yzmbt{
  528. font-size: 28rpx;
  529. text-align: left;
  530. }
  531. .yzmbts{
  532. font-size: 28rpx;
  533. width: 70rpx;
  534. }
  535. .yzmbtsr{
  536. margin-left: 80rpx;
  537. font-size: 28rpx;
  538. width: 70rpx;
  539. }
  540. .xialakuangL{
  541. margin-left: 20rpx;
  542. width: 60%;
  543. height: 60rpx;
  544. line-height: 60rpx;
  545. }
  546. .xialakuang{
  547. margin-left: 20rpx;
  548. width: 20%;
  549. height: 60rpx;
  550. line-height: 60rpx;
  551. }
  552. .imagV{
  553. width: 640rpx;
  554. height: 640rpx;
  555. background-color: antiquewhite;
  556. }
  557. .querenBt{
  558. margin-top: 30rpx;
  559. width: 80%;
  560. height: 60rpx;
  561. line-height: 60rpx;
  562. padding: 10rpx;
  563. border-radius: 20rpx;
  564. border: solid #40AE36;
  565. border-width: 0px 0px 6rpx 0px;
  566. text-align: center;
  567. justify-content: center;
  568. background-color: #40AE36;
  569. color: white;
  570. box-shadow: 0rpx 0rpx 10rpx 0rpx #40AE36;
  571. }
  572. .poptextList{
  573. width: 400rpx;
  574. height: 80rpx;
  575. text-align: center;
  576. line-height: 80rpx;
  577. border: solid lavender;
  578. border-width: 0px 0px 1rpx 0px;
  579. }
  580. </style>