移动端
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

152 lignes
4.5 KiB

  1. <template>
  2. <div class="home_wrapper">
  3. <!-- 头部开始 -->
  4. <van-nav-bar
  5. title="修改商品"
  6. fixed
  7. placeholder
  8. left-arrow
  9. @click-left="onClickLeft"
  10. />
  11. <!-- 头部结束 -->
  12. <!-- 内容开始 -->
  13. <div class="main">
  14. <van-field label="产品名称" required :rules="[{ required: true }]" v-model="product.productName" input-align="right" placeholder="请输入产品名称" />
  15. <van-field label="产品类型" required :rules="[{ required: true }]" v-model="product.productType" input-align="right" placeholder="请输入产品类型" />
  16. <van-field label="产品描述" required :rules="[{ required: true }]" type="textarea" autosize v-model="product.productLink" input-align="right" placeholder="请输入产品描述" />
  17. <van-field label="图片" :border="false" input-align="right" readonly />
  18. <div style="padding: 0 4% 2vh;">
  19. <van-uploader v-model="product.mainImgList" :after-read="afterReadEvidenceForm" :before-delete="deleteFileEvidenceForm" />
  20. </div>
  21. </div>
  22. <div class="main_btn">
  23. <p @click="submitForm">发布</p>
  24. </div>
  25. <!-- 内容结束 -->
  26. </div>
  27. </template>
  28. <script>
  29. import Cookies from "js-cookie";
  30. import {productGet,financialProductEdit,commonUpload} from "@/api/agriculturalTrusteeship";
  31. export default {
  32. name: "agriculturalTrusteeshipShopDetail",
  33. data() {
  34. return {
  35. activeKey: 0,
  36. active: 0,
  37. loading: false,
  38. finished: false,
  39. center: { lng: 122.089726, lat: 37.540728 }, //经纬度
  40. zoom: 15, //地图展示级别
  41. showDialog:false,
  42. product:{},
  43. mainImgArr:[],
  44. productTypeOptions:[],
  45. productTypeOptions2:[],
  46. productType:'',
  47. showProductType:false
  48. };
  49. },
  50. created() {
  51. this.getDicts("product_type").then(response => {
  52. for (var i = 0; i < response.data.length; i++) {
  53. this.productTypeOptions.push({text: response.data[i].dictLabel, value: response.data[i].dictValue});
  54. }
  55. this.productTypeOptions2 = response.data;
  56. });
  57. this.getDetail();
  58. },
  59. methods: {
  60. getDetail(){
  61. productGet(this.$route.query.id).then(response => {
  62. this.productType = response.data.productType;
  63. if (response.data.mainImg){
  64. response.data.mainImgList = [];
  65. var attachement = response.data.mainImg.split( "," );
  66. this.mainImgArr = response.data.mainImg.split( "," );
  67. attachement.forEach(responseAttach=>{
  68. response.data.mainImgList.push({
  69. url:'/api' + responseAttach,
  70. isImage: true
  71. });
  72. })
  73. }
  74. var that = this ;
  75. that.product = response.data;
  76. });
  77. },
  78. afterReadEvidenceForm(file){
  79. let params1 = new FormData();
  80. params1.append("file", file.file);
  81. commonUpload(params1).then((r1) => {
  82. // this.tEnforceSamplingGoodsList[index].attachement.push(r1.fileName);
  83. console.log(r1)
  84. this.mainImgArr.push(r1.fileName)
  85. })
  86. },
  87. deleteFileEvidenceForm(file,detail) {
  88. this.mainImgArr.splice(detail.index,1);
  89. this.product.mainImgList.splice(detail.index,1);
  90. },
  91. submitForm(){
  92. console.log(this.mainImgArr)
  93. this.product.mainImg = this.mainImgArr.join(',')
  94. financialProductEdit(this.product).then((res) => {
  95. if(res.code=="200"){
  96. this.$notify({ type: 'success', message: '发布成功' });
  97. setTimeout(function(){
  98. history.back(-1);
  99. },2000)
  100. }
  101. })
  102. },
  103. onConfirmProductType(data){
  104. this.product.productType = data.value;
  105. this.productType = data.text;
  106. this.showProductType = false;
  107. }
  108. },
  109. }
  110. </script>
  111. <style scoped lang="scss">
  112. .home_wrapper{
  113. background: #F6F6F6;
  114. min-height: 100vh;
  115. }
  116. .main{
  117. width: 92%;
  118. margin: 0 auto;
  119. margin-top: 2vh;
  120. border-radius: 10PX;
  121. overflow: hidden;
  122. background-color: #FFF;
  123. }
  124. .main_btn{
  125. display: flex;
  126. justify-content: space-around;
  127. padding: 4vh 0;
  128. p{
  129. font-size: .4rem;
  130. width: 35%;
  131. text-align: center;
  132. padding: 10PX 0;
  133. border-radius: 5rem;
  134. box-shadow: 0px 3PX 6PX 0px rgba(0,0,0,0.16);
  135. &:nth-child(1){
  136. background: #334281;
  137. color: #ffffff;
  138. }
  139. &:nth-child(2){
  140. background: #D1D5E4;
  141. color: #334281;
  142. }
  143. }
  144. }
  145. </style>